Jump to content
  • 0

PL Interrupts in Petalinux using Vitis


MichelleNicholes

Question

I have been learning GPIO in Petalinux and outside of Vitis I used UIO0 for the GPIO however when I tried to code using the GPIO in Vitis it was quite different.  Basically you create a memory map and link it to the GPIO and then write to the memory.  But now I want to implement Interrupts.  So far I have seen how you can do it by hand in the linux terminal but I have not found any tutorials or examples on how to use it in a Vitis application.   Any recommendations would be appreciated.

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Hi @MichelleNicholes,

I'm not very familiar with the Petalinux side of things (I'm guessing you set up interrupts and got the system-conf.dtsi changed in a similar style that is mentioned in this Xilinx thread here), but in terms of using interrupts in Vitis usually you can use something like scugic (after connecting whatever interrupt lines to the IRQ input on the Zynq processor block) to then facilitate the actual interrupts.

I found an example (for a 2016 version of the Xilinx software, but the general process flow should be the same) walking through the process at large here, https://github.com/k0nze/zedboard_pl_to_ps_interrupt_example, with an of alternate GPIO interrupt code setup here, https://github.com/Micro-Studios/Xilinx-GPIO-Interrupt/blob/master/GPIO_Interrupt.sdk/GPIO_Interrupt/src/helloworld.c. Xilinx also has their own interrupt example for xpgiops, https://github.com/Xilinx/embeddedsw/blob/master/XilinxProcessorIPLib/drivers/gpiops/examples/xgpiops_intr_example.c.

Let me know if you have any questions.

Thanks,
JColvin

Link to comment
Share on other sites

  • 0

@JColvin

All the examples you provided are using the standalone version.  I have the standalone version working.  The linux version works completely different and that is what I am trying to learn.  Do you know of any linux interrupt examples?  I have been searching and have not found any as of yet.   I see lots of tutorials who get the leds to blink but none reading from a switch or button triggering an interrupt.  Interesting enough, there are tutorials saying switch led but they do not implement the switch and interrupt in the example.

Link to comment
Share on other sites

  • 0

I misunderstood your original post. I had interpreted it that you had seen how to do the GPIO interrupts by hand in the Linux terminal, but were then confused on the Vitis side of things hence why I had linked a number of standalone materials. I will ask the engineer much more familiar with Petalinux materials for their input so I do not provide additional misinformation.

Thanks,
JColvin

Link to comment
Share on other sites

  • 0

Hi @MichelleNicholes,

You may know that GPIO are hardware resources and implicitly should be managed by the kernel via a driver. You can also manage them in user-space via /sys/class/ interface offered by the kernel. To implement this using Vitis(Cross Architecture and maybe Cross Platform) you must provide Vitis with a sysroot and maybe a toolchain found in petalinux SDK for your rootfs. This can be generated using petalinux: https://docs.xilinx.com/r/en-US/ug1144-petalinux-tools-reference-guide/Building-SDK. Starting there is mostly what you did in terminal (read write from /sys/ files).

Here is a similar situation describe step by step. https://xilinx.github.io/Embedded-Design-Tutorials/docs/2022.2/build/html/docs/Introduction/ZynqMPSoC-EDT/6-build-linux-sw-for-ps.html#creating-linux-applications-in-the-vitis-ide

Link to comment
Share on other sites

  • 0

I dont think lonel answered my question.  I already know how to generate the sdk so that I can use the vitis tool.  Interrupts caught and handled in bare bones is way different than how you catch and handle them in linux.   So far, in all the tutorials, they show us how we can see that an interrupt is being caught by the kernal by looking at a file /proc/interrupts and seeing a number increase for a certain interrupt number but they never teach how we get our code to see it and handle it.  Also, for turning on LEDs the tutorials had you do devmem to set the direction and to set the value for on or off.  However, in Vitis, you had to create a memory block associated with the gpio and in that block set the direction and values.  So how you do it in linux itself and how you do it in code are different.  Now I will say I saw a tutorial where someone actually polling the /proc/interrupts file and parsed out the number change to tell if an interrupt happened but surely that is not how its properly done.    

 

On a side note, I have seen as of today that in linux c code you can use the linux/interrupt.h to register your interrupt but that example seemed to use gpio as a module so I am not sure I am on the right track or not and I have no idea if linux/interrupt.h is included in vitis or not.  Still looking

What I am looking for is an actually tutorial on how to do interrupts in vitis for petalinux.

Link to comment
Share on other sites

  • 0

Have you looked at the AMD/Xilinx wiki? https://xilinx-wiki.atlassian.net/wiki/spaces/A/overview

There are a lot of ways to create a Linux FS that runs on a ZYNQ board. How you connect the HW design resources to the kernel starts getting complicated. This is a very complicated subject to master as it tends to change with kernel releases. I'm no expert on the subject.

I suggest starting off by learning how to use interrupts to control hardware on a PC running one of the popular Linux distributions like Ubuntu or Arch. Sometimes the kernel has support for devices that you can control in device mode. Sometimes you need to create a kernel driver or loadable module. For a platform, like ZYNQ, where the hardware is subject to change, before boot or even live, things get complicated. Everything connected to the PS pins should be relatively simple. Everything connected to the PL pins is likely to involve a steep learning curve. Unfortunately, the best learning resources are not necessarily easy to find. It takes a bit of luck.. and lots of effort.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...