Bare-metal Cortex-M firmware needs startup support without the standard library or an operating system. cortex-m-rt supplies a minimal runtime so application code does not have to implement the initial setup itself. section 1.3.3 section 2.1.1
The runtime handles key startup and handler tasks:
- Places the vector table, sets the initial stack pointer, initializes .data and .bss, then transfers control to the entry function. section 1.3.3
- Provides attributes such as #[entry], #[exception], and #[interrupt] to mark entry points and handlers, with weak defaults that can be overridden. section 1.3.3 section 3.5.1
- For non-standard setups, supports extension points such as a custom linker script, relocated vector table, early startup hook, or custom panic behavior. section 1.3.3
#[exception]
fn SysTick() {
// Handle the SysTick timer interrupt
}
A SysTick handler can be registered with #[exception]; external interrupt names such as TIM2 come from the target’s Peripheral Access Crate. section 4.5.7
Using the runtime avoids writing handler vector mappings by hand, which can be verbose and error-prone. Keep the minimal startup pattern in mind for troubleshooting or cases where the crate is unavailable or unsuitable. section 4.5.7 section 4.4.7
