These Marlin commands choose the tool in use, load, change and watch the filament, mix several filaments into one nozzle and control a Prusa Multi Material Unit (MMU). Most exist only when the matching option is built into the firmware. Lengths are in current units.
T: select a tool
| Command or parameter | Meaning |
|---|---|
T0 to T7 | Switch to that physical or virtual tool |
T | Since 2.1.3, without a number: report the current tool |
S 0/1 | 0 allows movement in X and Y after the change (the default), 1 prevents it |
F feedrate | Up to 2.0.0: feed rate of the tool change. Ignored in 2.x, where the change moves at XY_PROBE_FEEDRATE |
T3 S1 ; tool 3, no XY movement
With an MMU2
With a Multi Material Unit 2 or a clone, T0 to T7
choose a filament. The documentation says that at least 38.1 mm must then be
extruded, at a feed rate it gives as 19.02 mm/s, to reach the extruder, the
distance depending on the machine. Three further forms load it without such a
move:
| Command | Meaning |
|---|---|
T? | With MMU2_MENUS: wait for the target temperature, then load all the way to the nozzle |
Tx | With MMU2_MENUS: load up to the gears of a direct drive extruder, without heating |
Tc | Wait for the target temperature, then load from the gears to the nozzle |
T2 ; choose a filament
Tx ; bring it to the extruder gears
M104 S208
Tc ; wait, then load to the nozzle
M600 and M603: filament change
Both need ADVANCED_PAUSE_FEATURE and date from Marlin 1.1.0.
M600 parks the head, ejects the filament, waits for new filament and
the user’s confirmation, loads, primes and resumes. A runout sensor can start it.
The documentation notes that it currently needs an LCD controller.
M600 parameter | Meaning |
|---|---|
T index | Extruder |
E length | Retraction before moving to the change position, negative; default PAUSE_PARK_RETRACT_LENGTH |
U length | Retraction for unloading, negative |
L length | Load length, positive; longer for a Bowden tube |
X, Y position | Change position |
Z lift | Lift of Z, relative to the current height |
B count | Beeps to alert the user; default FILAMENT_CHANGE_ALERT_BEEPS |
R temp | Temperature on resuming; with AUTOTEMP, the lowest automatic temperature |
M603 stores the lengths: T index the extruder,
U length the unload retraction (negative) and
L length the load length (positive).
M600 X10 Y15 Z5 ; change at X10 Y15, 5 higher
M603 U120 L125 ; lengths as in the documentation’s example
M701 and M702: load and unload
These need NOZZLE_PARK_FEATURE, ADVANCED_PAUSE_FEATURE
and FILAMENT_LOAD_UNLOAD_GCODES, use the configured lengths by
default and respect the minimum extrusion temperature set by
M302.
| Command | Parameters | Meaning |
|---|---|---|
M701 | T index: extruder, by default the current one; Z distance: move Z by this much; L length: insertion length, positive, for a manual reload | Load filament |
M702 | T index: extruder, by default the current one, or all of them with FILAMENT_UNLOAD_ALL_EXTRUDERS; Z distance; U length: removal retraction, for a manual reload | Unload filament |
The documentation marks L and U as not optional, yet
shows both commands without parameters.
M217: filament swap at a tool change
Since 2.0.0, with more than one extruder: the lengths and speeds for retracting one filament and priming the next. Without parameters it reports them. The values are stored in EEPROM.
| Parameter | Meaning |
|---|---|
S length | Swap length |
B length | Extra length on resuming |
E length | Extra prime length |
P feedrate | Prime feed rate |
R feedrate | Retract feed rate |
U feedrate | Unretract feed rate |
F speed | Fan speed, 0 to 255 |
G seconds | Fan time |
Q | Prime the active tool with the configured swap settings |
Z raise | Z raise |
A n, L n | With TOOLCHANGE_MIGRATION_FEATURE: automatic migration mode and last migration tool |
W n | With TOOLCHANGE_PARK: enable parking |
X, Y position | With TOOLCHANGE_PARK: park position |
I, J, K, C, H, O position | Park position of the fourth to ninth axis, in that order |
V n | With TOOLCHANGE_FS_PRIME_FIRST_USED: prime a nozzle the first time it is used |
M605: several nozzles and dual X carriages
With DUAL_X_CARRIAGE the command picks the carriage mode. With
MULTI_NOZZLE_DUPLICATION, S2 enables duplication and
any other S disables it.
| Parameter | Meaning |
|---|---|
S mode | 0 full control, both carriages free within a safe distance; 1 auto-park, one parking while the other moves (0 and 1 need DUAL_X_CARRIAGE); 2 duplication, carriages and extruders moving together; 3 mirrored, the second repeating the first with X reversed |
X distance | Dual carriage: distance between the carriages |
R degrees | Dual carriage: temperature difference applied to E1 |
P mask | Duplication: bit mask of the nozzles in the set, E0 the lowest bit; 0 disables |
E index | Duplication: last nozzle in the set; 0 disables |
M605 S2 P5 ; duplicate on E0 and E2
M412: filament runout
Since 2.0.0, with FILAMENT_RUNOUT_SENSOR. When detection is on,
Marlin answers a runout with the configured commands, usually
M600. Without parameters the state is reported.
| Parameter | Meaning |
|---|---|
S 0/1 | Disable or enable detection, and reset the sensor |
R | Reset the sensor |
D length | With FILAMENT_RUNOUT_DISTANCE_MM: length still extruded after a sensor ahead of the gears reports a runout. Does not reset the sensor |
L length | Since 2.1.3, with FILAMENT_SWITCH_AND_MOTION: missing motion that counts as a runout at once; L0 leaves only the switch. Resets the sensor |
H 0/1 | With HOST_ACTION_COMMANDS: whether the host handles a runout. Not saved to EEPROM |
M412 S1 L10 ; switch and motion sensor, jam after 10 mm
M404 to M407: filament width sensor
With FILAMENT_WIDTH_SENSOR the flow is adjusted to the measured
width.
| Command | Parameters | Meaning |
|---|---|---|
M404 | W diameter | Set the nominal width, which should equal the slicer’s; alone, report it |
M405 | D cm: distance from the sensor to the hot end, whole centimetres; the previous value, at first MEASUREMENT_DELAY_CM, if omitted | Switch width flow control on; filament already past the sensor counts as nominal |
M406 | None | Switch it off |
M407 | None | Report the measured width, as Filament dia (measured mm): 1.768 |
M163 to M166: mixing extruder
With MIXING_EXTRUDER several filaments feed one nozzle. A stored
mix is a virtual tool, chosen with T.
| Command | Parameters | Meaning |
|---|---|---|
M163 | S index: component; P factor: its share, in proportion to the sum of all shares | Set one factor; it takes effect only once saved with M164 |
M164 | S tool: tool number, the active virtual tool if omitted | With MIXING_VIRTUAL_TOOLS: save the mix as a virtual tool |
M165 | A, B, C, D, H, I factor: components 1 to 6; omitted ones become 0 | With DIRECT_MIXING_IN_G1: set the whole mix of the active virtual tool |
M166 | A height: starting Z; Z height: ending Z; I tool: starting mix; J tool: ending mix; S 0/1: gradient off or on; T tool: tool number that selects the gradient, T alone cancelling it | Since 2.0.0, with GRADIENT_MIX: change gradually from one mix to another with height; below and above the range the end mixes apply fully |
M163 S0 P3
M163 S1 P5
M164 S4 ; a 3 to 5 mix as tool 4
M166 A0 Z250 I0 J1 S1 ; gradient over 250 mm
M403 and M704 to M709: Multi Material Unit
M403 belongs to the MMU2 (PRUSA_MMU2).
M704 to M709 need PRUSA_MMU3, since 2.1.3,
and do nothing while the MMU is disabled or a required parameter is missing or
names no slot. Slots are numbered from 0.
| Command | Parameters | Meaning |
|---|---|---|
M403 | E slot: 0 to 4; F type: 0 default (PLA, PETG and so on), 1 flexible, 2 PVA. Both required | Set the filament type of a slot |
M704 | P slot, required | Preload the slot’s filament to the MMU feeder |
M705 | P slot, required | Eject the filament from the slot |
M706 | P slot, required | Cut the filament, on an MMU with a cutter that is switched on |
M707 | A address: register, in hexadecimal, required | Read an MMU register and print it; for diagnosis |
M708 | A address, required and not 0x00; X value: 16 bits, default 0 | Write an MMU register |
M709 | S 0/1: disable or enable, saved to EEPROM; X kind: reset, 0 in software, 1 by pulsing the reset pin, 42 erasing the MMU’s EEPROM | Switch or reset the MMU, resets only while it is enabled; alone, print MMU is ON or MMU is OFF |
M708 A0x1b X5
M707 A0x1b
Sources
- MarlinDocumentation – Marlin’s own documentation source, files M163 to M166, M217, M403 to M407, M412, M600, M603, M605, M701, M702, M704 to M709, T and T-mmu2 in
docs/gcode/, as of 3 December 2026