Skip to content

stm32/N657X0: fix signing for Rev.B silicon and document flashing pro…#19290

Open
Mrpli wants to merge 2 commits into
micropython:masterfrom
Mrpli:fix-nucleo-n657x0-revb-mboot
Open

stm32/N657X0: fix signing for Rev.B silicon and document flashing pro…#19290
Mrpli wants to merge 2 commits into
micropython:masterfrom
Mrpli:fix-nucleo-n657x0-revb-mboot

Conversation

@Mrpli

@Mrpli Mrpli commented Jun 1, 2026

Copy link
Copy Markdown

Summary

This pull request fixes mboot boot failures on NUCLEO-N657X0-Q boards with Rev B silicon. The STM32N657X0 chip has two silicon revisions that require different FSBL signing header versions:

  • Rev code Z (Cut 1.1) requires STM32_N6_HEADER_VERSION = 2.1
  • Rev code B (Cut 2.0) requires STM32_N6_HEADER_VERSION = 2.3

Currently mpconfigboard.mk defaults to 2.1, causing Rev B boards to fail booting after deploy-trusted. The signing header version is updated to 2.3 in this PR.

Additionally, STM32CubeProgrammer v2.21.0 and later no longer auto-align the binary payload to a 0x400-byte boundary. The --align flag has been added to the STM32_SigningTool_CLI invocation in both stm32/Makefile and stm32/mboot/Makefile; otherwise, the signing step fails with an alignment error and firmware-trusted.bin will not be generated correctly.

The board documentation (board.md) has been extended to cover:

  • How to select the correct header version for each silicon revision.
  • The --align requirement for STM32CubeProgrammer v2.21.0+.
  • An alternative ST-LINK flashing procedure for cases where the mboot USB DFU device does not enumerate on the host PC.

Testing

Hardware tested:

  • NUCLEO-N657X0-Q board with Rev B silicon (chip marking "B")

Test steps:

  1. Build mboot with updated configuration:
   make -C ports/stm32/mboot BOARD=NUCLEO_N657X0
  1. Deploy trusted image via ST-LINK (bypassing DFU):
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG ap=1 \
  -el /opt/STM32CubeProgrammer/bin/ExternalLoader/MX25UM51245G_STM32N6570-NUCLEO.stldr \
  -w ports/stm32/mboot/build-NUCLEO_N657X0/firmware-trusted.bin 0x70000000 \
  -w ports/stm32/build-NUCLEO_N657X0/firmware.bin 0x70080000 \
  -hardRst
  1. Verify mboot activates:
  • Set CN9 to 3-4, JP2 to 1-2.
  • Connect USB cable to CN8.
  • Red LED2 should blink at 1 Hz, indicating mboot is active.
  • Host PC should detect a DFU device.
  1. Verify the --align fix:
    Without --align the signing step fails with an alignment error; with the flag added, firmware-trusted.bin is generated correctly.

Documentation:

  • Verified that board.md renders correctly and all added information is accurate.

Trade-offs and Alternatives

Defaulting to header version 2.3 means Rev Z (Cut 1.1) users must manually override with STM32_N6_HEADER_VERSION=2.1.However, Rev Z boards are no longer manufactured; all currently shipping boards use Rev B, so this change matches real-world hardware.

Alternatives considered:

1.Runtime header version detection:
The chip revision cannot be easily read before the FSBL is loaded, so build‑time selection is the only practical approach.

2.Using the USB DFU method only:
The DFU method relies on mboot being active, which fails on Rev B without the correct header version. The documented ST‑LINK alternative provides a fallback that works regardless of the mboot DFU state.

Generative AI

I used generative AI tools when creating this PR, but a human has checked the
code and is responsible for the code and the description above.

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

Code size report:

Reference:  samd/mphalport: Run events at least once in mp_hal_delay_ms. [af38ee1]
Comparison: stm32/n657x0: Remove STM32CubeProgrammer documentation section. [merge of 2ece331]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@Mrpli Mrpli force-pushed the fix-nucleo-n657x0-revb-mboot branch from f4f148f to 4e89504 Compare June 1, 2026 13:18
Signed-off-by: Mrpli <woe2468@outlook.com>
@Mrpli Mrpli force-pushed the fix-nucleo-n657x0-revb-mboot branch from 4e89504 to 1114402 Compare June 1, 2026 13:29
@kwagyeman

Copy link
Copy Markdown
Contributor

Yeah, this is required.


make -C ports/stm32/mboot BOARD=NUCLEO_N657X0 STM32_N6_HEADER_VERSION=2.3

## STM32CubeProgrammer v2.21.0 and later

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this section about --align is needed. The relevant changes have been made to the code (and the commits serve as the history/documentation).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback! You're absolutely right – the --align flag is already in the code, and the commit history documents it well. I've removed that documentation section and kept only the chip revision guidance and ST-LINK flashing procedure. Updated in commit 2ece331.

@Mrpli Mrpli force-pushed the fix-nucleo-n657x0-revb-mboot branch 3 times, most recently from d46c3c4 to c635f97 Compare June 9, 2026 09:44
As suggested by the reviewer, the --align flag implementation is already
documented in the commit history. Remove the documentation section about
STM32CubeProgrammer v2.21.0 and later, while keeping the chip revision
and ST-LINK flashing procedure sections.

Signed-off-by: Mrpli <woe2468@outlook.com>
@Mrpli Mrpli force-pushed the fix-nucleo-n657x0-revb-mboot branch from c635f97 to 2ece331 Compare June 9, 2026 09:51
@Mrpli Mrpli requested a review from dpgeorge June 9, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants