Failed to set MCUboot secondary to external flash. E: Failed to open flash area ID 2 (image 0 slot 1): -2, cannot continue

I have problem placing MCUboot secondary to external flash. I have been testing using nRF9160DK. Project compiles fine but device doesn't boot after flashing the firmware.

Here is the log from serial output of the board. I get error message E: Failed to open flash area ID 2 (image 0 slot 1): -2, cannot continue at the end.

*** Booting nRF Connect SDK v2.8.0-a2386bfc8401 ***
*** Using Zephyr OS v3.7.99-0bc3393fb112 ***
Attempting to boot slot 0.
Attempting to boot from address 0x8200.
I: Verifying signature against key 0.
I: Hash: 0xa5...ef
I: Firmware signature verified.
Firmware version 2
I: Setting monotonic counter (version: 2, slot: 0)

*** Booting MCUboot v2.1.0-dev-4594a8693738 ***
*** Using nRF Connect SDK v2.8.0-a2386bfc8401 ***
*** Using Zephyr OS v3.7.99-0bc3393fb112 ***
I: Starting bootloader
E: Failed to open flash area ID 2 (image 0 slot 1): -2, cannot continue

Here is simple project which I have been trying to use.

app_eft.zip

  • Hello,

    Samples from the SDK work fine. Changing SB_CONFIG_SECURE_BOOT_APPCORE=y from y to n didn't solve problem.

    I have enabled partition manager on overlay and also enabled partition manager for the external flash with 

    SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
    The debug logging for MCUboot didn't show more than what is in first post. The whole project is in zip file on first post.
  • Hello,

    I checked the ZIP file you shared, but I don't see a partition manager file defining the secondary slot in the external flash. Before integrating the external flash with MCUboot, please test whether you can write to and read from the external flash using a basic SPI/QSPI test sample provided by Zephyr (see the sample). I recommend referring to the MCUboot external flash test sample included in the SDK.

    Kind regards,
    Abhijith

  • Hello,

    I tried those samples and I managed to communicate with external flash using the samples. However that didn't help to solve my original problem.

    Here is the pm_static.yml file which is generated in build folder (copied partitions.yml from build folder and renamed to pm_static.yml). It shows that partition manager has allocated mcuboot_secondary to external flash.

    EMPTY_0:
      address: 0x14000
      end_address: 0x18000
      placement:
        before:
        - s1_pad
      region: flash_primary
      size: 0x4000
    EMPTY_1:
      address: 0x24000
      end_address: 0x28000
      placement:
        before:
        - mcuboot_pad
      region: flash_primary
      size: 0x4000
    app:
      address: 0x38000
      end_address: 0x100000
      region: flash_primary
      size: 0xc8000
    app_image:
      address: 0x28200
      end_address: 0x100000
      orig_span: &id001
      - tfm
      - app
      region: flash_primary
      size: 0xd7e00
      span: *id001
    b0:
      address: 0x0
      end_address: 0x8000
      placement:
        after:
        - start
      region: flash_primary
      size: 0x8000
    b0_container:
      address: 0x0
      end_address: 0x8000
      orig_span: &id002
      - b0
      region: flash_primary
      size: 0x8000
      span: *id002
    external_flash:
      address: 0xd8000
      end_address: 0x800000
      region: external_flash
      size: 0x728000
    mcuboot:
      address: 0x8200
      end_address: 0x14000
      placement:
        align:
          end: 0x1000
        before:
        - mcuboot_primary
      region: flash_primary
      sharers: 0x1
      size: 0xbe00
    mcuboot_pad:
      address: 0x28000
      end_address: 0x28200
      placement:
        align:
          start: 0x8000
        before:
        - mcuboot_primary_app
      region: flash_primary
      sharers: 0x2
      size: 0x200
    mcuboot_primary:
      address: 0x28000
      end_address: 0x100000
      orig_span: &id003
      - app
      - tfm
      - mcuboot_pad
      region: flash_primary
      size: 0xd8000
      span: *id003
    mcuboot_primary_app:
      address: 0x28200
      end_address: 0x100000
      orig_span: &id004
      - app
      - tfm
      region: flash_primary
      size: 0xd7e00
      span: *id004
    mcuboot_secondary:
      address: 0x0
      device: DT_CHOSEN(nordic_pm_ext_flash)
      end_address: 0xd8000
      placement:
        align:
          start: 0x4
      region: external_flash
      share_size:
      - mcuboot_primary
      size: 0xd8000
    mcuboot_sram:
      address: 0x20000000
      end_address: 0x20008000
      orig_span: &id005
      - tfm_sram
      region: sram_primary
      size: 0x8000
      span: *id005
    nrf_modem_lib_ctrl:
      address: 0x20008000
      end_address: 0x200084e8
      inside:
      - sram_nonsecure
      placement:
        after:
        - tfm_sram
        - start
      region: sram_primary
      size: 0x4e8
    nrf_modem_lib_rx:
      address: 0x2000a568
      end_address: 0x2000c568
      inside:
      - sram_nonsecure
      placement:
        after:
        - nrf_modem_lib_tx
      region: sram_primary
      size: 0x2000
    nrf_modem_lib_sram:
      address: 0x20008000
      end_address: 0x2000c568
      orig_span: &id006
      - nrf_modem_lib_ctrl
      - nrf_modem_lib_tx
      - nrf_modem_lib_rx
      region: sram_primary
      size: 0x4568
      span: *id006
    nrf_modem_lib_tx:
      address: 0x200084e8
      end_address: 0x2000a568
      inside:
      - sram_nonsecure
      placement:
        after:
        - nrf_modem_lib_ctrl
      region: sram_primary
      size: 0x2080
    otp:
      address: 0xff8388
      end_address: 0xff83fc
      region: otp
      size: 0x74
    provision:
      address: 0xff8108
      end_address: 0xff8388
      region: otp
      size: 0x280
    s0:
      address: 0x8000
      end_address: 0x14000
      orig_span: &id007
      - mcuboot
      - s0_pad
      region: flash_primary
      size: 0xc000
      span: *id007
    s0_image:
      address: 0x8200
      end_address: 0x14000
      orig_span: &id008
      - mcuboot
      region: flash_primary
      size: 0xbe00
      span: *id008
    s0_pad:
      address: 0x8000
      end_address: 0x8200
      placement:
        after:
        - b0_container
        align:
          start: 0x8000
      region: flash_primary
      share_size:
      - mcuboot_pad
      size: 0x200
    s1:
      address: 0x18000
      end_address: 0x24000
      orig_span: &id009
      - s1_pad
      - s1_image
      region: flash_primary
      size: 0xc000
      span: *id009
    s1_image:
      address: 0x18200
      end_address: 0x24000
      placement:
        after:
        - s1_pad
        - s0
      region: flash_primary
      share_size:
      - mcuboot
      size: 0xbe00
    s1_pad:
      address: 0x18000
      end_address: 0x18200
      placement:
        after:
        - s0
        align:
          start: 0x8000
      region: flash_primary
      share_size:
      - mcuboot_pad
      size: 0x200
    sram_nonsecure:
      address: 0x20008000
      end_address: 0x20040000
      orig_span: &id010
      - sram_primary
      - nrf_modem_lib_ctrl
      - nrf_modem_lib_tx
      - nrf_modem_lib_rx
      region: sram_primary
      size: 0x38000
      span: *id010
    sram_primary:
      address: 0x2000c568
      end_address: 0x20040000
      region: sram_primary
      size: 0x33a98
    sram_secure:
      address: 0x20000000
      end_address: 0x20008000
      orig_span: &id011
      - tfm_sram
      region: sram_primary
      size: 0x8000
      span: *id011
    tfm:
      address: 0x28200
      end_address: 0x38000
      inside:
      - mcuboot_primary_app
      placement:
        before:
        - app
      region: flash_primary
      size: 0xfe00
    tfm_nonsecure:
      address: 0x38000
      end_address: 0x100000
      orig_span: &id012
      - app
      region: flash_primary
      size: 0xc8000
      span: *id012
    tfm_secure:
      address: 0x28000
      end_address: 0x38000
      orig_span: &id013
      - mcuboot_pad
      - tfm
      region: flash_primary
      size: 0x10000
      span: *id013
    tfm_sram:
      address: 0x20000000
      end_address: 0x20008000
      inside:
      - sram_secure
      placement:
        after:
        - start
      region: sram_primary
      size: 0x8000

  • Hi Markus

    Abhijith is out of office, so I'll be looking after this case in his absence. I noticed that you're missing the SB_CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y config set in your sysbuild.conf file. So start by adding that and see if that makes any difference on your end.

    Best regards,

    Simon

Related