Accessing gpio_bd pins with sysfs on zc702

I'm using an FMCOMMS5 board with the ZC702.

I set it up based on the instructions here:

I have linux running from an SD card, and IIO Scope works well. Now I'd like to use some of the ZC702s switches and LEDs for debug purposes.

I tried getting access to them through sysfs, but I'm having issues with that. To start with, I just tried to turn on the LED connected to PMOD2_1.

According to 'hdl\projects\common\zc702\zc702_system_constr.xdc', this should be connected to gpio_bd[6]. I then got the base gpio number by checking gpiochip:

# ls /sys/class/gpio/gpiochip*

So the base is 906, and gpio_bd[6] should be 906+6. I then try:

# echo 912 > /sys/class/gpio/export 
# echo out > /sys/class/gpio/gpio912/direction
# echo 1 > /sys/class/gpio/gpio912/value

But I don't see the corresponding LED light up. I've tried similar things with other gpio, and also tried using the gpio connected to buttons and switches as inputs, but I haven't had any success.

What am I doing wrong here?

  • Hi,

    The ZYNQ GPIO controller has two sets of pins, the MIO pins and the EMIO pins. The MIO GPIOs are directly connected to fixed output pins of the package, while the EMIO pins are connected to the FPGA fabric and can be routed to any FPGA pin.

    The EMIO GPIOs start at an offset of 54. So gpio_bd[0] is GPIO 54 of the Zynq GPIO controller. Which means in your case PMOD2_1 should be 906 + 54 + 6 = 966.

    - Lars

  • Thanks for the reply, Lars. Unfortunately, that doesn't work any better.

    Here's the error that I now get:

    root@analog:/home/analog# echo 966 > /sys/class/gpio/export
    bash: ech: write error: Device or resource busy

    I get that error for all the gpio_bd pins that I've tried. From looking at the HDL, those GPIO seem like they're just connected directly to the EMIO of the processor. This makes me think that ADI's linux distribution is using those GPIO in a driver for something. Any ideas what I should check to find out what's already using the pins?

  • Hi,

    All the on-board LEDs on the ZC702 are mapped to the LED driver in the devicetree. See

    You can either remove them from the devicetree and rebuild the dtb blob or you can unbind the LED driver at runtime. Runtime unbind can be done using the following command:

    echo leds > /sys/bus/platform/drivers/leds-gpio/unbind

    After that the GPIOs should be available for custom usage.

    In general if you want to know if a GPIO is in use and by whom you can check the /sys/kernel/debug/gpio file.

    Of course you can also access the LEDs via the LED interface in /sys/class/leds.

    - Lars