Jump to content
  • 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...

Link to comment
Share on other sites

6 answers to this question

Recommended Posts


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). 



Link to comment
Share on other sites

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....

Link to comment
Share on other sites


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

  • Create New...