F9 Microkernel

March 25, 2026 · View on GitHub

F9 is an L4-inspired microkernel designed for ARM Cortex-M, targeting real-time embedded systems with hard determinism requirements. It implements the fundamental microkernel principles—address spaces, threads, and IPC, while adding advanced features from industrial RTOSes.

Design Goals

  • Hard Real-Time: Deterministic scheduling with preemption-threshold support
  • Security: MPU-based memory protection and isolated execution
  • Efficiency: Tickless scheduling, O(1) dispatcher, energy-aware operation
  • Verifiability: Formal verification properties and comprehensive test coverage

Key Features

Advanced Scheduling

  • Priority Bitmap Scheduler: O(1) thread selection, supporting 32 priority levels
  • Preemption-Threshold Scheduling (PTS): ThreadX-style deterministic scheduling reducing context switches in critical sections
  • Priority Inheritance Protocol: Automatic priority boosting to prevent priority inversion
  • Round-Robin: Fair scheduling within same priority level
  • Tickless Operation: Wake only on scheduled events or interrupts for power efficiency

Memory Management

  • MPU-Based Protection: Hardware memory isolation using ARM MPU (8 regions)
  • Flexible Pages: Power-of-2 aligned memory regions mapped to MPU regions
  • Address Spaces: Composed of flexible pages with Grant/Map/Flush operations
  • Memory Pools: Physical address areas with specific attributes

Inter-Process Communication

  • Synchronous IPC: L4-style message passing with blocking semantics
  • Short IPC: Register-only payload (MR0-MR7) for low latency
  • Full IPC: UTCB-based message copying for larger payloads
  • UTCBs: Always-mapped user-level thread control blocks for fast syscall argument access

Hardware Support

  • ARM Cortex-M4/M4F: Optimized for Cortex-M architecture
  • NVIC: Nested Vectored Interrupt Controller integration
  • Bit Banding: Hardware bit manipulation support (where available)
  • FPU: Lazy context switching for Cortex-M4F floating-point unit (VFPv4-D16)

Development Tools

  • KDB: In-kernel debugger with thread, memory, and timer inspection
  • KProbes: Dynamic instrumentation without recompilation (Linux kernel-inspired)
  • Profiling: Thread uptime, stack usage, memory fragmentation analysis
  • Test Suite: Automated regression tests with QEMU integration

API Sets

F9 provides two API layers for application development:

Native API (L4-style)

The kernel exposes an L4-family system call interface derived from L4Ka::Pistachio and seL4. Key syscalls:

SyscallDescription
L4_IpcSynchronous message passing between threads
L4_ThreadControlCreate, configure, and delete threads
L4_ScheduleSet thread scheduling parameters
L4_SpaceControlConfigure address spaces
L4_ExchangeRegistersRead/write thread register state
L4_SystemClockRead system time (microseconds)
L4_KernelInterfaceAccess Kernel Interface Page (KIP)

Extensions for embedded real-time:

  • L4_TimerNotify: Hardware timer with notification delivery
  • L4_NotifyWait / L4_NotifyPost / L4_NotifyClear: Lightweight notification primitives

POSIX API (PSE51/PSE52)

A user-space compatibility layer implementing IEEE Std 1003.13-2003 profiles for portable real-time applications:

ProfileDescriptionStatus
PSE51Minimal Realtime SystemAPI Compliant
PSE52Realtime Controller SystemPartial

Note: POSIX timer functions (timer_create, timer_settime) have limited functionality. Core threading, synchronization, and clock_gettime/nanosleep are fully operational.

Supported POSIX interfaces:

CategoryFunctions
Threadspthread_create, pthread_join, pthread_detach, pthread_self, pthread_equal, pthread_cancel, pthread_testcancel
Mutexespthread_mutex_* (normal, recursive, errorcheck), pthread_mutex_timedlock
Condition Variablespthread_cond_wait, pthread_cond_signal, pthread_cond_broadcast, pthread_cond_timedwait
Spinlockspthread_spin_init, pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock
Semaphoressem_init, sem_wait, sem_trywait, sem_timedwait, sem_post, sem_getvalue
Timeclock_gettime, nanosleep

The POSIX layer is implemented entirely in user space atop the native notification system, requiring no kernel modifications. See user/lib/posix for implementation details.

Documentation

Comprehensive documentation is available in the Documentation/ directory:

DocumentDescription
quick-start.mdBuild, flash, and debug instructions
scheduler.mdPriority bitmap scheduler and PTS implementation
threads.mdThread management, TCB structure, lifecycle
memory.mdMemory pools, flexible pages, MPU regions
ipc.mdSynchronous IPC, message passing, UTCBs
interrupt.mdNVIC integration, interrupt handling
ktimer.mdTimer subsystem, tickless scheduling
kprobes.mdDynamic instrumentation system
init-hooks.mdKernel initialization sequence
build-system.mdKconfig-based build system

Getting Started

Quick Build

make config    # Configure build options (Kconfig)
make           # Build F9 kernel → build/<BOARD>/f9.elf
make flash     # Flash to STM32F4 board (requires stlink)

QEMU Emulation (No Hardware Required)

make qemu

Press Ctrl+A then X to exit QEMU. Press ? for KDB debug menu (requires CONFIG_KDB).

QEMU uses the B-L475E-IOT01A machine with ARM semihosting for output and USART1 for KDB input. Both -semihosting and -serial mon:stdio are added automatically.

Supported Hardware

  • STM32F4DISCOVERY (STM32F407VG)
  • STM32F429I-DISC1 (STM32F429ZI)
  • NUCLEO-F429ZI (STM32F429ZI)
  • B-L475E-IOT01A (STM32L475VG) - QEMU target with FPU and MPU emulation

For detailed instructions including toolchain setup, serial configuration, and debugging, see Documentation/quick-start.md.

Configuration Options

F9 uses a Linux kernel-style build system via Kconfiglib. Run make config to configure options via menu. Key options:

OptionDescription
CONFIG_DEBUGSerial I/O for debugging
CONFIG_KDBIn-kernel debugger (press ? for menu)
CONFIG_KPROBESDynamic instrumentation system
CONFIG_SYMMAPSymbol map for profiling
CONFIG_KTIMER_TICKLESSTickless scheduling (power efficiency)
CONFIG_MAX_THREADSMaximum number of threads
CONFIG_MAX_KT_EVENTSMaximum kernel timer events
CONFIG_FPUFPU support with lazy context switching (Cortex-M4F)
CONFIG_PANIC_DUMP_STACKDump stack on kernel panic
CONFIG_QEMUQEMU emulation mode (auto-enabled for B-L475E-IOT01A)

For build system details, see Documentation/build-system.md.

License

F9 Microkernel is freely redistributable under the two-clause BSD License. See the LICENSE file for details.