From 2d173f51b1531ffbde3723655bae0adb9bca5ecb Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 5 Jul 2017 13:21:02 -0400 Subject: [PATCH] pru: Add documentation and install scripts for running on the PRU Signed-off-by: Kevin O'Connor --- config/generic-cramps.cfg | 75 +++++++++++++++++++++++++++++++++ config/generic-replicape.cfg | 78 ++++++++++++++++++++++++++++++++++ docs/beaglebone.md | 79 +++++++++++++++++++++++++++++++++++ scripts/install-beaglebone.sh | 65 ++++++++++++++++++++++++++++ scripts/klipper-pru-start.sh | 36 ++++++++++++++++ 5 files changed, 333 insertions(+) create mode 100644 config/generic-cramps.cfg create mode 100644 config/generic-replicape.cfg create mode 100644 docs/beaglebone.md create mode 100755 scripts/install-beaglebone.sh create mode 100755 scripts/klipper-pru-start.sh diff --git a/config/generic-cramps.cfg b/config/generic-cramps.cfg new file mode 100644 index 00000000..969faaf2 --- /dev/null +++ b/config/generic-cramps.cfg @@ -0,0 +1,75 @@ +# This file contains an example configuration for a Beaglebone PRU +# micro-controller attached to a CRAMPS board. + +# THIS FILE HAS NOT BEEN TESTED - PROCEED WITH CAUTION! + +# See the example.cfg file for a description of available parameters. + +[stepper_x] +step_pin: P8_13 +dir_pin: P8_12 +enable_pin: !P9_14 +step_distance: .0125 +endstop_pin: ^P8_8 +homing_speed: 50 +position_endstop: 0 +position_max: 200 + +[stepper_y] +step_pin: P8_15 +dir_pin: P8_14 +enable_pin: !P9_14 +step_distance: .0125 +endstop_pin: ^P8_10 +homing_speed: 50 +position_endstop: 0 +position_max: 200 + +[stepper_z] +step_pin: P8_19 +dir_pin: P8_18 +enable_pin: !P9_14 +step_distance: 0.00025 +endstop_pin: ^P9_13 +homing_speed: 5 +position_endstop: 0 +position_max: 200 + +[extruder] +step_pin: P9_16 +dir_pin: P9_12 +enable_pin: !P9_14 +step_distance: .002 +nozzle_diameter: 0.400 +filament_diameter: 1.750 +heater_pin: P9_15 +sensor_type: EPCOS 100K B57560G104F +sensor_pin: P9_36 +control: pid +pid_Kp: 22.2 +pid_Ki: 1.08 +pid_Kd: 114 +min_temp: 0 +max_temp: 250 + +[heater_bed] +heater_pin: P8_11 +sensor_type: EPCOS 100K B57560G104F +sensor_pin: P9_33 +control: watermark +min_temp: 0 +max_temp: 130 + +[fan] +pin: P9_41 + +[mcu] +serial: /dev/rpmsg_30 +pin_map: beaglebone + +[printer] +kinematics: cartesian +max_velocity: 300 +max_accel: 3000 +max_z_velocity: 5 +max_z_accel: 100 diff --git a/config/generic-replicape.cfg b/config/generic-replicape.cfg new file mode 100644 index 00000000..82f72863 --- /dev/null +++ b/config/generic-replicape.cfg @@ -0,0 +1,78 @@ +# This file contains an example configuration for the Beaglebone PRU +# micro-controller. + +# THIS FILE HAS NOT BEEN TESTED - PROCEED WITH CAUTION! + +# See the example.cfg file for a description of available parameters. + +[stepper_x] +step_pin: P8_17 +dir_pin: P8_26 +enable_pin: !P9_41 +step_distance: .0125 +endstop_pin: ^P9_25 +homing_speed: 50 +position_endstop: 0 +position_max: 200 + +[stepper_y] +step_pin: P8_12 +dir_pin: P8_19 +enable_pin: !P9_41 +step_distance: .0125 +endstop_pin: ^P9_23 +homing_speed: 50 +position_endstop: 0 +position_max: 200 + +[stepper_z] +step_pin: P8_13 +dir_pin: P8_14 +enable_pin: !P9_41 +step_distance: 0.00025 +endstop_pin: ^P9_13 +homing_speed: 5 +position_endstop: 0 +position_max: 200 + +# XXX - Extruder heater hooked up to i2c mosfet +#[extruder] +#step_pin: P9_12 +#dir_pin: P8_15 +#enable_pin: !P9_41 +#step_distance: .002 +#nozzle_diameter: 0.400 +#filament_diameter: 1.750 +#heater_pin: ? +#sensor_type: EPCOS 100K B57560G104F +#sensor_pin: P9_39 +#control: pid +#pid_Kp: 22.2 +#pid_Ki: 1.08 +#pid_Kd: 114 +#min_temp: 0 +#max_temp: 250 + +# XXX - Bed heater hooked up to i2c mosfet +#[heater_bed] +#heater_pin: ? +#sensor_type: EPCOS 100K B57560G104F +#sensor_pin: P9_40 +#control: watermark +#min_temp: 0 +#max_temp: 130 + +# XXX - Fan power hooked up to i2c mosfet +#[fan] +#pin: ? + +[mcu] +serial: /dev/rpmsg_30 +pin_map: beaglebone + +[printer] +kinematics: cartesian +max_velocity: 300 +max_accel: 3000 +max_z_velocity: 5 +max_z_accel: 100 diff --git a/docs/beaglebone.md b/docs/beaglebone.md new file mode 100644 index 00000000..2eea47a8 --- /dev/null +++ b/docs/beaglebone.md @@ -0,0 +1,79 @@ +This document describes the process of running Klipper on a Beaglebone +PRU. The PRU support is experimental. + +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. + +Then ssh into the beaglebone machine (ssh debian@beaglebone -- +password is "temppwd") and install Klipper by running the following +commands: +``` +git clone https://github.com/KevinOConnor/klipper +./klipper/scripts/install-beaglebone.sh +``` + +Install Octoprint +================= + +One may then install Octoprint: +``` +git clone https://github.com/foosel/OctoPrint.git +cd OctoPrint/ +virtualenv venv +./venv/bin/python setup.py install +``` + +And setup OctoPrint to start at bootup: +``` +sudo cp ~/OctoPrint/scripts/octoprint.init /etc/init.d/octoprint +sudo chmod +x /etc/init.d/octoprint +sudo cp ~/OctoPrint/scripts/octoprint.default /etc/default/octoprint +sudo update-rc.d octoprint defaults +``` + +It is necessary to modify OctoPrint's **/etc/default/octoprint** +configuration file. One must change the OCTOPRINT_USER user to +"debian", uncomment the BASEDIR, CONFIGFILE, and DAEMON settings and +change the references from "/home/pi/" to "/home/debian/": +``` +sudo nano /etc/default/octoprint +``` + +Then start the Octoprint service: +``` +sudo systemctl start octoprint +``` + +Make sure the octoprint web server is accessible - it should be at: +[http://beaglebone:5000/](http://beaglebone:5000/) + + +Building the micro-controller code +================================== + +To compile the Klipper micro-controller code, start by configuring it +for the "Beaglebone PRU": +``` +cd ~/klipper/ +make menuconfig +``` + +To build and install the new micro-controller code, run: +``` +sudo service klipper stop +make flash +sudo service klipper start +``` + +Remaining configuration +======================= + +Complete the installation by configuring Klipper and Octoprint +following the instructions in +[the main installation document](Installation.md#Configuring_Klipper). 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" < /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