-
Notifications
You must be signed in to change notification settings - Fork 780
Logical sectors #2352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Logical sectors #2352
Conversation
40981d5
to
2e41af6
Compare
2e41af6
to
549cffc
Compare
4b00235
to
31268f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds support for using fixed-size “logical” flash sectors (and optional run-time validation) instead of querying hardware page layouts in MCUBoot on Zephyr.
- Introduce
MCUBOOT_LOGICAL_SECTOR_SIZE
and validation macros inmcuboot_config.h
and Kconfig - Update
flash_map_extended.c
, CMakeLists, and loader/private/util code to switch between hardware and logical sectors - Remove legacy
flash_map_legacy.c
fallback and adjust build logic for flash layout
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
boot/zephyr/include/mcuboot_config/mcuboot_config.h | Define MCUBOOT_LOGICAL_SECTOR_SIZE and MCUBOOT_LOGICAL_SECTOR_VALIDATION |
boot/zephyr/flash_map_legacy.c | Removed obsolete legacy page-layout fallback |
boot/zephyr/flash_map_extended.c | Conditional logic for logical sectors and validation in flash APIs |
boot/zephyr/Kconfig | Add Kconfig options for logical sector size and validation |
boot/zephyr/CMakeLists.txt | Stop including legacy flash_map fallback unconditionally |
boot/bootutil/src/loader.c | Wrap split_image_check and context code to skip on logical sectors |
boot/bootutil/src/bootutil_priv.h | Conditional sector fields and inline functions for logical sectors |
boot/bootutil/src/bootutil_misc.c | Add boot_validate_logical_sectors and adjust area initialization |
Comments suppressed due to low confidence (4)
boot/zephyr/CMakeLists.txt:89
- Unconditionally removing the legacy
flash_map_legacy.c
include may break builds when neitherFLASH_PAGE_LAYOUT
nor logical sectors are enabled. Consider re-adding a conditional to include it when both are off.
)
boot/zephyr/Kconfig:1104
- [nitpick] The name
MCUBOOT_LOGICAL_SECTOR_SIZE_SET
is ambiguous; consider renaming to something likeMCUBOOT_LOGICAL_SECTOR_ENABLED
to clearly indicate it toggles logical-sector mode.
config MCUBOOT_LOGICAL_SECTOR_SIZE_SET
boot/zephyr/Kconfig:1124
- If logical sectors are enabled but validation is disabled,
FLASH_PAGE_LAYOUT
will not be selected, which can break flash layout support. EnsureFLASH_PAGE_LAYOUT
is selected whenever hardware page info is needed.
select FLASH_PAGE_LAYOUT if FLASH_HAS_PAGE_LAYOUT && !MCUBOOT_LOGICAL_SECTOR_SIZE_SET
boot/bootutil/src/loader.c:654
- [nitpick] Add a matching comment on the
#endif
(e.g./* logical sectors disabled */
) to clearly link the conditional guard to its closing directive.
#if !defined(MCUBOOT_LOGICAL_SECTOR_SIZE) || MCUBOOT_LOGICAL_SECTOR_SIZE == 0
The function has been provided to support Zephyr, but is not needed anymore. It does not even compile, actually. Signed-off-by: Dominik Ermel <[email protected]>
The commit adds support for logical/software sectors. User can select size of sector by which image will be moved using configuration identifier MCUBOOT_LOGICAL_SECTOR_SIZE. Non-0 value set to MCUBOOT_LOGICAL_SECTOR_SIZE will be used as sector size for image swap algorithms. Note that the value provided here should be aligned to hardware erase page of device(s) used and may not be smaller than of such a device. There is also additional option provided, MCUBOOT_LOGICAL_SECTOR_VALIDATE, that allows to enable validation of selected logical sector against true layout of a device. Signed-off-by: Dominik Ermel <[email protected]>
Add Kconfigs: - CONFIG_MCUBOOT_LOGICAL_SECTOR_SIZE - CONFIG_MCUBOOT_LOGICAL_SECTOR_VALIDATION Signed-off-by: Dominik Ermel <[email protected]>
c165e48
to
a0e7f0f
Compare
So far tested on nrf52840 with internal memory only.
Normal build from main, with hardware pages/sectors
Logical sectors ( -DCONFIG_MCUBOOT_LOGICAL_SECTOR_SIZE=4096 -DCONFIG_FLASH_PAGE_LAYOUT=n)
Logical sectors validation build (-DCONFIG_MCUBOOT_LOGICAL_SECTOR_SIZE=4096 -DCONFIG_MCUBOOT_LOGICAL_SECTOR_VALIDATION=y)