Marlin

Also known as: Marlin firmware

On this page 7

Marlin is an open-source firmware that runs directly on the microcontroller of a 3D printer mainboard and translates G-code commands into coordinated stepper motor pulses, heater control and sensor readings. Within 3D printer hardware, Marlin is the most widely deployed firmware for consumer fused filament printers, and many machines from mainstream manufacturers ship with a customized Marlin build.

Marlin, also called Marlin firmware, descends from the early RepRap firmware lineage and is distributed under the GNU General Public License. It performs all motion planning on the printer itself, which distinguishes it from host-based approaches such as Klipper, where a separate computer calculates movement.

How Marlin controls a 3D printer

Marlin works as a real-time control loop on the mainboard microcontroller: it reads G-code line by line, plans motion, generates step pulses and regulates temperatures without an operating system. The firmware receives commands over USB serial, from an SD card or through an attached host such as OctoPrint.

Each movement command passes through a look-ahead planner that buffers upcoming moves and computes junction speeds so the toolhead does not stop at every segment. The stepper interrupt then emits precisely timed pulses to the drivers, while a separate temperature routine runs PID control on the hotend and heated bed.

The following table shows the main firmware subsystems and what each one is responsible for.

SubsystemFunctionTypical configuration item
G-code parserInterprets commands such as G1, M104 and G28Enabled command set
Motion plannerBuffers moves and limits acceleration and jerkBuffer size, acceleration values
Stepper engineGenerates step and direction pulsesSteps per millimeter, driver type
Thermal managerRuns PID loops and watches for faultsPID constants, maximum temperatures
Probe and levelingMeasures the bed and compensates for tiltProbe offsets, mesh grid size
User interfaceDrives the display, encoder and menusDisplay controller model
Core subsystems inside Marlin

Configuring and compiling Marlin firmware

Marlin is configured at compile time, not at runtime: the user edits the header files Configuration.h and Configuration_adv.h, compiles the source and flashes the resulting binary to the board. This design keeps the firmware small enough for 8-bit AVR boards with very limited memory.

Most builds use PlatformIO inside a code editor, which selects the correct toolchain for the board environment. Some values, such as steps per millimeter, PID constants and probe offsets, can also be changed with M-codes and saved to EEPROM with M500, so routine calibration does not require recompiling.

The table below lists typical hardware platforms that Marlin supports and the practical consequences of each.

PlatformExample processorPractical consequence
8-bit AVRATmega2560Limited memory, fewer advanced features
32-bit STM32STM32F103, STM32F446Common on modern boards, ample headroom
32-bit LPCLPC1768, LPC1769Fast step rates, older 32-bit generation
ESP32ESP32-WROOMWireless options on selected boards
RP2040RP2040Low cost, newer and less mature support
Mainboard platforms supported by Marlin

Correct configuration requires matching the driver type, endstop logic, thermistor table and kinematics. A wrong thermistor setting is especially dangerous, because the firmware would read a false temperature and could overheat the hotend.

Key features for print quality and safety

Modern Marlin releases offer features that address both motion quality and machine safety, and most of them must be enabled explicitly in the configuration.

  • Linear Advance adjusts extruder pressure during acceleration to reduce corner bulging and seam blobs.
  • Input shaping, added in the 2.1 series, reduces ringing by filtering motion frequencies, though with less tuning depth than host-based tools.
  • Unified bed leveling and bilinear mesh leveling compensate for an uneven bed using a BLTouch or another bed probe.
  • Thermal runaway protection stops heating when a temperature fails to rise or drifts away from the target.
  • Sensorless homing uses Trinamic stepper driver stall detection instead of a physical endstop.
  • Filament runout sensor support pauses the print and triggers a filament change routine.

Thermal runaway protection deserves particular attention. Some early factory builds shipped with it disabled, and that omission was linked to fire risk; any machine running custom Marlin should keep the protection enabled for the hotend and the bed.

How Marlin compares with Klipper and RepRapFirmware

Marlin differs from its main alternatives mainly in where computation happens and how configuration is handled. Klipper moves motion planning to a host computer, while RepRapFirmware targets powerful 32-bit Duet boards with web-based configuration.

This comparison summarizes the practical differences that usually drive the choice.

AspectMarlinKlipperRepRapFirmware
Motion planningOn the mainboardOn a host computerOn the mainboard
ConfigurationCompile-time headersText file, no reflashingText file on SD card
Extra hardwareNone requiredSingle-board computerDuet-class board
Input shaping depthBasicExtensive with measurementGood
Hardware coverageVery broadBroadNarrower
Typical userStock and lightly modified printersTuning-focused enthusiastsCustom and professional builds
Marlin compared with other printer firmware

Marlin remains a sensible default for printers that need no extra computer and for owners who value a self-contained, well-documented system. Builders chasing the highest speeds on CoreXY or Voron machines usually prefer Klipper.

Common mistakes when running Marlin

Most Marlin problems come from configuration mismatches rather than from bugs in the firmware itself. The table connects frequent symptoms with their usual causes.

SymptomLikely causeFix
Axis moves the wrong wayInverted direction settingChange the direction flag or swap wiring
Temperature reads incorrectlyWrong thermistor tableSelect the matching sensor number
Settings revert after rebootValues not savedStore them with M500
Board does not boot after flashWrong build environmentRebuild for the exact board
Probe crashes into bedIncorrect Z offsetRecalibrate the probe offset
Typical Marlin symptoms and fixes

A further mistake is flashing an old EEPROM layout over a new firmware version. Running M502 followed by M500 resets stored values to the new compiled defaults and prevents confusing behavior.

The idea in brief

Marlin is the built-in brain of many 3D printers. A slicer turns a model into a long list of instructions, and Marlin reads those instructions one by one and tells the motors, heaters and fans exactly what to do.

Think of it as the conductor of a small orchestra. It keeps every motor in time, keeps the nozzle at the right temperature and stops everything if something looks unsafe. Because it is free and open, owners can adjust it to suit their own machine.

A practical scenario

A school makerspace runs six identical bed slinger printers, and the staff want automatic bed leveling after installing a BLTouch probe on each machine. The technician downloads the current Marlin source, selects the 32-bit STM32 board environment, enables bilinear leveling with a 5 by 5 probing grid and sets the probe offsets measured on the first printer.

After flashing, the technician sets the Z offset with a sheet of paper, stores it with M500 and adds G29 to the start G-code. First-layer failures drop sharply over the following term, and the same compiled binary is reused on all six printers, which keeps the fleet consistent and easy to maintain.