This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MCUBoot "reading sectors failed" problem with nrf-sdk v1.6.0

Hi all

We are switching to nrf-sdk v1.6.0 in our project and encountered a problem with MCUBoot.

The image builds successfully and can be flashed successfully as well. MCUBoot loads but is then unable to find a bootable image. There's a message which says:

W: Failed reading sectors; BOOT_MAX_IMG_SECTORS=128 - too small?

I tried increasing BOOT_MAX_IMG_SECTORS up to 91216. But there's still the same error message. I can't increase it more otherwise it overlaps SRAM region. I think the problem is somewhere else but I don't know where. Can someone give me a hint where to look for the problem?

I read that BOOT_MAX_IMG_SECTORS configuration is important for swapping the image in the secondary slot to the primary slot after an update.
I thought as a workaround I could configure MCUBoot to work in XIP Mode "execute in place", which does not need swapping and thus my initial problems disappears. Does anyone have a recommendation if it is a good idea to use XIP?

best regards

  • Attached below the contents of the partitions.yml. This corresponds to the configuration from my previous posts.

    EMPTY_0:
      address: 0xc000
      end_address: 0x10000
      placement:
        before:
        - mcuboot_pad
      region: flash_primary
      size: 0x4000
    app:
      address: 0x20200
      end_address: 0x88000
      region: flash_primary
      size: 0x67e00
    mcuboot:
      address: 0x0
      end_address: 0xc000
      placement:
        before:
        - mcuboot_primary
      region: flash_primary
      size: 0xc000
    mcuboot_pad:
      address: 0x10000
      end_address: 0x10200
      placement:
        align:
          start: 0x8000
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x10000
      end_address: 0x88000
      orig_span: &id001
      - app
      - mcuboot_pad
      - spm
      region: flash_primary
      sharers: 0x1
      size: 0x78000
      span: *id001
    mcuboot_primary_app:
      address: 0x10200
      end_address: 0x88000
      orig_span: &id002
      - app
      - spm
      region: flash_primary
      size: 0x77e00
      span: *id002
    mcuboot_secondary:
      address: 0x88000
      end_address: 0x100000
      placement:
        after:
        - mcuboot_primary
        align:
          start: 0x8000
      region: flash_primary
      share_size:
      - mcuboot_primary
      size: 0x78000
    nrf_modem_lib_ctrl:
      address: 0x20010000
      end_address: 0x200104e8
      inside:
      - sram_nonsecure
      placement:
        after:
        - spm_sram
        - start
      region: sram_primary
      size: 0x4e8
    nrf_modem_lib_rx:
      address: 0x200124e8
      end_address: 0x200144e8
      inside:
      - sram_nonsecure
      placement:
        after:
        - nrf_modem_lib_tx
      region: sram_primary
      size: 0x2000
    nrf_modem_lib_sram:
      address: 0x20010000
      end_address: 0x200144e8
      orig_span: &id003
      - nrf_modem_lib_ctrl
      - nrf_modem_lib_tx
      - nrf_modem_lib_rx
      region: sram_primary
      size: 0x44e8
      span: *id003
    nrf_modem_lib_tx:
      address: 0x200104e8
      end_address: 0x200124e8
      inside:
      - sram_nonsecure
      placement:
        after:
        - nrf_modem_lib_ctrl
      region: sram_primary
      size: 0x2000
    otp:
      address: 0xff8108
      end_address: 0xff83fc
      region: otp
      size: 0x2f4
    spm:
      address: 0x10200
      end_address: 0x20200
      inside:
      - mcuboot_primary_app
      placement:
        before:
        - app
      region: flash_primary
      size: 0x10000
    spm_sram:
      address: 0x20000000
      end_address: 0x20010000
      inside:
      - sram_secure
      placement:
        after:
        - start
      region: sram_primary
      size: 0x10000
    sram_nonsecure:
      address: 0x20010000
      end_address: 0x20040000
      orig_span: &id004
      - sram_primary
      - nrf_modem_lib_ctrl
      - nrf_modem_lib_tx
      - nrf_modem_lib_rx
      region: sram_primary
      size: 0x30000
      span: *id004
    sram_primary:
      address: 0x200144e8
      end_address: 0x20040000
      region: sram_primary
      size: 0x2bb18
    sram_secure:
      address: 0x20000000
      end_address: 0x20010000
      orig_span: &id005
      - spm_sram
      region: sram_primary
      size: 0x10000
      span: *id005
    

    Thank you for looking into it.

    best regards

  • Hello Nicolas,

    Have you already tried to do a fresh build by deleting the build folder and recompile the whole application?

    If that doesn’t help you could give it a shot flashing the MCUboot only from the HTTP application update sample to a device with the failing application.

    Can be done by using:

    nrfjprog --program *.hex --sectorerase

    File located in <build_dir>/mcuboot/zephyr/zephyr.hex

    Regards,

    Markus

  • I deleted the build directory and did a clean build. Unfortunately this did not help.

    Next I tried to flash the MCUBoot from the http update sample wiith your provided command. The "failed reading sectors" error disappeard but it is still not able to find a bootable image:

    Here's the output after flashing MCBoot only:
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=_ok=0x3
    I: Boot source: none
    I: Swap type: none
    E: Image in the primary slot is not valid!
    E: Unable to find bootable image

    best regards

  • Thanks a lot for the feedback, Nicolas!

    Something seems to be wrong with the bootloader image in your application, then. I’m afraid I can not tell you much more than this at the moment.

    When building the application in NCS v1.6.0, does the compiler throw any warnings or something that is different compared to the build in NCS you are switching from?

    Regards,

    Markus

  • Hi Markus

    I found the problem. As you said, the bootloader image had a problem. And this problem was introduced by the following CMake snippet which is part of our project CMakeLists.txt:

    if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/mcuboot.conf")
    list(APPEND mcuboot_OVERLAY_CONFIG
            "${CMAKE_CURRENT_SOURCE_DIR}/mcuboot.conf")
    endif()

    This worked fine for the previous version, but for 1.6 this is breaking the MCUBoot build configuration for some reason. Unfortunately I couldn't see any hint about a problem in the build output...

    The intention of this script is to append project specific configuration to MCUBoot, namely which key to use for the signature check, which key algorithm, etc.

    I am now looking for a solution to append my MCUBoot config without modifying the external source files.
    Do you know how this can be done? Or anyone else has an idea?

    best regards

Related