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

51 lines
987 B
Bash
Executable File

#!/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
# 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
# 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