Octoprint: Update printer firmware via Pi?

Created on 17 Jan 2014  路  17Comments  路  Source: OctoPrint/OctoPrint

This would be sweet feature.

determine feasibility plugin idea request

Most helpful comment

This is what I posted to the octopi issue list about what I needed to setup to update Marlin straight from Raspi

sudo pip install ino
sudo apt-get install arduino
cd Marlin-Marlin-v1
ln -s Marlin src
ino build -m mega2560
ino upload -p /dev/ttyACM0 -m mega2560

All 17 comments

I agree, I'm a bit worried though about the security implications of this. I think @hendricksonrw and me talked about that a couple of months back too...

Maybe in order to activate a hex file that has been uploaded to the client, you need to re-enter the password, or another admin-level password?

Sounds like an idea

Would love it.

Best Regards
Davide Ardizzoia

I do this already, and it wasn't so difficult to set up. The program I am using is called Ino, and I can edit, compile, and upload firmware directly from an ssh instance. There was some minor hacks involved to get it to work, but it is spelled out in the readme file I keep on the firmware repo: https://github.com/starno/Ino-Delta-Marlin It's not as nice as being able to access it from Octoprint directly, but the ability to keep an instance of firmware local to each machine on each machine has been a real game changer for me.

I just run the Arduino IDE on the PI via VNC. A bit slow but otherwise fine.

This is what I posted to the octopi issue list about what I needed to setup to update Marlin straight from Raspi

sudo pip install ino
sudo apt-get install arduino
cd Marlin-Marlin-v1
ln -s Marlin src
ino build -m mega2560
ino upload -p /dev/ttyACM0 -m mega2560

Hi everybody,
I too would be interested in this and I am quite willing to implement this myself as a system command.
Now, as mentioned above, this is already possible by following this simple procedure:

  1. Login by VNC or SSH to your RPi.
  2. Temporarily stop OctoPrint.
  3. Use either the Arduino IDE (using VNC, slow method, and it forces you to run X on your OctoPrint server, which in my book is a no-no) or the ino command-line utility (using SSH, not-so-slow method) to compile and flash the firmware and eventually test that it is working.
  4. Start OctoPrint.
  5. Logout
    Note that in this way VNC or SSH take care of any security considerations.

The way I see it implemented as a system command takes away a lot of the hassle:

  1. Upload pre-compiled hex file to OctoPrint server.
  2. In the System drop-down menu, select "Flash new firmware" option.
  3. OctoPrint temporarily disconnects from printer (and displays message indicating it's flashing a new firmware).
  4. OctoPrint calls avrdude with proper parameters to flash the new firmware.
  5. Once avrdude is done and has returned without errors, OctoPrint reconnects with printer.

Note that I personally prefer to compile the firmware on a PC (my Ubuntu workstation) where I can keep any changes in git/etc rather than compiling it on the RPi OctoPrint server (which at this stage I consider to be a dedicated machine).

What does everybody think about this proposed solution?

I keep my files on another machine and have a simple script that mounts the file system, compiles it and downloads it with ino and then un-mounts the file system. My intention was to run it from the system menu but it didn't work, probably due to running as the wrong user. I decided I wanted to see the output from ino anyway, so I just SSH in and run it.

Since downloading takes a substantial time I don't think takes much longer than it does with the IDE on my server.

Closer integration with OctoPrint would be nice but the current system I use is fairly painless. On one machine I have to remember to disconnect in OctoPrint to free the USB port, but on another I connect OctoPrint via the serial port on the expansion connector, so the USB connection is dedicated to firmware updates.

@nophead
Hi Chris
I definitely think your method is very practical but it assumes an infrastructure is already in place (file server, proper network mounts, etc). For the occasional firmware upgrade I have suggested a simple recipe (4 lines) in a Quick Tip in the wiki, which is relatively safe and guaranteed to work. It can be found here: https://github.com/foosel/OctoPrint/wiki/Assorted-OctoPrint-Quick-Tips#flashing-a-new-arduino-firmware-directly-from-your-octoprint-host

@AndrewBCN Thanks! I was able to update Marlin using the Pi with your help. I made a little script which stops OctoPrint, updates and restarts. I did have to change ttyUSB0 to ttyACM0, and I'm not enough of a Pi/Linux guy to know why, but it worked with that change. I also used three -v instead of four because I like a progress bar, plus the constant readout slows the process down.

@dansantee You are welcome! Btw I have edited the wiki and added your two tips (with proper attribution).

Gina, you may want to close this issue perhaps, since the QuickTip is easy to use and solves the problem?

For those who want to compile/upload from the raspberrypi. I managed to do it like this

Install the packages, arduino libraries, make (doublecheck) and pyserial (should be installed if already running OctoPrint). And clone the sources, in my case I tested Repetier Firmware devel branch.
I did not use arduino-mk from Raspbian repo because was outdated and didn't compile.

sudo apt-get install -y arduino make pyserial
cd ~
git clone https://github.com/sudar/Arduino-Makefile.git
git clone https://github.com/repetier/Repetier-Firmware.git
cd Repetier-Firmware
git checkout work092

Create the makefile, if you are using a different board try make show_boards

cd ~/Repetier-Firmware/src/ArduinoAVR/Repetier
cat > Makefile < BOARD_TAG = mega2560
ARDUINO_PORT = /dev/ttyACM*
include ~/Arduino-Makefile/Arduino.mk
EOT

Then edit/replace configurations.h and then verify make or compile/upload make upload
Just remember to release serial communication from Octoprint. (maybe sudo service octoprint stop before and sudo service octoprint start after flashing.

yeah, at least partially (the plugin does not support every single board available right now out of the box),

But as long as the firmware can be uploaded with avrdude on the board, it's only a matter of adding one/two lines in the plugin HTML template (that's what I did for my old sanguinololu board and it works well)

Compilation of the firmware still needs to be done separetly

@foosel I think this can be closed

Ah, good point!

Was this page helpful?
0 / 5 - 0 ratings