3D Printing and firmware hacking

Praying that I don't brick the board in the Creality CR-20 Pro...

I haven’t used the 3D printer for around 8 weeks or so. I have to admit, I’ve missed the background noise a little.

I started off a huge 6 day print, and something happened to it about 4 days in, it had some weird layer shift (which I think was caused by infill being too little at certain points) which meant the otherwise flawless print was pretty much ruined. What’s worse, because it was the best part of 700g of filament, there wasn’t a lot left from my 1KG roll.

I had about half of another roll in a box but the passion for printing had just completely evaporated. Especially considering this was the first ‘big’ thing I’d printed.

My lovely wife helped (did) tidy up and dusty around everywhere and I decided to wash the build plate, get the clips back on and try a print.

Luke wanted a Darth Vader (again), I decided to print something a little more practical.

I settled on a controller stand for an Xbox Series X controller for my desk.

I loaded up the STL file into Cura (admittedly the first time I’ve done anything since migrating to a new PC), sliced the file, grabbed the Gcode, uploaded it to Octoprint and started the print off.

A few seconds into the print, it started making a weird noise, the part of the machine where the filament is run in was going crazy. The head was just printing a load of garbage in a weird pile:

printer blob

Tried again, messed with the machine, tightened a few things up and everything seemed okay to me.

Decided to print a temperature tower from some already compiled Gcode. That printed fine.

I figured since I’m nearly out of filament, the printer is being a PITA and I have some time that I might look at updating the firmware again.

I’ve been meaning to look into it for some time now, the machine was on a nightly bugfix build from November 2019 and there’s been quite a few releases since then. It always seems overly complicated and so weird that you need to compile the firmware yourself - surely everyone’s CR-20 Pro is the same and it should just be a case of someone building it and making it available.

It seems not though, and I guess there’s an awful lot that could theoretically go wrong should you have a firmware file on the net that crashes the print head into the bed. A lot of broken machines. Perhaps it’s just always been that way because of the very nature of the machines - people buy them, hack them, play with them, make them better, break them, fix them.

Either way, it felt like even for me it was one of those things that needed some dedicated time to properly look into, especially given the chance that one misstep could brick the machine.

I had a dig around, downloaded the latest Marlin files and saw that there were effectively two files that needed to be modified, the firmware compiled and then uploaded.

I ran an M503 on my printer which gave me the following output:

Send: M503
Recv:   G21    ; Units in mm (mm)
Recv:   M149 C ; Units in Celsius
Recv:   M200 D1.75
Recv:   M200 D0
Recv:   M92 X80.00 Y80.00 Z400.00 E101.10
Recv:   M203 X250.00 Y250.00 Z5.00 E25.00
Recv:   M201 X500.00 Y500.00 Z100.00 E1000.00
Recv:   M204 P500.00 R500.00 T500.00
Recv:   M205 B20000.00 S0.00 T0.00 X10.00 Y10.00 Z0.40 E5.00
Recv:   M206 X0.00 Y0.00 Z0.00
Recv:   M420 S0 Z0.00
Recv:   G29 W I0 J0 Z-0.27500
Recv:   G29 W I1 J0 Z-0.17250
Recv:   G29 W I2 J0 Z-0.03000
Recv:   G29 W I3 J0 Z3.34500
Recv:   G29 W I0 J1 Z0.05500
Recv:   G29 W I1 J1 Z-0.00250
Recv:   G29 W I2 J1 Z-0.02750
Recv:   G29 W I3 J1 Z0.01500
Recv:   G29 W I0 J2 Z0.28000
Recv:   G29 W I1 J2 Z0.14500
Recv:   G29 W I2 J2 Z0.06250
Recv:   G29 W I3 J2 Z0.04500
Recv:   G29 W I0 J3 Z0.58750
Recv:   G29 W I1 J3 Z0.36250
Recv:   G29 W I2 J3 Z0.20750
Recv:   G29 W I3 J3 Z0.11000
Recv:   M145 S0 H200 B60 F0
Recv:   M145 S1 H230 B80 F0
Recv:   M301 P20.84 I1.96 D55.47
Recv:   M413 S1
Recv:   M851 Z-3.00
Recv:   M900 K0.00
Recv:   M603 L0.00 U100.00
Recv: ok
Recv:  T:47.62 /0.00 B:39.44 /0.00 @:0 B@:0

I grabbed the latest Marlin 2.0 from here


I found this plugin for VScode.


The plugin will automatically download PlatformIO.

If you open the Marlin project up, you’ll see that there’s a Marlin folder. Inside there was a configuration.h and a configuration_adv.h file.

I grabbed the CR-20 Pro config files from here:


And put them into that Marlin folder along with the _statusscreen.h file. There’s not a statusscreen file in the default Marlin firmware fileset so I do wonder if that’s what a lot of people run into when they get a blank screen post firmware update and think that they’ve bricked the machine.

I took a few of the M503 values, searched for the relevant GCode and replaced the figures with what I had in there.

I clicked on build, then plugged the printer into the PC (it’s usually plugged into a Raspberry Pi) and I clicked on the Upload button.

It flashed the firmware, verified it and I had brand new firmware, yay!

My Z-offset had been lost and the clips on the print bed had to be moved a bit because it’s checking a ‘slightly’ different point for the front and back right points but other than that, there were no catastrophes.

In order to fix my Z-offset I used this fantastic guide here:


I gave the printer the commands through Octoprint and it was really nice to get into it on a code level, the guide is great, just be careful when you’re lowering your Z-Offset by hand on the machine as part of this process involves disabling the safetys so there’s nothing to stop you from lowering it into the bed and destroying the nozzle/hot-end/machine.

It’s currently printing a small storage box for Dinogenics. I also took the opportunity to set up PrusaSlicer, install ArcWelder on the Octoprint server (something that I needed to upgrade the firmware in order to use) and I wanted a fresh STL and Gcode that I’d not used before for a fresh test.

Ideally this would have been less than an 8 hour print, but it is what it is.

The SSL cert I’ve got for the webcam expires 30th April, Certbot isn’t doing what it’s meant to do, it’s probably something to do with the machine being off for two months since I last fixed it, need to go and figure out which part of my firewall, haproxy or certbot config isn’t working right. I’ve noticed that certbot is quite a bit out of date and there’s a new version that I have to install through something called snap. Looks like another package manager. Could be interesting.

Longest blog post for a while and certainly the most tech heavy one. Feels good. Maybe more to come..

comments powered by Disqus