Repository navigation
Conversation
dcb49e8 to
3fa58fc
Compare
| config MCUBOOT_LEGACY_SWAP_OVERHEAD | ||
| depends on BOOT_LEGACY_SWAP_OVERHEAD |
There was a problem hiding this comment.
This symbol has no type, so Kconfig emits "MCUBOOT_LEGACY_SWAP_OVERHEAD defined without a type". That warning is what fails the build_zephyr_with_twister job. Please add bool and follow the sibling MCUBOOT_* symbols, which are hidden internal symbols. Something like:
| config MCUBOOT_LEGACY_SWAP_OVERHEAD | |
| depends on BOOT_LEGACY_SWAP_OVERHEAD | |
| config MCUBOOT_LEGACY_SWAP_OVERHEAD | |
| bool | |
| default y if BOOT_LEGACY_SWAP_OVERHEAD |
There was a problem hiding this comment.
correct, this is a zephyr symbol which is declared here: https://github.com/zephyrproject-rtos/zephyr/pull/126265/files as it is common between both application image and MCUboot, so it would not be defined in MCUboot
| if((CONFIG_SINGLE_APPLICATION_SLOT OR CONFIG_BOOT_FIRMWARE_LOADER) | ||
| set(required_upgrade_size "0") | ||
| elseif(CONFIG_BOOT_DIRECT_XIP OR CONFIG_BOOT_RAM_LOAD) AND NOT CONFIG_BOOT_DIRECT_XIP_REVERT | ||
| AND NOT CONFIG_BOOT_RAM_LOAD_REVERT | ||
| ) |
There was a problem hiding this comment.
The parentheses in this if/elseif chain are wrong. if((CONFIG_SINGLE_APPLICATION_SLOT OR CONFIG_BOOT_FIRMWARE_LOADER) is unbalanced. In the elseif, the AND NOT ... clauses sit outside the closing paren of elseif(...). Either CMake fails to parse this on the sysbuild path, or the condition does not mean what you intend. I think you want if(CONFIG_SINGLE_APPLICATION_SLOT OR CONFIG_BOOT_FIRMWARE_LOADER) followed by elseif((CONFIG_BOOT_DIRECT_XIP OR CONFIG_BOOT_RAM_LOAD) AND NOT CONFIG_BOOT_DIRECT_XIP_REVERT AND NOT CONFIG_BOOT_RAM_LOAD_REVERT). Could you also confirm you have built a sysbuild configuration with this change?
There was a problem hiding this comment.
Yep seems I missed moving the bracket. Builds were tested and working before splitting into various commits which is where the error was introduced. CI job of using this PR with the needed zephyr commit: https://github.com/mcu-tools/mcuboot/actions/runs/45357825720/job/138320341576
| math(EXPR boot_trailer_size "16 + ${max_align_size} * 4") | ||
| align_up(${boot_trailer_size} ${write_size} boot_trailer_size) |
There was a problem hiding this comment.
The estimate does not look at CONFIG_BOOT_LEGACY_SWAP_OVERHEAD. With that option enabled, the C side reserves BOOT_STATUS_STATE_COUNT * min_write_sz for the swap status in the trailer. Here boot_status_data_size is 0 for the non-swap modes, so the estimate would come out too small. Should the legacy case add that space? Also, does 16 + max_align_size * 4, aligned to write_size, match boot_trailer_sz() in bootutil_area.c for each mode?
There was a problem hiding this comment.
I thought about it, it's never been taken into consideration though with older modes so left it alone to replicate existing behaviour, think it should be added in? Yes it matches, the variable part is if encryption is enabled and that is handled elsewhere in CMake
| /* #define MCUBOOT_RAM_LOAD */ | ||
|
|
||
| #if defined(MCUBOOT_OVERWRITE_ONLY) || defined(MCUBOOT_DIRECT_XIP) || \ | ||
| defined(MCUBOOT_DIRECT_XIP_REVERT) || defined(MCUBOOT_RAM_LOAD_REVERT) || \\ |
There was a problem hiding this comment.
nit: there is a stray second backslash at the end of this line (\\). It should be a single \ continuation. Also, MCUBOOT_RAM_LOAD_REVERT is listed here, but MCUBOOT_OVERWRITE_ONLY-style modes are the only ones the Kconfig lets you select the legacy option for. Please keep the two lists in sync.
| defined(MCUBOOT_DIRECT_XIP_REVERT) || defined(MCUBOOT_RAM_LOAD_REVERT) || \\ | |
| defined(MCUBOOT_DIRECT_XIP_REVERT) || defined(MCUBOOT_RAM_LOAD_REVERT) || \ |
There was a problem hiding this comment.
it's all modes that are not swap modes, which includes overwrite and RAM load/direct XIP (including reverts) since it was adding the size of the swap area overhead in these modes, the revert modes use the status flags at the end of the image but do not use any swap areas, so the list (when corrected for double backslash) is correct
Fixes an oversight whereby non-swapping modes that are not single image modes were wrongly including the size of the swap area into calculations that limit the size of the image and put image status flags earlier than they should be placed Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds a Kconfig which can be enabled to continue using the legacy MCUboot 2.5 and earlier swap overhead calculations (if compatibility is required) Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
The image estimated overhead size missed some things, this has now been fixed Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
3fa58fc to
1561be0
Compare
Note: Not for 2.5.1, for 2.6/3.0
and
@d3zd3z was wondering about renaming --overwrite-only in imgtool since it's not just for upgrade/overwrite only mode, but any non-swap mode, e.g. --no-swap?
Fixes #2999