raspberrypi / cmprovision

Provisioning system for CM4 products
BSD 3-Clause "New" or "Revised" License
88 stars 11 forks source link

Progress on flashing #51

Open neil-benn opened 2 weeks ago

neil-benn commented 2 weeks ago

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 commented 2 weeks ago

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

https://github.com/raspberrypi/cmprovision/blob/f19ceec6065b77957fee0b10d7b655522c069bf7/resources/views/scriptexecute.blade.php#L107-L119

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)