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

43 lines
735 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
# 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