Updating Marlin Firmware - Step by Step Guide Note: This question is meant as a wiki to include all steps that are needed to update your printer with a self configured Marlin firmware version. The answer is a wiki that is currently in development and can be seen (and edited) by all users.



I have a printer and need to update my Marlin firmware to get some stuff done to my liking, especially to make sure I have TRP, have power loss recovery and then do a PID-tune. I am also not sure if a bootloader is flashed. So what I need is a step-by-step guide to:


prepare my printer for flashing
configure my Marlin firmware
get my new Marlin firmware onto my printer
Step 0: extracting old settings &amp; setting up

The first step is to get yourself a printing software that has a Console or Terminal like present in Repetier Host, Pronterface (as part of the Printrun software suite), OctoPrint or any other tool (e.g. serial connection with PuTTY also works) that allows to communicate with the printer to extract the settings we already have. Once we have the software installed and the printer connected, send M503 and copy the old settings into a file for later use.

Next, we need our development surroundings. Usually, you want to use Arduino IDE (but the PlatformIO plugin as part of Visual Studio Code can be used for both Arduino based microprocessors as 32-bit processors), but you need to know what kind of board the control board of your printer is derived from because some boards have native IDEs that work better for them. 

Step 1: Choice of Firmware

By some metrics of early 2020, about 80&nbsp;% of all shipped machines run Marlin in some fashionneed citation. The most prolific versions of Marlin at that point are often cited to be 1.1.9 and 2.x. Since anything before 1.1.9 is very much obsolete and needs an update anyway, we will look into 1.1.9 and 2.x only. Version 2.x was developed to include 32-bit microprocessors, but is compatible with 8-bit microprocessor printer boards. As the version jump indicates though, 2.x is pretty much an entire rewrite, so do your choice and jump to the correct next step.

Marlin 1.1.x

Typically, you start by grabbing a blank Marlin 1.1.9. The next step is to alter the static settings of the printer to match yours in Configuration.h - best use the settings from what we pulled earlier via M503 as a start. Alternatively, you can search for a configuration of your printer between known configuration files. You should at least need to adjust these:

For communications and filament diameter:

#define BAUDRATE 250000

// Generally expected filament diameter (1.75, 2.85, 3.0, ...). Used for Volumetric, Filament Width Sensor, etc.
#define DEFAULT_NOMINAL_FILAMENT_DIA 3.0


Choose your correct temperature tables, and make sure to turn on the one for the bed if you have one!

#define TEMP_SENSOR_0 1
[...]
#define TEMP_SENSOR_BED 0


Next come two blocks that set the 'this is ok' temperature area, for the hotends and bed respectively (only hotend shown here).

// Extruder temperature must be close to target for this long before M109 returns success
#define TEMP_RESIDENCY_TIME 10  // (seconds)
#define TEMP_HYSTERESIS 3       // (degC) range of +/- temperatures considered "close" to the target one
#define TEMP_WINDOW     1       // (degC) Window around target to start the residency timer x degC early.


The next slot is an important safety feature: Mintemp and Maxtemp. Unless you seriously, positively know your hotend can do more than 275 °C (which means you have an all-metal hotend), DON'T touch the Maxtemp, but you might set Mintemp to 0 °C if you like.

Next come PID-Tuning settings, you only need to work with those if you know what you are doing.

The next step is important also: make positively sure that these two lines are exactly as follows, no stray // in front to comment them out. This is TRP.

#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders
#define THERMAL_PROTECTION_BED     // Enable thermal protection for the heated bed


If your printer is a CoreXY or similarily uses 2 belts for moving along 2 axis, you look at the Mechanical Settings tab and alter it there, otherwise we skip further to the Endstop Settings. Enable (remove the leading //) the max-endstops if you have them, the rest is usually not necessary on most consumer-grade machines, then go further to the Movement Settings. From our M503 we grab the settings to fill out the following:

#define DEFAULT_AXIS_STEPS_PER_UNIT   { 80, 80, 4000, 500 }
#define DEFAULT_MAX_FEEDRATE          { 300, 300, 5, 25 }


If you have a probe, you look into Z-Probe Options and follow 0scar's guide here, skip it otherwise until you find the next snippet. Fix that one up to fit your bed and movement area. You might need to set values for the endstop to bed origin distance. These offsets, X_MIN_POS and Y_MIN_POS, need to contain the correct values to center the bed; see "How to center my prints on the build platform? (Re-calibrate homing offset)
".

// The size of the print bed
#define X_BED_SIZE 200
#define Y_BED_SIZE 200

// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS 0 // Value of zero means that the origin of the bed is at the endstop
#define Y_MIN_POS 0 // Value of zero means that the origin of the bed is at the endstop
#define Z_MIN_POS 0 
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
#define Z_MAX_POS 200


Next, uncomment (remove the leading //) the following line:

//#define EEPROM_SETTINGS // Enable for M500 and M501 commands


If you want to have a special pause position, uncomment and define it in 

//#define NOZZLE_PARK_FEATURE
#if ENABLED(NOZZLE_PARK_FEATURE)
  // Specify a park position as { X, Y, Z }
  #define NOZZLE_PARK_POINT { (X_MIN_POS + 10), (Y_MAX_POS - 10), 20 }
  #define NOZZLE_PARK_XY_FEEDRATE 100   // X and Y axes feedrate in mm/s (also used for delta printers Z axis)
  #define NOZZLE_PARK_Z_FEEDRATE 5      // Z axis feedrate in mm/s (not used for delta printers)
#endif


We are on the finishing stretch, just a few things in this file remaining! Select your language with the line: 

#define LCD_LANGUAGE en


Turn on the SD-Card slot by uncommenting 

//#define SDSUPPORT


The last step we need to alter in the Configuration.h is choosing the correct LCD controller. Uncomment the line corresponding to your printer - you might need to use a generic option.

Marlin 2.x

Again, grab the 2.x marlin, either the blank base or a preconfigured version. For some printer styles (like Delta), you have to take a specialized set. Then we look at our M503output and set our communications Baudrate and our motherboard (or the board it is derived from), then the number of extruders and the filament diameter:

#define BAUDRATE 250000

#ifndef MOTHERBOARD
  #define MOTHERBOARD BOARD_RAMPS_14_EFB
#endif

#define EXTRUDERS 1

#define DEFAULT_NOMINAL_FILAMENT_DIA 3.0


Next we go to thermal settings! We need the correct temperature sensor table for hotend and bed, possibly we could lower MINTEMP to 0. Don't touch MAXTEMP unless you know what you're doing and have a full-metal setup and you know your machine can take more.

#define TEMP_SENSOR_0 1
[...]
#define TEMP_SENSOR_BED 0


Our next step is making positively sure that TRP is on. Make sure these lines have no leading //

#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders
#define THERMAL_PROTECTION_BED     // Enable thermal protection for the heated bed
#define THERMAL_PROTECTION_CHAMBER // Enable thermal protection for the heated chamber


If the printer is a CoreXY or similar, enable the style in the mechanical settings area.

Enable (remove the leading //) the max-endstops if you have them, the rest is usually not necessary on most consumer-grade machines, then go further to the Movement Settings. From our M503 we grab the settings to fill out the following: 

#define DEFAULT_AXIS_STEPS_PER_UNIT   { 80, 80, 4000, 500 }
#define DEFAULT_MAX_FEEDRATE          { 300, 300, 5, 25 }


If you have a probe, you need to set it up - 0scar has a partial guide - and it is all in the Z Probe Options area! Otherwise, go on. We need to go down, and in the middle of the Probe setup, we find the bed settings. Set them up to fit your printer and possibly the offset from the home-switches to the build volume corner.

// The size of the print bed
#define X_BED_SIZE 200
#define Y_BED_SIZE 200

// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS 0
#define Y_MIN_POS 0
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
#define Z_MAX_POS 200


Down to Additional Features we go! Let's turn on the EEPROM by uncommenting (removing the //)...

//#define EEPROM_SETTINGS     // Persistent storage with M500 and M501


...and think about how you want to set up your preheats or where to have your special park position. But then comes the last part, which we really need to do: Set up the interface. Start by changing the language and turn on the SD-Slot by uncommenting the lower of these lines:

#define LCD_LANGUAGE en

//#define SDSUPPORT


Our last stop on setting up the basics is LCD / Controller Selection. We need to uncomment the right one here. If you don't find yours, use a generic one.

Step 2: Preparing the Board

There are 2 variants here: either you use a bootloader, or you prepare a .hex file for overwriting the whole firmware. In either case, we need to know what board we have, so we can compile with the correct encoding and setup. You might need to install a proper extension!

2.1 - Bootloader

A lot of boards come with a pre-flashed bootloader, which makes installing and revising software very fast. But not all boards have one flashed.

Flashing a bootloader needs you to have an Arduino and some cables or a different ISP or AVR programming tool. Complete instructions can be found here by Greenonline and here by Robert Lo Giacco and jpa. 

Or you take your control board to your local maker space and ask someone there to help you flash the bootloader - most maker spaces have at least someone that has an Arduino and can help you!

2.2 - .hex file

In this case, we don't need to do anything in this step. We'll have a different installation process though.

Step 3: Compiling &amp; Installing Firmware

Depending on your choice in the previous Step, you have to follow the corresponding branch here:

3.1 - Bootloader

If you have set your bootloader, now installing firmware is as simple as connecting your computer with the printer using a direct connection and doing a compile &amp; Upload command. 

3.2 - .hex file

After preparing your .hex file, you can upload it with one of the variants shown here by Greenonline, Trish or Thomas Weller

Step 4: Finishing touches

Seeding

Directly after installing up our new firmware on the printer, we need to seed our settings. Connect to the printer via any Console or Terminal (see Step 0) and use these commands

M502
M500


PID Tune

Then we run a PID-Tune. For the first extruder we send:

M303 E0 S200 C3


It will run the machine some and return values named Kp, Ki &amp; Kd. These directly correspond with P I &amp; D. Store them into the EEPROM and save with the following: 

M301 P##.## I#.## D##.##
M500