Skip to content

bitbox03: support STM32U5G9 testboard builds - #2138

Draft
NickeZ wants to merge 9 commits into
BitBoxSwiss:masterfrom
NickeZ:nickez-agent/bitbox03-testboard
Draft

NickeZ wants to merge 9 commits into
BitBoxSwiss:masterfrom
NickeZ:nickez-agent/bitbox03-testboard

Conversation

@NickeZ

@NickeZ NickeZ commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

The testboard selection previously built the STM32U5A9 dev-kit image, with the wrong device definitions and RAM layout for the STM32U5G9. Select dedicated testboard support for firmware, both bootloader stages and factory setup, including the generated GPIO, clock and SMPS setup.

Use STM32Cube U5 1.9.0 drivers and vendor stm32-metapac 21.0.0 to provide register and interrupt definitions for both MCUs. Preserve the startup register values when adapting the platform code to the new PAC.

Keep each board's artifacts in a separate build directory and add explicit testboard builds to CI.

Validated debug and release firmware plus all release bootloader and factory setup images for both boards. Checked ELF vector tables, stack addresses and finalized image headers; 63 Python and 25 Rust tests pass. Hardware execution has not been tested.

@NickeZ
NickeZ force-pushed the nickez-agent/bitbox03-testboard branch 2 times, most recently from 745b438 to d48db73 Compare October 8, 2026 12:26
The STM32U5G9 testboard needs its CMSIS device header alongside the
shared STM32U5 drivers. Import that header and update the existing
drivers to STM32Cube U5 1.9.0, with CMSIS 1.4.3 and HAL 1.6.3.

BitBox03 does not link libc, so also remove the unused Cube-generated
syscall and heap stubs from the dev-kit sources. They were already
excluded from compilation, so their removal preserves behavior.
The testboard needs register and interrupt definitions for STM32U5G9
as well as the dev kit's STM32U5A9. Vendor stm32-metapac 21.0.0, which
provides both devices, for the subsequent MCU integration.

This commit only adds the vendored crate and its checksum metadata;
the workspace dependency remains unchanged.
The MCU and platform crates hardcode STM32U5A9, preventing a board
from selecting STM32U5G9 register definitions and C bindings.

Use stm32-metapac with device features selected by the board, and
require exactly one device when compiling the embedded HAL. Keep
the dev kit on STM32U5A9 and include the GPIO driver needed for board
initialization. Host builds do not need the embedded PAC.

Adapt the RCC initialization to the new PAC API while preserving its
register values, including the MSIS and MSIK reset enables. Update
the lockfile together with the dependency switch.

Validation: all four dev-kit images build in release mode with
Cargo --locked --offline at this intermediate commit.
The testboard has different GPIO, clock and power requirements from
the dev kit. Add its generated STM32U5G9 board initialization,
including SMPS setup, flash configuration and HAL overrides.

Keep the generated C support separate from the Rust wrappers and
linker layout that will consume it.
Using the dev kit's board support would initialize the wrong pins
and describe the wrong RAM capacity on STM32U5G9.

Add testboard bindings, initialization and build helpers that select
STM32U5G9. Define the board's 3008 KiB main RAM region and generate
its linker memory map while preserving the shared flash layout and
reserved boot arguments. Compile the HAL override as a standalone
object so its strong symbols participate in the final link.

Register the three board crates in the workspace and lockfile.

Validation: Cargo --locked --offline checks pass for the board on
thumbv8m.main-none-eabihf and its build helper on the host.
Firmware, both bootloader stages and factory setup only accept the
dev-kit board, leaving the new testboard support unreachable.

Add the testboard feature and Cargo aliases for all four images.
Select its initialization, memory layout and HAL overrides, and
reject ambiguous board selection for embedded builds. Keep host
build scripts from requiring an embedded board selection.

Validation: all four images build in release mode for each board;
firmware also builds in debug mode through both Cargo aliases.
All builds use --locked --offline. Hardware execution is untested.
Selecting testboard still dispatches to dev-kit Cargo aliases, uses
the dev-kit probe device, and shares its output directory. Builds
and flashing therefore do not consistently target the chosen board.

Dispatch each image to the selected board's alias, identify the
STM32U5G9 probe device, and isolate artifacts under a board-specific
directory. Update CI artifact discovery and the build documentation
together with the path change.

Add command-generation tests covering both boards, debug and release,
and all four images, plus distinct artifact and device checks.

Validation: all 63 Python script tests pass.
The build matrix only exercises the default BitBox03 dev kit, so
regressions in testboard selection and linking can go unnoticed.

Build release testboard firmware, both bootloader stages and factory
setup, plus debug firmware. Pass the selected board to configuration
and include it in artifact names to distinguish the added jobs.

Validation: the corresponding release images and debug firmware
build locally. The GitHub Actions workflow has not been run.
Cube imports restore syscalls.c and sysmem.c even though BitBox03
does not link libc or compile these generated runtime stubs.

Exclude both files from every board import so updating the ST sources
no longer requires removing them manually.

Python formatting, syntax and diff checks passed.
@NickeZ
NickeZ force-pushed the nickez-agent/bitbox03-testboard branch from d48db73 to 58758a8 Compare November 17, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants