# luketheengineer/mdk architecture

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

- Interactive diagram: https://gitdiagram.com/luketheengineer/mdk
- Repository: https://github.com/luketheengineer/mdk

## Overview

MDK is a bare-metal, single-header SDK for ESP32 and ESP32-C3 firmware. A firmware application enters through the architecture startup code, which clears BSS, initializes the SoC, then calls the application’s main; firmware uses the architecture header’s GPIO, SPI, UART, timing and WS2812 APIs to interact with peripherals. README also documents separate build/flash/monitor tooling and the esputil flasher, but those implementations are absent from this tree. The sampled sources support startup-to-API and serial-to-SLIP relationships; examples and unsampled tool behavior are represented only where README or tree evidence identifies the capability.

Main entry points: [`tools/slipterm.c`](https://github.com/luketheengineer/mdk/blob/main/tools/slipterm.c) (SLIP terminal), [`examples`](https://github.com/luketheengineer/mdk/tree/main/examples) (Firmware application), [`esp32/boot.c`](https://github.com/luketheengineer/mdk/blob/main/esp32/boot.c) (ESP32 startup), [`esp32c3/boot.c`](https://github.com/luketheengineer/mdk/blob/main/esp32c3/boot.c) (ESP32-C3 startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["Firmware runtime"]
  node_firmware_app["Firmware application"]
  node_esp32_startup["ESP32 startup<br/>[boot.c]"]
  node_esp32c3_startup["ESP32-C3 startup<br/>[boot.c]"]
  node_bme_example["BME280 example<br/>[main.c]"]
  node_button_example["Button example<br/>[main.c]"]
  node_ws_example["WS2812 example<br/>[main.c]"]
end

subgraph group_peripherals["Hardware APIs"]
  node_esp32_api["ESP32 API<br/>[mdk.h]"]
  node_esp32c3_api["ESP32-C3 API<br/>[mdk.h]"]
  node_gpio["GPIO<br/>[mdk.h]"]
  node_spi["Bit-banged SPI<br/>[mdk.h]"]
  node_uart["UART output<br/>[mdk.h]"]
  node_timing["Timing and watchdog<br/>[mdk.h]"]
  node_ws2812["WS2812 output<br/>[mdk.h]"]
end

subgraph group_serialnet["Serial networking"]
  node_slipterm["SLIP terminal<br/>[slipterm.c]"]
  node_slip_codec["SLIP codec<br/>[slip.h]"]
end

node_device(("ESP device"))
node_serial["Serial port"]
node_network["Network interface"]
node_pty["PTY / modem"]
node_esputil["esputil flasher"]

node_esp32_startup -->|"initializes via"| node_esp32_api
node_esp32c3_startup -->|"initializes via"| node_esp32c3_api
node_firmware_app -.->|"runs on"| node_device
node_slipterm -->|"calls"| node_slip_codec
node_slipterm -->|"reads and writes"| node_serial
node_slipterm -->|"forwards packets"| node_network
node_slipterm -->|"forwards packets"| node_pty
node_device -.->|"flashed by"| node_esputil
node_bme_example -.->|"example firmware"| node_firmware_app
node_button_example -.->|"example firmware"| node_firmware_app
node_ws_example -.->|"uses"| node_ws2812

click node_firmware_app "https://github.com/luketheengineer/mdk/tree/main/examples"
click node_esp32_startup "https://github.com/luketheengineer/mdk/blob/main/esp32/boot.c"
click node_esp32c3_startup "https://github.com/luketheengineer/mdk/blob/main/esp32c3/boot.c"
click node_esp32_api "https://github.com/luketheengineer/mdk/blob/main/esp32/mdk.h"
click node_esp32c3_api "https://github.com/luketheengineer/mdk/blob/main/esp32c3/mdk.h"
click node_gpio "https://github.com/luketheengineer/mdk/blob/main/esp32c3/mdk.h"
click node_spi "https://github.com/luketheengineer/mdk/blob/main/esp32c3/mdk.h"
click node_uart "https://github.com/luketheengineer/mdk/blob/main/esp32/mdk.h"
click node_timing "https://github.com/luketheengineer/mdk/blob/main/esp32c3/mdk.h"
click node_ws2812 "https://github.com/luketheengineer/mdk/blob/main/esp32c3/mdk.h"
click node_slipterm "https://github.com/luketheengineer/mdk/blob/main/tools/slipterm.c"
click node_slip_codec "https://github.com/luketheengineer/mdk/blob/main/tools/slip.h"
click node_bme_example "https://github.com/luketheengineer/mdk/blob/main/examples/bme280/main.c"
click node_button_example "https://github.com/luketheengineer/mdk/blob/main/examples/button/main.c"
click node_ws_example "https://github.com/luketheengineer/mdk/blob/main/examples/ws2812/main.c"

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_app,node_esp32_startup,node_esp32c3_startup,node_bme_example,node_button_example,node_ws_example toneBlue
class node_esp32_api,node_esp32c3_api,node_gpio,node_spi,node_uart,node_timing,node_ws2812 toneAmber
class node_slipterm,node_slip_codec toneMint
class node_device,node_serial,node_network,node_pty,node_esputil toneIndigo
```

## Components

### Firmware runtime

- [Firmware application](https://github.com/luketheengineer/mdk/tree/main/examples): `examples`
- [ESP32 startup](https://github.com/luketheengineer/mdk/blob/main/esp32/boot.c): `esp32/boot.c`
- [ESP32-C3 startup](https://github.com/luketheengineer/mdk/blob/main/esp32c3/boot.c): `esp32c3/boot.c`
- [BME280 example](https://github.com/luketheengineer/mdk/blob/main/examples/bme280/main.c): `examples/bme280/main.c`
- [Button example](https://github.com/luketheengineer/mdk/blob/main/examples/button/main.c): `examples/button/main.c`
- [WS2812 example](https://github.com/luketheengineer/mdk/blob/main/examples/ws2812/main.c): `examples/ws2812/main.c`

### Hardware APIs

- [ESP32 API](https://github.com/luketheengineer/mdk/blob/main/esp32/mdk.h): `esp32/mdk.h`
- [ESP32-C3 API](https://github.com/luketheengineer/mdk/blob/main/esp32c3/mdk.h): `esp32c3/mdk.h`
- [GPIO](https://github.com/luketheengineer/mdk/blob/main/esp32c3/mdk.h): `esp32c3/mdk.h`
- [Bit-banged SPI](https://github.com/luketheengineer/mdk/blob/main/esp32c3/mdk.h): `esp32c3/mdk.h`
- [UART output](https://github.com/luketheengineer/mdk/blob/main/esp32/mdk.h): `esp32/mdk.h`
- [Timing and watchdog](https://github.com/luketheengineer/mdk/blob/main/esp32c3/mdk.h): `esp32c3/mdk.h`
- [WS2812 output](https://github.com/luketheengineer/mdk/blob/main/esp32c3/mdk.h): `esp32c3/mdk.h`

### Serial networking

- [SLIP terminal](https://github.com/luketheengineer/mdk/blob/main/tools/slipterm.c): `tools/slipterm.c`
- [SLIP codec](https://github.com/luketheengineer/mdk/blob/main/tools/slip.h): `tools/slip.h`

### Other components

- **ESP device**
- **Serial port**
- **Network interface**
- **PTY / modem**
- **esputil flasher**

## Connections

- ESP32 startup → ESP32 API: initializes via (evidence: `esp32/boot.c`)
- ESP32-C3 startup → ESP32-C3 API: initializes via (evidence: `esp32c3/boot.c`)
- Firmware application → ESP device: runs on (evidence: `README.md`)
- SLIP terminal → SLIP codec: calls (evidence: `tools/slipterm.c`)
- SLIP terminal → Serial port: reads and writes (evidence: `tools/slipterm.c`)
- SLIP terminal → Network interface: forwards packets (evidence: `tools/slipterm.c`)
- SLIP terminal → PTY / modem: forwards packets (evidence: `tools/slipterm.c`)
- ESP device → esputil flasher: flashed by (evidence: `README.md`)
- BME280 example → Firmware application: example firmware (evidence: `README.md`)
- Button example → Firmware application: example firmware (evidence: `README.md`)
- WS2812 example → WS2812 output: uses (evidence: `README.md`)
