Skip to content

boot/mcuboot: Update commit version - #3894

Merged
acassis merged 1 commit into
apache:masterfrom
daniel-p-carvalho:fix/mcuboot-version-get-sector
Oct 23, 2026
Merged

acassis merged 1 commit into
apache:masterfrom
daniel-p-carvalho:fix/mcuboot-version-get-sector

Conversation

@daniel-p-carvalho

Copy link
Copy Markdown
Contributor

Summary

Update CONFIG_MCUBOOT_VERSION to d6267bdb7f60a00f068b750f9efa2b6cb36bf47e, which includes mcu-tools/mcuboot#2908.

The NuttX port of flash_area_get_sector() looked the flash device up by fa_off + off, which only succeeds for off == 0. For any other offset it returned -errno (0) without filling the sector, and MCUboot used uninitialized stack values as the erase offset and size. With MCUBOOT_SWAP_USING_MOVE the loader then erased pages in a loop and left the primary slot corrupted, with no error and no reset. The fix looks the device up by flash area id and returns an offset relative to the area.

Impact

Users of boot/mcuboot get the MCUboot revision with the fixed flash_area_get_sector(). Without it, MCUBOOT_SWAP_USING_MOVE does not work on the NuttX port. No change to Kconfig symbols or the build process; only the default of the version string changes. Users who pin their own MCUBOOT_VERSION are not affected.

Testing

Host: Linux x86_64, arm-none-eabi-gcc 15.2.1.
Target: custom STM32G474RE board (out-of-tree, CONFIG_ARCH_BOARD_CUSTOM), MCUboot loader with MCUBOOT_SWAP_USING_MOVE, 2 x 192 KB slots, based on nuttx 7e652be44d and apps 2d68f38f7.

Before: the loader erased pages in a loop and the primary slot was corrupted (flash_area_erase: ID:1 offset:134271849 length:536870996 in the MCUboot log).

After, without any local patch:

  • Loader builds (50488 B) and boots the confirmed v1 image.
  • v2 written to the secondary slot: swap completes and v2 runs.
  • Reset without confirming: rollback to v1.
  • v2 again, then mcuboot_confirm and reset: v2 stays, no new swap.

Update the MCUboot version to include the fix for
flash_area_get_sector() in the NuttX port (mcu-tools/mcuboot#2908).
The function looked up the flash device by fa_off + off, which only
succeeded for off == 0. For any other offset it returned 0 without
filling the sector, so the caller used uninitialized stack values.
With MCUBOOT_SWAP_USING_MOVE this made the loader erase pages in a
loop and left the primary slot corrupted.

Assisted-by: Claude Code:claude-sonnet-5-5
Signed-off-by: Daniel P. Carvalho <[email protected]>

@cederom cederom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you @daniel-p-carvalho for fixing the issue directly on the upstream project! :-)

@xiaoxiang781216

Copy link
Copy Markdown
Contributor

@daniel-p-carvalho need reduce the firmware size:

====================================================================================
Configuration/Tool: same70-qmtech/mcuboot-loader,CONFIG_ARM_TOOLCHAIN_GNU_EABI
2026-10-22 01:53:11
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Disabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Enabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Building NuttX...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

100 1881k    0 1881k    0     0  2616k      0 --:--:-- --:--:-- --:--:-- 2616k
arm-none-eabi-ld: /github/workspace/sources/nuttx/nuttx section `.ramfunc' will not fit in region `flash'
arm-none-eabi-ld: region `flash' overflowed by 120 bytes
make[1]: *** [Makefile:240: nuttx] Error 1
make: *** [tools/Unix.mk:575: nuttx] Error 2
make: Target 'all' not remade because of errors.

@daniel-p-carvalho

Copy link
Copy Markdown
Contributor Author

The overflow comes from the size of the new MCUboot (about 370 bytes more) on a configuration that already uses 99.7% of its flash, not from this change. I sent apache/nuttx#20909, which enables LTO in same70-qmtech:mcuboot-loader as same70-xplained already does, and lists other ways to save flash. Once it is merged this CI check should pass on a re-run.

xiaoxiang781216 pushed a commit to apache/nuttx that referenced this pull request Oct 23, 2026
The same70-qmtech:mcuboot-loader target fills its 128 KB flash to near
capacity (99.7%, about 440 bytes free), so any growth of the image breaks
the CI build. Updating MCUboot (apache/nuttx-apps#3894) adds about 370
bytes and fails with:

  arm-none-eabi-ld: nuttx section `.ramfunc' will not fit in region `flash'
  arm-none-eabi-ld: region `flash' overflowed by 120 bytes

Following the precedent in commit 8f3060e for same70-xplained:mcuboot-loader
and commit ef87bdf for the stm32g4 cansock configurations, enable
CONFIG_LTO_FULL=y. This drops flash usage to about 85-87% (about 17 KB of
headroom) without dropping any application or feature.

Only the build was checked, the board is not available to run the loader.

Assisted-by: Claude Code:claude-sonnet-5-5
Signed-off-by: Daniel P. Carvalho <[email protected]>
@daniel-p-carvalho

Copy link
Copy Markdown
Contributor Author

@xiaoxiang781216 apache/nuttx#20909 (LTO in same70-qmtech:mcuboot-loader) is now merged, so the flash overflow that failed Linux (arm-07) should be gone. Could you please restart the CI for this PR? Re-running only the failed jobs will not help, since the nuttx tree used by the build is fixed when the run starts. If the new run is green, could you merge it as well? Thanks.

@acassis
acassis merged commit 01d752f into apache:master Oct 23, 2026
36 of 41 checks passed
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.

6 participants