Skip to content

Commit 69c7ba7

Browse files
committed
[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>
1 parent a22b373 commit 69c7ba7

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
@@ -1732,8 +1732,8 @@ boot_perform_update(struct boot_loader_state *state, struct boot_status *bs)
17321732
* swap was finished to avoid a new revert.
17331733
*/
17341734
swap_type = BOOT_SWAP_TYPE(state);
1735-
if (swap_type == BOOT_SWAP_TYPE_REVERT ||
1736-
swap_type == BOOT_SWAP_TYPE_PERM) {
1735+
if ((swap_type == BOOT_SWAP_TYPE_REVERT || swap_type == BOOT_SWAP_TYPE_PERM)
1736+
&& (!IS_NSIB_OWNED(BOOT_CURR_IMG(state)))) {
17371737
rc = swap_set_image_ok(BOOT_CURR_IMG(state));
17381738
if (rc != 0) {
17391739
BOOT_SWAP_TYPE(state) = swap_type = BOOT_SWAP_TYPE_PANIC;
@@ -1760,7 +1760,7 @@ boot_perform_update(struct boot_loader_state *state, struct boot_status *bs)
17601760
}
17611761
#endif /* MCUBOOT_HW_ROLLBACK_PROT */
17621762

1763-
if (BOOT_IS_UPGRADE(swap_type)) {
1763+
if (BOOT_IS_UPGRADE(swap_type) && (!IS_NSIB_OWNED(BOOT_CURR_IMG(state)))) {
17641764
rc = swap_set_copy_done(BOOT_CURR_IMG(state));
17651765
if (rc != 0) {
17661766
BOOT_SWAP_TYPE(state) = BOOT_SWAP_TYPE_PANIC;
@@ -1796,8 +1796,8 @@ boot_complete_partial_swap(struct boot_loader_state *state,
17961796
/* The following states need image_ok be explicitly set after the
17971797
* swap was finished to avoid a new revert.
17981798
*/
1799-
if (bs->swap_type == BOOT_SWAP_TYPE_REVERT ||
1800-
bs->swap_type == BOOT_SWAP_TYPE_PERM) {
1799+
if ((bs->swap_type == BOOT_SWAP_TYPE_REVERT || bs->swap_type == BOOT_SWAP_TYPE_PERM)
1800+
&& (!IS_NSIB_OWNED(BOOT_CURR_IMG(state)))) {
18011801
rc = swap_set_image_ok(BOOT_CURR_IMG(state));
18021802
if (rc != 0) {
18031803
BOOT_SWAP_TYPE(state) = BOOT_SWAP_TYPE_PANIC;
@@ -2346,10 +2346,12 @@ context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp)
23462346
* pretending we just reverted back to primary slot.
23472347
*/
23482348
#ifndef MCUBOOT_OVERWRITE_ONLY
2349-
/* image_ok needs to be explicitly set to avoid a new revert. */
2350-
rc = swap_set_image_ok(BOOT_CURR_IMG(state));
2351-
if (rc != 0) {
2352-
BOOT_SWAP_TYPE(state) = BOOT_SWAP_TYPE_PANIC;
2349+
if (!IS_NSIB_OWNED(BOOT_CURR_IMG(state))) {
2350+
/* image_ok needs to be explicitly set to avoid a new revert. */
2351+
rc = swap_set_image_ok(BOOT_CURR_IMG(state));
2352+
if (rc != 0) {
2353+
BOOT_SWAP_TYPE(state) = BOOT_SWAP_TYPE_PANIC;
2354+
}
23532355
}
23542356
#endif /* !MCUBOOT_OVERWRITE_ONLY */
23552357
break;

0 commit comments

Comments
 (0)