Skip to content

Commit cc879d7

Browse files
tomchygithub-actions[bot]
authored andcommitted
[nrf noup] loader: Do not write trailer for NSIB images
The NSIB does not check the MCUboot image trailer. Writing data to it (i.e. copy done or image ok flags) artificially limits the maximum size of the MCUboot image that can be provided. Ref: NCSDK-39564 Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no> (cherry picked from commit 69c7ba7)
1 parent 0dccb74 commit cc879d7

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

boot/bootutil/src/loader.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,8 +1718,8 @@ boot_perform_update(struct boot_loader_state *state, struct boot_status *bs)
17181718
* swap was finished to avoid a new revert.
17191719
*/
17201720
swap_type = BOOT_SWAP_TYPE(state);
1721-
if (swap_type == BOOT_SWAP_TYPE_REVERT ||
1722-
swap_type == BOOT_SWAP_TYPE_PERM) {
1721+
if ((swap_type == BOOT_SWAP_TYPE_REVERT || swap_type == BOOT_SWAP_TYPE_PERM)
1722+
&& (!IS_NSIB_OWNED(BOOT_CURR_IMG(state)))) {
17231723
rc = swap_set_image_ok(BOOT_CURR_IMG(state));
17241724
if (rc != 0) {
17251725
BOOT_SWAP_TYPE(state) = swap_type = BOOT_SWAP_TYPE_PANIC;
@@ -1746,7 +1746,7 @@ boot_perform_update(struct boot_loader_state *state, struct boot_status *bs)
17461746
}
17471747
#endif /* MCUBOOT_HW_ROLLBACK_PROT */
17481748

1749-
if (BOOT_IS_UPGRADE(swap_type)) {
1749+
if (BOOT_IS_UPGRADE(swap_type) && (!IS_NSIB_OWNED(BOOT_CURR_IMG(state)))) {
17501750
rc = swap_set_copy_done(BOOT_CURR_IMG(state));
17511751
if (rc != 0) {
17521752
BOOT_SWAP_TYPE(state) = BOOT_SWAP_TYPE_PANIC;
@@ -1782,8 +1782,8 @@ boot_complete_partial_swap(struct boot_loader_state *state,
17821782
/* The following states need image_ok be explicitly set after the
17831783
* swap was finished to avoid a new revert.
17841784
*/
1785-
if (bs->swap_type == BOOT_SWAP_TYPE_REVERT ||
1786-
bs->swap_type == BOOT_SWAP_TYPE_PERM) {
1785+
if ((bs->swap_type == BOOT_SWAP_TYPE_REVERT || bs->swap_type == BOOT_SWAP_TYPE_PERM)
1786+
&& (!IS_NSIB_OWNED(BOOT_CURR_IMG(state)))) {
17871787
rc = swap_set_image_ok(BOOT_CURR_IMG(state));
17881788
if (rc != 0) {
17891789
BOOT_SWAP_TYPE(state) = BOOT_SWAP_TYPE_PANIC;
@@ -2332,10 +2332,12 @@ context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp)
23322332
* pretending we just reverted back to primary slot.
23332333
*/
23342334
#ifndef MCUBOOT_OVERWRITE_ONLY
2335-
/* image_ok needs to be explicitly set to avoid a new revert. */
2336-
rc = swap_set_image_ok(BOOT_CURR_IMG(state));
2337-
if (rc != 0) {
2338-
BOOT_SWAP_TYPE(state) = BOOT_SWAP_TYPE_PANIC;
2335+
if (!IS_NSIB_OWNED(BOOT_CURR_IMG(state))) {
2336+
/* image_ok needs to be explicitly set to avoid a new revert. */
2337+
rc = swap_set_image_ok(BOOT_CURR_IMG(state));
2338+
if (rc != 0) {
2339+
BOOT_SWAP_TYPE(state) = BOOT_SWAP_TYPE_PANIC;
2340+
}
23392341
}
23402342
#endif /* !MCUBOOT_OVERWRITE_ONLY */
23412343
break;

0 commit comments

Comments
 (0)