redpitaya-puzzlefw/sw/buildroot_overlay/etc/init.d/S91puzzlefw_driver.sh

51 lines
987 B
Bash
Raw Normal View History

2024-09-22 11:35:58 +02:00
#!/bin/sh
#
# Load puzzlefw kernel driver.
#
start() {
# Check that the FPGA is running.
# If the PuzzleFW firmware is not running on the FPGA,
# attempting to load the driver will crash the system.
read fpga_state </sys/class/fpga_manager/fpga0/state
if [ "$fpga_state" != "operating" ]; then
echo "ERROR: FPGA not operating" >&2
exit 1
fi
2024-10-05 00:34:40 +02:00
# Check that the FPGA has finished reset.
# If the FPGA is in reset, loading the driver will crash the system.
reset_done="$(gpioget 0 55)"
if [ "$reset_done" -ne 1 ]; then
echo "ERROR: FPGA in reset" >&2
exit 1
fi
2024-09-22 11:35:58 +02:00
# Load module.
echo "Loading puzzlefw driver ..."
insmod /opt/puzzlefw/driver/puzzlefw.ko
}
stop() {
echo -n "Unloading puzzlefw driver ..."
rmmod puzzlefw
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac