Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress on flashing #51

Open
neil-benn opened this issue Jun 14, 2024 · 1 comment
Open

Progress on flashing #51

neil-benn opened this issue Jun 14, 2024 · 1 comment

Comments

@neil-benn
Copy link

Hello,

I'm trying to work out if I can turn an LED on when a board is being flashed and turn it off when it has finished. I was thinking of using the pre and post install scripts and raspi-gpio configure a gpio to output and drive it high/low with the scripts.

I think that the pre/post install scripts are run on the target RPi however a simple command of raspi-gpio set 17 OP dh in the script doesn't work. Is it possible for the pre install scripts to access the GPIO hardware or am I limited to file operations alone.

If that is the case then where on the provisioner code is the area that controls the flashing please? I can then look at hooking lights up to the provisioner RPi to detail that something is being flashed.

Thanks.

Cheers,

Neil

@maxnet
Copy link
Collaborator

maxnet commented Jun 15, 2024

By default if there is a single led defined in the device tree it will toggle it on start of provisioning and when done.
If there is a led0 and led1 it will blink alternately when finished.

https://github.com/raspberrypi/scriptexecutor/blob/640d74972f0d775c3bee112d80e5b25b4a64ed25/scriptexecute/board/overlay/etc/init.d/S99scriptexec#L33-L36

if [ -e /sys/class/leds/led1 ]; then
while true; do
echo 255 > /sys/class/leds/led0/brightness
echo 0 > /sys/class/leds/led1/brightness
sleep 0.5
echo 0 > /sys/class/leds/led0/brightness
echo 255 > /sys/class/leds/led1/brightness
sleep 0.5
done
fi
if [ -e /sys/class/leds/led0 ]; then
echo 255 > /sys/class/leds/led0/brightness
fi

Naturally, if you use a different board design and want other GPIOs than usual for leds, you must alter the device tree accordingly so the led maps to the right GPIO, and toss the device tree (overlay) files and config.txt modification in /var/lib/cmprovision/scriptexecute

If you want to take shortcuts, and access GPIOs directly instead of writing a device tree file for your board, you can do so as well, but then you will need to use shell commands that work with the /sys gpio interface instead of convenience programs like "raspi-gpio" that do not exist in Linux distributions other than RPI OS.

Among the lines of:

# Make GPIO available to user space
echo "17" >/sys/class/gpio/export
echo "out" >/sys/class/gpio/gpio17/direction
# Turn it on
echo "1" >/sys/class/gpio/gpio17/value

(untested)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants