nRF9160 FOTA using sdk2.1.0 and SPM fails to get flash area from ID

sdk v2.1.0

nRF9160 modem v1.3.5

Hi,

I am changing my application, based on a LWM2M client, from SDK 1.9.1 to SDK 2.1.0 while maintaining the use of SPM.

Everything works correctly except when I try to do a FOTA...

After completing the image download, the dfu_target_mcuboot library returns error -14 (-ENOENT) and FOTA is cancelled.

Log output:

[00:03:19.476,837] <inf> UC__FOTA: HTTPS download: 99%
[00:03:19.477,294] <dbg> fota_download: download_client_callback: Progress: 520192/524903 bytes
[00:03:19.860,076] <dbg> fota_download: download_client_callback: Progress: 521216/524903 bytes
[00:03:20.115,844] <dbg> fota_download: download_client_callback: Progress: 522240/524903 bytes
[00:03:20.342,803] <dbg> fota_download: download_client_callback: Progress: 523264/524903 bytes
[00:03:20.573,913] <dbg> fota_download: download_client_callback: Progress: 524288/524903 bytes
[00:03:20.853,637] <inf> UC__FOTA: HTTPS download: 100%
[00:03:20.854,125] <dbg> fota_download: download_client_callback: Progress: 524903/524903 bytes
[00:03:20.918,609] <err> dfu_target_mcuboot: boot_request_upgrade_multi for image-0 error -14
[00:03:20.919,830] <err> fota_download: dfu_target_done error: -14

After digging into the SDK I notice that the flash_area_open() function cannot get the area with ID=2 (mcuboot_secondary) from the list of existing areas...

int flash_area_open(uint8_t id, const struct flash_area **fap)
{
	const struct flash_area *area;

	if (flash_map == NULL) {
		return -EACCES;
	}
	/* RC add */
	LOG_DBG("flashID:%d | flash_map_entries:%d", id, flash_map_entries);
	for (int i = 0; i < flash_map_entries; i++) {
		LOG_DBG("flash_map[%d].fa_id=%d", i, flash_map[i].fa_id);
	}
	/* RC end */
	area = get_flash_area_from_id(id);
	if (area == NULL) {
		return -ENOENT;
	}

	if (!area->fa_dev || !device_is_ready(area->fa_dev)) {
		return -ENODEV;
	}

	*fap = area;

	return 0;
}

Log output using sdk2.1.0

[01:25:12.470,458] <inf> UC__FOTA: HTTPS download: 100%
[01:25:12.470,916] <dbg> fota_download: download_client_callback: Progress: 524903/524903 bytes
[01:25:12.523,162] <dbg> fota_download: download_client_callback: dfu_target_done error: 0
[01:25:12.523,712] <dbg> flash_map: flash_area_open: flashID:2 | flash_map_entries:16
[01:25:12.524,261] <dbg> flash_map: flash_area_open: flash_map[0].fa_id=0
[01:25:12.524,780] <dbg> flash_map: flash_area_open: flash_map[1].fa_id=1
[01:25:12.525,299] <dbg> flash_map: flash_area_open: flash_map[2].fa_id=3
[01:25:12.525,817] <dbg> flash_map: flash_area_open: flash_map[3].fa_id=4
[01:25:12.526,336] <dbg> flash_map: flash_area_open: flash_map[4].fa_id=5
[01:25:12.526,855] <dbg> flash_map: flash_area_open: flash_map[5].fa_id=6
[01:25:12.527,343] <dbg> flash_map: flash_area_open: flash_map[6].fa_id=7
[01:25:12.527,862] <dbg> flash_map: flash_area_open: flash_map[7].fa_id=8
[01:25:12.528,381] <dbg> flash_map: flash_area_open: flash_map[8].fa_id=9
[01:25:12.528,900] <dbg> flash_map: flash_area_open: flash_map[9].fa_id=10
[01:25:12.529,418] <dbg> flash_map: flash_area_open: flash_map[10].fa_id=11
[01:25:12.529,937] <dbg> flash_map: flash_area_open: flash_map[11].fa_id=12
[01:25:12.530,487] <dbg> flash_map: flash_area_open: flash_map[12].fa_id=13
[01:25:12.531,005] <dbg> flash_map: flash_area_open: flash_map[13].fa_id=14
[01:25:12.531,524] <dbg> flash_map: flash_area_open: flash_map[14].fa_id=15
[01:25:12.532,043] <dbg> flash_map: flash_area_open: flash_map[15].fa_id=17
[01:25:12.532,592] <dbg> mcuboot_util: boot_set_pending_multi: flash_area_open id:2 error: -2
[01:25:12.533,172] <err> dfu_target_mcuboot: boot_request_upgrade_multi for image-0 error -14
[01:25:12.533,752] <dbg> dfu_target: dfu_target_schedule_update: dfu_target_schedule_update error: -14
[01:25:12.534,332] <err> fota_download: dfu_target_done error: -14
[01:25:12.534,790] <err> UC__FOTA: Error while downloading new firmware

Log output using sdk1.9.1

[00:00:34.082,061] <dbg> flash_map.flash_area_open: flashID:2 | flash_map_entries:18
[00:00:34.082,550] <dbg> flash_map.flash_area_open: flash_map[0].fa_id=0
[00:00:34.083,007] <dbg> flash_map.flash_area_open: flash_map[1].fa_id=1
[00:00:34.083,465] <dbg> flash_map.flash_area_open: flash_map[2].fa_id=2
[00:00:34.083,923] <dbg> flash_map.flash_area_open: flash_map[3].fa_id=3
[00:00:34.084,381] <dbg> flash_map.flash_area_open: flash_map[4].fa_id=4
[00:00:34.084,808] <dbg> flash_map.flash_area_open: flash_map[5].fa_id=5
[00:00:34.085,266] <dbg> flash_map.flash_area_open: flash_map[6].fa_id=6
[00:00:34.085,723] <dbg> flash_map.flash_area_open: flash_map[7].fa_id=7
[00:00:34.086,181] <dbg> flash_map.flash_area_open: flash_map[8].fa_id=8
[00:00:34.086,639] <dbg> flash_map.flash_area_open: flash_map[9].fa_id=9
[00:00:34.087,066] <dbg> flash_map.flash_area_open: flash_map[10].fa_id=10
[00:00:34.087,554] <dbg> flash_map.flash_area_open: flash_map[11].fa_id=11
[00:00:34.088,012] <dbg> flash_map.flash_area_open: flash_map[12].fa_id=12
[00:00:34.088,470] <dbg> flash_map.flash_area_open: flash_map[13].fa_id=13
[00:00:34.088,928] <dbg> flash_map.flash_area_open: flash_map[14].fa_id=14
[00:00:34.089,385] <dbg> flash_map.flash_area_open: flash_map[15].fa_id=15
[00:00:34.089,843] <dbg> flash_map.flash_area_open: flash_map[16].fa_id=16
[00:00:34.090,332] <dbg> flash_map.flash_area_open: flash_map[17].fa_id=17

But consulting the build\pm.config and partitions.yml file, the areas are there and correctly defined...

pm.config using sdk 2.1.0:

PM_B0_OFFSET=0x0
PM_B0_ADDRESS=0x0
PM_B0_END_ADDRESS=0x8000
PM_B0_SIZE=0x8000
PM_B0_NAME=b0
PM_B0_ID=0
PM_b0_ID=PM_B0_ID
PM_b0_IS_ENABLED=1
PM_0_LABEL=B0
PM_B0_CONTAINER_OFFSET=0x0
PM_B0_CONTAINER_ADDRESS=0x0
PM_B0_CONTAINER_END_ADDRESS=0x8000
PM_B0_CONTAINER_SIZE=0x8000
PM_B0_CONTAINER_NAME=b0_container
PM_B0_CONTAINER_ID=1
PM_b0_container_ID=PM_B0_CONTAINER_ID
PM_b0_container_IS_ENABLED=1
PM_1_LABEL=B0_CONTAINER
PM_B0_CONTAINER_SPAN="b0"
PM_MCUBOOT_SECONDARY_OFFSET=0x0
PM_MCUBOOT_SECONDARY_ADDRESS=0x0
PM_MCUBOOT_SECONDARY_END_ADDRESS=0xd0000
PM_MCUBOOT_SECONDARY_SIZE=0xd0000
PM_MCUBOOT_SECONDARY_NAME=mcuboot_secondary
PM_MCUBOOT_SECONDARY_ID=2
PM_mcuboot_secondary_ID=PM_MCUBOOT_SECONDARY_ID
PM_mcuboot_secondary_IS_ENABLED=1
PM_2_LABEL=MCUBOOT_SECONDARY
PM_S0_OFFSET=0x8000
PM_S0_ADDRESS=0x8000
PM_S0_END_ADDRESS=0x18000
PM_S0_SIZE=0x10000
PM_S0_NAME=s0
PM_S0_ID=3
PM_s0_ID=PM_S0_ID
PM_s0_IS_ENABLED=1
PM_3_LABEL=S0
PM_S0_SPAN="s0_pad mcuboot"
PM_S0_PAD_OFFSET=0x8000
PM_S0_PAD_ADDRESS=0x8000
PM_S0_PAD_END_ADDRESS=0x8200
PM_S0_PAD_SIZE=0x200
PM_S0_PAD_NAME=s0_pad
PM_S0_PAD_ID=4
PM_s0_pad_ID=PM_S0_PAD_ID
PM_s0_pad_IS_ENABLED=1
PM_4_LABEL=S0_PAD
PM_MCUBOOT_OFFSET=0x8200
PM_MCUBOOT_ADDRESS=0x8200
PM_MCUBOOT_END_ADDRESS=0x18000
PM_MCUBOOT_SIZE=0xfe00
PM_MCUBOOT_NAME=mcuboot
PM_MCUBOOT_ID=5
PM_mcuboot_ID=PM_MCUBOOT_ID
PM_mcuboot_IS_ENABLED=1
PM_5_LABEL=MCUBOOT
PM_S0_IMAGE_OFFSET=0x8200
PM_S0_IMAGE_ADDRESS=0x8200
PM_S0_IMAGE_END_ADDRESS=0x18000
PM_S0_IMAGE_SIZE=0xfe00
PM_S0_IMAGE_NAME=s0_image
PM_S0_IMAGE_ID=6
PM_s0_image_ID=PM_S0_IMAGE_ID
PM_s0_image_IS_ENABLED=1
PM_6_LABEL=S0_IMAGE
PM_S0_IMAGE_SPAN="mcuboot"
PM_S1_OFFSET=0x18000
PM_S1_ADDRESS=0x18000
PM_S1_END_ADDRESS=0x28000
PM_S1_SIZE=0x10000
PM_S1_NAME=s1
PM_S1_ID=7
PM_s1_ID=PM_S1_ID
PM_s1_IS_ENABLED=1
PM_7_LABEL=S1
PM_S1_SPAN="s1_pad s1_image"
PM_S1_PAD_OFFSET=0x18000
PM_S1_PAD_ADDRESS=0x18000
PM_S1_PAD_END_ADDRESS=0x18200
PM_S1_PAD_SIZE=0x200
PM_S1_PAD_NAME=s1_pad
PM_S1_PAD_ID=8
PM_s1_pad_ID=PM_S1_PAD_ID
PM_s1_pad_IS_ENABLED=1
PM_8_LABEL=S1_PAD
PM_S1_IMAGE_OFFSET=0x18200
PM_S1_IMAGE_ADDRESS=0x18200
PM_S1_IMAGE_END_ADDRESS=0x28000
PM_S1_IMAGE_SIZE=0xfe00
PM_S1_IMAGE_NAME=s1_image
PM_S1_IMAGE_ID=9
PM_s1_image_ID=PM_S1_IMAGE_ID
PM_s1_image_IS_ENABLED=1
PM_9_LABEL=S1_IMAGE
PM_MCUBOOT_PAD_OFFSET=0x28000
PM_MCUBOOT_PAD_ADDRESS=0x28000
PM_MCUBOOT_PAD_END_ADDRESS=0x28200
PM_MCUBOOT_PAD_SIZE=0x200
PM_MCUBOOT_PAD_NAME=mcuboot_pad
PM_MCUBOOT_PAD_ID=10
PM_mcuboot_pad_ID=PM_MCUBOOT_PAD_ID
PM_mcuboot_pad_IS_ENABLED=1
PM_10_LABEL=MCUBOOT_PAD
PM_MCUBOOT_PRIMARY_OFFSET=0x28000
PM_MCUBOOT_PRIMARY_ADDRESS=0x28000
PM_MCUBOOT_PRIMARY_END_ADDRESS=0xf8000
PM_MCUBOOT_PRIMARY_SIZE=0xd0000
PM_MCUBOOT_PRIMARY_NAME=mcuboot_primary
PM_MCUBOOT_PRIMARY_ID=11
PM_mcuboot_primary_ID=PM_MCUBOOT_PRIMARY_ID
PM_mcuboot_primary_IS_ENABLED=1
PM_11_LABEL=MCUBOOT_PRIMARY
PM_MCUBOOT_PRIMARY_SPAN="app spm mcuboot_pad"
PM_APP_IMAGE_OFFSET=0x28200
PM_APP_IMAGE_ADDRESS=0x28200
PM_APP_IMAGE_END_ADDRESS=0xf8000
PM_APP_IMAGE_SIZE=0xcfe00
PM_APP_IMAGE_NAME=app_image
PM_APP_IMAGE_ID=12
PM_app_image_ID=PM_APP_IMAGE_ID
PM_app_image_IS_ENABLED=1
PM_12_LABEL=APP_IMAGE
PM_APP_IMAGE_SPAN="spm app"
PM_MCUBOOT_PRIMARY_APP_OFFSET=0x28200
PM_MCUBOOT_PRIMARY_APP_ADDRESS=0x28200
PM_MCUBOOT_PRIMARY_APP_END_ADDRESS=0xf8000
PM_MCUBOOT_PRIMARY_APP_SIZE=0xcfe00
PM_MCUBOOT_PRIMARY_APP_NAME=mcuboot_primary_app
PM_MCUBOOT_PRIMARY_APP_ID=13
PM_mcuboot_primary_app_ID=PM_MCUBOOT_PRIMARY_APP_ID
PM_mcuboot_primary_app_IS_ENABLED=1
PM_13_LABEL=MCUBOOT_PRIMARY_APP
PM_MCUBOOT_PRIMARY_APP_SPAN="app spm"
PM_SPM_OFFSET=0x28200
PM_SPM_ADDRESS=0x28200
PM_SPM_END_ADDRESS=0x38200
PM_SPM_SIZE=0x10000
PM_SPM_NAME=spm
PM_SPM_ID=14
PM_spm_ID=PM_SPM_ID
PM_spm_IS_ENABLED=1
PM_14_LABEL=SPM
PM_APP_OFFSET=0x38200
PM_APP_ADDRESS=0x38200
PM_APP_END_ADDRESS=0xf8000
PM_APP_SIZE=0xbfe00
PM_APP_NAME=app
PM_APP_ID=15
PM_app_ID=PM_APP_ID
PM_app_IS_ENABLED=1
PM_15_LABEL=APP
PM_EXTERNAL_FLASH_OFFSET=0xd0000
PM_EXTERNAL_FLASH_ADDRESS=0xd0000
PM_EXTERNAL_FLASH_END_ADDRESS=0x800000
PM_EXTERNAL_FLASH_SIZE=0x730000
PM_EXTERNAL_FLASH_NAME=external_flash
PM_EXTERNAL_FLASH_ID=16
PM_external_flash_ID=PM_EXTERNAL_FLASH_ID
PM_external_flash_IS_ENABLED=1
PM_16_LABEL=EXTERNAL_FLASH
PM_SETTINGS_STORAGE_OFFSET=0xf8000
PM_SETTINGS_STORAGE_ADDRESS=0xf8000
PM_SETTINGS_STORAGE_END_ADDRESS=0x100000
PM_SETTINGS_STORAGE_SIZE=0x8000
PM_SETTINGS_STORAGE_NAME=settings_storage
PM_SETTINGS_STORAGE_ID=17
PM_settings_storage_ID=PM_SETTINGS_STORAGE_ID
PM_settings_storage_IS_ENABLED=1
PM_17_LABEL=SETTINGS_STORAGE
PM_PROVISION_OFFSET=0x0
PM_PROVISION_ADDRESS=0xff8108
PM_PROVISION_END_ADDRESS=0xff8388
PM_PROVISION_SIZE=0x280
PM_PROVISION_NAME=provision
PM_OTP_OFFSET=0x280
PM_OTP_ADDRESS=0xff8388
PM_OTP_END_ADDRESS=0xff83fc
PM_OTP_SIZE=0x74
PM_OTP_NAME=otp
PM_SPM_SRAM_OFFSET=0x0
PM_SPM_SRAM_ADDRESS=0x20000000
PM_SPM_SRAM_END_ADDRESS=0x20004000
PM_SPM_SRAM_SIZE=0x4000
PM_SPM_SRAM_NAME=spm_sram
PM_SRAM_SECURE_OFFSET=0x0
PM_SRAM_SECURE_ADDRESS=0x20000000
PM_SRAM_SECURE_END_ADDRESS=0x20004000
PM_SRAM_SECURE_SIZE=0x4000
PM_SRAM_SECURE_NAME=sram_secure
PM_SRAM_SECURE_SPAN="spm_sram"
PM_NRF_MODEM_LIB_CTRL_OFFSET=0x4000
PM_NRF_MODEM_LIB_CTRL_ADDRESS=0x20004000
PM_NRF_MODEM_LIB_CTRL_END_ADDRESS=0x200044e8
PM_NRF_MODEM_LIB_CTRL_SIZE=0x4e8
PM_NRF_MODEM_LIB_CTRL_NAME=nrf_modem_lib_ctrl
PM_NRF_MODEM_LIB_SRAM_OFFSET=0x4000
PM_NRF_MODEM_LIB_SRAM_ADDRESS=0x20004000
PM_NRF_MODEM_LIB_SRAM_END_ADDRESS=0x200084e8
PM_NRF_MODEM_LIB_SRAM_SIZE=0x44e8
PM_NRF_MODEM_LIB_SRAM_NAME=nrf_modem_lib_sram
PM_NRF_MODEM_LIB_SRAM_SPAN="nrf_modem_lib_ctrl nrf_modem_lib_tx nrf_modem_lib_rx"
PM_SRAM_NONSECURE_OFFSET=0x4000
PM_SRAM_NONSECURE_ADDRESS=0x20004000
PM_SRAM_NONSECURE_END_ADDRESS=0x20040000
PM_SRAM_NONSECURE_SIZE=0x3c000
PM_SRAM_NONSECURE_NAME=sram_nonsecure
PM_SRAM_NONSECURE_SPAN="sram_primary nrf_modem_lib_ctrl nrf_modem_lib_tx nrf_modem_lib_rx"
PM_NRF_MODEM_LIB_TX_OFFSET=0x44e8
PM_NRF_MODEM_LIB_TX_ADDRESS=0x200044e8
PM_NRF_MODEM_LIB_TX_END_ADDRESS=0x200064e8
PM_NRF_MODEM_LIB_TX_SIZE=0x2000
PM_NRF_MODEM_LIB_TX_NAME=nrf_modem_lib_tx
PM_NRF_MODEM_LIB_RX_OFFSET=0x64e8
PM_NRF_MODEM_LIB_RX_ADDRESS=0x200064e8
PM_NRF_MODEM_LIB_RX_END_ADDRESS=0x200084e8
PM_NRF_MODEM_LIB_RX_SIZE=0x2000
PM_NRF_MODEM_LIB_RX_NAME=nrf_modem_lib_rx
PM_SRAM_PRIMARY_OFFSET=0x84e8
PM_SRAM_PRIMARY_ADDRESS=0x200084e8
PM_SRAM_PRIMARY_END_ADDRESS=0x20040000
PM_SRAM_PRIMARY_SIZE=0x37b18
PM_SRAM_PRIMARY_NAME=sram_primary
PM_NUM=18
PM_ALL_BY_SIZE="otp mcuboot_pad s0_pad s1_pad provision nrf_modem_lib_ctrl nrf_modem_lib_rx nrf_modem_lib_tx spm_sram sram_secure nrf_modem_lib_sram b0 settings_storage b0_container mcuboot s1_image s0_image spm s0 s1 sram_primary sram_nonsecure app app_image mcuboot_primary_app mcuboot_secondary mcuboot_primary external_flash"

partitions.yml using sdk 2.1.0:

app:
  address: 0x38200
  end_address: 0xf8000
  region: flash_primary
  size: 0xbfe00
app_image:
  address: 0x28200
  end_address: 0xf8000
  orig_span: &id001
  - spm
  - app
  region: flash_primary
  size: 0xcfe00
  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: 0xd0000
  end_address: 0x800000
  region: external_flash
  size: 0x730000
mcuboot:
  address: 0x8200
  end_address: 0x18000
  placement:
    before:
    - mcuboot_primary
  region: flash_primary
  sharers: 0x1
  size: 0xfe00
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: 0xf8000
  orig_span: &id003
  - app
  - spm
  - mcuboot_pad
  region: flash_primary
  size: 0xd0000
  span: *id003
mcuboot_primary_app:
  address: 0x28200
  end_address: 0xf8000
  orig_span: &id004
  - app
  - spm
  region: flash_primary
  size: 0xcfe00
  span: *id004
mcuboot_secondary:
  address: 0x0
  device: /soc/peripheral@40000000/spi@b000/mx25l6433f@0
  end_address: 0xd0000
  placement:
    align:
      start: 0x4
  region: external_flash
  share_size:
  - mcuboot_primary
  size: 0xd0000
nrf_modem_lib_ctrl:
  address: 0x20004000
  end_address: 0x200044e8
  inside:
  - sram_nonsecure
  placement:
    after:
    - spm_sram
    - start
  region: sram_primary
  size: 0x4e8
nrf_modem_lib_rx:
  address: 0x200064e8
  end_address: 0x200084e8
  inside:
  - sram_nonsecure
  placement:
    after:
    - nrf_modem_lib_tx
  region: sram_primary
  size: 0x2000
nrf_modem_lib_sram:
  address: 0x20004000
  end_address: 0x200084e8
  orig_span: &id005
  - nrf_modem_lib_ctrl
  - nrf_modem_lib_tx
  - nrf_modem_lib_rx
  region: sram_primary
  size: 0x44e8
  span: *id005
nrf_modem_lib_tx:
  address: 0x200044e8
  end_address: 0x200064e8
  inside:
  - sram_nonsecure
  placement:
    after:
    - nrf_modem_lib_ctrl
  region: sram_primary
  size: 0x2000
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: 0x18000
  orig_span: &id006
  - s0_pad
  - mcuboot
  region: flash_primary
  size: 0x10000
  span: *id006
s0_image:
  address: 0x8200
  end_address: 0x18000
  orig_span: &id007
  - mcuboot
  region: flash_primary
  size: 0xfe00
  span: *id007
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: 0x28000
  orig_span: &id008
  - s1_pad
  - s1_image
  region: flash_primary
  size: 0x10000
  span: *id008
s1_image:
  address: 0x18200
  end_address: 0x28000
  placement:
    after:
    - s1_pad
    - s0
  region: flash_primary
  share_size:
  - mcuboot
  size: 0xfe00
s1_pad:
  address: 0x18000
  end_address: 0x18200
  placement:
    after:
    - s0
    align:
      start: 0x8000
  region: flash_primary
  share_size:
  - mcuboot_pad
  size: 0x200
settings_storage:
  address: 0xf8000
  end_address: 0x100000
  placement:
    before:
    - end
  region: flash_primary
  size: 0x8000
spm:
  address: 0x28200
  end_address: 0x38200
  inside:
  - mcuboot_primary_app
  placement:
    before:
    - app
  region: flash_primary
  size: 0x10000
spm_sram:
  address: 0x20000000
  end_address: 0x20004000
  inside:
  - sram_secure
  placement:
    after:
    - start
  region: sram_primary
  size: 0x4000
sram_nonsecure:
  address: 0x20004000
  end_address: 0x20040000
  orig_span: &id009
  - sram_primary
  - nrf_modem_lib_ctrl
  - nrf_modem_lib_tx
  - nrf_modem_lib_rx
  region: sram_primary
  size: 0x3c000
  span: *id009
sram_primary:
  address: 0x200084e8
  end_address: 0x20040000
  region: sram_primary
  size: 0x37b18
sram_secure:
  address: 0x20000000
  end_address: 0x20004000
  orig_span: &id010
  - spm_sram
  region: sram_primary
  size: 0x4000
  span: *id010

pm.config using sdk 1.9.1:

PM_B0_OFFSET=0x0
PM_B0_ADDRESS=0x0
PM_B0_END_ADDRESS=0x8000
PM_B0_SIZE=0x8000
PM_B0_NAME=b0
PM_B0_ID=0
PM_b0_ID=PM_B0_ID
PM_b0_IS_ENABLED=1
PM_0_LABEL=B0
PM_B0_CONTAINER_OFFSET=0x0
PM_B0_CONTAINER_ADDRESS=0x0
PM_B0_CONTAINER_END_ADDRESS=0x8000
PM_B0_CONTAINER_SIZE=0x8000
PM_B0_CONTAINER_NAME=b0_container
PM_B0_CONTAINER_ID=1
PM_b0_container_ID=PM_B0_CONTAINER_ID
PM_b0_container_IS_ENABLED=1
PM_1_LABEL=B0_CONTAINER
PM_B0_CONTAINER_SPAN="b0"
PM_MCUBOOT_SECONDARY_OFFSET=0x0
PM_MCUBOOT_SECONDARY_ADDRESS=0x0
PM_MCUBOOT_SECONDARY_END_ADDRESS=0xd0000
PM_MCUBOOT_SECONDARY_SIZE=0xd0000
PM_MCUBOOT_SECONDARY_NAME=mcuboot_secondary
PM_MCUBOOT_SECONDARY_ID=2
PM_mcuboot_secondary_ID=PM_MCUBOOT_SECONDARY_ID
PM_mcuboot_secondary_IS_ENABLED=1
PM_2_LABEL=MCUBOOT_SECONDARY
PM_S0_OFFSET=0x8000
PM_S0_ADDRESS=0x8000
PM_S0_END_ADDRESS=0x18000
PM_S0_SIZE=0x10000
PM_S0_NAME=s0
PM_S0_ID=3
PM_s0_ID=PM_S0_ID
PM_s0_IS_ENABLED=1
PM_3_LABEL=S0
PM_S0_SPAN="mcuboot s0_pad"
PM_S0_PAD_OFFSET=0x8000
PM_S0_PAD_ADDRESS=0x8000
PM_S0_PAD_END_ADDRESS=0x8200
PM_S0_PAD_SIZE=0x200
PM_S0_PAD_NAME=s0_pad
PM_S0_PAD_ID=4
PM_s0_pad_ID=PM_S0_PAD_ID
PM_s0_pad_IS_ENABLED=1
PM_4_LABEL=S0_PAD
PM_MCUBOOT_OFFSET=0x8200
PM_MCUBOOT_ADDRESS=0x8200
PM_MCUBOOT_END_ADDRESS=0x18000
PM_MCUBOOT_SIZE=0xfe00
PM_MCUBOOT_NAME=mcuboot
PM_MCUBOOT_ID=5
PM_mcuboot_ID=PM_MCUBOOT_ID
PM_mcuboot_IS_ENABLED=1
PM_5_LABEL=MCUBOOT
PM_S0_IMAGE_OFFSET=0x8200
PM_S0_IMAGE_ADDRESS=0x8200
PM_S0_IMAGE_END_ADDRESS=0x18000
PM_S0_IMAGE_SIZE=0xfe00
PM_S0_IMAGE_NAME=s0_image
PM_S0_IMAGE_ID=6
PM_s0_image_ID=PM_S0_IMAGE_ID
PM_s0_image_IS_ENABLED=1
PM_6_LABEL=S0_IMAGE
PM_S0_IMAGE_SPAN="mcuboot"
PM_S1_OFFSET=0x18000
PM_S1_ADDRESS=0x18000
PM_S1_END_ADDRESS=0x28000
PM_S1_SIZE=0x10000
PM_S1_NAME=s1
PM_S1_ID=7
PM_s1_ID=PM_S1_ID
PM_s1_IS_ENABLED=1
PM_7_LABEL=S1
PM_S1_SPAN="s1_pad s1_image"
PM_S1_PAD_OFFSET=0x18000
PM_S1_PAD_ADDRESS=0x18000
PM_S1_PAD_END_ADDRESS=0x18200
PM_S1_PAD_SIZE=0x200
PM_S1_PAD_NAME=s1_pad
PM_S1_PAD_ID=8
PM_s1_pad_ID=PM_S1_PAD_ID
PM_s1_pad_IS_ENABLED=1
PM_8_LABEL=S1_PAD
PM_S1_IMAGE_OFFSET=0x18200
PM_S1_IMAGE_ADDRESS=0x18200
PM_S1_IMAGE_END_ADDRESS=0x28000
PM_S1_IMAGE_SIZE=0xfe00
PM_S1_IMAGE_NAME=s1_image
PM_S1_IMAGE_ID=9
PM_s1_image_ID=PM_S1_IMAGE_ID
PM_s1_image_IS_ENABLED=1
PM_9_LABEL=S1_IMAGE
PM_MCUBOOT_PAD_OFFSET=0x28000
PM_MCUBOOT_PAD_ADDRESS=0x28000
PM_MCUBOOT_PAD_END_ADDRESS=0x28200
PM_MCUBOOT_PAD_SIZE=0x200
PM_MCUBOOT_PAD_NAME=mcuboot_pad
PM_MCUBOOT_PAD_ID=10
PM_mcuboot_pad_ID=PM_MCUBOOT_PAD_ID
PM_mcuboot_pad_IS_ENABLED=1
PM_10_LABEL=MCUBOOT_PAD
PM_MCUBOOT_PRIMARY_OFFSET=0x28000
PM_MCUBOOT_PRIMARY_ADDRESS=0x28000
PM_MCUBOOT_PRIMARY_END_ADDRESS=0xf8000
PM_MCUBOOT_PRIMARY_SIZE=0xd0000
PM_MCUBOOT_PRIMARY_NAME=mcuboot_primary
PM_MCUBOOT_PRIMARY_ID=11
PM_mcuboot_primary_ID=PM_MCUBOOT_PRIMARY_ID
PM_mcuboot_primary_IS_ENABLED=1
PM_11_LABEL=MCUBOOT_PRIMARY
PM_MCUBOOT_PRIMARY_SPAN="spm app mcuboot_pad"
PM_MCUBOOT_PRIMARY_APP_OFFSET=0x28200
PM_MCUBOOT_PRIMARY_APP_ADDRESS=0x28200
PM_MCUBOOT_PRIMARY_APP_END_ADDRESS=0xf8000
PM_MCUBOOT_PRIMARY_APP_SIZE=0xcfe00
PM_MCUBOOT_PRIMARY_APP_NAME=mcuboot_primary_app
PM_MCUBOOT_PRIMARY_APP_ID=12
PM_mcuboot_primary_app_ID=PM_MCUBOOT_PRIMARY_APP_ID
PM_mcuboot_primary_app_IS_ENABLED=1
PM_12_LABEL=MCUBOOT_PRIMARY_APP
PM_MCUBOOT_PRIMARY_APP_SPAN="app spm"
PM_SPM_OFFSET=0x28200
PM_SPM_ADDRESS=0x28200
PM_SPM_END_ADDRESS=0x38200
PM_SPM_SIZE=0x10000
PM_SPM_NAME=spm
PM_SPM_ID=13
PM_spm_ID=PM_SPM_ID
PM_spm_IS_ENABLED=1
PM_13_LABEL=SPM
PM_SPM_APP_OFFSET=0x28200
PM_SPM_APP_ADDRESS=0x28200
PM_SPM_APP_END_ADDRESS=0xf8000
PM_SPM_APP_SIZE=0xcfe00
PM_SPM_APP_NAME=spm_app
PM_SPM_APP_ID=14
PM_spm_app_ID=PM_SPM_APP_ID
PM_spm_app_IS_ENABLED=1
PM_14_LABEL=SPM_APP
PM_SPM_APP_SPAN="spm app"
PM_APP_OFFSET=0x38200
PM_APP_ADDRESS=0x38200
PM_APP_END_ADDRESS=0xf8000
PM_APP_SIZE=0xbfe00
PM_APP_NAME=app
PM_APP_ID=15
PM_app_ID=PM_APP_ID
PM_app_IS_ENABLED=1
PM_15_LABEL=APP
PM_EXTERNAL_FLASH_OFFSET=0xd0000
PM_EXTERNAL_FLASH_ADDRESS=0xd0000
PM_EXTERNAL_FLASH_END_ADDRESS=0x800000
PM_EXTERNAL_FLASH_SIZE=0x730000
PM_EXTERNAL_FLASH_NAME=external_flash
PM_EXTERNAL_FLASH_ID=16
PM_external_flash_ID=PM_EXTERNAL_FLASH_ID
PM_external_flash_IS_ENABLED=1
PM_16_LABEL=EXTERNAL_FLASH
PM_SETTINGS_STORAGE_OFFSET=0xf8000
PM_SETTINGS_STORAGE_ADDRESS=0xf8000
PM_SETTINGS_STORAGE_END_ADDRESS=0x100000
PM_SETTINGS_STORAGE_SIZE=0x8000
PM_SETTINGS_STORAGE_NAME=settings_storage
PM_SETTINGS_STORAGE_ID=17
PM_settings_storage_ID=PM_SETTINGS_STORAGE_ID
PM_settings_storage_IS_ENABLED=1
PM_17_LABEL=SETTINGS_STORAGE
PM_PROVISION_OFFSET=0x0
PM_PROVISION_ADDRESS=0xff8108
PM_PROVISION_END_ADDRESS=0xff8388
PM_PROVISION_SIZE=0x280
PM_PROVISION_NAME=provision
PM_OTP_OFFSET=0x280
PM_OTP_ADDRESS=0xff8388
PM_OTP_END_ADDRESS=0xff83fc
PM_OTP_SIZE=0x74
PM_OTP_NAME=otp
PM_SPM_SRAM_OFFSET=0x0
PM_SPM_SRAM_ADDRESS=0x20000000
PM_SPM_SRAM_END_ADDRESS=0x20004000
PM_SPM_SRAM_SIZE=0x4000
PM_SPM_SRAM_NAME=spm_sram
PM_SRAM_SECURE_OFFSET=0x0
PM_SRAM_SECURE_ADDRESS=0x20000000
PM_SRAM_SECURE_END_ADDRESS=0x20004000
PM_SRAM_SECURE_SIZE=0x4000
PM_SRAM_SECURE_NAME=sram_secure
PM_SRAM_SECURE_SPAN="spm_sram"
PM_NRF_MODEM_LIB_CTRL_OFFSET=0x4000
PM_NRF_MODEM_LIB_CTRL_ADDRESS=0x20004000
PM_NRF_MODEM_LIB_CTRL_END_ADDRESS=0x200044e8
PM_NRF_MODEM_LIB_CTRL_SIZE=0x4e8
PM_NRF_MODEM_LIB_CTRL_NAME=nrf_modem_lib_ctrl
PM_NRF_MODEM_LIB_SRAM_OFFSET=0x4000
PM_NRF_MODEM_LIB_SRAM_ADDRESS=0x20004000
PM_NRF_MODEM_LIB_SRAM_END_ADDRESS=0x200084e8
PM_NRF_MODEM_LIB_SRAM_SIZE=0x44e8
PM_NRF_MODEM_LIB_SRAM_NAME=nrf_modem_lib_sram
PM_NRF_MODEM_LIB_SRAM_SPAN="nrf_modem_lib_ctrl nrf_modem_lib_tx nrf_modem_lib_rx"
PM_SRAM_NONSECURE_OFFSET=0x4000
PM_SRAM_NONSECURE_ADDRESS=0x20004000
PM_SRAM_NONSECURE_END_ADDRESS=0x20040000
PM_SRAM_NONSECURE_SIZE=0x3c000
PM_SRAM_NONSECURE_NAME=sram_nonsecure
PM_SRAM_NONSECURE_SPAN="sram_primary nrf_modem_lib_ctrl nrf_modem_lib_tx nrf_modem_lib_rx"
PM_NRF_MODEM_LIB_TX_OFFSET=0x44e8
PM_NRF_MODEM_LIB_TX_ADDRESS=0x200044e8
PM_NRF_MODEM_LIB_TX_END_ADDRESS=0x200064e8
PM_NRF_MODEM_LIB_TX_SIZE=0x2000
PM_NRF_MODEM_LIB_TX_NAME=nrf_modem_lib_tx
PM_NRF_MODEM_LIB_RX_OFFSET=0x64e8
PM_NRF_MODEM_LIB_RX_ADDRESS=0x200064e8
PM_NRF_MODEM_LIB_RX_END_ADDRESS=0x200084e8
PM_NRF_MODEM_LIB_RX_SIZE=0x2000
PM_NRF_MODEM_LIB_RX_NAME=nrf_modem_lib_rx
PM_SRAM_PRIMARY_OFFSET=0x84e8
PM_SRAM_PRIMARY_ADDRESS=0x200084e8
PM_SRAM_PRIMARY_END_ADDRESS=0x20040000
PM_SRAM_PRIMARY_SIZE=0x37b18
PM_SRAM_PRIMARY_NAME=sram_primary
PM_NUM=18
PM_ALL_BY_SIZE="otp mcuboot_pad s0_pad s1_pad provision nrf_modem_lib_ctrl nrf_modem_lib_rx nrf_modem_lib_tx spm_sram sram_secure nrf_modem_lib_sram b0 settings_storage b0_container mcuboot s1_image s0_image spm s0 s1 sram_primary sram_nonsecure app mcuboot_primary_app spm_app mcuboot_secondary mcuboot_primary external_flash"

partitions.yml using sdk 1.9.1:

app:
  address: 0x38200
  end_address: 0xf8000
  region: flash_primary
  size: 0xbfe00
b0:
  address: 0x0
  end_address: 0x8000
  placement:
    after:
    - start
  region: flash_primary
  size: 0x8000
b0_container:
  address: 0x0
  end_address: 0x8000
  orig_span: &id001
  - b0
  region: flash_primary
  size: 0x8000
  span: *id001
external_flash:
  address: 0xd0000
  end_address: 0x800000
  region: external_flash
  size: 0x730000
mcuboot:
  address: 0x8200
  end_address: 0x18000
  placement:
    before:
    - mcuboot_primary
  region: flash_primary
  sharers: 0x1
  size: 0xfe00
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: 0xf8000
  orig_span: &id002
  - spm
  - app
  - mcuboot_pad
  region: flash_primary
  size: 0xd0000
  span: *id002
mcuboot_primary_app:
  address: 0x28200
  end_address: 0xf8000
  orig_span: &id003
  - app
  - spm
  region: flash_primary
  size: 0xcfe00
  span: *id003
mcuboot_secondary:
  address: 0x0
  device: MX25L64
  end_address: 0xd0000
  placement:
    align:
      start: 0x4
  region: external_flash
  share_size:
  - mcuboot_primary
  size: 0xd0000
nrf_modem_lib_ctrl:
  address: 0x20004000
  end_address: 0x200044e8
  inside:
  - sram_nonsecure
  placement:
    after:
    - spm_sram
    - start
  region: sram_primary
  size: 0x4e8
nrf_modem_lib_rx:
  address: 0x200064e8
  end_address: 0x200084e8
  inside:
  - sram_nonsecure
  placement:
    after:
    - nrf_modem_lib_tx
  region: sram_primary
  size: 0x2000
nrf_modem_lib_sram:
  address: 0x20004000
  end_address: 0x200084e8
  orig_span: &id004
  - nrf_modem_lib_ctrl
  - nrf_modem_lib_tx
  - nrf_modem_lib_rx
  region: sram_primary
  size: 0x44e8
  span: *id004
nrf_modem_lib_tx:
  address: 0x200044e8
  end_address: 0x200064e8
  inside:
  - sram_nonsecure
  placement:
    after:
    - nrf_modem_lib_ctrl
  region: sram_primary
  size: 0x2000
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: 0x18000
  orig_span: &id005
  - mcuboot
  - s0_pad
  region: flash_primary
  size: 0x10000
  span: *id005
s0_image:
  address: 0x8200
  end_address: 0x18000
  orig_span: &id006
  - mcuboot
  region: flash_primary
  size: 0xfe00
  span: *id006
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: 0x28000
  orig_span: &id007
  - s1_pad
  - s1_image
  region: flash_primary
  size: 0x10000
  span: *id007
s1_image:
  address: 0x18200
  end_address: 0x28000
  placement:
    after:
    - s1_pad
    - s0
  region: flash_primary
  share_size:
  - mcuboot
  size: 0xfe00
s1_pad:
  address: 0x18000
  end_address: 0x18200
  placement:
    after:
    - s0
    align:
      start: 0x8000
  region: flash_primary
  share_size:
  - mcuboot_pad
  size: 0x200
settings_storage:
  address: 0xf8000
  end_address: 0x100000
  placement:
    before:
    - end
  region: flash_primary
  size: 0x8000
spm:
  address: 0x28200
  end_address: 0x38200
  inside:
  - mcuboot_primary_app
  placement:
    before:
    - app
  region: flash_primary
  size: 0x10000
spm_app:
  address: 0x28200
  end_address: 0xf8000
  orig_span: &id008
  - spm
  - app
  region: flash_primary
  size: 0xcfe00
  span: *id008
spm_sram:
  address: 0x20000000
  end_address: 0x20004000
  inside:
  - sram_secure
  placement:
    after:
    - start
  region: sram_primary
  size: 0x4000
sram_nonsecure:
  address: 0x20004000
  end_address: 0x20040000
  orig_span: &id009
  - sram_primary
  - nrf_modem_lib_ctrl
  - nrf_modem_lib_tx
  - nrf_modem_lib_rx
  region: sram_primary
  size: 0x3c000
  span: *id009
sram_primary:
  address: 0x200084e8
  end_address: 0x20040000
  region: sram_primary
  size: 0x37b18
sram_secure:
  address: 0x20000000
  end_address: 0x20004000
  orig_span: &id010
  - spm_sram
  region: sram_primary
  size: 0x4000
  span: *id010

External flash settings on DT:

&spi3 {
	status = "okay";
	pinctrl-0 = <&spi3_default_overlay>;
	pinctrl-1 = <&spi3_sleep_overlay>;
	pinctrl-names = "default", "sleep";
	cs-gpios = <&gpio0 9 GPIO_ACTIVE_LOW>;
	mx25l64: mx25l6433f@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <100000000>;    //100MHz
		//label = "MX25L64";
		size = <67108864>;    //64Mbit - 8MByte
		has-dpd;
		t-enter-dpd = <10000>;    //10usec
		t-exit-dpd = <100000>;    //100usec
	};
};

/ {
	chosen {
		nordic,pm-ext-flash = &mx25l64;
	};
};

Why is the pointer to the mcuboot_secondary area not defined in *flash_map?

It seems that the areas defined in the external flash are ignored (ID=2 and ID=16)!

What am I doing wrong?


Regards,

Ricardo

Related