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
  • 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
Avnet Boards General Can't find read_sw and write_led scripts
  • 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 4 replies
  • Subscribers 356 subscribers
  • Views 656 views
  • Users 0 members are here
Related

Can't find read_sw and write_led scripts

Former Member
Former Member over 13 years ago

I'm just getting started withe the ZedBoard and trying to run Demo 1 in the u201CGetting Started Guideu201D.  According to the guide, there should be a read_sw script and a write_led script in /usr/bin, but I donu2019t see those scripts.  Anyone run into this issue before?

  • Sign in to reply
  • Cancel
  • zedhed
    0 zedhed over 13 years ago

    Hi vsm,

    I see both of those scripts in /usr/bin

    The read_sw script consists of the following:

    #!/bin/sh
    value=0;
    for i in 0 1 2 3 4 5 6 7;
    do
            sw=$((76-$i));
            sw_tmp=`cat /sys/class/gpio/gpio$sw/value`;
            value=$(($value*2));
            value=$(($value+$sw_tmp));
    done;
    printf "0x%x %d
    " $value $value;

    The write_led consists of the following:

    #!/bin/sh
    value=$(($1));

    if [ $value -ge 0 ]; then
            for i in 0 1 2 3 4 5 6 7;
            do
                    led=$(($i+61));
                    echo $(($value&0x01)) > /sys/class/gpio/gpio$led/value;
                    value=$(($value/2));
            done;
    fi;

    Is is possible that you have overwritten your SD card with a different build of Linux?  If so, you could restore your image back to the factory settings by using the SD card image from the Digilent source files package.

    Take a look at this post, which discusses the Digilent source package:

    http://zedboard.org/node/241

    Regards,

    -Kevin

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • nwk
    0 nwk over 12 years ago

    Also, in order to use the read_sw and write_led scripts, you first need to setup the gpio.


    The SD card that ships with the Zedboard does this with /etc/init.d/rcS:


    echo "++ Exporting LEDs & SWs"
    for i in 0 1 2 3 4 5 6 7;
    do
      sw=$(($i+69));
      led=$(($i+61));
      echo $sw > /sys/class/gpio/export;
      echo $led > /sys/class/gpio/export;
      echo out > /sys/class/gpio/gpio$led/direction;
    done;

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

    Good evening, I'm doing my memory, the second year in master, after build in the linux zedboard. I want to turn the LEDs without the write_led . with a Linux application in the SDK tool:

    using the port in the file system.ucf
    Net processing_system7_0_GPIO <7> LOC = T22 | IOSTANDARD = LVCMOS33;
    Net processing_system7_0_GPIO <8> LOC = T21 | IOSTANDARD = LVCMOS33;
    Net processing_system7_0_GPIO <9> LOC = U22 | = IOSTANDARD= LVCMOS33;
    Net processing_system7_0_GPIO <10> LOC = U21 | = IOSTANDARD =LVCMOS33;
    Net processing_system7_0_GPIO <11> LOC = V22 | = IOSTANDARD =LVCMOS33;
    Net processing_system7_0_GPIO <12> LOC = W22 | IOSTANDARD = LVCMOS33;
    Net processing_system7_0_GPIO <13> LOC = U19 | = IOSTANDARD =LVCMOS33;
    Net processing_system7_0_GPIO <14> LOC = U14 | = IOSTANDARD= LVCMOS33;

    I don't no if the port using is correct or not?

    # include "xgpio.h"
    # include "xparameters.h"
    int main ();
    {
    xgpio LED;

    XGpio_Initialize (& led, XPAR_PS7_GPIO_0_DEVICE_ID);
       Bits 7-14 / / i can find the right mask derection; XGpio_SetDataDirection (& LED, 1.0 x0000)
    XGpio_DiscreteWrite (& LED xffff 1.0);

    return 0;
    }


    thank you :)

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

    # include "xgpio.h"
    # include "xparameters.h"
    int main ();
    {
    xgpio LED;

    XGpio_Initialize (& led, XPAR_PS7_GPIO_0_DEVICE_ID);
    XGpio_SetDataDirection (& LED,1,x0000)//i can find the right mask derection Bits 7-14
    XGpio_DiscreteWrite (& LED,1,0xffff);

    return 0;
    }

    • 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