• 0
nattaponj

How to access GPIO on OS: Linux

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

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

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 ? 

Share this post


Link to post
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