Arduino has just released the new arduino-cli tool which can do everything the normal Arduino gui can do. It is still in alpha status though so maybe not all features are available yet.
With this tool it would be possible to create a plugin where one can edit, compile and upload the printer firmware directly on the server.
One would hope that the plugin author is up to the challenge. There's a lot riding on a successful flashing of the firmware.
All critical parts (compiling and uploading) are done by the arduino-cli binary, so I don't see a lot of risks here. Arduino-based printer boards can't be bricked by uploading wrong firmware.
:laugh: I don't believe that. What about a half-upload, followed by a loss of connection?
I'm not here to discuss Arduino upload behavior. As I said all uploading would be done by an external program, arduino-cli, provided by the Arduino-creators.
There is a plugin that upload the firmware to the printer, but it has to be already compiled. I´ve used it a few times, but I´ll tell you that it doesn´t make me feel comfortable with it.
That is an interesting concept. I've used the Firmware Updater plugin for quite some time without ever having any issues, but of course I've never lost power mid-flash. Before that plugin was published to the respository I had previously used OctoPrint-flashArduino. On the most recent compiles I've done with Marlin it actually creates two hex files, one with ".with_bootloader" in the file name.
Same, I tried it once and I think it does some auto update check or something, I remember a setting to check for new versions of maybe avrdude or the plugin, anyway with that on the plugin would crash / hang for me. Used it once, then removed it. I'd rather tftp the firmware binary to the octoprint machine, then putty in and use avrdude manually, much safer (no more risk than there would be using the arduino gui).
I have to admit, this file name always confuses me... does it mean the hex
includes the bootloader (so to be flashed on a barebones MCU) or does it mean it needs a bootloader?
My assumption is that means the file includes the boot loader. I've been flashing the other one without that in the filename and it's worked every time.
Presumably by your actions, you're not overcopying the existing bootloader. In theory, if you flashed the other version, it would overcopy both.
Rant:
Why does the Arduino world include so much hoodoo in it? Most of us have printer controller boards which we don't know as intimately as the Raspberry. What does it take to backup your printer's board? ("Well, that depends...") Do I also need to backup the bootloader on that? ("That depends..." or "I've never done that...") Why isn't there a way of querying the printer to extract/create a configuration.h
file for Marlin (or the one for the board itself)? It's such a pain to buy a proprietary printer and then try to reverse-engineer a newer/better Marlin for it.
The reason for the warnings about bootloaders is that the plugin isn't designed to be used with a programmer, it's designed to use the Arduino bootloader to upload the firmware. The Arduino bootloader works over serial, and can't set fuses (you need a programmer to do that), and you need to change the fuses in order to allow you to overwrite a bootloader (it's a security feature on the avr mcus). If you attempt to upload a firmware with a bootloader, my guess is that one of four things will probably happen:
- It'll fail because of fuses or you not using a programmer (not sure if a programmer is strictly required, as I've never attempted to upload a bootloader or firmware with a bootloader without one)
- It'll fail and brick the board because the firmware was too large for the available flash on the board (because the firmware + bootloader would have just barely fit if it were in the right place), but somehow it managed to upload part of what you were trying for
- It'll succeed and brick the board because all the addresses/offsets are wrong and/or the bootloader isn't expecting another bootloader at the entry point and/or the bootloader puts it into an infinite booting loop and/or the bootloader tries to do something illegal from that part of the flash and then splat
- It'll succeed because your fuses allowed it somehow and it went to the right place, even though you didn't have a programmer (this would surprise me on a printer control board, as sometimes the fuses are set so wrong that even uploading a proper firmware will brick them)
Nothing. If the fuses are set properly, you shouldn't be able to do a readback of the firmware. Of course, they're often not set properly, but still, don't do this if you're asking the question, because you most likely won't be able to restore it properly. This is in the realm of reverse engineering, which is probably not one's forte if they have this question; most people who defeat security to do a readback know they're probably going to be missing stuff to make the device actually work, and are trying to reverse engineer something, though sometimes people are successful (usually involving lots of desoldering and sometimes an FPGA or two - see https://hackaday.com/2017/02/02/33c3-hunz-deconstructs-the-amazon-dash-button/).
Possibly, but the fuses are usually set so that you can't read back the bootloader. If they're not, something is wrong.
Most manufacturers don't want you compiling your own firmware and putting it on their printers, because then they would have to support it. Most will, in fact, tell you your warranty is void, even though you probably installed your own firmware because theirs was old/weaksauce/dangerous (see runaway protection threads), and you've likely made their printer better in ways they should learn from. Of course, if you don't know what you're doing, you may have bricked the board and they don't want to support that (learn to use a programmer properly first, mmmkay?). I'm not saying it's a good thing, but its a thing. Also, Marlin also doesn't have a way to read back the config settings, AFAIK, but you could write one and contribute it.
@supertaz Yes and no to that. The avrdude
program over serial can backup your printer's controller EEPROM with commands similar to:
avrdude -C ./avrdude.conf -c avrisp -b 38400 -i 10 -p m644p -P /dev/tty.usbserial- -F -U flash:r:factory_gen6.hex:i
The "r" there after flash:
indicate that you want to read it. You can probably guess about most of those flags since it's a reasonable interface.
I'm just surprised how terse all this is for the Arduino. More ease-of-use tools are necessary, methinks.
An M501
will reasonably report the information that would go into a configuration.h
, btw.
There's just so many printer startups which die, leaving behind printers/customers with no support path forward.