Update mcuboot with SMP

I cannot find any information on how to update mcuboot over SMP when using the immutable bootloader.

I have my NRF52840 setup with the chained bootloader: b0 -> mcuboot -> app.

Is there a way to update mcuboot via SMP (UART or BLE)?

I saw this post but nothing newer.

Parents
  • Hi

    I have not been able to find any example showcasing this.

    But from our Adding an upgradable bootloader and nRF Secure Immutable Bootloader, it should be possible to do.

    Regards,
    Sigurd Hellesvik

  • I have read through all of that documentation many many times. I am looking for detailed steps of how to update the MCUboot S0/S1 images with mcumgr via UART/BLE.

  • I think it should be to use the SMP server to upload an image of MCUBoot to the space where the old MCUBoot were.

    I am trying to make a sample showcasing this, but I were not able to make it work today. I will continue on the sample on Monday.

    Regards,
    Sigurd Hellesvik

  • Hi

    Sorry for the delay.

    I am not done yet, but I have a sample which almost works. See my nsib_mcuboot_smp sample.
    This sample is able to use SMP Server to upload MCUBoot once, but I am not able to do it again with the new version of MCUBoot.

    You can test the sample and see if it is able to help you with your issue.

    I will continue debugging my sample, but can not promise anything on how long time this will take.

    Regards,
    Sigurd Hellesvik

  • I tested with your example and it works for updating mcuboot once like you describe.

    I suspect to update mcuboot a second time, you need to use signed_by_mcuboot_and_b0_s0_image_update.bin but I havent tried this yet.

    I tried this with my code and its not working correctly. I suspect it is because I have slot1 configured to be in external QSPI.

    So I tried your example with external QSPI for slot1 and it breaks. Seems there is an issue if you want to put slot1 in QSPI. I would like to see if we can get this resolved because I need to have slot1 in QSPI.

    Heres the code diff I tested with against your sample:

    diff --git a/bootloader_samples/nsib_mcuboot_smp/boards/nrf52840dk_nrf52840.overlay b/bootloader_samples/nsib_mcuboot_smp/boards/nrf52840dk_nrf52840.overlay
    new file mode 100644
    index 0000000..b58f8c7
    --- /dev/null
    +++ b/bootloader_samples/nsib_mcuboot_smp/boards/nrf52840dk_nrf52840.overlay
    @@ -0,0 +1,29 @@
    +
    +/ {
    +	chosen {
    +		/* required for partition manager to use external flash */
    +		nordic,pm-ext-flash = &mx25r64;
    +	};
    +};
    +
    +/delete-node/ &slot1_partition;
    +/delete-node/ &scratch_partition;
    +
    +
    +&mx25r64 {
    +
    +        partitions {
    +                compatible = "fixed-partitions";
    +                #address-cells = <1>;
    +                #size-cells = <1>;
    +
    +                slot1_partition: partition@0 {
    +                        label = "image-1";
    +                        reg = <0x00000000 0x00067000>;
    +                };
    +                scratch_partition: partition@da000 {
    +                        label = "image-scratch";
    +                        reg = <0x00070000 0x00001000>;
    +                };
    +        };
    +};
    diff --git a/bootloader_samples/nsib_mcuboot_smp/child_image/mcuboot/prj.conf b/bootloader_samples/nsib_mcuboot_smp/child_image/mcuboot/prj.conf
    index 5fda561..12bc10e 100644
    --- a/bootloader_samples/nsib_mcuboot_smp/child_image/mcuboot/prj.conf
    +++ b/bootloader_samples/nsib_mcuboot_smp/child_image/mcuboot/prj.conf
    @@ -7,4 +7,10 @@ CONFIG_MAIN_STACK_SIZE=10240
     CONFIG_LOG=y
     CONFIG_LOG_MODE_MINIMAL=y
     
    -CONFIG_FW_INFO_FIRMWARE_VERSION=5
    +CONFIG_FW_INFO_FIRMWARE_VERSION=2
    +
    +CONFIG_MULTITHREADING=y
    +CONFIG_NORDIC_QSPI_NOR=y
    +CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    +CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=4
    +CONFIG_BOOT_MAX_IMG_SECTORS=256
    diff --git a/bootloader_samples/nsib_mcuboot_smp/prj.conf b/bootloader_samples/nsib_mcuboot_smp/prj.conf
    index f497585..672a8da 100644
    --- a/bootloader_samples/nsib_mcuboot_smp/prj.conf
    +++ b/bootloader_samples/nsib_mcuboot_smp/prj.conf
    @@ -10,5 +10,9 @@ CONFIG_SECURE_BOOT=y
     CONFIG_SB_SIGNING_KEY_FILE="nsib_priv.pem"
     CONFIG_BUILD_S1_VARIANT=y
     
    -CONFIG_FW_INFO_FIRMWARE_VERSION=1
    -CONFIG_MCUBOOT_IMAGE_VERSION="1.1.1"
    +CONFIG_MCUBOOT_IMAGE_VERSION="1.0.0"
    +
    +CONFIG_MULTITHREADING=y
    +CONFIG_NORDIC_QSPI_NOR=y
    +CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    +CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=4
    

Reply
  • I tested with your example and it works for updating mcuboot once like you describe.

    I suspect to update mcuboot a second time, you need to use signed_by_mcuboot_and_b0_s0_image_update.bin but I havent tried this yet.

    I tried this with my code and its not working correctly. I suspect it is because I have slot1 configured to be in external QSPI.

    So I tried your example with external QSPI for slot1 and it breaks. Seems there is an issue if you want to put slot1 in QSPI. I would like to see if we can get this resolved because I need to have slot1 in QSPI.

    Heres the code diff I tested with against your sample:

    diff --git a/bootloader_samples/nsib_mcuboot_smp/boards/nrf52840dk_nrf52840.overlay b/bootloader_samples/nsib_mcuboot_smp/boards/nrf52840dk_nrf52840.overlay
    new file mode 100644
    index 0000000..b58f8c7
    --- /dev/null
    +++ b/bootloader_samples/nsib_mcuboot_smp/boards/nrf52840dk_nrf52840.overlay
    @@ -0,0 +1,29 @@
    +
    +/ {
    +	chosen {
    +		/* required for partition manager to use external flash */
    +		nordic,pm-ext-flash = &mx25r64;
    +	};
    +};
    +
    +/delete-node/ &slot1_partition;
    +/delete-node/ &scratch_partition;
    +
    +
    +&mx25r64 {
    +
    +        partitions {
    +                compatible = "fixed-partitions";
    +                #address-cells = <1>;
    +                #size-cells = <1>;
    +
    +                slot1_partition: partition@0 {
    +                        label = "image-1";
    +                        reg = <0x00000000 0x00067000>;
    +                };
    +                scratch_partition: partition@da000 {
    +                        label = "image-scratch";
    +                        reg = <0x00070000 0x00001000>;
    +                };
    +        };
    +};
    diff --git a/bootloader_samples/nsib_mcuboot_smp/child_image/mcuboot/prj.conf b/bootloader_samples/nsib_mcuboot_smp/child_image/mcuboot/prj.conf
    index 5fda561..12bc10e 100644
    --- a/bootloader_samples/nsib_mcuboot_smp/child_image/mcuboot/prj.conf
    +++ b/bootloader_samples/nsib_mcuboot_smp/child_image/mcuboot/prj.conf
    @@ -7,4 +7,10 @@ CONFIG_MAIN_STACK_SIZE=10240
     CONFIG_LOG=y
     CONFIG_LOG_MODE_MINIMAL=y
     
    -CONFIG_FW_INFO_FIRMWARE_VERSION=5
    +CONFIG_FW_INFO_FIRMWARE_VERSION=2
    +
    +CONFIG_MULTITHREADING=y
    +CONFIG_NORDIC_QSPI_NOR=y
    +CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    +CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=4
    +CONFIG_BOOT_MAX_IMG_SECTORS=256
    diff --git a/bootloader_samples/nsib_mcuboot_smp/prj.conf b/bootloader_samples/nsib_mcuboot_smp/prj.conf
    index f497585..672a8da 100644
    --- a/bootloader_samples/nsib_mcuboot_smp/prj.conf
    +++ b/bootloader_samples/nsib_mcuboot_smp/prj.conf
    @@ -10,5 +10,9 @@ CONFIG_SECURE_BOOT=y
     CONFIG_SB_SIGNING_KEY_FILE="nsib_priv.pem"
     CONFIG_BUILD_S1_VARIANT=y
     
    -CONFIG_FW_INFO_FIRMWARE_VERSION=1
    -CONFIG_MCUBOOT_IMAGE_VERSION="1.1.1"
    +CONFIG_MCUBOOT_IMAGE_VERSION="1.0.0"
    +
    +CONFIG_MULTITHREADING=y
    +CONFIG_NORDIC_QSPI_NOR=y
    +CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    +CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=4
    

Children
Related