Install Marlin on the Anet ET5 Pro

FunduinoPublished on

Vom Anet-Bootloader zur offenen Firmware

Wer seinen Anet ET4 oder ET5 auf Marlin umrüstet, tauscht die geschlossene Werksfirmware gegen den Standard der 3D-Druck-Szene: frei konfigurierbar, gut dokumentiert und mit breiter Unterstützung im Netz.

Der Weg dorthin führt über vier Etappen: die Entwicklungsumgebung einrichten, die Firmware an den eigenen Drucker anpassen und kompilieren, einmalig einen neuen Bootloader per ST-Link in das geöffnete Gerät schreiben und den Drucker danach neu einmessen.

Das ist kein Nachmittagsprojekt. Die Garantie erlischt, das Mainboard kann dabei zerstört werden, und die In-Circuit-Programmierung findet am geöffneten Gerät neben offenen Netzspannungskontakten statt.

Printer display at startup with OpenBLT
OpenBLT installs the firmware

Before you start

This guide is for makers who want to upgrade an Anet ET4 or ET5 to Marlin firmware. Read the following points before you get started:

  • The 3D printer's warranty is void once you upgrade it.
  • There's plenty of help online if you run into problems - but only in English.
  • Experience with electronic circuits is required, as is some familiarity with development environments and the programming tool for STM32 microcontrollers.
  • An incorrect upgrade can render the mainboard unusable.
  • You upgrade at your own risk.

Working with mains voltage: The one-time in-circuit programming of the bootloader requires the housing to be opened. This exposes contacts carrying mains voltage. This work may only be performed by persons trained to work with mains voltage, while observing all safety precautions - including the use of an isolation transformer.

What the conversion delivers - and what it costs

Advantages:

  • Standard firmware with extensive online support
  • Future firmware updates are conveniently installed via the SD card; the time-consuming in-circuit programming is only needed once
  • Operating parameters can be adjusted over a wide range, making it easier to use other hardware such as an extruder or bed-level sensor
  • A BLTouch distance sensor can be used

Disadvantages:

  • The touchscreen is trickier to use – a stylus helps; alternatively, you can control the printer via USB using Pronterface, OctoPrint, or similar software
  • Known bug in this Marlin version: After loading or changing filament, you must turn the printer off and back on; otherwise, the bed and extruder heaters will no longer be activated
  • To really benefit from it, you’ll need to familiarize yourself with Marlin’s parameters afterwards

The guide was written by Ulrich Meyer-Ciolek and is licensed under CC-BY-4.0. David Terán adapted Marlin for the ET4/ET5 series and published it on GitHub.

What you need

  • An Anet ET4/ET5 series 3D printer
  • A Windows PC – firmware can also be created on a Mac, but in-circuit programming is difficult and is not covered here
  • Internet access for downloads
  • An in-circuit programming adapter for STM32, search term ST-Link V2
  • A USB 2 extension cable, Type A plug to Type A socket
  • 2 mm and 3 mm Allen keys – the 3 mm key is included with the printer

Set the capacitive bed-level sensor correctly before the conversion. This will make it easier to set the probe Z-offset later.

Install Visual Studio Code and PlatformIO

The firmware is generated with the free IDE Visual Studio Code from Microsoft. Install it as usual.

Next, add two extensions. Click the gear in the bottom left, go to Extensions, and install these one after the other:

  • PlatformIO – generates programs for the processor installed in the ET4/ET5
  • Auto Build Marlin – the Marlin-specific extension
Gear icon for extension management in Visual Studio Code
Access the extensions via the gear icon
Search result for PlatformIO in the Extensions Manager
Install the PlatformIO extension
Search result Auto Build Marlin in the Extensions Manager
Install the Auto Build Marlin extension
1 / 3

Install the ST-Link Utility

STMicroelectronics provides the software for the programmer adapter free of charge - but only after you enter your name and a valid email address, to which the download link will be sent.

During installation, you must allow the USB driver for the programmer adapter. Then plug the adapter into your PC and launch ST-Link Utility. Under Target → Settings, you can see whether the adapter has been detected. If an error message appears, it's time to troubleshoot.

Main window of the ST-Link Utility software
The ST-Link Utility

Download the bootloader and Marlin

Two downloads are required:

  • The OpenBLT bootloader adapted by David Terán OpenBLT bootloader. If you don't want to compile it yourself, the openblt_et4.bin file is all you need - it works with all ET4 and ET5 printers.
  • The adapted Marlin firmware from his GitHub page, via Code → Download ZIP.

Extract the Marlin archive to a directory of your choice - all further work will take place there. Then open this directory in Visual Studio Code.

GitHub page of David Terán’s Marlin fork
Get Marlin per Code → Download ZIP
Dialog for opening a folder in Visual Studio Code
Open the extracted folder
1 / 2

Customize Marlin for your own printer

David Terán has done the groundwork; only a few changes remain:

  • platformio.ini – at the very bottom of the directory listing. Press Ctrl+F, search for ET4, and remove the comment marker before #board_build.offset = 0x10000. This moves the firmware further back in memory so it doesn't overwrite the bootloader.
  • EasyConfig.h in the Marlin subdirectory – enter your printer model after #define ET_MODEL. Valid options are ET_MODEL_ET4, ET_MODEL_ET4_PLUS, ET_MODEL_ET4X, ET_MODEL_ET4_PRO, ET_MODEL_ET5, ET_MODEL_ET5X, and ET_MODEL_ET5_PRO. A little further down, you can enter a name that will appear on the display at startup.
  • Configuration.h – change //#define ET_EASY_CONFIG to #define ET_EASY_CONFIG. Also enter the offset between the bed-leveling sensor and the nozzle: for the ET5 Pro with the standard sensor, use #define NOZZLE_TO_PROBE_OFFSET { -25, -8.5, 0 }. Leave the Z value at 0; you'll adjust it later.
  • Configuration_adv.h – set the initial value of the probe offset wizard so that the nozzle stays safely above the bed at startup.

The # in a C header file is not a comment character; it introduces a preprocessor directive, so don't remove it. Comments in C begin with //.

Add a marker as a comment after each changed line, for example // Funduino 01.04.2021. Then you can find your changes later using search.

File platformio.ini in the Visual Studio Code directory view
platformio.ini is at the very bottom
Entry `board_build.offset` in the `platformio.ini` file
Remove the comment character before board_build.offset
Line with the Define ET_EASY_CONFIG in the editor
Activate ET_EASY_CONFIG
Parameter NOZZLE_TO_PROBE_OFFSET in the editor
The offset between the sensor and the nozzle
1 / 4

Switch the heated bed to bang-bang control

On the author's ET5 Pro, PWM control of the heated bed does not work - the driver on the mainboard does not seem to be designed for it. There are no schematics for the mainboard, so the only option is to switch from PID control to the Bang-Bang method: simple on-off control with hysteresis.

The temperature then fluctuates by about 2 to 4 degrees. This is less precise than PID control, but not a problem.

Do not try to force PID control of the bed. This can thermally destroy the driver on the mainboard, and it cannot be replaced easily.

Original PID settings for the heated bed
Previous: PID-controlled PWM
Changed settings for bang-bang control
Later: bang-bang control
1 / 2

Compile the firmware

Click the small checkmark at the bottom left edge of the window – the tooltip shows PlatformIO: Build. Depending on your computer, this may take a while.

The success message will then appear in the terminal window. The result is the file firmware.srec in the .pio\build\ET4 subdirectory. Copy it to a microSD card.

However, the printer can't do anything with it yet – it's missing the OpenBLT bootloader.

Build process success message in the terminal window
The firmware was successfully generated.

Write the bootloader using ST-Link

How to prepare the printer: unload the filament, turn off the printer and unplug it, unscrew the filament holder, remove the glass bed, carefully lay the printer on its right side - the side without the IEC power inlet - and remove the bottom plate.

Next to the processor is a single-row, four-pin header. The top pin is labeled U , and the bottom one is labeled G. Data and Clock are in between. Connect all pins except U to the adapter: G to GND, Data to SWDIO, Clock to SWCLK.

Then connect the adapter to the PC using a USB extension cable, plug in the printer, and turn it on.

In ST-Link Utility, set the memory size to 0x100000, connect via Target → Connect, and back up the existing memory using File → Save file as. Then open openblt_et4.bin and start with Target → Program & Verify.

Check the wiring multiple times. A live pin on the programmer adapter—3.3 V or 5 V—connected to the mainboard usually means the end of the mainboard.

Four-pin header next to the processor on the motherboard
The programming interface on the mainboard
ST-Link V2 adapter connected to the mainboard
This is how the adapter is connected.
Success message after programming the bootloader
The bootloader has been written.
1 / 3

Install Marlin

Close ST-Link Utility, unplug the adapter from the PC, turn off the printer, and disconnect the adapter from the mainboard.

The next time you turn it on, the printer displays the OpenBLT logo and an error message: No firmware found. Turn it off again, insert the Micro SD card containing firmware.srec, and turn it on. OpenBLT installs the firmware and starts the printer with it.

Printer display at startup with OpenBLT
OpenBLT installs the firmware

Initialize the EEPROM

Marlin can't do anything with the old EEPROM contents, so the EEPROM must be reset. To do this, send G-code to the printer using a terminal program.

Connect the PC to the printer via USB. The built-in USB-to-serial converter is a CH340; you can get the driver from the manufacturer, WCH. You can see which COM port the printer has been assigned in Device Manager.

Pronterface is a suitable terminal program; alternatively, use MatterControl or OctoPrint. Connect at 250000 baud and select the correct COM port.

Pronterface terminal program with printer connected
Pronterface connected at 250000 baud
Initialize EEPROM
M502   ; Load factory settings
M500   ; Save settings permanently

Set the probe Z offset

The probe Z-offset is the distance between the bed-level sensor’s trigger point and the nozzle tip. It is always negative because the sensor triggers before the nozzle touches the bed.

Heat up first – the bed and nozzle to the temperatures you usually print at, for example 60 and 205 degrees. Values measured when cold differ significantly due to thermal expansion.

After the preparation commands, slide a sheet of regular printer paper under the nozzle and carefully move the nozzle downward using the terminal program’s axis controls until the paper can only be moved with resistance. Then save the offset shown on the display.

Marlin switches off the hotend heater after a while without a print job - this is normal and no cause for concern.

You can fine-tune the value on your next print: Measure the thickness of the printed skirt with calipers and compare it with the initial layer height set in the slicer.

Sheet of paper between the nozzle and print bed, offset on the display
Determine the Z offset using a sheet of paper
Prepare probe Z-offset measurement
G28        ; Home all axes
M851 Z0    ; Reset Z0 offset
M500       ; Save the current settings
M501       ; … and activate them
G28 Z      ; Home the Z axis again
G1 F60 Z0  ; Move the nozzle to the true Z0 offset (determined by the probe)
M211 S0    ; Disable the software endstop, otherwise you can't move the nozzle
           ; any closer to the print bed
Save the measured probe Z offset
M851 Z X.XX  ; In the example in the manual, X.XX would be -1.6
M211 S1      ; Reactivate the software endstop
M500         ; Save the values permanently
M501         ; … and activate them

Set up auto bed leveling

First, level the corners of the print bed using the LCD menu. Then it’s worth adding auto bed leveling to your slicer’s start code so it runs before every print.

If you want to save the nearly two minutes, load the correction matrix determined once instead.

Auto bed leveling in the slicer's start code
G28   ; Home
G29   ; Auto bed leveling
M500  ; save the calculated correction matrix

; Alternative, if the matrix has already been saved:
M420 S1  ; enable auto bed leveling and load the saved matrix

PID tuning of the hotend

Marlin can measure the control loop for the hotend temperature itself. During PID tuning it determines the parameters for stable control - the firmware handles the math.

You set the target temperature and the number of measurement cycles. At the end, Marlin displays the values it has determined. You could enter them permanently in Configuration.h; it’s more common to save them in the printer’s permanent memory.

If you regularly print at widely varying temperatures, run the tuning for each one and add the commands to the start G-code of the corresponding slicer profiles.

PID tuning of the print bed is not possible with this printer because the driver on the mainboard cannot handle PWM control.

PID tuning process in the terminal window
PID tuning of the hotend
PID tuning of the hotend to 205 degrees
M106 E0 S255     ; Start the fan at 100%
M303 E0 S205 C8  ; Perform PID tuning, 8 measurement cycles

; Then save the values determined by Marlin,
; using the values from the guide as an example:
M301 P24.28 I1.96 D75.02
M500  ; save
M501  ; and activate
Rate the instructions

Comments

Ask a question or share an experience

Contact us if something doesn’t work. Please include your board and the error message.

We review every comment before publication. Your email address remains with us.