# rt-thread/rtthread-nano architecture

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

- Interactive diagram: https://gitdiagram.com/rt-thread/rtthread-nano
- Repository: https://github.com/rt-thread/rtthread-nano

## Overview

This tree is an RT-Thread embedded operating-system repository with an STM32F407 board application, architecture ports, kernel services, and FinSH shell components. The visible board workflow initializes STM32 hardware, then periodically delays and prints a greeting through RT-Thread APIs. The tree also includes CMSIS headers and a DSP test suite; the latter is test infrastructure rather than the embedded product runtime, so it is omitted. Source evidence is sparse for internal kernel and shell calls, so those relationships are not inferred.

Main entry points: [`rt-thread/bsp/stm32f407-msh/Core/Src/main.c`](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/bsp/stm32f407-msh/Core/Src/main.c) (Board entry loop), [`rt-thread/bsp/stm32f407-msh/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h`](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/bsp/stm32f407-msh/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h) (STM32 HAL), [`rt-thread/bsp/stm32f407-msh/Core/Inc/main.h`](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/bsp/stm32f407-msh/Core/Inc/main.h) (Board definitions), [`rt-thread/bsp/stm32f407-msh/Core/Inc/stm32f4xx_hal_conf.h`](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/bsp/stm32f407-msh/Core/Inc/stm32f4xx_hal_conf.h) (HAL configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_board["Board Application"]
  node_main["Board entry loop<br/>[main.c]"]
  node_mainheader["Board definitions<br/>[main.h]"]
  node_hal["STM32 HAL<br/>[stm32f4xx_hal.h]"]
  node_halconfig["HAL configuration"]
end

subgraph group_kernel["RT-Thread Kernel"]
  node_kernelapi["RT-Thread API<br/>[rtthread.h]"]
  node_thread["Thread services<br/>[thread.c]"]
  node_scheduler["Scheduler<br/>[scheduler.c]"]
  node_ipc["IPC services<br/>[ipc.c]"]
  node_timer["Timer services<br/>[timer.c]"]
  node_memory["Memory services<br/>[mem.c]"]
  node_heap["Memory heaps<br/>[memheap.c]"]
  node_slab["Slab allocator<br/>[slab.c]"]
  node_kservice["Kernel utilities<br/>[kservice.c]"]
end

subgraph group_ports["CPU Ports"]
  node_armport["ARM Cortex-M ports<br/>[cpuport.c]"]
  node_riscvport["RISC-V port<br/>[cpuport.c]"]
  node_gic["ARM GICv3 support<br/>[gicv3.c]"]
  node_mmu["ARMv6 MMU<br/>[mmu.c]"]
end

subgraph group_shell["FinSH Shell"]
  node_shellcore["Interactive shell<br/>[shell.c]"]
  node_msh["MSH commands<br/>[msh.c]"]
  node_cmd["FinSH commands<br/>[cmd.c]"]
  node_mshfile["MSH file commands<br/>[msh_file.c]"]
  node_parser["Command parser<br/>[msh_parse.c]"]
end

node_device(("STM32F407 board"))

node_device -->|"starts"| node_main
node_main -->|"initializes hardware"| node_hal
node_main -->|"delays and prints"| node_kernelapi
node_main -->|"includes"| node_mainheader
node_mainheader -->|"includes"| node_hal
node_hal -->|"includes"| node_halconfig

click node_main "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/bsp/stm32f407-msh/Core/Src/main.c"
click node_mainheader "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/bsp/stm32f407-msh/Core/Inc/main.h"
click node_hal "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/bsp/stm32f407-msh/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h"
click node_halconfig "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/bsp/stm32f407-msh/Core/Inc/stm32f4xx_hal_conf.h"
click node_kernelapi "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/include/rtthread.h"
click node_thread "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/thread.c"
click node_scheduler "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/scheduler.c"
click node_ipc "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/ipc.c"
click node_timer "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/timer.c"
click node_memory "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/mem.c"
click node_heap "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/memheap.c"
click node_slab "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/slab.c"
click node_kservice "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/kservice.c"
click node_armport "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/libcpu/arm/cortex-m4/cpuport.c"
click node_riscvport "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/libcpu/risc-v/common/cpuport.c"
click node_gic "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/libcpu/arm/cortex-a/gicv3.c"
click node_mmu "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/libcpu/arm/armv6/mmu.c"
click node_shellcore "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/components/finsh/shell.c"
click node_msh "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/components/finsh/msh.c"
click node_cmd "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/components/finsh/cmd.c"
click node_mshfile "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/components/finsh/msh_file.c"
click node_parser "https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/components/finsh/msh_parse.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_main,node_mainheader,node_hal,node_halconfig toneBlue
class node_kernelapi,node_thread,node_scheduler,node_ipc,node_timer,node_memory,node_heap,node_slab,node_kservice toneAmber
class node_armport,node_riscvport,node_gic,node_mmu toneMint
class node_shellcore,node_msh,node_cmd,node_mshfile,node_parser toneRose
class node_device toneIndigo
```

## Components

### Board Application

- [Board entry loop](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/bsp/stm32f407-msh/Core/Src/main.c): `rt-thread/bsp/stm32f407-msh/Core/Src/main.c`
- [Board definitions](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/bsp/stm32f407-msh/Core/Inc/main.h): `rt-thread/bsp/stm32f407-msh/Core/Inc/main.h`
- [STM32 HAL](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/bsp/stm32f407-msh/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h): `rt-thread/bsp/stm32f407-msh/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h`
- [HAL configuration](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/bsp/stm32f407-msh/Core/Inc/stm32f4xx_hal_conf.h): `rt-thread/bsp/stm32f407-msh/Core/Inc/stm32f4xx_hal_conf.h`

### RT-Thread Kernel

- [RT-Thread API](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/include/rtthread.h): `rt-thread/include/rtthread.h`
- [Thread services](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/thread.c): `rt-thread/src/thread.c`
- [Scheduler](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/scheduler.c): `rt-thread/src/scheduler.c`
- [IPC services](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/ipc.c): `rt-thread/src/ipc.c`
- [Timer services](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/timer.c): `rt-thread/src/timer.c`
- [Memory services](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/mem.c): `rt-thread/src/mem.c`
- [Memory heaps](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/memheap.c): `rt-thread/src/memheap.c`
- [Slab allocator](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/slab.c): `rt-thread/src/slab.c`
- [Kernel utilities](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/src/kservice.c): `rt-thread/src/kservice.c`

### CPU Ports

- [ARM Cortex-M ports](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/libcpu/arm/cortex-m4/cpuport.c): `rt-thread/libcpu/arm/cortex-m4/cpuport.c`
- [RISC-V port](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/libcpu/risc-v/common/cpuport.c): `rt-thread/libcpu/risc-v/common/cpuport.c`
- [ARM GICv3 support](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/libcpu/arm/cortex-a/gicv3.c): `rt-thread/libcpu/arm/cortex-a/gicv3.c`
- [ARMv6 MMU](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/libcpu/arm/armv6/mmu.c): `rt-thread/libcpu/arm/armv6/mmu.c`

### FinSH Shell

- [Interactive shell](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/components/finsh/shell.c): `rt-thread/components/finsh/shell.c`
- [MSH commands](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/components/finsh/msh.c): `rt-thread/components/finsh/msh.c`
- [FinSH commands](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/components/finsh/cmd.c): `rt-thread/components/finsh/cmd.c`
- [MSH file commands](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/components/finsh/msh_file.c): `rt-thread/components/finsh/msh_file.c`
- [Command parser](https://github.com/rt-thread/rtthread-nano/blob/master/rt-thread/components/finsh/msh_parse.c): `rt-thread/components/finsh/msh_parse.c`

### Other components

- **STM32F407 board**

## Connections

- STM32F407 board → Board entry loop: starts (evidence: `rt-thread/bsp/stm32f407-msh/Core/Src/main.c`)
- Board entry loop → STM32 HAL: initializes hardware (evidence: `rt-thread/bsp/stm32f407-msh/Core/Src/main.c`)
- Board entry loop → RT-Thread API: delays and prints (evidence: `rt-thread/bsp/stm32f407-msh/Core/Src/main.c`)
- Board entry loop → Board definitions: includes (evidence: `rt-thread/bsp/stm32f407-msh/Core/Src/main.c`)
- Board definitions → STM32 HAL: includes (evidence: `rt-thread/bsp/stm32f407-msh/Core/Inc/main.h`)
- STM32 HAL → HAL configuration: includes (evidence: `rt-thread/bsp/stm32f407-msh/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h`)
