Skip to main content

Firmware: Marlin, Klipper, RepRapFirmware

📍 Where we are: Part II · The Machine Stack — Chapter 4 of 16. Chapter 3 described the mechanics; this chapter looks at the program that makes the motors and heaters obey G-code.

The simple version

Firmware is the conductor of the printer's orchestra. The score is G-code ("move here, heat to this temperature"), and the conductor decides, many thousands of times a second, exactly when each motor takes its next step and how hard each heater should be pushed. Marlin puts the conductor and the musicians on one small board. Klipper puts the conductor's planning on a bigger computer and leaves a small board to play the notes on time.

What this chapter covers​

We cover what firmware does, then the three major open projects: Marlin, Klipper and RepRapFirmware. For each we say how it is configured, how it divides work between processors and what its licence is. We finish with trade-offs. Version facts were checked in November 2026.

What firmware does​

A printer firmware has four jobs. It parses G-code commands. It does motion planning: it converts a path in millimetres into motor steps, respecting limits on speed and acceleration. It performs kinematics, mapping a requested position to motor positions (the mappings in Chapter 3). And it runs control loops and safety, chiefly the temperature control of heaters, which Chapter 5 covers.

A planned move, in numbers​

Most firmware shapes each move as a trapezoid of speed: accelerate, cruise, decelerate. The Klipper code overview describes this as splitting each move into acceleration, cruise and deceleration phases [7]. The snippet below computes the timing. It uses only the Python standard library and we ran it with Python 3; the speeds and accelerations are illustrative, not measured on a printer.

import math

def trapezoid(dist, v_max, accel):
"""(t_accel, t_cruise, t_total) for a move that starts and ends at rest."""
d_acc = v_max**2 / (2 * accel)
if 2 * d_acc >= dist: # too short to reach v_max: triangle
t = math.sqrt(dist / accel)
return t, 0.0, 2 * t
t_acc = v_max / accel
t_cruise = (dist - 2 * d_acc) / v_max
return t_acc, t_cruise, 2 * t_acc + t_cruise

for d in (2, 50, 200):
ta, tc, tt = trapezoid(d, 200, 3000) # 200 mm/s, 3000 mm/s^2
print(f"{d:>4} mm: accel {ta:.3f}s cruise {tc:.3f}s total {tt:.3f}s")
2 mm: accel 0.026s cruise 0.000s total 0.052s
50 mm: accel 0.067s cruise 0.183s total 0.317s
200 mm: accel 0.067s cruise 0.933s total 1.067s

A 2 mm move never reaches 200 mm/s: it is all acceleration. That is why short segments (curves, fine detail) are bounded by acceleration, not by the top speed in the slicer.

Marlin​

Marlin's repository calls it "a firmware for RepRap 3D printers optimized for both 8 and 32 bit microcontrollers", licensed GPL-3.0; its README lists Erik van der Zalm as founder and Scott Lahteine as project lead, and lists targets from AVR boards (RAMPS, Melzi, RAMBo) to STM32, LPC176x, SAMD, Teensy, ESP32 and RP2040 [1]. The source headers state that it is "based on Sprinter and grbl" [2].

Marlin is configured at compile time. You edit Configuration.h and Configuration_adv.h, build and flash. The lines below are copied from the stock example Configuration.h of release 2.1.2.10; we did not compile them [2].

#define MOTHERBOARD BOARD_RAMPS_14_EFB
#define SERIAL_PORT 0
#define BAUDRATE 250000
#define X_DRIVER_TYPE A4988
#define TEMP_SENSOR_0 1
#define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders
#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 500 }

Optional features live in the advanced file, where LIN_ADVANCE (pressure compensation in the extruder, set with LIN_ADVANCE_K or M900) is off by default [3] [4]. The same file contains INPUT_SHAPING_X and INPUT_SHAPING_Y with default 40 Hz frequency and 0.15 damping, tuned with M593 [3].

Klipper​

Klipper is GPL-3.0 and describes itself as combining "the power of a general purpose computer with one or more micro-controllers" [5]. GitHub showed no formal releases when we looked; the newest tag was v0.13.0, from April 2025 [5].

The host/MCU split is the key idea. A host (for example a Raspberry Pi) runs Klippy, written mostly in Python with C helpers, which turns G-code into planned moves, does look-ahead, runs the trapezoid generator and computes step times with an iterative solver. It compresses them into queue_step commands for the microcontroller, whose C code appends them to a queue and fires each step from a hardware timer interrupt [7]. The Features page claims each stepper event is scheduled with a precision of 25 microseconds or better, and that settings live in a text config file with no reflashing needed [6].

Three columns comparing Marlin, Klipper and RepRapFirmware by where planning, step generation and configuration live. Marlin plans and steps on one board and is configured at compile time; Klipper splits planning (host, Python) from step timing (microcontroller, C); RepRapFirmware runs on Duet-class boards and is configured by G-code in config.g. Original diagram by the authors, created with AI assistance.

A typical install builds the microcontroller image on the host and then edits printer.cfg [10]:

cd ~/klipper/
make menuconfig
make
ls /dev/serial/by-id/* # find the board's serial path
cp ~/klipper/config/example-cartesian.cfg ~/printer.cfg

We did not run these on hardware; they are quoted from the Installation page. The [input_shaper] section is similar: the docs recommend mzv for most printers and describe measuring resonances either with a printed ringing tower or with an ADXL345 accelerometer on a Raspberry Pi and SHAPER_CALIBRATE [8] [9]:

[input_shaper]
shaper_freq_x: ... # from the ringing test model
shaper_freq_y: ...
shaper_type: mzv

RepRapFirmware​

RepRapFirmware (RRF) is C++ under GPLv3 and targets ARM Cortex-M boards (ATSAM4E, ATSAM4S, SAME70, SAME5x), maintained by the Duet3D organisation; we saw release 3.7.0 listed in November 2026 [11]. Its wiki describes a "G-code everywhere" principle: configuration is done with G-code in config.g, and most changes apply on the fly without a restart; a web configuration tool generates the file [12]. Expansion and tool boards of the Duet 3 family run separate firmware (Duet3Expansion, GPL-3.0), shipped within RRF releases [13]. Prusa's own printers use yet another GPLv3 firmware, Prusa-Firmware-Buddy [14].

How to choose​

MarlinKlipperRepRapFirmware
ConfigurationEdit headers, rebuild, flashText file, restartG-code in config.g
ProcessorsOne boardHost plus one or more MCUsDuet-class ARM board
Needs extra computerNoYes (host)Not for the core firmware
Hardware rangeAVR, STM32, LPC, SAMD, ESP32, RP2040 and others (README list)ARM, AVR and others (Features page)ARM Cortex-M boards, mainly Duet

The table follows each project's own documentation; we found no neutral benchmark across the three, so we make no speed or quality ranking.

Why it matters​

Firmware is where a machine's character lives: the same frame behaves differently under different firmware. Open firmware also means you can audit safety features and fix bugs yourself, but it also means the burden of correct configuration is on you.

In the real world​

If you buy a printer, check which firmware it runs and whether the vendor publishes the exact source: Marlin's README states that vendors shipping it must keep it open [1].

Key terms​

  • Firmware — the program on the printer's microcontroller that controls motors and heaters.
  • Motion planning — converting a path into timed steps within speed and acceleration limits.
  • Look-ahead — planning a move with knowledge of the following moves so the printer need not stop between them.
  • MCU — microcontroller unit, the small chip that runs firmware and drives pins.
  • Host — the general-purpose computer, such as a Raspberry Pi, that runs Klipper's planning code.
  • Input shaping — shaping commanded motion to cancel resonance and reduce ringing (ghosting at edges).
  • Linear Advance — Marlin's extruder pressure compensation (LIN_ADVANCE).
  • config.g — RepRapFirmware's G-code configuration file.

Where this leads​

Firmware needs hardware to command: Electronics, stepper drivers and control boards.