diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-07-05 12:26:47 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-07-05 12:50:54 -0400 |
commit | b32ba3727bf6b07bb1099cde694f9d55081855ca (patch) | |
tree | 4368c2732df640f381eecd2ff2ca49ebf05de6f3 /scripts | |
parent | 57932713086ad599048c7b70fb89285d55c86f92 (diff) | |
download | kutter-b32ba3727bf6b07bb1099cde694f9d55081855ca.tar.gz kutter-b32ba3727bf6b07bb1099cde694f9d55081855ca.tar.xz kutter-b32ba3727bf6b07bb1099cde694f9d55081855ca.zip |
pru: Add support for "make flash" rule
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/flash-pru.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/flash-pru.sh b/scripts/flash-pru.sh new file mode 100755 index 00000000..c0fee3e5 --- /dev/null +++ b/scripts/flash-pru.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# This script installs the PRU firmware on a beaglebone machine. + +if [ "$EUID" -ne 0 ]; then + echo "This script must be run as root" + exit -1 +fi +set -e + +# Install new firmware +echo "Installing firmware to /lib/firmware/" +cp out/pru0.elf /lib/firmware/am335x-pru0-fw +cp out/pru1.elf /lib/firmware/am335x-pru1-fw +sync + +# Shutdown existing Klipper instance (if applicable). The goal is to +# put the GPIO pins in a safe state. +if [ -c /dev/rpmsg_pru30 ]; then + echo "Attempting to shutdown existing firmware..." + ( echo "FORCE_SHUTDOWN" > /dev/rpmsg_pru30 ) 2> /dev/null || ( echo "Firmware busy! Please shutdown Klipper and then retry." && exit 1 ) + sleep 1 + ( echo "FORCE_SHUTDOWN" > /dev/rpmsg_pru30 ) 2> /dev/null || ( echo "Firmware busy! Please shutdown Klipper and then retry." && exit 1 ) + sleep 1 +fi +set +e + +# Restart the PRU +echo "Restarting pru_rproc module" +rmmod -f pru_rproc +modprobe pru_rproc |