# marlinfirmware/marlin architecture

> Architecture diagram of the GitHub repository marlinfirmware/marlin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marlinfirmware/marlin
- Repository: https://github.com/marlinfirmware/marlin

## Overview

Marlin is configurable 3D-printer firmware for multiple hardware platforms. The principal workflow is host commands entering firmware, being planned as coordinated motion, and executed through board-specific hardware; thermal control is another runtime domain. The README documents the shared HAL and support for up to nine axes and eight extruders. The supplied excerpts do not show the main command-processing or motion call chain, so those relationships are marked unverified. The graph also includes documented hardware abstraction and visible storage/UI and USB-storage subsystems; unsampled subsystem details are represented cautiously.

Main entry points: [`Marlin/src/MarlinCore.h`](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/MarlinCore.h) (Firmware core), [`Marlin/src/module/planner.h`](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/module/planner.h) (Motion planning), [`Marlin/src/module/temperature.h`](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/module/temperature.h) (Thermal control), [`Marlin/src/lcd/extui`](https://github.com/marlinfirmware/marlin/tree/bugfix-2.1.x/Marlin/src/lcd/extui) (LCD interfaces)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Printer runtime"]
  node_firmware["Firmware core<br/>[MarlinCore.h]"]
  node_motion["Motion planning<br/>[planner.h]"]
  node_axes["Axis state<br/>[motion.h]"]
  node_stepper["Stepper execution<br/>[stepper.h]"]
  node_thermal["Thermal control<br/>[temperature.h]"]
  node_thermistors["Thermistor tables<br/>[thermistors.h]"]
  node_config["Machine configuration<br/>[Configuration.h]"]
  node_advconfig["Advanced configuration"]
end

subgraph group_hardware["Hardware abstraction"]
  node_hal["Common HAL API<br/>[HAL.h]"]
  node_platformhal["Platform HALs"]
  node_controllerfan["Controller fan<br/>[controllerfan.cpp]"]
end

subgraph group_interfaces["User interfaces"]
  node_lcd["LCD interfaces"]
  node_webui["Web UI<br/>[webmarlin.js]"]
end

subgraph group_storage["Removable and flash storage"]
  node_usbhost["USB host storage<br/>[masstorage.cpp]"]
  node_usbhost3["UHS bulk storage"]
  node_sd[("SD storage<br/>[storage.h]")]
  node_flashui[("Touch UI flash<br/>[flash_storage.cpp]")]
  node_flashmks[("MKS flash storage")]
end

node_host(("Command host"))

node_host -.->|"sends commands"| node_firmware
node_firmware -.->|"dispatches motion"| node_motion
node_motion -.->|"uses axis state"| node_axes
node_motion -.->|"plans steps"| node_stepper
node_firmware -.->|"controls temperatures"| node_thermal
node_thermal -.->|"uses tables"| node_thermistors
node_firmware -.->|"uses HAL"| node_hal
node_hal -.->|"abstracts platforms"| node_platformhal
node_controllerfan -->|"reads temperatures"| node_thermal
node_config -.->|"configures"| node_firmware
node_advconfig -.->|"configures"| node_firmware
node_lcd -.->|"provides UI"| node_firmware
node_webui -.->|"interfaces with"| node_firmware
node_usbhost3 -.->|"alternative implementation"| node_usbhost
node_usbhost -.->|"provides USB storage"| node_sd
node_flashui -.->|"stores UI data"| node_lcd
node_flashmks -.->|"stores UI data"| node_lcd

click node_firmware "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/MarlinCore.h"
click node_motion "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/module/planner.h"
click node_axes "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/module/motion.h"
click node_stepper "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/module/stepper.h"
click node_thermal "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/module/temperature.h"
click node_thermistors "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/module/thermistor/thermistors.h"
click node_config "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/Configuration.h"
click node_advconfig "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/Configuration_adv.h"
click node_hal "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/HAL/HAL.h"
click node_platformhal "https://github.com/marlinfirmware/marlin/tree/bugfix-2.1.x/Marlin/src/HAL"
click node_controllerfan "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/feature/controllerfan.cpp"
click node_lcd "https://github.com/marlinfirmware/marlin/tree/bugfix-2.1.x/Marlin/src/lcd/extui"
click node_webui "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/buildroot/web-ui/data/www/webmarlin.js"
click node_usbhost "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp"
click node_usbhost3 "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h"
click node_sd "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/sd/storage.h"
click node_flashui "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp"
click node_flashmks "https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_firmware,node_motion,node_axes,node_stepper,node_thermal,node_thermistors,node_config,node_advconfig toneBlue
class node_hal,node_platformhal,node_controllerfan toneAmber
class node_lcd,node_webui toneMint
class node_usbhost,node_usbhost3,node_sd,node_flashui,node_flashmks toneRose
class node_host toneIndigo
```

## Components

### Printer runtime

- [Firmware core](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/MarlinCore.h): `Marlin/src/MarlinCore.h`
- [Motion planning](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/module/planner.h): `Marlin/src/module/planner.h`
- [Axis state](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/module/motion.h): `Marlin/src/module/motion.h`
- [Stepper execution](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/module/stepper.h): `Marlin/src/module/stepper.h`
- [Thermal control](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/module/temperature.h): `Marlin/src/module/temperature.h`
- [Thermistor tables](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/module/thermistor/thermistors.h): `Marlin/src/module/thermistor/thermistors.h`
- [Machine configuration](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/Configuration.h): `Marlin/Configuration.h`
- [Advanced configuration](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/Configuration_adv.h): `Marlin/Configuration_adv.h`

### Hardware abstraction

- [Common HAL API](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/HAL/HAL.h): `Marlin/src/HAL/HAL.h`
- [Platform HALs](https://github.com/marlinfirmware/marlin/tree/bugfix-2.1.x/Marlin/src/HAL): `Marlin/src/HAL`
- [Controller fan](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/feature/controllerfan.cpp): `Marlin/src/feature/controllerfan.cpp`

### User interfaces

- [LCD interfaces](https://github.com/marlinfirmware/marlin/tree/bugfix-2.1.x/Marlin/src/lcd/extui): `Marlin/src/lcd/extui`
- [Web UI](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/buildroot/web-ui/data/www/webmarlin.js): `buildroot/web-ui/data/www/webmarlin.js`

### Removable and flash storage

- [USB host storage](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp): `Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp`
- [UHS bulk storage](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h): `Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h`
- [SD storage](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/sd/storage.h): `Marlin/src/sd/storage.h`
- [Touch UI flash](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp): `Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp`
- [MKS flash storage](https://github.com/marlinfirmware/marlin/blob/bugfix-2.1.x/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp): `Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp`

### Other components

- **Command host**

## Connections

- Command host → Firmware core: sends commands
- Firmware core → Motion planning: dispatches motion
- Motion planning → Axis state: uses axis state
- Motion planning → Stepper execution: plans steps (evidence: `Marlin/src/module/stepper.h`)
- Firmware core → Thermal control: controls temperatures
- Thermal control → Thermistor tables: uses tables (evidence: `Marlin/src/module/temperature.h`)
- Firmware core → Common HAL API: uses HAL (evidence: `README.md`)
- Common HAL API → Platform HALs: abstracts platforms (evidence: `README.md`)
- Controller fan → Thermal control: reads temperatures (evidence: `Marlin/src/feature/controllerfan.cpp`)
- Machine configuration → Firmware core: configures
- Advanced configuration → Firmware core: configures
- LCD interfaces → Firmware core: provides UI
- Web UI → Firmware core: interfaces with
- UHS bulk storage → USB host storage: alternative implementation
- USB host storage → SD storage: provides USB storage
- Touch UI flash → LCD interfaces: stores UI data (evidence: `Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp`)
- MKS flash storage → LCD interfaces: stores UI data (evidence: `Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp`)
