- 
                Notifications
    You must be signed in to change notification settings 
- Fork 834
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_SIZEand validation macros inmcuboot_config.hand Kconfig
- Update flash_map_extended.c, CMakeLists, and loader/private/util code to switch between hardware and logical sectors
- Remove legacy flash_map_legacy.cfallback 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_SIZEandMCUBOOT_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_sectorsand adjust area initialization | 
Comments suppressed due to low confidence (4)
boot/zephyr/CMakeLists.txt:89
- Unconditionally removing the legacy flash_map_legacy.cinclude may break builds when neitherFLASH_PAGE_LAYOUTnor 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_SETis ambiguous; consider renaming to something likeMCUBOOT_LOGICAL_SECTOR_ENABLEDto 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_LAYOUTwill not be selected, which can break flash layout support. EnsureFLASH_PAGE_LAYOUTis 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
a0e7f0f    to
    06c777a      
    Compare
  
    06c777a    to
    e933a48      
    Compare
  
    e933a48    to
    aae09c4      
    Compare
  
    aae09c4    to
    3e834e8      
    Compare
  
    29abe0c    to
    6313946      
    Compare
  
    | Any update on this PR? We would be interested in using this. | 
| I'm working with this PR and providing feedback to @de-nordic on discord here: | 
| 
 This is quite ready as is, I am working on enabling tests for this. | 
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_VERIFY_LOGICAL_SECTORS, that allows to enable validation of selected logical sector against true layout of a device. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Add Kconfigs: - CONFIG_MCUBOOT_LOGICAL_SECTOR_SIZE - CONFIG_MCUBOOT_VERIFY_LOGICAL_SECTORS Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Enable logical sector testing. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
6313946    to
    e4b0779      
    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_VERIFY_LOGICAL_SECTORS=y)