A preemptive RTOS for the STM32F446RE (Cortex-M4F), written from scratch on direct register access. There is no HAL, LL or CMSIS device header: every register struct is derived from the reference manuals and mapped to its address.
API reference: https://ka5j.github.io/stm32_rtos/ (generated by
Doxygen and published from main at each release).
| Read | For |
|---|---|
| Architecture | Layers, boot sequence, clock tree, memory map |
| Design notes | Why the conventions are what they are |
| Contributing | Conventions, documentation style, workflow |
| Versioning | Version policy and release procedure |
| Security | Reporting, threat model, CI trust boundaries |
| Changelog | What changed in each release |
This table is the single source of truth for project status.
| Layer | Status |
|---|---|
Boot (soc/stm32f446/: startup, linker script) |
Done |
Registers (arch/cortex-m4/, soc/stm32f446/) |
Done: 4 core and 10 chip peripherals |
Drivers (drivers/) |
GPIO, RCC, Flash, PWR, UART, NVIC, SysTick, Fault, EXTI, IWDG, WWDG |
Board support (board/nucleo-f446re/) |
180 MHz clock bring-up (bspClockInit()); pin mapping not started |
| Kernel and RTOS API | Not started |
| Peripheral API | Not started |
Application (app/) |
main() is an empty loop |
| Tooling (build, lint, tests, docs, CI) | Done |
Hardware: the drivers, bspClockInit() and the fault handler pass the
on-target smoke test (make smoke-flash) on a NUCLEO-F446RE, in debug and
release builds. On the host, drivers and the BSP have 100% line and branch
coverage. UART receive is not checked on the board, since it needs a sender,
and main() is still an empty loop. See
Host testing and its limits.
Known limitations:
- Concurrency: no driver is concurrency-safe yet (see Concurrency).
- Timeouts: waits are bounded poll counts, not times, and UART takes its count from the caller (see Poll-count timeouts).
- Startup:
- it never sets
SCB->VTOR, which is fine when booting from flash at0x08000000; - nothing runs
.init_array, so C constructors are unsupported; the link fails on one rather than leaving it uncalled; - stack overflow is not detected at run time.
- it never sets
- RCC:
rccPllConfig()does not check the VCO frequency limits, andrccBusPrescalerConfig()does not check the APB maximums. The single configuration is checked at compile time inbsp.h.- The SYSCLK-source decoder knows HSI, HSE and PLL, not the PLLR option.
- UART:
uartInit()leaves CR2/CR3 fields other than STOP untouched. - SysTick:
systickInit()does not clear a pending SysTick exception. - Clock bring-up:
bspClockInit()does not unwind on failure, so it cannot simply be retried. - Faults:
Fault_Handlerrecords the fault and spins. Nothing recovers, andfaultRecorddoes not survive a reset.
| Tool | Needed for | Notes |
|---|---|---|
| Arm GNU Toolchain | building, make debug |
CI uses 15.2.rel1 |
GNU Make, a host cc |
everything; make test, make coverage |
|
OpenOCD, nc |
make flash, erase, debug |
|
clang-format 18 |
make format-check |
Other versions can format differently from CI; make warns, and finds Homebrew's keg-only llvm@18 by itself |
cppcheck 2.13.0 |
make lint |
Other versions report different MISRA findings; scripts/install_cppcheck.sh builds 2.13.0 without sudo and make lint uses it automatically |
| Doxygen 1.18.0, Graphviz | make docs |
Distribution packages are usually too old; without Graphviz the diagrams are silently dropped |
gcovr 8.8 |
make coverage |
Needs Python 3.10 or newer |
codespell 2.4.3 |
make spell |
CI runs it; pip install --require-hashes -r scripts/ci/requirements.txt installs CI's exact gcovr and codespell |
On macOS: brew install llvm@18 cppcheck doxygen graphviz gcovr.
References used throughout the code:
- RM0390, the F446 reference manual. Section numbers are from Rev 6.
- PM0214, the Cortex-M4 programming manual.
- UM1724, the Nucleo-64 user manual.
git clone https://github.com/ka5j/stm32_rtos.git
cd stm32_rtos
make hooks # once: run the checks on every commit
make # build/stm32_rtos.{elf,bin,hex} and a size report
make flash # program the NUCLEO-F446RE over its ST-LINKRead Contributing before changing code.
| Command | What it does |
|---|---|
make / make all |
Build the firmware (BUILD=release for -O2) and print its size |
make size |
Print flash and RAM use of the built ELF |
make flash |
Build if needed, program and verify over ST-LINK, then reset |
make erase |
Mass-erase the chip |
make debug |
Start OpenOCD, attach GDB, load the ELF and halt at reset |
make smoke |
Build the on-target smoke test, build/smoke.elf |
make stack-usage |
List each function's stack frame from the last build, deepest first |
make smoke-flash |
Flash the smoke test; it reports PASS/FAIL on the VCP (115200 8N1) |
make test |
Build and run the host unit tests, plus the vector-table and test-registration checks; SANITIZE=1 adds ASan and UBSan |
make coverage |
Run the tests instrumented; fail below 100% line or branch coverage of drivers/ and board/ |
make lint |
cppcheck with the MISRA C:2012 addon; fail on any finding |
make all ANALYZE=1 |
Also run GCC's static analyzer (-fanalyzer); fail on any finding |
make spell |
codespell over code, comments and docs (settings in .codespellrc) |
make format |
Apply .clang-format |
make format-check |
Fail if any file needs formatting |
make docs |
Generate docs/html/; fail on any Doxygen warning |
make check-version |
Fail if the Doxyfile and CHANGELOG versions disagree (TAG=vX.Y.Z also checks a tag) |
make check-pr |
Run CI's pull-request file checks against BASE (default origin/develop) |
make hooks |
Point git at the tracked pre-commit hook |
make clean |
Remove build/ and docs/html/ |
make re |
clean, then all |
MIT, see LICENSE.