Installing the bootloader
Before installing any “custom” firmware on your printer, you will need to install or “flash” a bootloader to your board. If you are familiar with Arduino boards, you know that all you have to do to flash a new sketch, is just connect the board via USB cable to your pc, compile and flash.
This happens thanks to a small piece of code called the “bootloader” which lives in a specific memory section of the processor.
By definition the Arduino bootloader is the little program that runs when you turn the Arduino on, or press the reset button. Its main function is to wait for the Arduino software on your computer to send it a new program for the Arduino, which it then writes to the memory on the Arduino.
The diagram below shows a typical Arduino memory map.
The “Boot Flash Section” is where our bootloader lives. This section of the program memory is normally write protected to ensure it is not accidentally overwritten which would render the cpu useless. It is also for this reason most printer manufacturers choose to ship boards with pre-installed firmware but without a bootloader.
A word of Warning
Uploading the wrong firmware to your printer could potentially brick your control board. However this is not even the biggest problem. Wrong parameters in the firmware, could result in printer damage, and even a fire hazard from the heaters. In a nutshell if you are not sure about something, STOP and do some research or ask before carrying on.
It is also imperative following any firmware upgrade, not to leave the printer unattended for any length of time. The new firmware could always contain bugs that have not yet been documented. Such bugs could also lead to printer damage and injury.
Getting down to it
To update the bootloader you can follow one of the many youtube videos and writeups out there, but in a nutshell you will need :
- Dupont Wires, 5 Female to Female, and 1 Female to Male
- An Arduino Uno (or clone). (A USBASP AVR Programmer will also do the trick)
- A Windows PC or MAC with the Arduino IDE pre-installed
- Connect the Uno to your PC
- Open the Arduino IDE and select Arduino ISP from the example sketches
- Burn the sketch to the Uno
- Add the Sanguino boards to the ide from https://raw.githubusercontent.com/Lauszus/Sanguino/master/package_lauszus_sanguino_index.json
Connect the Arduino uno to the Creality control board as shown below. Both ICSP headers follow a 1 to 1 connection, except for the RST pin on the Creality board, which needs to go to Pin 10 of the UNO board using the Male to Female Dupont Wire
Select the Sanguino board from the IDE
Burn the bootloader
Installing Marlin 2.x
If you don’t have it already installed, Install Visual Studio Code from here
Install the Platformio Extension following the instructions here
Install the Marlin Firmware Auto build Extension
Clone or download the latest Marlin firmware from here
Open Platformio.ini and edit the [platformio] section as follows :
[platformio] src_dir = Marlin boards_dir = buildroot/share/PlatformIO/boards default_envs = melzi include_dir = Marlin
Now copy configuration.h, configuration_adv.h, _Bootscreen.h, and _Statussceen.h from Configurations-release-2.0.6 -> Creality -> Ender-3 -> CrealityV1 to the Marlin Directory (Marlin-2.0.x->Marlin)
Feel free to do any changes and customisations you deem fit. In my case I had to edit the line 756 to
#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 800, 100.11 }
from
#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 93 }
For the sake of completeness, also edit line 76
// Author info of this build printed to the host during boot and M115#define STRING_CONFIG_H_AUTHOR "(xxxxxxxxxxxxx, Ender-5)" // Who made the changes.
Once all the configuration changes have been done, it is time to compile and upload our firmware. Click on the (M)arlin extension on the left of your screen, and then click on “show the ABM panel
The creality board inside my ender 5 is based around the ATmega1284P
Click on the Build button to the right of “melzi_optimized”, and allow the firmware to compile. If you choose “melzi” the upload will fail, since this is setup with the “wrong” baud rate in platformio.ini.
Unless there are any errors, you should eventually see something like this in your terminal window
You might need to scroll up to actually see the above, but as a rule of thumb, if you do not see any red lines during compilation, everything is OK.
Connect the printer via USB to your computer, and hit the “Upload” button, to the right of the build button. The compiler will be triggered again, but this time, after a successfully compiling our code, the generated hex file will be uploaded to our board. Asuming your board has been correctly installed with a bootloader you should see an output similar to the below
Your creality ender is now running on Marlin 2.x.
Troubleshooting
If the compiler fails during the linking process running out of memory, take a look at Marlin 2.0 program memory usage by feature on AVR 8Bit boards.
If you receive a repeated timeout error during the programming stage, make sure that the bootloader has been correctly installed