Boot and recovery manager for embedded systems.
C99 | Zero dependencies | Zero allocations | Callback-driven | Portable
Without a startup orchestrator, devices can get stuck in crash loops: boot, fail, reset, repeat.
microboot tracks boot history, detects crash loops, and lets you switch into a recovery strategy before a device gets stuck permanently.
- Boot reason detection (cold, watchdog, crash dump, brownout, user)
- Crash loop detection with configurable threshold
- Boot mode decision (NORMAL, RECOVERY, SAFE, FACTORY)
- Persistent CRC-protected boot record
- Clean shutdown tracking
- Boot confirmation hook to reset crash counter
- Last uptime tracking for diagnostics
mboot_t boot;
mboot_init(&boot, &flash_io, HAL_GetTick);
mboot_start(&boot);
switch (mboot_mode(&boot)) {
case MBOOT_MODE_NORMAL:
start_application();
mboot_confirm(&boot);
break;
case MBOOT_MODE_RECOVERY:
start_recovery_server();
break;
case MBOOT_MODE_FACTORY:
load_factory_defaults();
start_application();
break;
default:
break;
}Linux/macOS:
cd tests
makeWindows (MSYS2/MinGW shell):
cd tests
make| Macro | Default | Description |
|---|---|---|
MBOOT_CRASH_LOOP_THRESHOLD |
3 | Crashes before recovery mode |
MBOOT_CRASH_WINDOW_MS |
30000 | Time window for crash counting |
MBOOT_MAGIC |
0x424F4F54 |
Record validation magic |
include/mboot.h: public APIsrc/mboot.c: implementationtests/test_all.c: test suitedocs/: design and integration docs
GitHub Actions workflow runs build and tests on each push and pull request to master.
MIT License, Copyright (c) 2026 Vanderhell. See LICENSE.