Secure bootloader chain + two-stage upgradable bootloader MCUBOOT

I am working with nRF connect SDK with nRF5340DK. I am compiling code using nRF connect (ncs-1.8.0) for VS code with nrf5340dk_nrf5340_cpuapp board.

prj.conf as below,

CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_MCUMGR=y
CONFIG_SECURE_BOOT=y
Using this I can enabling two-stage bootloader, here are the log,
 
*** Booting Zephyr OS build v2.7.0-ncs1 ***

Attempting to boot slot 0.

Attempting to boot from address 0x8200.

Verifying signature against key 0.

Hash: 0x12...93

Firmware signature verified.

Firmware version 1

Booting (0x8200).

*** Booting Zephyr OS build v2.7.0-ncs1 ***

I: Starting bootloader
I: Primary image: magic=good, swap_type=0x3, copy_done=0x1, image_ok=0x1
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Swap type: none
I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Bootloader chainload address offset: 0x28000
I: Jumping to the first image slot
*** Booting Zephyr OS build v2.7.0-ncs1 ***
I can firmware upgrade over-the-air (FOTA) for application using app_update.bin file.
Question:
1) How can I upgrade the second stage bootloader(MCUBoot bootloader)?
2) Which bin file to upload for upgrade the second stage bootloader?
Parents Reply
  • I think I found a fix for being able to update the network core while NSIB is enabled. Apply this patch to bootloader/mcuboot (associated with NCS v1.9.0):

    diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c
    index d5c370c4..7b2d823b 100644
    --- a/boot/bootutil/src/loader.c
    +++ b/boot/bootutil/src/loader.c
    @@ -926,6 +926,7 @@ boot_validated_swap_type(struct boot_loader_state *state,
             vtable = (uint32_t *)(vtable_addr);
             reset_addr = vtable[1];
     #ifdef PM_S1_ADDRESS
    +        if(reset_addr < PM_CPUNET_B0N_ADDRESS){ 
             const struct flash_area *primary_fa;
             int rc = flash_area_open(flash_area_id_from_multi_image_slot(
                         BOOT_CURR_IMG(state),
    @@ -942,6 +943,7 @@ boot_validated_swap_type(struct boot_loader_state *state,
                 */
                 return BOOT_SWAP_TYPE_NONE;
             }
    +        }
     #endif /* PM_S1_ADDRESS */
         }
     #endif /* PM_S1_ADDRESS || CONFIG_SOC_NRF5340_CPUAPP */
    

    I will do some more testing and provide you with the complete sample and the patch.

    Best regards,

    Simon

Children
Related