# annoyedmilk/esp32-s31-linux architecture

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

- Interactive diagram: https://gitdiagram.com/annoyedmilk/esp32-s31-linux
- Repository: https://github.com/annoyedmilk/esp32-s31-linux

## Overview

This repository ports Linux to the ESP32-S31 Korvo-1 and supplies the firmware and platform support needed to boot it. The principal workflow is ROM startup through the ESP-IDF loader, OpenSBI, Linux, initramfs, and a Buildroot root filesystem on SD. The graph also shows the documented display, storage, USB, Wi-Fi, and SoC-support capabilities. Some kernel and userspace components are represented by their enclosing source directories because their implementations were not sampled; edges for those capabilities rely on the README.

Main entry points: [`bootloader/main/main.c`](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/bootloader/main/main.c) (ESP-IDF loader), [`linux`](https://github.com/annoyedmilk/esp32-s31-linux/tree/main/linux) (Linux kernel), [`bootloader/components/esp_hosted/shm_slave_api.c`](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/bootloader/components/esp_hosted/shm_slave_api.c) (ESP-Hosted firmware), [`br2-external/package/esp-hosted-linux/shm/esp_shm.c`](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/br2-external/package/esp-hosted-linux/shm/esp_shm.c) (Shared-memory transport)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_boot["Boot and firmware"]
  node_rom(("ESP ROM"))
  node_loader["ESP-IDF loader<br/>[main.c]"]
  node_display["LCD scanout<br/>[display.c]"]
  node_sdinit["SD initialization<br/>[sd.c]"]
  node_rmtinit["RMT setup<br/>[rmt.c]"]
  node_opensbi["OpenSBI platform<br/>[platform.c]"]
end

subgraph group_transport["Hosted Wi-Fi"]
  node_hosted_fw["ESP-Hosted firmware<br/>[shm_slave_api.c]"]
  node_hosted_linux["Shared-memory transport<br/>[esp_shm.c]"]
  node_shm_layout["Shared SRAM layout"]
end

subgraph group_kernel["Linux platform"]
  node_kernel["Linux kernel"]
  node_clic["CLIC interrupts"]
  node_cache["Cache support<br/>[esp32s31-cache.c]"]
  node_device_drivers["SoC drivers"]
end

subgraph group_userspace["Root filesystem"]
  node_initramfs["Initramfs<br/>[mkinitramfs.py]"]
  node_rootfs["Buildroot root filesystem"]
  node_sdcard[("SD-card storage<br/>[S10sdcard]")]
  node_console["Shell and login"]
end

node_user(("Board user"))
node_wifi(("Wi-Fi network"))

node_rom -->|"starts"| node_loader
node_loader -->|"initializes"| node_display
node_loader -->|"initializes"| node_sdinit
node_loader -->|"initializes"| node_rmtinit
node_loader -->|"starts firmware"| node_hosted_fw
node_loader -->|"starts hart"| node_opensbi
node_opensbi -->|"enters Linux"| node_kernel
node_kernel -->|"starts"| node_initramfs
node_initramfs -->|"hands off"| node_rootfs
node_rootfs -->|"mounts"| node_sdcard
node_user -->|"logs in"| node_console
node_kernel -->|"routes interrupts"| node_clic
node_kernel -->|"syncs caches"| node_cache
node_kernel -->|"supports hardware"| node_device_drivers
node_loader -->|"leaves scanout running"| node_display
node_hosted_fw -->|"uses layout"| node_shm_layout
node_hosted_linux -->|"uses layout"| node_shm_layout
node_hosted_fw -->|"exchanges frames"| node_hosted_linux
node_hosted_linux -->|"provides Wi-Fi transport"| node_kernel
node_user -->|"connects through"| node_wifi

click node_loader "https://github.com/annoyedmilk/esp32-s31-linux/blob/main/bootloader/main/main.c"
click node_display "https://github.com/annoyedmilk/esp32-s31-linux/blob/main/bootloader/main/display.c"
click node_sdinit "https://github.com/annoyedmilk/esp32-s31-linux/blob/main/bootloader/main/sd.c"
click node_rmtinit "https://github.com/annoyedmilk/esp32-s31-linux/blob/main/bootloader/main/rmt.c"
click node_opensbi "https://github.com/annoyedmilk/esp32-s31-linux/blob/main/opensbi/platform/esp32s31/platform.c"
click node_kernel "https://github.com/annoyedmilk/esp32-s31-linux/tree/main/linux"
click node_clic "https://github.com/annoyedmilk/esp32-s31-linux/blob/main/linux/drivers/irqchip/irq-esp32s31-clic.c"
click node_cache "https://github.com/annoyedmilk/esp32-s31-linux/blob/main/linux/drivers/cache/esp32s31-cache.c"
click node_device_drivers "https://github.com/annoyedmilk/esp32-s31-linux/tree/main/linux/drivers"
click node_hosted_fw "https://github.com/annoyedmilk/esp32-s31-linux/blob/main/bootloader/components/esp_hosted/shm_slave_api.c"
click node_hosted_linux "https://github.com/annoyedmilk/esp32-s31-linux/blob/main/br2-external/package/esp-hosted-linux/shm/esp_shm.c"
click node_shm_layout "https://github.com/annoyedmilk/esp32-s31-linux/blob/main/shared/esp32s31-hosted-shm.h"
click node_initramfs "https://github.com/annoyedmilk/esp32-s31-linux/blob/main/scripts/mkinitramfs.py"
click node_rootfs "https://github.com/annoyedmilk/esp32-s31-linux/tree/main/br2-external"
click node_sdcard "https://github.com/annoyedmilk/esp32-s31-linux/blob/main/br2-external/board/esp32s31/rootfs-overlay/etc/init.d/S10sdcard"
click node_console "https://github.com/annoyedmilk/esp32-s31-linux/tree/main/br2-external/board/esp32s31/rootfs-overlay"

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_rom,node_loader,node_display,node_sdinit,node_rmtinit,node_opensbi,node_user toneBlue
class node_hosted_fw,node_hosted_linux,node_shm_layout toneAmber
class node_kernel,node_clic,node_cache,node_device_drivers toneMint
class node_initramfs,node_rootfs,node_sdcard,node_console toneRose
class node_wifi toneIndigo
```

## Components

### Boot and firmware

- **ESP ROM**
- [ESP-IDF loader](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/bootloader/main/main.c): `bootloader/main/main.c`
- [LCD scanout](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/bootloader/main/display.c): `bootloader/main/display.c`
- [SD initialization](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/bootloader/main/sd.c): `bootloader/main/sd.c`
- [RMT setup](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/bootloader/main/rmt.c): `bootloader/main/rmt.c`
- [OpenSBI platform](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/opensbi/platform/esp32s31/platform.c): `opensbi/platform/esp32s31/platform.c`

### Hosted Wi-Fi

- [ESP-Hosted firmware](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/bootloader/components/esp_hosted/shm_slave_api.c): `bootloader/components/esp_hosted/shm_slave_api.c`
- [Shared-memory transport](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/br2-external/package/esp-hosted-linux/shm/esp_shm.c): `br2-external/package/esp-hosted-linux/shm/esp_shm.c`
- [Shared SRAM layout](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/shared/esp32s31-hosted-shm.h): `shared/esp32s31-hosted-shm.h`

### Linux platform

- [Linux kernel](https://github.com/annoyedmilk/esp32-s31-linux/tree/main/linux): `linux`
- [CLIC interrupts](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/linux/drivers/irqchip/irq-esp32s31-clic.c): `linux/drivers/irqchip/irq-esp32s31-clic.c`
- [Cache support](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/linux/drivers/cache/esp32s31-cache.c): `linux/drivers/cache/esp32s31-cache.c`
- [SoC drivers](https://github.com/annoyedmilk/esp32-s31-linux/tree/main/linux/drivers): `linux/drivers`

### Root filesystem

- [Initramfs](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/scripts/mkinitramfs.py): `scripts/mkinitramfs.py`
- [Buildroot root filesystem](https://github.com/annoyedmilk/esp32-s31-linux/tree/main/br2-external): `br2-external`
- [SD-card storage](https://github.com/annoyedmilk/esp32-s31-linux/blob/main/br2-external/board/esp32s31/rootfs-overlay/etc/init.d/S10sdcard): `br2-external/board/esp32s31/rootfs-overlay/etc/init.d/S10sdcard`
- [Shell and login](https://github.com/annoyedmilk/esp32-s31-linux/tree/main/br2-external/board/esp32s31/rootfs-overlay): `br2-external/board/esp32s31/rootfs-overlay`

### Other components

- **Board user**
- **Wi-Fi network**

## Connections

- ESP ROM → ESP-IDF loader: starts (evidence: `README.md`)
- ESP-IDF loader → LCD scanout: initializes (evidence: `README.md`)
- ESP-IDF loader → SD initialization: initializes (evidence: `README.md`)
- ESP-IDF loader → RMT setup: initializes (evidence: `README.md`)
- ESP-IDF loader → ESP-Hosted firmware: starts firmware (evidence: `bootloader/main/main.c`)
- ESP-IDF loader → OpenSBI platform: starts hart (evidence: `README.md`)
- OpenSBI platform → Linux kernel: enters Linux (evidence: `README.md`)
- Linux kernel → Initramfs: starts (evidence: `README.md`)
- Initramfs → Buildroot root filesystem: hands off (evidence: `README.md`)
- Buildroot root filesystem → SD-card storage: mounts (evidence: `README.md`)
- Board user → Shell and login: logs in (evidence: `README.md`)
- Linux kernel → CLIC interrupts: routes interrupts (evidence: `README.md`)
- Linux kernel → Cache support: syncs caches (evidence: `README.md`)
- Linux kernel → SoC drivers: supports hardware (evidence: `README.md`)
- ESP-IDF loader → LCD scanout: leaves scanout running (evidence: `README.md`)
- ESP-Hosted firmware → Shared SRAM layout: uses layout (evidence: `bootloader/components/esp_hosted/shm_slave_api.c`)
- Shared-memory transport → Shared SRAM layout: uses layout (evidence: `br2-external/package/esp-hosted-linux/shm/esp_shm.c`)
- ESP-Hosted firmware → Shared-memory transport: exchanges frames
- Shared-memory transport → Linux kernel: provides Wi-Fi transport (evidence: `README.md`)
- Board user → Wi-Fi network: connects through (evidence: `README.md`)
