TheMaxus

Installing Marlin on Ender 3 V2

Ender 3 V2 comes with Creality’s own version of Marlin, but usually it’s pretty outdated, so by installing the newest version of Marlin you’re going to get more flexible firmware and more features and bug fixes.

Marlin doesn’t provide pre-built binaries, because it’s would be a nightmare to compile it for every printer that Marlin supports, so we have to build it ourselves.

While this guide focuses specifically on Ender 3 V2, the process is roughly the same for most other 32-bit printers so you can use this guide for other 3d-printers.

Tools required

Getting the source code

We’re going to need two different repos, code repo and the configuration repo.

You can download them using git:

git clone https://github.com/MarlinFirmware/Marlin.git
git clone https://github.com/MarlinFirmware/Configurations.git

Then we need to select the correct version in both repos:

git checkout <version number>

Using this method we can easily download newer versions in the future using:

git fetch
git checkout <new version>

Alternatively you can download the specific version from Releases on GitHub (Firmware, Configs).

Now we need to copy Ender 3 V2 default configuration files from the Configurations repo. Remember to do this every time you download a new version!

Go to the Configurations repo and go to config/examples/Creality/Ender-3 V2/CrealityV422

Here we have a choice between the CrealityUI and MarlinUI, CrealityUI is the UI printer comes with, and MarlinUI is more minimalistic text based UI, those can be changed later in configuration file so it shouldn’t matter that much which one we choose.

Copy Configuration.h and Configuration_adv.h files and put them into Marlin directory in the Marlin repo.

At this point you can just press Build in Marlin Autobuild panel and flash the firmware with the default settings.

If you want to customize your firmware, edit the Configuration.h file. I like to enable S-Curve Acceleration to reduce ringing artifacts and enable manual mesh bed leveling.

PID Calibration

You most likely are going to need to calibrate hotend and heated bed PID after flashing the firmware. This is best done before flashing the firmware but can also be done after.

There are multiple ways of initiating PID calibration:

Pronterface

Pronterface has a really handy g-code console. Connect your printer by USB to the computer. In the console enter M303 E0 S200 C8 U1 after which M303 E-1 S90 C8 U1, then if you want to save the settings to EEPROM type M503

M303 outputs PID values to the console so you can put those values in the configuration file to make those values permanent.

G-Code file

You can write the commands to .gcode file, upload the file to an SD card and run it.

Here’s an example:
NOTE: I have not tested the following code, use at your own risk!

M928 pidlog.txt     ; Start writing log to SD card
G28                 ; Home
G0 Z40              ; Move hotend 40mm up
M303 E0 S200 C8 U1  ; Calibrate hotend PID for 200C temperature in 8 cycles and use those settings
M303 E-1 S90 C8 U1  ; Calibrate heated bed PID for 90C temperature in 8 cycles and use those settings
M503                ; Output settings to log/serial
M500                ; Save settings to EEPROM
M29                 ; Stop logging

Using stty

You can also use Unix tty to control your printer when you connect to your printer via USB.
First we’re going to setup the tty using:

sudo stty -F /dev/ttyUSB0 115200 -echo -onlcr

Then you can either use pipes to read and write to printer

echo "M503" >> /dev/ttyUSB0
cat /dev/ttyUSB0

or you can use screen or minicom

screen /dev/ttyUSB0 115200
# For minicom ideally you need to set it up first
minicom -s

although at least for me screen and minicom output comes weirdly formatted.

This way we can send the calibration commands without using Pronterface.

Flashing the firmware

On the most printers you only have to update the printer itself, but Ender 3 V2 uses a display with it’s own controller, so we need to flash the LCD as well.

LCD

First we need to update the LCD firmware. In the Configurations repo go to config/examples/Creality/Ender-3 V2/LCD Files and copy DWIN_SET folder to an empty FAT32 formatted microSD card. Disconnect and remove the LCD assembly from the printer. Unscrew all the screws on the back of the LCD and remove the plastic cover. Insert the microSD into the slot on the PCB. Connect the LCD cable and power-on the printer. The LCD should turn red/orange, this means it updated successfully. Remove the microSD, assemble the LCD and power-off the printer.

Printer

Now in the Marlin folder go to .pio/build/STM32F103RET6_crealitand copy the bin file NOT elf file to the microSD and insert it into the slot on the printer. Now power-on the printer and it should update.

If you’re going to use the SD card for printing, don’t forget to delete the bin file on the SD card, so the printer doesn’t update every time you turn it on, as it wears down the flash memory on the board.

Conclusion

Now you have shiny, brand new hopefully not broken firmware on your 3d-printer. Now you can print Benchy and compare the results to the old firmware.