Jump to content
  • 0

How to access GPIO on OS: Linux


nattaponj

Question

Hello,

I create project on SDSoc 2015.4 using platform (https://github.com/Digilent/SDSoC-platforms/tree/master/2015.4/zybo_hdmi_in)

and I select Operating System is Linux because I use about image processing.

but I want to access 4 LEDs on PL.

Can I access the LED on PL? How to access GPIO (e.g. LEDs) on OS: Linux

Previously I used OS: Standalone project.
I can access by Xil_Out32(XPAR_AXI_GPIO_LED_BASEADDR, 0x2); but on Linux I can't.

image.png.20095c55520d44b6b710d989a4dc7bca.png

Thanks in advance

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

The suggestion @jackfrye11 provides probably the most straightforward route. You can mmap the physical address using /dev/mem, there is a lot of documentation out there for how to do this.

There is another option if the axi_gpio core is registered as a GPIO device in the device tree (you should be able to tell by checking the boot messages). If that is the case you can use the sys/class/gpio interface to control the LEDs. That would be the easier method if you want to control the LEDs from the command line or a shell script (if you want to control them from a C program then /dev/mem might be easier). You should be able to find plenty of documentation on the sysfs interface for GPIO online. Basically you just echo values to some files found in those folders to control the LEDs. You can find the correct number to echo to export in the boot messages where you see the physical address of the axi_gpio  get registered. You will need to export 4 numbers, one for each LED.

Actually, come to think of it, we might export the proper GPIOs in the init script. After you boot the Zybo, try reading this file: etc/init.d/rcS . Does it looks like it is reading or writing any files in /sys/class/gpio ? 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...