element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet & Tria Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
ZedBoard Hardware Design gpio offset
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Avnet Boards Forums to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 5 replies
  • Subscribers 353 subscribers
  • Views 1120 views
  • Users 0 members are here
Related

gpio offset

Former Member
Former Member over 11 years ago

Hello,
How do you determine the offset of the gpioxx.
#!/bin/bash
#This appears to work with fpga.bin loaded
echo "++ Exporting switches "
for i in 0 1 2 3 4 5 6 7;
do
        sw=$(($i+65));
        echo $sw > /sys/class/gpio/export;
done;

#!/bin/sh
value=0;
for i in 0 1 2 3 4 5 6 7;
do
        sw=$((72-$i));
        sw_tmp=`cat /sys/class/gpio/gpio$sw/value`;
        value=$(($value*2));
        value=$(($value+$sw_tmp));
done;
printf "0x%x %d
" $value $value;
This work with the system.ucf.
NET processing_system7_0_GPIO_pin[11]tLOC = F22  | IOSTANDARD="LVCMOS25";  # "SW0"
NET processing_system7_0_GPIO_pin[12]tLOC = G22  | IOSTANDARD="LVCMOS25";  # "SW1"
NET processing_system7_0_GPIO_pin[13]tLOC = H22  | IOSTANDARD="LVCMOS25";  # "SW2"
NET processing_system7_0_GPIO_pin[14]tLOC = F21  | IOSTANDARD="LVCMOS25";  # "SW3"
NET processing_system7_0_GPIO_pin[15]tLOC = H19  | IOSTANDARD="LVCMOS25";  # "SW4"
NET processing_system7_0_GPIO_pin[16]tLOC = H18  | IOSTANDARD="LVCMOS25";  # "SW5"
NET processing_system7_0_GPIO_pin[17]tLOC = H17  | IOSTANDARD="LVCMOS25";  # "SW6"
NET processing_system7_0_GPIO_pin[18]tLOC = M15  | IOSTANDARD="LVCMOS25";  # "SW7"

NET processing_system7_0_GPIO_pin[19]tLOC = T22  | IOSTANDARD="LVCMOS33";  # "LD0"
NET processing_system7_0_GPIO_pin[20]tLOC = T21  | IOSTANDARD="LVCMOS33";  # "LD1"
NET processing_system7_0_GPIO_pin[21]tLOC = U22  | IOSTANDARD="LVCMOS33";  # "LD2"
NET processing_system7_0_GPIO_pin[22]tLOC = U21  | IOSTANDARD="LVCMOS33";  # "LD3"
NET processing_system7_0_GPIO_pin[23]tLOC = V22  | IOSTANDARD="LVCMOS33";  # "LD4"
NET processing_system7_0_GPIO_pin[24]tLOC = W22  | IOSTANDARD="LVCMOS33";  # "LD5"
NET processing_system7_0_GPIO_pin[25]tLOC = U19  | IOSTANDARD="LVCMOS33";  # "LD6"
NET processing_system7_0_GPIO_pin[26]tLOC = U14  | IOSTANDARD="LVCMOS33";  # "LD7"
I can not get the LED to work.

Thanks

  • Sign in to reply
  • Cancel
  • Former Member
    0 Former Member over 11 years ago

    Try dmesg | grep gpio, it should give you the base address of each GPIO peripheral plus the base (offset) of the register map for the individual device registers.

     

    -Gary

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago

    Step 1
    uname -a
    Linux zedboard 3.12.0 #1 SMP PREEMPT Sat Mar 29t13:42:20 MDT 2014 armv7l GNU/Lin
    ux
    Step 2
    dmesg | grep gpio
    [    0.039407] zynq_gpio e000a000.gpio:tgpio att0xe000a000 mapped to 0xe080e000
    [    0.746760] input: gpio_keys.7 as /devices/gpio_keys.7/input/input0
    [   64.860929] pmodoled_gpio: module istfrom the staging directory, the quality
    is unknown, you have been warned.
    [   64.873794] pmodoled-gpio-spi [zed_oled] SPItProbing
    Step 3
    ls /sys/class/gpio
    exporttgpiochip0  unexport
    Step 4
    export_sw
    ++ Exporting switches
    Step 5
    ls /sys/class/gpio
    exporttgpio66tgpio68tgpio70tgpio72t   unexport
    gpio65tgpio67  gpio69tgpio71  gpiochip0
    Step 6
    switches 01010101
    read_sw
    0x55 85  this works okay
    Step 7
    trying the following since the leds were after the switches.

    less export_led
    #!/bin/bash
    echo "++ Exporting leds "                
    for i in 0 1 2 3 4 5 6 7;
    do                      
            led=$(($i+73));
      techo $led > /sys/class/gpio/export;
            echo out > /sys/class/gpio/gpio$led/direction;
    done;

    ++ Exporting leds
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio73/direction: No such file or director
    y
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio74/direction: No such file or director
    y
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio75/direction: No such file or director
    y
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio76/direction: No such file or director
    y
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio77/direction: No such file or director
    y
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio78/direction: No such file or director
    y
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio79/direction: No such file or director
    y
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio80/direction: No such file or director
    y
    Step 8 no new gpio73-gpio80.
    ls /sys/class/gpio
    export  gpio66  gpio68  gpio70  gpio72     unexport
    gpio65  gpio67  gpio69  gpio71  gpiochip0

    Step 9 modified export_led
    #!/bin/bash
    echo "++ Exporting leds "
    for i in 0 1 2 3 4 5 6 7;
    do
            led=$(($i+57));
            echo $led > /sys/class/gpio/export;
            echo out > /sys/class/gpio/gpio$led/direction;
    done;
    ./export_led
    ++ Exporting leds
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio57/direction: No such file or director
    y
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio58/direction: No such file or director
    y
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio59/direction: No such file or director
    y
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio60/direction: No such file or director
    y
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio61/direction: No such file or director
    y
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio62/direction: No such file or director
    y
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio63/direction: No such file or director
    y
    ./export_led: line 6: echo: write error: Device or resource busy
    ./export_led: line 7: /sys/class/gpio/gpio64/direction: No such file or director
    y
    step 10
    ls /sys/class/gpio no new gpio57-gpio64
    export  gpio66  gpio68  gpio70  gpio72     unexport
    gpio65  gpio67  gpio69  gpio71  gpiochip0
    The initial system.bit was ZedBoard_Linux_Design.
    fpga.bin was generated with cf_adv7511_zed and uses
    less /etc/init.d/fpga-image-load.sh
    #!/bin/sh

    BITFILE=/usr/share/fpga.bin

    case "$1" in
      start)
        if [ ! -e /dev/xdevcfg ]; then
          mknod /dev/xdevcfg c 259 0
        fi
        if [ ! -e "${BITFILE}" ]; then
          echo "FPGA bitfile ${BITFILE} does not exist"
          exit 1
        fi
        cat "${BITFILE}" > /dev/xdevcfg
        result=`cat /sys/devices/amba.[0123]/f8007000.devcfg/prog_done`
        if [ $result -ne 1 ]; then
          echo "ERROR configuring FPGA, logic is not configured!"
          exit 1
        fi
        ;;
    esac

    Any and all help is appreciated.
    Thanks


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago

    Take a look at the Zynq Linux Speedway, Lab 3.1 and see if that is helpful. It is based on an older version of the tools/linux but may still be on target.The Implementing Linux on the Zynq 7000 SoC can be downloaded from here:

     

    http://www.zedboard.org/support/trainings-and-videos

     

    Let us know how it works.

     

    -Gary

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago

    Hello All
    My problem is that I cannot get the 8 leds to work.  The 8 switches are working.
    ls /sys/class/gpio/
    export    gpiochip0  unexport
    root@zedboard:/etc/init.d# export_sw
    ++ Exporting switches
    root@zedboard:/etc/init.d# cat /usr/bin/export_sw
    #!/bin/bash
    #This appears to work with fpga.bin loaded
    echo "++ Exporting switches "
    for i in 0 1 2 3 4 5 6 7;
    do
            sw=$(($i+65));
            echo $sw > /sys/class/gpio/export;
    done;
    root@zedboard:/etc/init.d# ls /sys/class/gpio/
    export    gpio66    gpio68    gpio70    gpio72       unexport
    gpio65    gpio67    gpio69    gpio71    gpiochip0
    cat /usr/bin/read_sw
    #!/bin/sh
    value=0;
    for i in 0 1 2 3 4 5 6 7;
    do
            sw=$((72-$i));
            sw_tmp=`cat /sys/class/gpio/gpio$sw/value`;
            value=$(($value*2));
            value=$(($value+$sw_tmp));
    done;
    printf "0x%x %d
    " $value $value;
    setting the switches 10101010
    root@zedboard:/etc/init.d# read_sw
    0xaa 170

    I recently built a system.bit and with meta-topic a fpga.bin
    It appears that the fpga.bin is being loaded since I have a script
    ck_fpga  that I extracted from /etc/init.d/fpga-image-load.sh
    #!/bin/sh
    #extracted from /etc/init.d/fpga-image-load.sh
    #used to check if fpga.bin was loaded.
    result=`cat     /sys/devices/amba.[0123]/f8007000.devcfg/prog_done`
    echo $result
    root@zedboard:~# ./ck_fpga
    1

    I would think that 8 Leds would be 73-80.
    cat /usr/bin/export_led
    #!/bin/bash
    #This appears to work with fpga.bin loaded
    echo "++ Exporting switches "
    for i in 0 1 2 3 4 5 6 7 ;
    do
            led=$(($i+73));
            echo $led > /sys/class/gpio/export;
            echo out > /sys/class/gpio/gpio$led/direction;
    done;
    This gets errors.
    Could this be the problem ZedBoard_Linux_Design net processing_system7_0_GPIO<7>  LOC = T22 while the
    cf_adv7511_zed uses NET processing_system7_0_GPIO_pin[11].  I have gone over this many times but can not determine the offsets needed to get the 8 Leds to work.   Any and all help is appreciated. Thanks
                                               ZedBoard_Linux_Design
    system.ucf
    ############################
    #                          #
    # On-board LED's           #
    #                          #
    ############################
    net processing_system7_0_GPIO<7>  LOC = T22 | IOSTANDARD = LVCMOS33;    # LD0
    net processing_system7_0_GPIO<8>  LOC = T21 | IOSTANDARD = LVCMOS33;    # LD1
    net processing_system7_0_GPIO<9>  LOC = U22 | IOSTANDARD = LVCMOS33;    # LD2
    net processing_system7_0_GPIO<10> LOC = U21 | IOSTANDARD = LVCMOS33;    # LD3
    net processing_system7_0_GPIO<11> LOC = V22 | IOSTANDARD = LVCMOS33;    # LD4
    net processing_system7_0_GPIO<12> LOC = W22 | IOSTANDARD = LVCMOS33;    # LD5
    net processing_system7_0_GPIO<13> LOC = U19 | IOSTANDARD = LVCMOS33;    # LD6
    net processing_system7_0_GPIO<14> LOC = U14 | IOSTANDARD = LVCMOS33;    # LD7

    ############################
    #                          #
    # On-board Slide Switches  #
    #                          #
    ############################
    net processing_system7_0_GPIO<15> LOC = F22 | IOSTANDARD = LVCMOS33;    # SW0
    net processing_system7_0_GPIO<16> LOC = G22 | IOSTANDARD = LVCMOS33;    # SW1
    net processing_system7_0_GPIO<17> LOC = H22 | IOSTANDARD = LVCMOS33;    # SW2
    net processing_system7_0_GPIO<18> LOC = F21 | IOSTANDARD = LVCMOS33;    # SW3
    net processing_system7_0_GPIO<19> LOC = H19 | IOSTANDARD = LVCMOS33;    # SW4
    net processing_system7_0_GPIO<20> LOC = H18 | IOSTANDARD = LVCMOS33;    # SW5
    net processing_system7_0_GPIO<21> LOC = H17 | IOSTANDARD = LVCMOS33;    # SW6
    net processing_system7_0_GPIO<22> LOC = M15 | IOSTANDARD = LVCMOS33;    # SW7
    GPIO
        MIO GPIO MIO
            EMIO GPIO (Width) 60
    MIO 0   GPIO gpio[0] disabled
    MIO 9   GPIO gpio[9] disabled
    MIO 10   GPIO gpio[10] disabled
               .
               .
               .
    MIO 15   GPIO gpio[15] disabled
    Ports
                  Connected Port
    (IO_IF)GPIO_0 Connected to External Ports
                  External Posts::processing_system7_0_MIO
           GPIO   External Posts::processing_system7_0_GPIO IO [59:0]
           GPIO_I                                             I [59:0]
           GPIO_O                                             O [59:0]
           GPIO_T                                             O [59:0]


                                               cf_adv7511_zed
    system.ucf
    NET processing_system7_0_GPIO_pin[11]    LOC = F22  | IOSTANDARD="LVCMOS25";  # "SW0"
    NET processing_system7_0_GPIO_pin[12]    LOC = G22  | IOSTANDARD="LVCMOS25";  # "SW1"
    NET processing_system7_0_GPIO_pin[13]    LOC = H22  | IOSTANDARD="LVCMOS25";  # "SW2"
    NET processing_system7_0_GPIO_pin[14]    LOC = F21  | IOSTANDARD="LVCMOS25";  # "SW3"
    NET processing_system7_0_GPIO_pin[15]    LOC = H19  | IOSTANDARD="LVCMOS25";  # "SW4"
    NET processing_system7_0_GPIO_pin[16]    LOC = H18  | IOSTANDARD="LVCMOS25";  # "SW5"
    NET processing_system7_0_GPIO_pin[17]    LOC = H17  | IOSTANDARD="LVCMOS25";  # "SW6"
    NET processing_system7_0_GPIO_pin[18]    LOC = M15  | IOSTANDARD="LVCMOS25";  # "SW7"

    NET processing_system7_0_GPIO_pin[19]    LOC = T22  | IOSTANDARD="LVCMOS33";  # "LD0"
    NET processing_system7_0_GPIO_pin[20]    LOC = T21  | IOSTANDARD="LVCMOS33";  # "LD1"
    NET processing_system7_0_GPIO_pin[21]    LOC = U22  | IOSTANDARD="LVCMOS33";  # "LD2"
    NET processing_system7_0_GPIO_pin[22]    LOC = U21  | IOSTANDARD="LVCMOS33";  # "LD3"
    NET processing_system7_0_GPIO_pin[23]    LOC = V22  | IOSTANDARD="LVCMOS33";  # "LD4"
    NET processing_system7_0_GPIO_pin[24]    LOC = W22  | IOSTANDARD="LVCMOS33";  # "LD5"
    NET processing_system7_0_GPIO_pin[25]    LOC = U19  | IOSTANDARD="LVCMOS33";  # "LD6"
    NET processing_system7_0_GPIO_pin[26]    LOC = U14  | IOSTANDARD="LVCMOS33";  # "LD7"
    GPIO
        MIO GPIO MIO
            EMIO GPIO (Width) 32
    MIO 0   GPIO gpio[0] disabled
    MIO 9   GPIO gpio[9] disabled
    MIO 10   GPIO gpio[10] disabled
               .
               .
               .
    MIO 15   GPIO gpio[15] disabled
    Ports
                  Connected Port
    (IO_IF)GPIO_0 Connected to External Ports
           GPIO   External Posts::processing_system7_0_GPIO_pin IO [31:0]
           GPIO_I                                             I [31:0]
           GPIO_O                                             O [31:0]
           GPIO_T                                             O [31:0]

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago

    Hello All
    /usr/bin/export_sw
    #!/bin/bash
    #This appears to work with fpga.bin loaded
    echo "++ Exporting switches "
    for i in 0 1 2 3 4 5 6 7;
    do
            sw=$(($i+65));
            echo $sw > /sys/class/gpio/export;
    done;
    /usr/bin/read_sw
    #!/bin/sh
    value=0;
    for i in 0 1 2 3 4 5 6 7;
    do
            sw=$((72-$i));
            sw_tmp=`cat /sys/class/gpio/gpio$sw/value`;
            value=$(($value*2));
            value=$(($value+$sw_tmp));
    done;
    printf "0x%x %d
    " $value $value;
    echo default-on > /sys/class/leds/ld0:red/trigger
    or
    echo 0 > /sys/class/leds/ld7:red/brightness
    echo 1 > /sys/class/leds/ld7:red/brightness
    Thanks to
    Mike Looijmans

        TOPIC Embedded Systems
        Eindhovenseweg 32-C, NL-5683 KH Best
        Postbus 440, NL-5680 AK Best
        Telefoon: (+31) (0) 499 33 69 79
    He See the documentation, just google on "/sys/class/leds" for directions.also provided a site for help on leds
    meta-topic and poky also fixed sound ADAU1761
    Thanks all

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube