zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.8k stars 6.58k forks source link

mcuboot+application don't start on mimxrt1050_evk #80284

Open blemouzy opened 1 week ago

blemouzy commented 1 week ago

Describe the bug

With default flash SPI partitions layout, flashing an application seems to erase mcuboot on mimxrt1050_evk.

Tested with Zephyr v3.7.0 and Zephyr main (39917ae5e6423fe74edce399b927ddff38670817).

To Reproduce

  1. Flash mcuboot
cd bootloader/mcuboot/boot/zephyr/
echo "CONFIG_BOOT_SIGNATURE_TYPE_NONE=y" >> prj.conf
west build -b mimxrt1050_evk@hyperflash
west flash --runner=jlink --erase

==> mcuboot starts as expected:

*** Booting MCUboot v2.1.0-rc1-36-gfb2cf0ec3da3 ***
*** Using Zephyr OS build v3.7.0 ***
I: Starting bootloader
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
W: Failed reading image headers; Image=0
E: Unable to find bootable image
  1. Flash application
cd zephyr/samples/basic/blinky/
echo "CONFIG_BOOTLOADER_MCUBOOT=y" >> prj.conf
echo "CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE=y" >> prj.conf
west build -b mimxrt1050_evk@hyperflash
west flash --runner=jlink

==> nothing is printed on serial like application programming erased mcuboot.

Expected behavior

mcuboot and application start:

*** Booting MCUboot v2.1.0-rc1-36-gfb2cf0ec3da3 ***
*** Using Zephyr OS build v3.7.0 ***
I: Starting bootloader
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: Image index: 0, Swap type: none
I: Bootloader chainload address offset: 0x100000
I: Jumping to the first image slot
*** Booting Zephyr OS build v3.7.0 ***
LED state: OFF
LED state: ON

Additional context

I made some tests and with the following flash SPI partition change, mcuboot and application start as expected:

zephyr/boards/nxp/mimxrt1050_evk/mimxrt1050_evk_mimxrt1052_hyperflash.overlay

partitions {
    compatible = "fixed-partitions";
    #address-cells = <1>;
    #size-cells = <1>;
    boot_partition: partition@0 {
        label = "mcuboot";
        reg = <0x00000000 DT_SIZE_M(1)>;
    };
    /* The MCUBoot swap-move algorithm uses the last 14 sectors
        * of the primary slot0 for swap status and move.
        */
    slot0_partition: partition@100000 {
        label = "image-0";
        reg = <0x00100000 DT_SIZE_M(3)>;
    };
    slot1_partition: partition@400000 {
        label = "image-1";
        reg = <0x00400000 DT_SIZE_M(3)>;
    };
    storage_partition: partition@700000 {
        label = "storage";
        reg = <0x00700000 DT_SIZE_M(58)>;
    };
};

I hope this is helpful.

butok commented 1 day ago

Hi @blemouzy

Going to order the board.
Are you using the IMXRT1050-EVKB board (https://www.nxp.com/part/IMXRT1050-EVKB)?

Meanwhile, could you try the the MCUBoot sysbuild sample:

blemouzy commented 1 day ago

Hi @butok

Are you using the IMXRT1050-EVKB board (https://www.nxp.com/part/IMXRT1050-EVKB)?

Yes (revision B1).

Meanwhile, could you try the the MCUBoot sysbuild sample:

* west build -p always -b mimxrt1050_evk --sysbuild samples/sysbuild/with_mcuboot

* west flash

Same issue.