Linear Advance Calibration for Marlin Firmware: K-Factor Tuning Without Klipper
Our Klipper coverage talks about pressure advance in several places, but a large share of printers on this site's reader base still run stock Marlin — most Creality Ender/CR-series boards, scratch-built RAMPS or SKR machines that haven't been converted, and plenty of older Prusa-style printers. Marlin has its own answer to the same underlying extrusion-lag problem, called Linear Advance, and it's configured and tuned completely differently from Klipper's pressure advance even though the physics it's compensating for is identical. This guide covers enabling and calibrating Linear Advance on Marlin specifically — our general Marlin firmware setup guide covers board configuration, steps/mm, and bed leveling, but doesn't touch K-factor tuning, which is its own calibration pass done after the printer is otherwise dialed in.
What Linear Advance Actually Fixes
Extruders don't respond to commanded flow instantaneously — there's a lag between the stepper motor turning and pressurized filament actually exiting the nozzle, caused by the compressibility of molten plastic in the melt zone and any slack in a Bowden tube. Without compensation, this shows up as blobbing and bulging at the start of fast moves (where the nozzle is still catching up to the commanded flow from the previous slow segment) and gaps or thin spots right after decelerating into a corner (where residual pressure keeps extruding after the stepper has already slowed down). Linear Advance tells the firmware to pre-emptively increase or decrease extruder stepper speed proportional to the rate of change in print speed, so pressure in the melt zone rises and falls in sync with the actual toolpath instead of lagging behind it.
The tuning knob is a single value called the K-factor, specified in Marlin's M900 K<value> G-code command. It's conceptually identical to Klipper's pressure_advance setting, but the numeric scale is different between the two firmwares (Marlin's K values are typically in the 0–1 range for direct drive and can run higher for Bowden setups) — don't copy a pressure_advance number from a Klipper config into Marlin's M900 and expect it to mean the same thing.
Enabling Linear Advance in Firmware
Linear Advance isn't on by default in a stock Marlin build. In Configuration_adv.h, find and uncomment:
- #define LIN_ADVANCE — enables the feature itself.
- #define LIN_ADVANCE_K 0.0 — sets a default K value that's overridden by any M900 sent later; leave at 0 and tune it properly rather than guessing a starting number here.
Recompile and flash using the same PlatformIO workflow covered in our general Marlin setup guide. If you're on a stock Creality board running factory firmware rather than a self-compiled build, check whether the manufacturer's released source already has LIN_ADVANCE enabled — many do on current releases, but older factory firmware often doesn't, which means you'll need to build and flash your own binary before any of the calibration below will do anything.
Running the K-Factor Calibration Print
Marlin includes a built-in calibration pattern generator via M493 on some newer builds, but the more universal and reliable method across firmware versions is a dedicated calibration tower or pattern STL/G-code, several of which are freely available and specifically designed around Marlin's M900 command (rather than Klipper-oriented tools like the Klipper SAVE_CONFIG plugin or Ellis's pressure advance calculator, which won't directly help here). The standard approach:
- Slice a pattern that prints a tall, thin tower or a line test with embedded M900 K<value> commands that step the K-factor up incrementally as the print progresses — commonly from K=0 to K=1.0 in increments of 0.05–0.1 for direct drive extruders, or a wider range for Bowden setups.
- Print it at a speed and acceleration representative of your actual print settings — calibrating at slow speed and then printing fast afterward under-corrects, since the pressure lag Linear Advance compensates for scales with how quickly the toolpath accelerates and decelerates.
- Inspect the tower by eye along its height. Look for the band where corners stop bulging (over-extrusion from pressure not yet released) and lines stop thinning right after sharp direction changes (under-extrusion from pressure dropping before the extruder catches up). The best K value is the band where both artifacts are minimized simultaneously — too low and you'll still see corner blobbing, too high and you'll see gaps or thin extrusion after fast corners.
- Note the K value printed at that height (most calibration patterns include small embossed or engraved numbers along the tower marking which K value was active at each height) and set it permanently.
Setting the Final Value
Once you've identified the best K-factor from the test print, there are two ways to make it stick:
MethodHowWhen to use Slicer start G-codeAdd M900 K0.XX to your slicer's custom start G-code, after homing and before the first extrusion moveBest for most users — keeps the value under version control in your slicer profile and makes it easy to maintain per-filament values later EEPROM saveSend M900 K0.XX once over serial or the printer's own console, then M500 to save to EEPROMUseful if you print from multiple slicers or hosts and want one printer-side default, but easy to forget it's set when debugging later extrusion issuesK-factor is somewhat filament and even somewhat temperature dependent — a value tuned on PLA at 205°C will usually be in the right ballpark for PLA generally but can drift meaningfully for PETG or TPU, which behave very differently in the melt zone. Printers that regularly swap between very different materials benefit from keeping separate K values in per-filament slicer profiles rather than relying on a single EEPROM-saved number.
Troubleshooting Signs You Have the Wrong K
- Corners still blob despite a nonzero K: K is too low, or acceleration/jerk settings are higher than what you calibrated at — recalibrate at your actual print acceleration.
- Thin, starved extrusion right after fast corners: K is too high, overcorrecting and pulling pressure down too aggressively.
- Inconsistent results between prints at different speeds: this is expected to some degree with Linear Advance's linear model — it's a simpler, less adaptive compensation than Klipper's pressure advance combined with input shaping, and very high-speed printing on stock Marlin firmware will generally show its limits here before a Klipper-converted machine would.
Linear Advance won't make a stock Marlin printer perform identically to a tuned Klipper machine with full pressure advance and input shaping working together, but correctly calibrated it meaningfully cleans up corner quality on any printer that hasn't been converted, and it's a five-minute firmware change plus one calibration print rather than a full Klipper migration.