diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-07-05 13:21:02 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-07-05 14:21:32 -0400 |
commit | 2d173f51b1531ffbde3723655bae0adb9bca5ecb (patch) | |
tree | 781921bb209c5b116b8bf0c0bd7f5869734f9cbd /scripts | |
parent | b32ba3727bf6b07bb1099cde694f9d55081855ca (diff) | |
download | kutter-2d173f51b1531ffbde3723655bae0adb9bca5ecb.tar.gz kutter-2d173f51b1531ffbde3723655bae0adb9bca5ecb.tar.xz kutter-2d173f51b1531ffbde3723655bae0adb9bca5ecb.zip |
pru: Add documentation and install scripts for running on the PRU
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/install-beaglebone.sh | 65 | ||||
-rwxr-xr-x | scripts/klipper-pru-start.sh | 36 |
2 files changed, 101 insertions, 0 deletions
diff --git a/scripts/install-beaglebone.sh b/scripts/install-beaglebone.sh new file mode 100755 index 00000000..209f6948 --- /dev/null +++ b/scripts/install-beaglebone.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# This script installs Klipper on a Beaglebone running Debian Jessie +# for use with its PRU micro-controller. + +# Step 1: Do main install +install_main() +{ + # Run the octopi script - raspbian is close enough to debian for + # this to work. + ${SRCDIR}/scripts/install-octopi.sh +} + +# Step 2: Install additional system packages +install_packages() +{ + # Install desired packages + PKGLIST="gcc-pru" + + report_status "Installing beaglebone packages..." + sudo apt-get install --yes ${PKGLIST} +} + +# Step 3: Install startup script +install_script() +{ + report_status "Installing pru start script..." + sudo cp "${SRCDIR}/scripts/klipper-pru-start.sh" /etc/init.d/klipper_pru + sudo update-rc.d klipper_pru defaults +} + +# Step 4: Install pru udev rule +install_udev() +{ + report_status "Installing pru udev rule..." + sudo /bin/sh -c "cat > /etc/udev/rules.d/pru.rules" <<EOF +KERNEL=="rpmsg_pru30", MODE="0666" +EOF +} + +# Helper functions +report_status() +{ + echo -e "\n\n###### $1" +} + +verify_ready() +{ + if [ "$EUID" -eq 0 ]; then + echo "This script must not run as root" + exit -1 + fi +} + +# Force script to exit if an error occurs +set -e + +# Find SRCDIR from the pathname of this script +SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )" + +# Run installation steps defined above +verify_ready +install_main +install_packages +install_script +install_udev diff --git a/scripts/klipper-pru-start.sh b/scripts/klipper-pru-start.sh new file mode 100755 index 00000000..747543a2 --- /dev/null +++ b/scripts/klipper-pru-start.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# System startup script to start the PRU firmware + +### BEGIN INIT INFO +# Provides: klipper_pru +# Required-Start: $local_fs +# Required-Stop: +# Default-Start: 3 4 5 +# Default-Stop: 0 1 2 6 +# Short-Description: Klipper_PRU daemon +# Description: Starts the PRU for Klipper. +### END INIT INFO + +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +DESC="klipper_pru startup" +NAME="klipper_pru" + +. /lib/lsb/init-functions + +case "$1" in +start) log_daemon_msg "Starting klipper_pru" $NAME + # Enable ADC module + echo 'BB-ADC' > /sys/devices/platform/bone_capemgr/slots + # Start PRU firmware + if [ ! -c /dev/rpmsg_pru30 ]; then + rmmod -f pru_rproc + modprobe pru_rproc + fi + ;; +stop|restart|reload|force-reload|status) + ;; +*) log_action_msg "Usage: /etc/init.d/klipper_pru {start|stop|status|restart|reload|force-reload}" + exit 2 + ;; +esac +exit 0 |