Updating printers ancient firmware in 2020

Well, this is just my little journey in 2020th second lock down.

By default I use my main printers, namely an “Anet A8” and a “TronXY X5” remotely, as each printer has a Raspberry Pi hooked up running OctoPrint to deal with Wifi and project storage.

But whenever I need to work right at the printer I need to use the display and it is a pain. Both printers were running some old Marlin V1.x.x.x firmware, where probably no security features where enabled. I did not care about that, as the OctoPrint instance has its own warning system ans it even able to shut a printer down by cutting the power.

However these interfaces are crap. If you turn a wheel left you expect it to count down, but it did the opposite. And when browsing to menus the selector always moves in the wrong direction. Then for calibration you need to move the head, but after 30 seconds the menu resets to the main screen. A pain! The TronXY also had the eeprom disabled in firmware. In addition to that both printers had menu items for SD Card usage, which I never even used, but no menus for stuff like homing a single axis.

You can imagine that I preferred using the OctoPrint interface on my ipad instead of the displays on the printer itself.

Yesterday I needed to calibrate my Anet A8, as I had to print a large print, which uses most of the print bed, just leaving about 5mm around on all sides. I did not get it to fit, as the default offset was wrong due to a bowden + E3D conversion I did about three years ago. I could have done try and error with modifying the printers slicer settings, but I didn´t I wanted it done right, once and for all.

I started installing “Visual Studio code”. Within I installed “Platform IO” and “Auto Build Marlin”

Then I picked the marlin software from github and the configuration archive from the same location. I extracted marlin and the configuration stuff, copied the default ANet A8 configuration files over the default ones in marlin.

I opened the folder within Visual Studio Code, located the “Auto Build Marlin” panel and clicked on “build”.

After a few minutes it was done. Yeah, I was surprised, too. My next problem was to find out how to flash the new binary without swapping SD-Cards, carry a computer next to my printer or just use a long usb cable to hook up a computer.

The solution was simple. I did just nothing. Well, physical. Even so the stuff is located in another room, I opened SSH and logged into my OctoPrint instance of the Anet A8, where I performed:

sudo apt-get install avrdude

A few seconds later it was done.

A quick test using showed the flashing would work and there is someone listening on the other end of the usb port:

avrdude -b 57600 -p ATmega1284P -c arduino -P /dev/ttyUSB0 -v -U thiswillfail.hex

It showed information about the printers hardware and that the board in general is ready to be flashed using that command, which failed due to the non existing firmware. This of course only works, when OctoPrint is disconnected from the printer via web intrface, because the serial will be in use otherwise.

Since I did not want to setup more than needed on my Raspberry Pi or other systems, I decided to upload the firmware.hex file to my web page. A simple “wget https://geit.de/tmp/firmware.hex” call and the firmware was located on the Raspberry Pi.

avrdude -b 57600 -p ATmega1284P -c arduino -P /dev/ttyUSB0 -v -U firmware.hex

It started flashing, then it did a verify run and the printer restarted with a shiny new marlin, where most issues already were fixed.

I opened the conguration.h and edited some lines. For example I disabled the SD-Card support, which also removed the menu items and regains some internal space, you can use for additional features. I also added PID control for the bed and heaters and fixed the default bed location, so the 0/0 is the corner of the bed and not some location outside the print area.

A day later I considered doing the same with the TronXY X5, but I did not know if there is a bootloader allowing to flash the firmware at all. I basically did the same as above. I logged into OctoPrint using SSH, installed avrdude and ran the command with the broken non existing firmware name. To my surprise it showed be nearly the same data than the Anet A8.

But there was one big issue. There is no default configuration for the TronXY X5 in the marlin repo. So what setup and which cpu or board pins to use? Well, I am an impatient and lazy guy, sometimes taking a risk. I took the profile of my printers successor. The TronXY X5S. It is a real CoreXY printer, while mine is just faking one. But mine has bearings and not crappy plastic wheels. I just changed the name wanted to compile it, but “Auto Build Marlin” gave me a choice.

Do I have the small board or the one with the bigger flash? The board is hidden inside a 3d printer case buried under tons of wires and finding the proper and secure answer would have taken at least 60 minutes. The only reason I would want to do that, would be a failed flash and only if I had to install a replacement SKR board while I am in there, anywere. Did I mention that I am lazy? I glanced at my printer: “You are a big boy, aren´t you?” I compiled the big version and flashed it the same way as I did with the Anet A8 above.

The printer restarted. The display was garbled but more or less readable. I could see the logo and the new firmware version was shown. The default info screen was also covered in little faulty segments. I clicked “Home X” and the printer moved the carriage right into the wall. Great. I changed the X direction in the firmware, compiled and uploaded it again. I had the new homing menu items enabled, so I just pushed “Home X” again and it worked. Promising! Then I selected “Home Y” and hell broke loose. The printer moved toward the Y end stop, but kept running into the X end stop. Good that all my printers have an emergency switch. The second time I used it today.

Well, remember I told you above that the successor was a real CoreXY? Yeah! It means that if only one axis moves, both motors for x and y need to move to perform the action. Someone, no clue who, forgot to deselect the CoreXY setting in the printers profile.

But on the bright side. The board side was compatible and so was the pin out. The end stops worked.

Next flash and another use of the emergency switch. Oh, this thing payed for the money I never payed for it, as it was removed from some 80th hardware. Well, you guessed it. Z direction was wrong and the nozzle drilled into the print bed.

After making sure to enable all features I wanted and to disable all features I don´t want, the final flash.

Everything worked fine. Everything? Right. I was starting to get used to have a broken display. Hell, no. I fixed the broken display mount two month ago and I will not tolerate it showing only a crappy content. I asked Mr. google. Mr. Google seems to have a neighbour named “Wiki”. Must be some kid on a boat or so. However this friendly guy knew exactly my issue. Crappy displays sometimes need a crappy timing. He was even so friendly to point out the lines I need to add. A compile and a flash later result was not good.

Was this Wiki kid taunting me? No, my display was just more crappy than the usually crappy display. I doubled the delay values and you guessed it: A compile and a flashing process later it worked.

In the end I must say this turned out to be a good one. I basically have two new printers. Remember they had the stock firmware compiled by some Chinese dude in 2016 or so. Now the latest and greatest Marlin is running on my printers, the annoying presets are gone, I can use the eeprom for the first time. The SD Card menus are no longer mocking me, when I need to skip them to get to the more important menu entries. The click wheel operates in the right direction and I have PID control, so no more overshooting by 15°C when heating the nozzle.

Maybe this inspires you to do the same with some old printer you barely use.

Supplemental: All my printed calibration cubes on both printers looked like melted ice-blocks. I printed several on each printer using different thermistor types (as I had to guess on the TronXY X5) in the firmware, but basically nothing happened. The cubes looked like crap.

Then I watched a print finish and saw the obvious. The part cooling fan was not turning. I did not check that, after the update. I pushed “Fan on” in OctoPrint and it started running. I checked the GCode and the command was there. WTF

Well, the problem was Cura. Well sort off. It seems old marlin versions ignore the P argument in “M106 S255 P1”. The “1” means part cooling fan #1. It should be zero. I checked my other older gcodes and they all worked fine before and they all have P1 as argument. Then I checked the printer settings in Cura and there is a “1” for cooling fan. The bubble clearly says: “Leave the value as default 0 unless you have more than one part cooling fan.” I for sure never changed that.

“BUT WHY IS THERE A 1?” I checked for the other printer and it is set there, too. So the next step is to write a script to fix all the M106 commands on all printers. I checked all the gcode I have and only the most recent are using the “P1” extension, so I guess it got added by the latest Cura 4.8.0 version with the wrong default.

I don’t have any old printers to update, but I enjoyed your story. And, you’ve given me an idea & a question. First, thanks for the avrdude syntax. I may be able to use it to let me flash genuine Creality firmware on my printer. That’s the idea. Here’s the question: do you know if avrdude can flash BIN files as well as HEX?

Also, I already upgraded my printer to Marlin 2.0.1 using almost exactly the same VS Code procedure you used. I want the Creality firmware because there’s a video on YT showing that it will automatically detect & configure itself to use a BL Touch.

Not sure about the bin file, but basically it is easier to use the bin file, as avrdude needs to read the hex file and convert the hex nibbles to bytes to serial send them, while the bin file can be send without any modifications.

In other words: if avrdude cannot write .bin files, the developer was a dick :smiley:

:smiley: :smiley: LOL Well, that’s optimistic at least.

@Geit I love this story and learned a bunch of things I will use in future videos about updating Marlin.

Right now I am doing the research for a video about installing Marlin on ANET ET4/5 printers which have solid hardware but terrible firmware. ANET has started to help the community port Marlin but it seems the bootloader built into the ET4/5 will only load their proprietary firmware.

I have always used the Arduino IDE but I like the idea of trying out Visual Studio. I also was not familiar with avrdude which is quite interesting. Most folks recommend using the ST-Link V2 with the ST-Link utility. I will be researching the easiest way to explain to folks who have limited or no electrical engineering backgrounds how to get Marlin on the ET4. Your story opened some additional areas of thought for me.

I also will be evaluating fixing one other design decision from ANET that bugs me. The Bowden tube OD on the ET4

Thanks again for all of your participation in this forum.

VSCode is recommended for Marlin 2.x now. Probably due to limitations of the 8 bit base Arduino.

It automatically installs all required dependencies, which was a pain with older versions of ArduinoIDE. Before you needed to look at the error output and search for the library to install, install that, try again and repeat the stuff several times until it finally compiles. VSCode is doing all that automatically.

The optional “Auto Build Marlin” module extracts stuff from the configurations files and applies them to the .ino file, so you do not have modify any of that. All you do is hit build or in my case where the script found two potential boards I had to select build in the right row.

It does not get easier than that. :smiley:

Agreed; VS Code seems to be an advancement on Arduino IDE.