├── ensurePublicKeysAdded.sh ├── startpocketnc-ui.sh ├── disableServices.sh ├── preUpdate.sh ├── updateScript.sh ├── enableServices.sh ├── .gitignore ├── pocketnc-ui.service ├── PocketNC.service ├── .gitmodules ├── Rockhopper.service ├── restartPocketNC.sh ├── startPocketNC.sh ├── startRockhopper.sh ├── ensureTmpRemotesAdded.sh ├── OverlaySettings2.0.1-beta-7AndOlder.inc ├── stopPocketNC.sh ├── stopRockhopper.sh ├── copyDefaultFiles.py ├── keys.asc ├── postUpdate.sh ├── applyOldOverlaySettings.py └── README.md /ensurePublicKeysAdded.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | gpg --import keys.asc 4 | -------------------------------------------------------------------------------- /startpocketnc-ui.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd /home/pocketnc/pocketnc/pocketnc-ui 4 | python -m SimpleHTTPServer 80 5 | -------------------------------------------------------------------------------- /disableServices.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | systemctl disable Rockhopper.service 4 | systemctl disable PocketNC.service 5 | systemctl disable pocketnc-ui.service 6 | -------------------------------------------------------------------------------- /preUpdate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./applyOldOverlaySettings.py $1 4 | 5 | cd Settings 6 | 7 | if [ -x ./preUpdate ]; then 8 | ./preUpdate $1 9 | fi 10 | 11 | cd .. 12 | -------------------------------------------------------------------------------- /updateScript.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./preUpdate.sh $1 4 | 5 | git checkout tags/$1 6 | git submodule update 7 | 8 | ./postUpdate.sh $1 9 | 10 | sudo shutdown -r now 11 | -------------------------------------------------------------------------------- /enableServices.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | systemctl enable /home/pocketnc/pocketnc/Rockhopper.service 4 | systemctl enable /home/pocketnc/pocketnc/PocketNC.service 5 | systemctl enable /home/pocketnc/pocketnc/pocketnc-ui.service 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tmp_params.var 2 | tmp_params.var.bak 3 | 4 | # Swap 5 | [._]*.s[a-v][a-z] 6 | [._]*.sw[a-p] 7 | [._]s[a-v][a-z] 8 | [._]sw[a-p] 9 | 10 | # Session 11 | Session.vim 12 | 13 | # Temporary 14 | .netrwhist 15 | *~ 16 | # Auto-generated tag files 17 | tags 18 | -------------------------------------------------------------------------------- /pocketnc-ui.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Web interface to Rockhopper (which provides interface to linuxcnc) via web sockets 3 | After=Rockhopper.service 4 | 5 | [Service] 6 | ExecStart=/home/pocketnc/pocketnc/startpocketnc-ui.sh 7 | 8 | [Install] 9 | WantedBy=multi-user.target 10 | -------------------------------------------------------------------------------- /PocketNC.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=PocketNC Service 3 | After=generic-board-startup.service 4 | 5 | [Service] 6 | ExecStart=/home/pocketnc/pocketnc/startPocketNC.sh 7 | ExecStop=/home/pocketnc/pocketnc/stopPocketNC.sh 8 | User=pocketnc 9 | KillMode=process 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "pocketnc-ui"] 2 | path = pocketnc-ui 3 | url = https://github.com/PocketNC/pocketnc-ui.git 4 | [submodule "Rockhopper"] 5 | path = Rockhopper 6 | url = https://github.com/PocketNC/Rockhopper.git 7 | [submodule "Settings"] 8 | path = Settings 9 | url = https://github.com/PocketNC/Settings.git 10 | -------------------------------------------------------------------------------- /Rockhopper.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Web server providing interface to linuxcnc via web sockets 3 | After=PocketNC.service 4 | 5 | [Service] 6 | ExecStart=/home/pocketnc/pocketnc/startRockhopper.sh 7 | ExecStop=/home/pocketnc/pocketnc/stopRockhopper.sh 8 | User=pocketnc 9 | TimeoutStopSec=5 10 | KillMode=process 11 | 12 | [Install] 13 | WantedBy=multi-user.target 14 | -------------------------------------------------------------------------------- /restartPocketNC.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Reloading services..." 4 | sudo systemctl --system daemon-reload 5 | 6 | echo "Killing Rockhopper..." 7 | sudo systemctl stop Rockhopper.service 8 | 9 | echo "Killing PocketNC..." 10 | sudo systemctl stop PocketNC.service 11 | 12 | sleep 1 13 | 14 | echo "Starting PocketNC..." 15 | sudo systemctl start PocketNC.service 16 | 17 | echo "Starting Rockhopper..." 18 | sudo systemctl start Rockhopper.service 19 | -------------------------------------------------------------------------------- /startPocketNC.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -f /home/pocketnc/pocketnc/Settings/PocketNC.ini ];then 4 | rm /home/pocketnc/pocketnc/Settings/PocketNC.ini 5 | fi 6 | 7 | if [ -f /home/pocketnc/.pocketnc_env ]; then 8 | source /home/pocketnc/.pocketnc_env 9 | fi 10 | 11 | export PATH=$PATH:/home/pocketnc/pocketnc/Settings 12 | 13 | cd /home/pocketnc/pocketnc/Settings/ 14 | 15 | ./generateINI.py 16 | 17 | linuxcnc /home/pocketnc/pocketnc/Settings/PocketNC.ini 18 | -------------------------------------------------------------------------------- /startRockhopper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -f /home/pocketnc/.pocketnc_env ]; then 4 | source /home/pocketnc/.pocketnc_env 5 | fi 6 | 7 | sleep 1 8 | 9 | dummy_pid=$(pgrep dummy.sh) 10 | until [ -n "$dummy_pid" ]; do 11 | echo "Waiting for dummy.sh before starting LinuxCNCWebSktSvr..." 12 | dummy_pid=$(pgrep dummy.sh) 13 | sleep 1 14 | done 15 | 16 | python /home/pocketnc/pocketnc/Rockhopper/LinuxCNCWebSktSvr.py /home/pocketnc/pocketnc/Settings/PocketNC.ini 17 | -------------------------------------------------------------------------------- /ensureTmpRemotesAdded.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check for tmp remotes 4 | if ! git remote -v | grep -q '/tmp/pocketnc'; then 5 | git remote add tmp /tmp/pocketnc 6 | fi 7 | 8 | cd Rockhopper 9 | if ! git remote -v | grep -q '/tmp/pocketnc/Rockhopper'; then 10 | git remote add tmp /tmp/pocketnc/Rockhopper 11 | fi 12 | cd .. 13 | 14 | cd pocketnc-ui 15 | if ! git remote -v | grep -q '/tmp/pocketnc/pocketnc-ui'; then 16 | git remote add tmp /tmp/pocketnc/pocketnc-ui 17 | fi 18 | cd .. 19 | 20 | cd Settings 21 | if ! git remote -v | grep -q '/tmp/pocketnc/Settings'; then 22 | git remote add tmp /tmp/pocketnc/Settings 23 | fi 24 | cd .. 25 | -------------------------------------------------------------------------------- /OverlaySettings2.0.1-beta-7AndOlder.inc: -------------------------------------------------------------------------------- 1 | [AXIS_0] 2 | MAX_ACCELERATION=10 3 | MAX_VELOCITY=1 4 | SCALE=8333.333 5 | STEPGEN_MAX_VEL=1.2 6 | 7 | [AXIS_1] 8 | MAX_ACCELERATION=10 9 | SCALE=8333.333 10 | 11 | [AXIS_2] 12 | MAX_ACCELERATION=10 13 | MAX_VELOCITY=1 14 | SCALE=-8333.333 15 | STEPGEN_MAX_VEL=1.2 16 | 17 | [AXIS_3] 18 | MAX_ACCELERATION=300 19 | MAX_VELOCITY=37.5 20 | STEPGEN_MAX_ACC=360 21 | STEPGEN_MAX_VEL=45 22 | 23 | [AXIS_4] 24 | MAX_ACCELERATION=300 25 | MAX_VELOCITY=37.5 26 | SCALE=222.222 27 | STEPGEN_MAX_ACC=360 28 | STEPGEN_MAX_VEL=45 29 | 30 | [TRAJ] 31 | MAX_ANGULAR_VELOCITY=100 32 | DEFAULT_VELOCITY=0.75 33 | MAX_LINEAR_VELOCITY=1.41 34 | -------------------------------------------------------------------------------- /stopPocketNC.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pgrep -f "/home/pocketnc/pocketnc/Settings/dummy.sh" | while read -r pid ; do 4 | echo "Killing subprocess dummy.sh $pid" 5 | kill $pid 6 | done 7 | 8 | halcmd -R 9 | 10 | linuxcnc_pids=$(pgrep linuxcnc) 11 | waitCount=0 12 | 13 | while [ -n "$linuxcnc_pids" ] && (( $waitCount < 600 )); do 14 | linuxcnc_pids=$(pgrep linuxcnc) 15 | sleep .1; 16 | let waitCount++ 17 | done 18 | 19 | pgrep linuxcnc | while read -r pid ; do 20 | echo "Timeout expired, force killing LinuxCNC process $pid" 21 | kill -9 $pid 22 | done 23 | 24 | pgrep hss_sensors | while read -r pid ; do 25 | echo "Timeout expired, force killing hss_sensors HAL component $pid" 26 | kill -9 $pid 27 | done 28 | -------------------------------------------------------------------------------- /stopRockhopper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pgrep -f "python /home/pocketnc/pocketnc/Rockhopper/LinuxCNCWebSktSvr.py" | while read -r pid ; do 4 | echo "Killing LinuxCNCWebSktSvr.py $pid" 5 | kill $pid 6 | done 7 | 8 | rockhopper_pid=$(pgrep -f "python /home/pocketnc/pocketnc/Rockhopper/LinuxCNCWebSktSvr.py" ) 9 | waitCount=0 10 | 11 | while [ -n "$rockhopper_pid" ] && (( $waitCount < 30 )); do 12 | rockhopper_pid=$(pgrep -f "python /home/pocketnc/pocketnc/Rockhopper/LinuxCNCWebSktSvr.py" ) 13 | sleep .1; 14 | let waitCount++ 15 | done 16 | 17 | pgrep -f "python /home/pocketnc/pocketnc/Rockhopper/LinuxCNCWebSktSvr.py" | while read -r pid ; do 18 | echo "Timeout expired, force killing Rockhopper $pid" 19 | kill -9 $pid 20 | done 21 | 22 | -------------------------------------------------------------------------------- /copyDefaultFiles.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import subprocess 4 | import os 5 | import shutil 6 | 7 | ROOT_DIRECTORY = "/home/pocketnc/pocketnc" 8 | TOOL_TABLE_FILE = os.path.join(ROOT_DIRECTORY, "Settings/tool.tbl") 9 | TOOL_TABLE_DEFAULT_FILE = os.path.join(ROOT_DIRECTORY, "Settings/tool.tbl.default") 10 | 11 | CLIENT_CONFIG_FILE = os.path.join(ROOT_DIRECTORY, "Rockhopper/CLIENT_CONFIG.JSON") 12 | CLIENT_CONFIG_DEFAULT_FILE = os.path.join(ROOT_DIRECTORY, "Rockhopper/CLIENT_CONFIG.JSON.default") 13 | 14 | A_COMP_FILE = os.path.join(ROOT_DIRECTORY, "Settings/a.comp"); 15 | A_COMP_DEFAULT_FILE = os.path.join(ROOT_DIRECTORY, "Settings/a.comp.default"); 16 | 17 | B_COMP_FILE = os.path.join(ROOT_DIRECTORY, "Settings/b.comp"); 18 | B_COMP_DEFAULT_FILE = os.path.join(ROOT_DIRECTORY, "Settings/b.comp.default"); 19 | 20 | if not os.path.isfile(A_COMP_FILE): 21 | shutil.copyfile(A_COMP_DEFAULT_FILE, A_COMP_FILE) 22 | 23 | if not os.path.isfile(B_COMP_FILE): 24 | shutil.copyfile(B_COMP_DEFAULT_FILE, B_COMP_FILE) 25 | 26 | if not os.path.isfile(TOOL_TABLE_FILE): 27 | shutil.copyfile(TOOL_TABLE_DEFAULT_FILE, TOOL_TABLE_FILE) 28 | 29 | if not os.path.isfile(CLIENT_CONFIG_FILE): 30 | shutil.copyfile(CLIENT_CONFIG_DEFAULT_FILE, CLIENT_CONFIG_FILE); 31 | -------------------------------------------------------------------------------- /keys.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | 3 | mQENBF7rplABCAC+S7vnGPwSFQietYzfvjxmAtJX4yPP5V6h1CQpcM6YK8HTZGC2 4 | AqF/N/8UtOXyGno13V277mbKCvCnLUPfZstFrtDFOEXlWS2W8LBUCYgD2i8gceQ8 5 | 1eTb630WsNB46BKmtgsJsz+iVQZkYWhJXVzokCdiyQkKrpxknXwe5CdXvxO9kVXN 6 | jsIqJrtxbfCuU/zQAarG4A5foBLK/WUj6cX17MfCNm280sa787el5L4tsx2qytOc 7 | 3nVHxyweMSujfY8l1Vxd1b/LU90QgmkU+F4nDHcNZ7CNky2vPpCjJe5mUQtOhl0P 8 | v4cQQhx5p2Q0266cYHBKvGayfsTs6TPGfFkJABEBAAG0JVBvY2tldCBOQyBDb21w 9 | YW55IDxpbmZvQHBvY2tldG5jLmNvbT6JAVQEEwEIAD4WIQTxBAWfyPW7895d1ARl 10 | nLHbAY8YDwUCXuumUAIbAwUJA8JnAAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAK 11 | CRBlnLHbAY8YD1psB/9EEdiHTIJpFBAEhXozE07jdp2VQPsH58XWN6zUAwmyqKXL 12 | AHEpAD7xaF7LZ1vITqJbv2+/tT25p/BuS0HEyf6WqgpQhATMm66iyiq402TreE1J 13 | IZRT6Kx6ledZJ3xxSmYCsk4kw8YgxWE6lbK+SF/z+AipudKFy605fuzH6wf6Xkeh 14 | M87wLdbq/ENPRMwGbix1n4vx45NNISUXl1NalsBmRcSVg3GNNaDPDx9WuNzjr1EQ 15 | fCOIwFZJRLutvXYd7TmUE3Z+K/TVrdmxPLWDQBTVusk5GFoDG5ocKI2cGC/PKq2c 16 | aeImeVfb+6cjpHXhubl8oAh//e8RO+RN3D+5C4sluQENBF7rplABCADTttqf3kkZ 17 | v9UdzZ+APkq9xrNlnDedg/W3lOXjKKfwh948Bc9hvUjx69PW6mRsaOhk1ZjTxuvz 18 | UtZFIFLk4cDxolrCFWgl8K39r/Y8x4oGvjXOpVRellJI1Fhgkwb251CHfPQ9CUHy 19 | M4Trm7RAYMdmNejg0wcWpIQWDSGN5qOeegy5RRepf/ybqau9DPx/rjecUMIHyV74 20 | ZiciSrZ3qSh2J3/RJuqQ3IjVfWq0BV1KQmUkHy5w6H7bKrQ87D4mY1q6RoO4KDb4 21 | 3+B97cRDEneWn9c4Fr8lUXpLcj8FxAp5luripjkOgjVctJT4i3sZtA+GOvX4z16n 22 | SgA/2J1biBOLABEBAAGJATwEGAEIACYWIQTxBAWfyPW7895d1ARlnLHbAY8YDwUC 23 | XuumUAIbDAUJA8JnAAAKCRBlnLHbAY8YD/wVB/wNwYLDtCHWcONUeV5Mk0kyzBqe 24 | VYX+AAUnV+lWlBsm3n/3Zrgj676mvQqXA23iugXs2dZNC9CUA6uNlaAUiGT4gMiK 25 | HU1en4aN0DNgTTuPWOySXojaoqgeveAV0tZmR2cAzwVhVj7vPjqtgvOL9FOARrSZ 26 | VhKfg+bxLBtvAPQU6lYVs5r+in0jybV1rk6DFUmuykiSyljS2zTQtLt2ChOH1VHm 27 | atpBo48St2LbGMAyB/XKeQtmIsirQf9EBJNKXfndroSB7JujxMwxdbr3eW4o7N/4 28 | Zn2FtVytaptdKfgCvSz3rrJig5DuxtCuSPx/yfcrZBB/wEzC5VqSLIlIBRwO 29 | =np27 30 | -----END PGP PUBLIC KEY BLOCK----- 31 | -------------------------------------------------------------------------------- /postUpdate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./copyDefaultFiles.py 4 | 5 | # Check if swap space is being used 6 | if [ -f /my_swap ]; then 7 | if grep --quiet /my_swap /etc/fstab; then 8 | echo "Swap space already being allocated at boot" 9 | else 10 | sudo mkswap /my_swap 11 | sudo swapon /my_swap 12 | sudo su -c 'echo "/my_swap swap swap defaults 0 0" >> /etc/fstab' 13 | fi 14 | fi 15 | 16 | ./ensureTmpRemotesAdded.sh 17 | ./ensurePublicKeysAdded.sh 18 | 19 | # Check for internet connection. 20 | if ping -q -c 1 -W 1 github.com >/dev/null; then 21 | # Update /opt/scripts/boot to commit b61125c1485bee929340cacc06c85c6fcfd678bc 22 | # This commit changes the ethernet-over-usb protocol used with macOS from ECM 23 | # to NCM, because with v11 macOS no longer supports ECM 24 | cd /opt/scripts/boot 25 | sudo git fetch origin 26 | sudo git checkout b61125c1485bee929340cacc06c85c6fcfd678bc 27 | 28 | if ! dpkg -l | grep bb-usb-gadgets; then 29 | sudo apt update 30 | sudo apt install bb-usb-gadgets 31 | fi 32 | else #If no connection, assume update is occuring over USB 33 | if [ -d /tmp/boot-scripts/ ]; then 34 | cd /opt/scripts/boot 35 | git remote add tmp /tmp/boot-scripts 36 | sudo git fetch tmp 37 | sudo git checkout b61125c1485bee929340cacc06c85c6fcfd678bc 38 | fi 39 | if [ -d /tmp/ ] && ! dpkg -l | grep bb-usb-gadgets; then 40 | sudo dpkg -i /tmp/debs/bb-usb-gadgets_1.20200504.0-0~stretch+20200504_all.deb 41 | fi 42 | fi 43 | 44 | 45 | # Prevent shared memory from being cleaned up when pocketnc user closes SSH 46 | sudo sed -i 's/^#RemoveIPC=yes/RemoveIPC=no/' /etc/systemd/logind.conf 47 | # Remove line which is incorrectly setting usb0 as default gateway from /etc/network/interfaces 48 | # ONLY IF bb-usb-gadgets IS INSTALLED. 49 | # We would rather have: 50 | # - usb tethering working, network gateway broken 51 | # than 52 | # - network gateway working, usb tethering broken 53 | if dpkg-query -s bb-usb-gadgets | grep "install ok installed"; then 54 | sudo sed -i 's/^\([^#]*gateway\)/#\1/g' /etc/network/interfaces 55 | else 56 | sudo sed -i '/gateway/s/#//g' /etc/network/interfaces 57 | fi 58 | 59 | 60 | cd /home/pocketnc/pocketnc/Settings 61 | 62 | if [ -x ./dtc.sh ]; then 63 | sudo ./dtc.sh 64 | fi 65 | 66 | if [ -x ./postUpdate ]; then 67 | ./postUpdate 68 | fi 69 | 70 | cd .. 71 | 72 | sudo systemctl --system daemon-reload 73 | -------------------------------------------------------------------------------- /applyOldOverlaySettings.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import os 5 | import subprocess 6 | import re 7 | import pprint 8 | 9 | POCKETNC_DIRECTORY = "/home/pocketnc/pocketnc" 10 | 11 | sys.path.insert(0, os.path.join(POCKETNC_DIRECTORY, "Rockhopper")); 12 | from ini import read_ini_data, merge_ini_data, write_ini_data, ini_differences, remove_ini_data 13 | 14 | CALIBRATION_OVERLAY_FILE = os.path.join(POCKETNC_DIRECTORY, "Settings/CalibrationOverlay.inc") 15 | OLD_OVERLAY_FILE = os.path.join(POCKETNC_DIRECTORY, "OverlaySettings2.0.1-beta-7AndOlder.inc") 16 | DEFAULT_FILE = os.path.join(POCKETNC_DIRECTORY, "Settings/PocketNC.ini.default") 17 | 18 | # The CalibrationOverlay.inc file is supposed to store only the settings that are specific to 19 | # an individual machine's calibration. 20 | # In v2.0.1-beta-7 and before the CalibrationOverlay.inc file contained important machine settings 21 | # not specific to a machine. All later versions have those settings in PocketNC.ini.default. 22 | # The calibration overlay file only stores differences between PocketNC.ini.default and the current 23 | # settings, so in newer versions the settings are removed from the overlay file. Since the calibration 24 | # overlay is supposed to be machine specific and is not version controlled, those settings are needed 25 | # when reverting to an old version. This script is run in preUpdate.sh in versions 26 | # after v2.0.1-beta-7 and detects what version we're switching to. If we're switching to version 27 | # v2.0.1-beta-7 or before, merge the settings in OverlaySettings2.0.1-beta-7AndOlder.inc with CalibrationOverlay.inc. 28 | # If we're switching to a later version, remove those settings from the overlay. 29 | 30 | 31 | # modified from https://stackoverflow.com/questions/5967500/how-to-correctly-sort-a-string-with-a-number-inside 32 | def toIntOrString(text): 33 | try: 34 | retval = int(text) 35 | except ValueError: 36 | retval = text 37 | return retval 38 | 39 | def natural_keys(text): 40 | return [ toIntOrString(c) for c in re.split('[v.-]', text) ] 41 | 42 | v = sys.argv[1] 43 | 44 | calibration = read_ini_data(CALIBRATION_OVERLAY_FILE) 45 | old = read_ini_data(OLD_OVERLAY_FILE) 46 | 47 | if natural_keys(v) <= natural_keys("v2.0.1-beta-7"): 48 | # if we're changing to a version less than or equal to v2.0.1-beta-7 49 | # then add in the old settings to the overlay 50 | merged = merge_ini_data(calibration, old) 51 | 52 | write_ini_data(merged, CALIBRATION_OVERLAY_FILE) 53 | else: 54 | # otherwise, remove the old settings from the overlay 55 | trimmed = remove_ini_data(calibration, [ { 'name': p['values']['name'], 'section': p['values']['section'] } for p in old['parameters'] ]) 56 | 57 | write_ini_data(trimmed, CALIBRATION_OVERLAY_FILE) 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pocket NC 2 | 3 | This respository contains all the settings and software required to setup MachineKit on a BeagleBone Black for 4 | controlling the Pocket NC v2. 5 | 6 | *This document is in progress, it may not be complete or correct* 7 | 8 | ## Setup a BeagleBone Black for use in a Pocket NC v2 9 | 10 | ### Flash BBB with latest MachineKit image 11 | 12 | # with wget 13 | wget https://rcn-ee.com/rootfs/bb.org/testing/2017-02-12/machinekit/bone-debian-8.7-machinekit-armhf-2017-02-12-4gb.img.xz 14 | 15 | # with curl 16 | curl -O https://rcn-ee.com/rootfs/bb.org/testing/2017-02-12/machinekit/bone-debian-8.7-machinekit-armhf-2017-02-12-4gb.img.xz 17 | 18 | xzcat bone-debian-8.7-machinekit-armhf-2017-02-12-4gb.img.xz > bone-debian-8.7-machinekit-armhf-2017-02-12-4gb.img 19 | 20 | # on linux /dev/sdX on Mac /dev/rdiskX (on Mac you can use diskutil list to find what X is, make sure you use diskutil unmountDisk /dev/diskX) 21 | sudo dd bs=1m if=bone-debian-8.7-machinekit-armhf-2017-02-12-4gb.img of=/dev/ 22 | 23 | Insert the SD card into the BBB and power it on over USB. Connect to the BBB and enable the flasher script on boot. Then reboot to flash the image. 24 | 25 | ssh machinekit@192.168.7.2 26 | sudo sed -i 's/^#cmdline=init=\/opt\/scripts\/tools\/eMMC\/init-eMMC-flasher-v3.sh$/cmdline=init=\/opt\/scripts\/tools\/eMMC\/init-eMMC-flasher-v3.sh/' /boot/uEnv.txt 27 | sudo reboot 28 | 29 | ### Set up pocketnc user 30 | 31 | We're going to change the machinekit user name to pocketnc by creating a temporary 32 | user, giving it sudo privileges, changing the machinekit user to pocketnc using the 33 | temporary user, then deleting the temporary user. 34 | 35 | # use username/password machinekit/machinekit 36 | ssh machinekit@192.168.7.2 37 | sudo adduser temporary 38 | sudo adduser temporary sudo 39 | exit 40 | 41 | ssh temporary@192.168.7.2 42 | 43 | # The next command will error if there are any processes running owned by the machinekit user. 44 | # It will list the process id. Run `sudo kill ` for every process until the following command goes through. 45 | sudo usermod -l pocketnc machinekit 46 | sudo usermod -d /home/pocketnc -m pocketnc 47 | exit 48 | 49 | # password should still be machinekit 50 | ssh pocketnc@192.168.7.2 51 | 52 | # change password to pocketnc (or whatever you like) 53 | passwd 54 | 55 | # Setup no password for sudo 56 | # on the last line change machinekit to pocketnc 57 | # it should look like (no #): 58 | # pocketnc ALL=NOPASSWD: ALL 59 | sudo visudo 60 | 61 | sudo deluser temporary 62 | sudo rm -r /home/temporary 63 | sudo ln -s /home/pocketnc /home/machinekit 64 | 65 | ### Change boot message 66 | 67 | sudo sh -c "cat < /etc/issue.net 68 | Debian GNU/Linux 8 69 | 70 | Pocket NC Image (based on Machinekit Debian Image 2017-02-12) 71 | 72 | Support/FAQ: http://www.pocketnc.com/faq 73 | 74 | default username:password is [pocketnc:pocketnc] 75 | EOF" 76 | 77 | sudo cp /etc/issue.net /etc/issue 78 | 79 | ### Update hostname 80 | 81 | # Change hostname from beaglebone to pocketnc 82 | sudo sed -i 's/beaglebone/pocketnc/g' /etc/hosts 83 | sudo sed -i 's/beaglebone/pocketnc/g' /etc/hostname 84 | 85 | ### Reboot (make sure ethernet is plugged in) 86 | 87 | sudo reboot 88 | 89 | ### Update apt-get 90 | 91 | sudo apt-get update 92 | sudo apt-get upgrade 93 | 94 | ### Disable graphical boot 95 | 96 | # disable lightdm (the windowing system) 97 | sudo systemctl disable lightdm 98 | 99 | ### Disable Apache 100 | 101 | sudo systemctl disable apache2 102 | sudo systemctl stop apache2 103 | 104 | 105 | ### Install dependencies for Rockhopper 106 | 107 | sudo pip install tornado==4.5.2 108 | sudo apt-get install graphviz graphviz-dev # 2.38.0-7 109 | sudo pip install pygraphviz --install-option="--include-path=/usr/include/graphviz/" --install-option="--library-path=/usr/lib/graphviz" 110 | sudo pip install netifaces 111 | 112 | ### Clone this repository including submodules and run init scripts 113 | 114 | git clone --recursive https://github.com/PocketNC/pocketnc.git 115 | cd pocketnc 116 | sudo ./enableServices.sh 117 | ./postUpdate.sh 118 | 119 | mkdir ~/ncfiles 120 | 121 | sudo reboot 122 | --------------------------------------------------------------------------------