The memory map defines where every byte of your firmware lives. Getting it wrong causes hard faults, corrupted flash, or stack overflows. Getting it right is invisible — the firmware just works.

STM32F407 memory map:

0x08000000 ┌─────────────────┐
           │  Vector table   │ 4 bytes × (IRQ count + 16) ≈ 400B
           │  .text (code)   │ Firmware instructions
           │  .rodata        │ Constants, string literals, lookup tables
           │  .data (init)   │ Initial values for .data section
0x08100000 └─────────────────┘  (1MB FLASH limit)

0x20000000 ┌─────────────────┐
           │  .data          │ Initialised globals (copied from FLASH at startup)
           │  .bss           │ Zero-initialised globals
           │  Heap (if any)  │ Grows upward (not used in no_std)
           │  ← free →       │
           │  Stack          │ Grows downward from top of RAM
0x20020000 └─────────────────┘  (128KB RAM limit)

Stack sizing: The stack needs worst-case depth including interrupt nesting. A rule of thumb: 1KB per task stack + 512B for each interrupt handler that can preempt it. In Cerberus-OS, each task has a statically allocated 2KB stack defined in the linker script.

Cerberus-OS PMP alignment requirement: RISC-V PMP with NAPOT mode requires regions to be naturally aligned to a power-of-two size. A 2KB stack must be placed at a 2KB-aligned address. The linker script enforces this:

task0_stack (NOLOAD) : ALIGN(2048) {
    . = . + 2048;
    _task0_stack_top = .;
} > RAM

Flash wear considerations: If the firmware writes to its own flash (configuration storage, firmware update), the write sectors must be isolated from code sectors. STM32F4's flash is sector-erased (16KB to 128KB sectors) — a single byte write erases the entire sector. Configuration must live in a dedicated sector.