Skip to content

Disallow single-sector partitions in flash + CUSTOM_TRAILER support for STM32F4 - #940

Open
danielinux wants to merge 5 commits into
wolfSSL:masterfrom
danielinux:fix-erase-lastsector
Open

danielinux wants to merge 5 commits into
wolfSSL:masterfrom
danielinux:fix-erase-lastsector

Conversation

@danielinux

Copy link
Copy Markdown
Member

Issue #937 points out a problem with small partition (single-block), which also carry the flags in the same block. This case is technically impossible to manage on those devices with very large sector sizes. As workaround, we suggest to implement CUSTOM_PARTITION_TRAILER with a mechanism pointing to separate partitions. In STM32F4 (like the F411 where the issue was reported), sectors '1' and '2' are smaller (16KB) and can be used to offload the partition flags sector using custom trailer functions.

This patch adds:

  • Extra checks at compile time, to forbid single-block (or 2-blocks in case of NVM_FLASH_WRITEONCE) partition geometry without the CUSTOM_PARTITION_TRAILER flag
  • Custom trailer partitions (carved via linker script mapping) on sectors '1' and '2' when stm32f4 is compiled with the CUSTOM_PARTITION_TRAILER option
  • CI regression tests using renode emulated STM32F411 with the CUSTOM_PARTITION_TRAILER option turned on.

Copilot AI balanced review requested due to automatic review settings October 15, 2026 15:43

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #940

Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .github/workflows/test-renode-blackpill-custom-trailer.yml, Makefile, arch.mk, config/examples/stm32f4-small-blocks-uart-update.config, config/examples/stm32f407-discovery.config, config/examples/stm32f411-blackpill.config, docs/flash_partitions.md, hal/stm32f4-trailer.ld, options.mk, tools/config.mk, tools/renode/stm32f4_flash_alias.repl, tools/scripts/renode-test-custom-trailer.sh, tools/unit-tests/Makefile
Coverage: 3 of 7 in-scope changed file(s) opened by the reviewer; not opened: include/wolfboot/wolfboot.h, test-app/startup_arm.c, tools/keytools/sign.c, tools/unit-tests/unit-update-flash.c

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Lite

Comment thread src/update_flash.c Outdated
@danielinux danielinux self-assigned this Oct 27, 2026

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #940

Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .github/workflows/test-build-cmake.yml, .github/workflows/test-renode-blackpill-custom-trailer.yml, CMakeLists.txt, CMakePresets.json, Makefile, arch.mk, config/examples/stm32f4-small-blocks-uart-update.config, config/examples/stm32f407-discovery.config, config/examples/stm32f411-blackpill.config, docs/flash_partitions.md, hal/stm32f4-trailer.ld, options.mk, tools/config.mk, tools/renode/stm32f4_flash_alias.repl, tools/scripts/renode-test-custom-trailer.sh, tools/unit-tests/Makefile
Coverage: 1 of 2 in-scope changed file(s) opened by the reviewer; not opened: tools/unit-tests/unit-update-flash.c

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Lite

Comment thread src/update_flash.c Outdated

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #940

Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .github/workflows/test-build-cmake.yml, .github/workflows/test-renode-blackpill-custom-trailer.yml, CMakeLists.txt, CMakePresets.json, Makefile, arch.mk, config/examples/stm32f4-small-blocks-uart-update.config, config/examples/stm32f407-discovery.config, config/examples/stm32f411-blackpill.config, docs/flash_partitions.md, hal/stm32f4-trailer.ld, options.mk, tools/config.mk, tools/renode/stm32f4_flash_alias.repl, tools/scripts/renode-test-custom-trailer.sh, tools/unit-tests/Makefile
Coverage: 1 of 2 in-scope changed file(s) opened by the reviewer; not opened: tools/unit-tests/unit-update-flash.c

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed stale reviews from themself October 27, 2026 17:46

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

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.

3 participants