MCUboot get a wrong image header when using ext flash

Hi, 

I am using NCS 2.2.0, nRF5340.

A few days ago, i add NSIB to my project, but i can't upgrade MCUboot. I find some puzzled quetionns after reading the MCUboot code.

In loader.c, path ${NCS_ROOT}/bootloader/mcuboot/boot/bootutil/src/loader.c

> struct image_header *hdr = (struct image_header *)secondary_fa->fa_off;

It is ok when using internal flash but ext flash.

When i using ext flash, the image header should read from ext flash not 'secondary_fa->fa_off'.

At this point, it will generate erasing the secondary when upgrading target is not the first item later.

Is this question is true?

Best regards,

Yang Hu

Parents
  • Hi,

    I do not see any issues here. Also, we use external flash extensively with MCUBoot in both SDK examples and reference designs, bot for nRF5340 and other devices. I see you have made other threads for specific issues so I suggest you continue in those and we close this (as it seems like it is just based on misunderstandings while reading the MCUboot code, if I am not mistaken).

Reply
  • Hi,

    I do not see any issues here. Also, we use external flash extensively with MCUBoot in both SDK examples and reference designs, bot for nRF5340 and other devices. I see you have made other threads for specific issues so I suggest you continue in those and we close this (as it seems like it is just based on misunderstandings while reading the MCUboot code, if I am not mistaken).

Children
  • Hi,

    Thanks for your reply.

    If i use internal flash,  after this line 'struct image_header *hdr = (struct image_header *)secondary_fa->fa_off;' , i can get the true image_header data, and IMAGE_MAGIC is hdr->ih_magic.

    But if i use ext flash, after this line 'struct image_header *hdr = (struct image_header *)secondary_fa->fa_off;'  the hdr means nothing. The 'secondary_fa->fa_off' is only an address in ext flash which identify Image Header. Then, we should use ' flash_area_read()' to get the true data of Image Header.

    This thread is Using a ext flash problem, and others threads is upgrade MCUboot problem.

    If you think the two threads is the same issue, i will turn to other threads.

    Best Regards,

    Yang Hu

  • By the way, this problem only happen when NSIB is added.

    I have a project that can upgrade application and not adding NSIB.

  • There is an issue when using secure boot (NSIB) on the nRF5340 with external flash in nRF Connect SDK 2.2.0 This is only triggered when using ISIB. In this case MCUboot assumes all images goes to the netcore for some reason. We are looking into this but I do not have a solution at the moment.

    (A colleague of mine is looking into this and have a private case with a colleague of yours (case ID 301063)).