Setup OctoPrint with Smoothie
Since this guide was originally written, traditional SD streaming commands were added to Smoothie, so it is no longer necessary to do this to use the SD card. However, it is much, much faster to transfer using the USB mass storage device functionality of Smoothie, so this suggests two methods.
The premise of this method is to create a script that auto-mounts, transfers files from the upload folder, and unmounts Smoothie. This assumes you are using the default uploads folder: ~/.octoprint/uploads.
- Install OctoPrint on your server. The devel branch has been tested and works, presumably the master branch will work as well.
- Flash Smoothie with a new build of the edge branch--the master branch and older copies of edge will fail.
- Create a folder for Smoothie to mount at.
sudo mkdir /media/Smoothie
- Create an upload script. In this example, I created it in the folder ~/scripts.
- Copy and paste the following text into SmoothieUpload.sh. Note that I am assuming the name of the SD card is 'Smoothie'. Either rename your card, or change /dev/disk/by-label/Smoothie to /dev/disk/by-label/<YOUR_CARD_NAME>.
#!/bin/bash # This will mount Smoothie, copy Octoprint's upload folder to the SD card, and then unmount. sudo mount -tvfat -onoexec,nodev,noatime,nodiratime,gid=pi,uid=pi,dmask=0002,fmask=0113 /dev/disk/by-label/Smoothie /media/Smoothie cp /home/pi/.octoprint/uploads/*.g* /media/Smoothie sudo sync sudo umount /media/Smoothie
Then save file ^X, Y (for yes), and then click enter to save under the name.
- Make the file executable.
chmod +x ~/scripts/SmoothieUpload.sh
- Add the following to your config.yaml file by typing: sudo nano ~/.octoprint/config.yaml
system: actions: - action: copy command: /home/pi/scripts/SmoothieUpload.sh confirm: You are about to copy files to SD name: Copy to SD
- Restart OctoPrint.
- To upload files to Smoothie, first use the Upload button. NOTE: DO NOT use the "Upload to SD" button--it won't break anything, but it defeats the purpose of all this work.
- Once the file or files are uploaded, press System -> Copy to SD.
- You will be notified when the upload is complete. This usually takes a minute or two for large (>10Mb) files.
- Refresh SD files, and you're ready to print! I recommend you delete the locally-stored copies of the files so later on you don't continually re-upload them.
Troubleshooting: If you get an error when you try to save that says "No such file exists", save the SmoothieUpload.sh to home/pi by typing:
Then insert the text in #4 as mentioned above ^.
Then execute with chmod +x ~/SmoothieUpload.sh
When you config.yaml file... make the command: /home/pi/SmoothieUpload.sh
If you receive a sudo error after executing "Copy to SD" from the system menu inside Octoprint then try and add script commands (mount, umount and sync) to the sudo password exclusion list for the user pi as follows:
SSH into the pi
add the following line to the end of the file: pi ALL = NOPASSWD: /bin/mount, /bin/umount, /bin/sync
save the file and reboot (sudo reboot now)
Optional folder handling: Note: Now with Folder support in Octoprint, you can create a folder called SD and move all files in the SD folder to the SD card by changing the following line in SmoothieUpload.sh
cp /home/pi/.octoprint/uploads/.g /media/Smoothie
mv /home/pi/.octoprint/uploads/SD/.g /media/Smoothie
This would allow you to keep some gcode files in Octoprint and move only the ones you want to the SD card. Also, this would ensure that files are not copied multiple times to the SD card (which would simply take a long time). This is specially useful for large gcode files with a lot of small moves - that may slow down the printer if streamed through Octoprint.
This is the method I originally used, which mounts the SD card automatically and uploads files directly to it by using it as OctoPrint's uploads folder. Slightly faster, and eliminates a button click, but it has two downsides. First, it means your server and your microcontroller both have access to the card at the same time, which could be dangerous (don't edit files while you're printing!), and second, it makes Octoprint a bit sluggish.
Install OctoPrint on your server. The devel branch has been tested and works, presumably the master branch will work as well.
Flash Smoothie with a new build of the edge branch--the master branch and older copies of edge will fail.
Install usbmount on the server.
sudo apt-get install usbmount
Open /etc/usbmount/usbmount.conf as superuser.
In the MOUNTOPTIONS line, remove sync. NOTE: this prevents extremely slow writes to the SD card, but can cause data loss if you do not perform a sync before removing or resetting your Smoothieboard.
replace the FS_MOUNTOPTIONS with the following line:
Note that <USER> should be replaced with the groupid and userid of the user under whom OctoPrint runs. On a standard installation on Rasbian, <USER>=pi for both.
Attach your Smoothieboard to the server. Make sure that under /media/usb0 you see a config file, and it is owned and editable by you. If you have multiple USB devices attached, there may be issues if the numbering changes, I do not yet know a way to ensure that Smoothieboard is always usb0 if there are multiple mass storage devices.
Either through the Settings pop-up or through editing config.yaml, make sure OctoPrint has SD support enabled and set the Upload folder to /media/usb0.
To upload a file, use the Upload button. NOTE: DO NOT use the "Upload to SD" button--it won't break anything, but it defeats the purpose of mounting the card.
Once the file is uploaded, click on the SD card icon, and click "Refresh SD". If the newly-uploaded file does not appear, wait a few seconds and try again. If it still does not appear, confirm that the upload folder is set correctly. If it is, perform the command "sudo sync" on your server to force a sync.
You can now print the file. Each file will appear twice, since the local file system and the SD card are the same thing, so either set the file tab to only show files stored on SD, or be sure to select the copy of the file with "n/a" as the size.