aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBlackStump <altocoey@hotmail.com>2019-12-19 04:11:40 +1100
committerKevinOConnor <kevin@koconnor.net>2019-12-18 12:11:40 -0500
commit7532e4ccea6f89e31d0d2f7f2f7e8ddac64abd46 (patch)
treeee12d8b400f0c38b081be05ee2890eb7fbbe7474
parentf3b4173e6b4b6ebd34b7efc31c07914d063f3b07 (diff)
downloadkutter-7532e4ccea6f89e31d0d2f7f2f7e8ddac64abd46.tar.gz
kutter-7532e4ccea6f89e31d0d2f7f2f7e8ddac64abd46.tar.xz
kutter-7532e4ccea6f89e31d0d2f7f2f7e8ddac64abd46.zip
scripts: Replicape pru update start scripts (#2277)
Signed-off-by: Trevor Wilson <altocoey@hotmail.com>
-rw-r--r--docs/beaglebone.md9
-rwxr-xr-xscripts/install-beaglebone.sh6
-rw-r--r--scripts/install-debian.sh105
-rwxr-xr-xscripts/klipper-pru-start.sh18
4 files changed, 123 insertions, 15 deletions
diff --git a/docs/beaglebone.md b/docs/beaglebone.md
index 2dcba7a3..af0d6d1d 100644
--- a/docs/beaglebone.md
+++ b/docs/beaglebone.md
@@ -5,10 +5,11 @@ Building an OS image
====================
Start by installing the
-[latest Jessie IoT](https://beagleboard.org/latest-images) image
-(2017-03-19 or later). One may run the image from either a micro-SD
-card or from builtin eMMC. If using the eMMC, install it to eMMC now
-by following the instructions from the above link.
+[Debian 9.9 2019-08-03 4GB SD IoT]
+(https://beagleboard.org/latest-images) image.
+One may run the image from either a micro-SD card or from
+builtin eMMC. If using the eMMC, install it to eMMC now by
+following the instructions from the above link.
Then ssh into the beaglebone machine (ssh debian@beaglebone --
password is "temppwd") and install Klipper by running the following
diff --git a/scripts/install-beaglebone.sh b/scripts/install-beaglebone.sh
index 695e9f15..a68c8d06 100755
--- a/scripts/install-beaglebone.sh
+++ b/scripts/install-beaglebone.sh
@@ -5,9 +5,9 @@
# 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
+ # Run the debian script - should
+ # work.
+ ${SRCDIR}/scripts/install-debian.sh
}
# Step 2: Install additional system packages
diff --git a/scripts/install-debian.sh b/scripts/install-debian.sh
new file mode 100644
index 00000000..e2614d76
--- /dev/null
+++ b/scripts/install-debian.sh
@@ -0,0 +1,105 @@
+#!/bin/bash
+# This script installs Klipper on an debian
+#
+
+PYTHONDIR="${HOME}/klippy-env"
+SYSTEMDDIR="/etc/systemd/system"
+KLIPPER_USER=$USER
+KLIPPER_GROUP=$KLIPPER_USER
+
+# Step 1: Install system packages
+install_packages()
+{
+ # Packages for python cffi
+ PKGLIST="python-virtualenv virtualenv python-dev libffi-dev build-essential"
+ # kconfig requirements
+ PKGLIST="${PKGLIST} libncurses-dev"
+ # hub-ctrl
+ PKGLIST="${PKGLIST} libusb-dev"
+ # AVR chip installation and building
+ PKGLIST="${PKGLIST} avrdude gcc-avr binutils-avr avr-libc"
+ # ARM chip installation and building
+ PKGLIST="${PKGLIST} stm32flash libnewlib-arm-none-eabi"
+ PKGLIST="${PKGLIST} gcc-arm-none-eabi binutils-arm-none-eabi"
+
+ # Update system package info
+ report_status "Running apt-get update..."
+ sudo apt-get update
+
+ # Install desired packages
+ report_status "Installing packages..."
+ sudo apt-get install --yes ${PKGLIST}
+}
+
+# Step 2: Create python virtual environment
+create_virtualenv()
+{
+ report_status "Updating python virtual environment..."
+
+ # Create virtualenv if it doesn't already exist
+ [ ! -d ${PYTHONDIR} ] && virtualenv ${PYTHONDIR}
+
+ # Install/update dependencies
+ ${PYTHONDIR}/bin/pip install -r ${SRCDIR}/scripts/klippy-requirements.txt
+}
+
+# Step 3: Install startup script
+install_script()
+{
+# Create systemd service file
+ KLIPPER_LOG=/tmp/klippy.log
+ report_status "Installing system start script..."
+ sudo /bin/sh -c "cat > $SYSTEMDDIR/klipper.service" << EOF
+#Systemd service file for klipper
+[Unit]
+Description=Starts klipper on startup
+After=network.target
+
+[Install]
+WantedBy=multi-user.target
+
+[Service]
+Type=simple
+User=$KLIPPER_USER
+RemainAfterExit=yes
+ExecStart=${PYTHONDIR}/bin/python ${SRCDIR}/klippy/klippy.py ${HOME}/printer.cfg -l ${KLIPPER_LOG}
+Restart=always
+RestartSec=10
+EOF
+# Use systemctl to enable the klipper systemd service script
+ sudo systemctl enable klipper.service
+}
+
+# Step 4: Start host software
+start_software()
+{
+ report_status "Launching Klipper host software..."
+ sudo systemctl start klipper
+}
+
+# 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_packages
+create_virtualenv
+install_script
+start_software
diff --git a/scripts/klipper-pru-start.sh b/scripts/klipper-pru-start.sh
index 88ff98e0..5d9af529 100755
--- a/scripts/klipper-pru-start.sh
+++ b/scripts/klipper-pru-start.sh
@@ -17,6 +17,8 @@ NAME="klipper_pru"
KLIPPER_HOST_MCU=/usr/local/bin/klipper_mcu
KLIPPER_HOST_ARGS="-w -r"
PIDFILE=/var/run/klipper_mcu.pid
+RPROC0=/sys/class/remoteproc/remoteproc1
+RPROC1=/sys/class/remoteproc/remoteproc2
. /lib/lsb/init-functions
@@ -35,8 +37,8 @@ pru_stop()
fi
log_daemon_msg "Stopping pru"
- echo 4a334000.pru0 > /sys/bus/platform/drivers/pru-rproc/unbind
- echo 4a338000.pru1 > /sys/bus/platform/drivers/pru-rproc/unbind
+ echo 'stop' > $RPROC0/state
+ echo 'stop' > $RPROC1/state
}
pru_start()
@@ -44,17 +46,17 @@ pru_start()
if [ -c /dev/rpmsg_pru30 ]; then
pru_stop
else
- echo 4a334000.pru0 > /sys/bus/platform/drivers/pru-rproc/unbind
- echo 4a338000.pru1 > /sys/bus/platform/drivers/pru-rproc/unbind
+ echo 'stop' > $RPROC0/state
+ echo 'stop' > $RPROC1/state
fi
sleep 1
log_daemon_msg "Starting pru"
- echo 4a334000.pru0 > /sys/bus/platform/drivers/pru-rproc/bind
- echo 4a338000.pru1 > /sys/bus/platform/drivers/pru-rproc/bind
+ echo 'start' > $RPROC0/state
+ echo 'start' > $RPROC1/state
- log_daemon_msg "Loading ADC module"
- echo 'BB-ADC' > /sys/devices/platform/bone_capemgr/slots
+ # log_daemon_msg "Loading ADC module"
+ # echo 'BB-ADC' > /sys/devices/platform/bone_capemgr/slots
}
mcu_host_stop()