knaxuslearn · build · ship

Roadmaps / STM32

Electronics · 16 study weeks · 4 phases

STM32 Roadmap Beta

16 study weeks on one board. You take an STM32G4 Nucleo from a blank chip to firmware you can trust: timing you have measured, a control loop that holds its deadline, protocols that survive garbage input, faults that leave evidence, and a bootloader that survives a power cut during an update. At 8 hours a week the core path is 128 hours and takes 16 weeks. At 12 hours a week it takes about 11 weeks, and at 16 hours a week about 8 weeks. You build one product across all four phases, a fail-safe pump-speed controller, and every phase adds a checkpoint to it. At the end you can say, with numbers, when a loop belongs in an interrupt and when in an RTOS task, and what an update path must guarantee before you ship it to a customer.

This roadmap is in beta and keeps improving over time. If you spot an error, please email your suggestions and corrections to [email protected].

Read first

  1. Phase 1 · Study weeks 1-4

    Board, boot, clocks and a measured baseline

    This phase lets you build, flash, debug and measure the chip from a clean checkout, so Phase 2 has a number to beat. Read the board user manual (UM2505), the datasheet (DS12712) and the chip's reference manual (RM0440, st.com/resource/en/reference_manual/rm0440-stm32g4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) as you go, and the Interrupt blog's linker-script and map-file posts (interrupt.memfault.com) in Week 2.

    • 4 repos
    • Milestone checkpoint
    1. Study week 1The board: Cortex-M4F, memory map, 3.3 V rules, ST-LINK/V3E (debug, virtual serial port, mass storage)8 h
    2. Study week 2What runs before main: vector table, reset handler, .data and .bss setup, linker script, map file8 h
    3. Study week 3Clocks and power: 24 MHz crystal, PLL to 170 MHz, boost mode, flash wait states, instruction cache and prefetch, MCO output, SysTick, DWT cycle counter8 h
    4. Study week 4Timers, ADC and DMA: center-aligned PWM, a timer-triggered ADC, circular DMA, interrupts, where in the PWM period you sample8 h
  2. Phase 2 · Study weeks 5-8

    Real-time control and an RTOS

    This phase puts a controller on top of the Phase 1 sampling and lets you decide, with a number, what runs in an interrupt and what runs in a task.

    • 3 repos
    • Milestone checkpoint
    1. Study week 5A discrete PI controller, anti-windup, identifying the plant from a step capture, float on a Cortex-M4F (single-precision FPU, lazy stacking)8 h
    2. Study week 6Interrupts: NVIC priority bits (16 levels on this chip), tail-chaining, stack frame, BASEPRI, sharing data between an ISR and main8 h
    3. Study week 7FreeRTOS on Cortex-M4F: tasks, queues, notifications, priority grouping (all bits preempt) and configMAXSYSCALLINTERRUPTPRIORITY, mutex against binary semaphore, stack high-water marks8 h
    4. Study week 8Tuning and proof: disturbance rejection, CPU-load measurement, seeded faults, the three-way latency comparison8 h
  3. Phase 3 · Study weeks 9-12

    Interfaces, watchdogs and faults

    This phase makes the firmware survive bad input and bad code, and leave evidence when it does fail.

    • 4 repos
    • Milestone checkpoint
    1. Study week 9UART with DMA and idle-line detection, ring buffers, framing, the hardware CRC unit, a parser with no hardware calls8 h
    2. Study week 10Protocol design: lengths, timeouts, back-pressure, resynchronisation8 h
    3. Study week 11Watchdogs: independent against window, who feeds it and when, timer break input, pull-down safe state, reset reasons, brown-out reset level8 h
    4. Study week 12Fault anatomy: stacked frame, EXCRETURN, fault status registers, precise against imprecise bus faults, a record in a .noinit section of main SRAM that survives reset (not CCM SRAM, which an option byte can erase at reset, and check RM0440 for which SRAM has a parity option before using SRAM2), decoding with addr2line8 h
  4. Phase 4 · Study weeks 13-16

    Ship it: bootloader, update and operations

    This phase makes the product updatable in the field without a service visit, and lets you prove it with power cuts.

    • 4 repos
    • Milestone checkpoint
    1. Study week 13Flash internals: banks, 2 KB pages, doubleword programming, ECC, option bytes, read-while-write8 h
    2. Study week 14Bootloader and image format: header (magic, version, length, CRC-32, board id), slot choice, jumping to an app (stack pointer, VTOR, peripheral reset), append-only metadata log, trial boot and confirm8 h
    3. Study week 15Update protocol over serial: chunks, acknowledgements, restart from the last good chunk8 h
    4. Study week 16Checkpoint 4: the 20 cuts, the soak, rollback, reproducible build8 h

Also in this roadmap