scripts: Replicape pru update start scripts (#2277)
Signed-off-by: Trevor Wilson <altocoey@hotmail.com>
This commit is contained in:
parent
f3b4173e6b
commit
7532e4ccea
|
@ -5,10 +5,11 @@ Building an OS image
|
||||||
====================
|
====================
|
||||||
|
|
||||||
Start by installing the
|
Start by installing the
|
||||||
[latest Jessie IoT](https://beagleboard.org/latest-images) image
|
[Debian 9.9 2019-08-03 4GB SD IoT]
|
||||||
(2017-03-19 or later). One may run the image from either a micro-SD
|
(https://beagleboard.org/latest-images) image.
|
||||||
card or from builtin eMMC. If using the eMMC, install it to eMMC now
|
One may run the image from either a micro-SD card or from
|
||||||
by following the instructions from the above link.
|
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 --
|
Then ssh into the beaglebone machine (ssh debian@beaglebone --
|
||||||
password is "temppwd") and install Klipper by running the following
|
password is "temppwd") and install Klipper by running the following
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
# Step 1: Do main install
|
# Step 1: Do main install
|
||||||
install_main()
|
install_main()
|
||||||
{
|
{
|
||||||
# Run the octopi script - raspbian is close enough to debian for
|
# Run the debian script - should
|
||||||
# this to work.
|
# work.
|
||||||
${SRCDIR}/scripts/install-octopi.sh
|
${SRCDIR}/scripts/install-debian.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
# Step 2: Install additional system packages
|
# Step 2: Install additional system packages
|
||||||
|
|
|
@ -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
|
|
@ -17,6 +17,8 @@ NAME="klipper_pru"
|
||||||
KLIPPER_HOST_MCU=/usr/local/bin/klipper_mcu
|
KLIPPER_HOST_MCU=/usr/local/bin/klipper_mcu
|
||||||
KLIPPER_HOST_ARGS="-w -r"
|
KLIPPER_HOST_ARGS="-w -r"
|
||||||
PIDFILE=/var/run/klipper_mcu.pid
|
PIDFILE=/var/run/klipper_mcu.pid
|
||||||
|
RPROC0=/sys/class/remoteproc/remoteproc1
|
||||||
|
RPROC1=/sys/class/remoteproc/remoteproc2
|
||||||
|
|
||||||
. /lib/lsb/init-functions
|
. /lib/lsb/init-functions
|
||||||
|
|
||||||
|
@ -35,8 +37,8 @@ pru_stop()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_daemon_msg "Stopping pru"
|
log_daemon_msg "Stopping pru"
|
||||||
echo 4a334000.pru0 > /sys/bus/platform/drivers/pru-rproc/unbind
|
echo 'stop' > $RPROC0/state
|
||||||
echo 4a338000.pru1 > /sys/bus/platform/drivers/pru-rproc/unbind
|
echo 'stop' > $RPROC1/state
|
||||||
}
|
}
|
||||||
|
|
||||||
pru_start()
|
pru_start()
|
||||||
|
@ -44,17 +46,17 @@ pru_start()
|
||||||
if [ -c /dev/rpmsg_pru30 ]; then
|
if [ -c /dev/rpmsg_pru30 ]; then
|
||||||
pru_stop
|
pru_stop
|
||||||
else
|
else
|
||||||
echo 4a334000.pru0 > /sys/bus/platform/drivers/pru-rproc/unbind
|
echo 'stop' > $RPROC0/state
|
||||||
echo 4a338000.pru1 > /sys/bus/platform/drivers/pru-rproc/unbind
|
echo 'stop' > $RPROC1/state
|
||||||
fi
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
log_daemon_msg "Starting pru"
|
log_daemon_msg "Starting pru"
|
||||||
echo 4a334000.pru0 > /sys/bus/platform/drivers/pru-rproc/bind
|
echo 'start' > $RPROC0/state
|
||||||
echo 4a338000.pru1 > /sys/bus/platform/drivers/pru-rproc/bind
|
echo 'start' > $RPROC1/state
|
||||||
|
|
||||||
log_daemon_msg "Loading ADC module"
|
# log_daemon_msg "Loading ADC module"
|
||||||
echo 'BB-ADC' > /sys/devices/platform/bone_capemgr/slots
|
# echo 'BB-ADC' > /sys/devices/platform/bone_capemgr/slots
|
||||||
}
|
}
|
||||||
|
|
||||||
mcu_host_stop()
|
mcu_host_stop()
|
||||||
|
|
Loading…
Reference in New Issue