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 1122 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
Parents
  • 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
Reply
  • 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
Children
No Data
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