• 0

Arty-Z7-20 BSP 2017.4: GPIO with Switches



finally i was able to make a petalinux build with the BSP 2017.4 - so far, so good. Then i find out, which uio device is connected with the Arty-Z7-20 Buttons and switches. Both - the Buttons and also the Switches - are connected to one GPIO-IP-Core (Dual-Channel, all inputs).

One AXI-GPIO has one base address and a dual channel GPIO has even only one base address. So the only way to address both channels is to use the base address offset for channel one and for channel two, isn't it?

If i read channel one - which is assigned to the Buttons - then i can read the Buttons. If i read the channel two (Switches) - one code line later - then i got no result.

So my questions is:

What must i do to read the Arty-Z7-20 Switches (petalinux, BSP 2017.4)?


Thank you...

Edited by deppenkaiser

Share this post

Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0


Glad to hear you are making progress. 

The data input register for channel two is offset 0x8 bytes after the base address for the AXI-GPIO controller. You will need to read that register.

How you do this depends on what method you ended up going with, dev/mem or uio. If you went uio, we wrote the libgpio library specifically for providing an API to UIO mapped AXI GPIO devices. I'd recommend building that in to your rootfs using petalinux-config (it should actually be built in by default). For an example of how to use libgpio, see the gpioutil source. gpioutil is a command-line tool for togging/getting GPIO bits (it should also be in rootfs by default, give it a shot in your running system). 



Share this post

Link to post
Share on other sites
  • 0

Side note, to use gpioutil, first run "gpioutil -d" in order to get the needed uio number of the axi GPIO  attached to the switches. Then use the following to read switch 0:

gpioutil <uio#> 0 2 -i 0


Share this post

Link to post
Share on other sites
  • 0

Hello @sbobrowicz,

1. I got "Petalinux-Arty-Z7-20-2017.4-1.zip".

2. I fixed the incomplete archive with "vivado-library.zip".

3. I fixed the Vivado build Errors.

4. I created a Linux "Hello world"-App with SDK.

5. I created and configure a new petalinux project with the get-hw-description Option.

6. I build the petalinux image.

7. I saw no uio devices.

8. I added one uio device for the "axi_gpio_sw" device (with Interrupt).

9. I build a new petalinux image.

10. I saw one uio device with registered Interrupts in /proc/interrupts

11. I Changed the "Hello world"-App to read data from UIO with GPIO Channel 1.

12. I added the same code to read channel two but i used the correct Offset for channel two.

#define GPIO_CHANNEL_1_DATA           0x00


#define GPIO_CHANNEL_2_DATA           0x08


13. I saw no data changing even if i use the Switches.

14. I think that there are more Errors on the given Vivado design.

Can you please check this? Why can i read data from channel one and not from channel two?


Thank you....

Share this post

Link to post
Share on other sites
  • 0


your macro to Access the Memory is wrong, if you would use the right macro, then your Offset calculation would work.



I found the error in my Offset calculation, thats could be also the reason for my uio issue! :-)

I will tell you the results.

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