Sorry, you need to enable JavaScript to visit this website.

Can't find read_sw and write_led scripts

Unsolved
5 posts / 0 new
vsm's picture
vsm
Junior(0)
Can't find read_sw and write_led scripts

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

zedhed's picture
zedhed
Moderator(22)
RE: Can't find read_sw and write_led scripts

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\n" $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

nwk's picture
nwk
Junior(0)
setup gpio first

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;

roumarou's picture
roumarou
Junior(0)
application linux .

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

roumarou's picture
roumarou
Junior(0)
# include "xgpio.h"

# 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;
}