Flash area error when attempting DFU via nRF Connect App

Hello,

I'm getting the following error  when attempting to perform a DFU. I'm using the Android nRF Connect app.

00> I: Image index: 0, Swap type: test
00> I: Image index: 1, Swap type: none
00> E: Failed to open flash area ID 1: -2

Flash Area ID of 1 indicates it's external flash. Error -2 is ENOENT. So it's saying that no such flash area exists? I suspect something is not configured correctly.

Here is my external flash devicetree snippet:

&spi4 {
	compatible = "nordic,nrf-spim";
	status = "okay";
	pinctrl-0 = <&spi4_default>;
	pinctrl-1 = <&spi4_sleep>;
	pinctrl-names = "default", "sleep";
	cs-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;

	sst26vf: sst26vf064b@0 {
		compatible = "jedec,spi-nor";
				reg = <0>;
		spi-max-frequency = <24000000>;
		jedec-id = [bf 26 43]; /* see datasheet table 5-4, p.25 */

		/* see datasheet pp. 72-79 for basic flash parameters table below */
		sfdp-bfp = [
			fd 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 80 bb
			fe ff ff ff  ff ff 00 ff  ff ff 44 0b  0c 20 0d d8
			0f d8 10 d8  20 91 48 24  80 6f 1d 81  ed 0f 77 38
			30 b0 30 b0  f7 ff ff ff  29 c2 5f ff  f0 30 c0 80
		];
		size = <67108864>;

	 	requires-ulbpr; /* sst26vf has block write protections enabled by default */
	};
};

The project is based on the smart lock sample code. I had to increase the size of the bootloader region to get it to fit. Here is the pm_static_dfu.yml file:

mcuboot:
  address: 0x0
  size: 0xc000
  region: flash_primary
mcuboot_pad:
  address: 0xc000
  size: 0x200
app:
  address: 0xc200
  size: 0xeae00
mcuboot_primary:
  orig_span: &id001
  - mcuboot_pad
  - app
  span: *id001
  address: 0xc000
  size: 0xeb000
  region: flash_primary
mcuboot_primary_app:
  orig_span: &id002
  - app
  span: *id002
  address: 0xc200
  size: 0xeae00
factory_data:
  address: 0xf7000
  size: 0x1000
  region: flash_primary
settings_storage:
  address: 0xf8000
  size: 0x8000
  region: flash_primary
mcuboot_primary_1:
  address: 0x0
  size: 0x40000
  device: flash_ctrl
  region: ram_flash
mcuboot_secondary:
  address: 0x0
  size: 0xef000
  device: SST26VF
  region: external_flash
mcuboot_secondary_1:
  address: 0xef000
  size: 0x40000
  device: SST26VF
  region: external_flash
external_flash:
  address: 0x12f000
  size: 0x6D1000
  device: SST26VF
  region: external_flash
pcd_sram:
  address: 0x20000000
  size: 0x2000
  region: sram_primary

I'm don't know how or if this yaml file relates to the partitions defined in the devicetree, but here are the devicetree partitions:

&flash0 {

	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x00000000 0x00010000>;
		};
		slot0_partition: partition@10000 {
			label = "image-0";
		};
		slot0_ns_partition: partition@50000 {
			label = "image-0-nonsecure";
		};
		slot1_partition: partition@80000 {
			label = "image-1";
		};
		slot1_ns_partition: partition@c0000 {
			label = "image-1-nonsecure";
		};
		/* 0xf0000 to 0xf7fff reserved for TF-M partitions */
		storage_partition: partition@f8000 {
			label = "storage";
			reg = <0x000f8000 0x00008000>;
		};
	};
}

Thanks.

  • Hello,

    Thanks for the update and good to hear that you made some progress with the sample project.

    <err> bt_hci_driver: Endpoint binding failed with -11
    00> [00:00:01.007,415] <err> bt_hci_core: HCI driver open failed (-11)
    00> Bluetooth init failed (err -11)

    On seeing the error message I guess there is some issue in communicating the app core and netcore of nRF5340, the appcore doesn't seem to communicate with network core. Could you try erasing the chip and flash it again? See this page on Building and programming on nRF5340 and make sure you are building it for the right target.

    nrfjprog --recover -f nrf53 --coprocessor CP_NETWORK (for network core)

    nrfjprog --recover -f nrf53(for app core) 

    Menon said:
    I would also recommend checking the memory report-->Partition manager to see if the partitioning was performed as expected. See this ticket.

    Could you also try checking this to make sure the partitioning is done as expected?

    Kind Regards,

    Abhijith

  • Hi Luis,

    I am getting the same error after OTA. ie

    [00:01:48.352,539] <err> mcumgr_img_grp: Failed to open flash area ID 2: -2
    [00:01:48.603,454] <inf> mcuboot_util: Swap type: none
    D: RDSR 40 QE 1 need 1: no-change
    I: Starting bootloader
    I: Swap type: perm
    I: Swap type: perm
    I: Image upgrade secondary slot -> primary slot
    I: Erasing the primary slot
    I: Copying the secondary slot to the primary slot: 0x2eda0 bytes
    D: writing magic; fa_id=4 off=0x55ff0 (0x65ff0)
    D: erasing secondary header
    D: erasing secondary trailer
    I: Image upgrade secondary slot -> primary slot
    I: Erasing the primary slot
    I: Copying the secondary slot to the primary slot: 0x2e8d4 bytes
    D: writing magic; fa_id=2 off=0x3fff0 (0x3fff0)
    I: Turned on network core
    I: Turned off network core
    D: erasing secondary header
    D: erasing secondary trailer
    I: Bootloader chainload address offset: 0x10000

    and here is my prj.conf file 

    CONFIG_MAIN_STACK_SIZE=2048
    
    #for LOG
    CONFIG_LOG=y
    CONFIG_LOG_MODE_DEFERRED=y
    CONFIG_LOG_RUNTIME_FILTERING=y
    CONFIG_LOG_BUFFER_SIZE=5120
    CONFIG_LOG_PRINTK=y
    CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD=0
    # CONFIG_COVERAGE=n
    CONFIG_LOG_TAG_MAX_LEN=8
    
    #for timer
    CONFIG_NRFX_TIMER0=y
    
    #for events
    CONFIG_EVENTS=y
    
    #for fuel gauge
    CONFIG_FUEL_GAUGE=y
    CONFIG_MAX17048=y
    
    #for I2C
    CONFIG_I2C=y
    
    
    #for NVS
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_NVS=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    #for Bluetooth
    CONFIG_BT=y
    CONFIG_BT_DEBUG_LOG=n
    CONFIG_BT_SMP=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_BAS=y
    CONFIG_BT_DIS=y
    CONFIG_BT_DIS_PNP=n
    CONFIG_BT_DEVICE_NAME="sample"
    CONFIG_BT_DIS_MODEL="sample"
    CONFIG_BT_DIS_MANUF="sample"
    CONFIG_BT_DIS_HW_REV=y
    CONFIG_BT_DIS_HW_REV_STR="0.1"
    CONFIG_BT_DIS_SW_REV=y
    CONFIG_BT_DIS_SW_REV_STR="0.0.1"
    CONFIG_BT_DIS_FW_REV=y
    CONFIG_BT_DIS_FW_REV_STR="0.0.1"
    #GATT_CLIENT needed for requesting ATT_MTU update
    CONFIG_BT_GATT_CLIENT=y
    #PHY update needed for updating PHY request
    CONFIG_BT_USER_PHY_UPDATE=y
    #For data length update
    CONFIG_BT_USER_DATA_LEN_UPDATE=y
    #Over-ride various BT settings for extended data packet size
    CONFIG_BT_ATT_PREPARE_COUNT=4
    CONFIG_BT_L2CAP_TX_MTU=498
    CONFIG_BT_L2CAP_TX_FRAG_COUNT=15
    CONFIG_BT_BUF_EVT_RX_SIZE=251
    CONFIG_BT_BUF_CMD_TX_SIZE=251
    CONFIG_BT_BUF_ACL_RX_SIZE=502
    CONFIG_BT_BUF_ACL_TX_COUNT=15
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_RX_STACK_SIZE=4096
    
    #for RTC
    CONFIG_NRFX_RTC0=y
    
    #To enable floating point values
    CONFIG_FPU=y
    
    #----------------
    # Enable Bootloader
    CONFIG_BOOTLOADER_MCUBOOT=y
    
    # Enable SMP Server
    CONFIG_MCUMGR=y
    CONFIG_MCUMGR_GRP_IMG=y
    
    # CONFIG_MCUMGR_GRP_IMG dependencies
    # CONFIG_FLASH=y
    CONFIG_IMG_MANAGER=y
    
    # CONFIG_IMG_MANAGER dependencies
    CONFIG_STREAM_FLASH=y
    
    # CONFIG_MCUMGR dependencies
    CONFIG_NET_BUF=y
    CONFIG_ZCBOR=y
    
    # Required for CONFIG_IMG_MANAGER
    CONFIG_FLASH_MAP=y
    
    # Enable BLE transfer
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
    
    CONFIG_MCUBOOT_USE_ALL_AVAILABLE_RAM=y
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP=y
    CONFIG_NRF53_UPGRADE_NETWORK_CORE=y
    CONFIG_UPDATEABLE_IMAGE_NUMBER=2
    CONFIG_ADD_MCUBOOT_MEDIATE_SIM_FLASH_DTS=y
    
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
    
    
    
    
    
    

    if any clue regarding this please let me know.

    thanks in advance.

  • Hi Abhijith,

    I rigged up a breakout board with an SST26VF SPI flash part to the DK board. I wired it up to the same pins my custom board uses.

    This did not work at first. However, if I changed the SCK line from P0.03 to P0.12, it works. I believe this is due to the P0.03 pin being shared with the NFC antenna. It's unclear what needs to be modified to allow P0.03 to behave properly as the SPI SCK on the DK board. Do I need to remove R43 and R46 and short R42/R45?

    Here's the output of a successful upgrade. You can see the "MODIFIED BY LUIS" string in the updated image. I find it curious that I still see the failed to open flash area error. Not sure what that error means or if it's even meaningful.

    *** Booting nRF Connect SDK v2.5.1 ***
    I: Starting bootloader
    I: Image index: 0, Swap type: none
    I: Image index: 1, Swap type: none
    I: Bootloader chainload address offset: 0xc000
    *** Booting nRF Connect SDK v2.5.1 ***
    Starting Bluetooth Peripheral LBS example
    [00:00:00.006,408] <inf> fs_nvs: 2 Sectors of 4096 bytes
    [00:00:00.006,439] <inf> fs_nvs: alloc wra: 0, f80
    [00:00:00.006,439] <inf> fs_nvs: data wra: 0, d4
    [00:00:00.039,276] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    [00:00:00.039,337] <inf> bt_hci_core: HW Variant: nRF53x (0x0003)
    [00:00:00.039,367] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 197.47763 Build 2370639017
    [00:00:00.041,625] <inf> bt_hci_core: No ID address. App must call settings_load()
    Bluetooth initialized
    [00:00:00.044,464] <inf> bt_hci_core: Identity: C5:E1:A2:57:DC:F1 (random)
    [00:00:00.044,494] <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x2102, manufacturer 0x0059
    [00:00:00.044,525] <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x2102
    Advertising successfully started
    Connected
    Security changed: C4:93:D9:69:DF:A4 (public) level 4
    Disconnected (reason 19)
    Connected
    Security changed: C4:93:D9:69:DF:A4 (public) level 4
    [00:00:57.946,716] <inf> mcuboot_util: Image index: 0, Swap type: none
    [00:00:57.947,540] <inf> mcuboot_util: Image index: 1, Swap type: none
    [00:00:57.947,570] <err> mcumgr_img_grp: Failed to open flash area ID 1: -2
    [00:00:58.095,672] <inf> mcuboot_util: Image index: 0, Swap type: none
    [00:00:58.331,146] <inf> mcumgr_img_grp: Erased 0x28000 bytes of image slot
    [00:00:58.350,280] <inf> mcumgr_img_grp: Erased 0x1000 bytes of image slot trailer
    [00:01:15.994,140] <inf> mcuboot_util: Image index: 1, Swap type: none
    [00:01:16.456,054] <inf> mcumgr_img_grp: Erased 0x32000 bytes of image slot
    [00:01:16.475,158] <inf> mcumgr_img_grp: Erased 0x1000 bytes of image slot trailer
    *** Booting nRF Connect SDK v2.5.1 ***
    I: Starting bootloader
    I: Image index: 0, Swap type: perm
    I: Image index: 1, Swap type: perm
    I: Image 0 upgrade secondary slot -> primary slot
    I: Erasing the primary slot
    I: Image 0 copying the secondary slot to the primary slot: 0x27c90 bytes
    I: Image 1 upgrade secondary slot -> primary slot
    I: Erasing the primary slot
    I: Image 1 copying the secondary slot to the primary slot: 0x31544 bytes
    I: Bootloader chainload address offset: 0xc000
    *** Booting nRF Connect SDK v2.5.1 ***
    Starting Bluetooth Peripheral LBS example MODIFIED BY LUIS!!!!
    [00:00:00.006,408] <inf> fs_nvs: 2 Sectors of 4096 bytes
    [00:00:00.006,439] <inf> fs_nvs: alloc wra: 0, f80
    [00:00:00.006,439] <inf> fs_nvs: data wra: 0, d4
    [00:00:00.039,245] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    [00:00:00.039,306] <inf> bt_hci_core: HW Variant: nRF53x (0x0003)
    [00:00:00.039,337] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 197.47763 Build 2370639017
    [00:00:00.041,595] <inf> bt_hci_core: No ID address. App must call settings_load()
    Bluetooth initialized
    [00:00:00.044,464] <inf> bt_hci_core: Identity: C5:E1:A2:57:DC:F1 (random)
    [00:00:00.044,494] <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x2102, manufacturer 0x0059
    [00:00:00.044,494] <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x2102
    Advertising successfully started
    

    I tried the exact same code on my custom board and it does not work. The custom board uses P0.03 as the clock line. I already added the uicr snippet below to make the pins behave as normal GPIOs. I don't think that's the failure cause, though, because I don't get any external flash errors on bootup.

    # to make NFC pins GPIOs
    &uicr {
    	nfct-pins-as-gpios;
    };

    Here's the attempted update log on the custom board. Again, I don't see any external flash errors on boot or during the upgrade. It seems to be erasing the sectors just fine.

    00> *** Booting nRF Connect SDK v2.5.1 ***
    00> Starting Bluetooth Peripheral LBS example
    00> [00:00:00.006,805] <inf> fs_nvs: 2 Sectors of 4096 bytes
    00> [00:00:00.006,805] <inf> fs_nvs: alloc wra: 0, fe8
    00> [00:00:00.006,835] <inf> fs_nvs: data wra: 0, 0
    00> [00:00:00.039,062] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    00> [00:00:00.039,093] <inf> bt_hci_core: HW Variant: nRF53x (0x0003)
    00> [00:00:00.039,123] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 197.47763 Build 2370639017
    00> [00:00:00.041,381] <inf> bt_hci_core: No ID address. App must call settings_load()
    00> Bluetooth initialized
    00> [00:00:00.043,762] <inf> bt_hci_core: Identity: E1:C7:E4:D3:7E:A3 (random)
    00> [00:00:00.043,792] <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x2102, manufacturer 0x0059
    00> [00:00:00.043,792] <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x2102
    00> Advertising successfully started
    00> Connected
    00> Disconnected (reason 19)
    00> Connected
    00> [00:00:43.615,264] <wrn> bt_att: Unhandled ATT code 0x1d
    00> Passkey for 44:F7:43:45:7E:71 (random): 043590
    00> Security changed: 44:F7:43:45:7E:71 (random) level 4
    00> Pairing completed: C4:93:D9:69:DF:A4 (public), bonded: 1
    00> [00:01:24.540,435] <inf> mcuboot_util: Image index: 0, Swap type: none
    00> [00:01:24.541,259] <inf> mcuboot_util: Image index: 1, Swap type: none
    00> [00:01:24.541,290] <err> mcumgr_img_grp: Failed to open flash area ID 1: -2
    00> [00:01:24.711,975] <inf> mcuboot_util: Image index: 0, Swap type: none
    00> [00:01:24.948,486] <inf> mcumgr_img_grp: Erased 0x28000 bytes of image slot
    00> [00:01:24.967,834] <inf> mcumgr_img_grp: Erased 0x1000 bytes of image slot trailer
    00> [00:01:41.957,000] <inf> mcuboot_util: Image index: 1, Swap type: none
    00> [00:01:42.406,646] <inf> mcumgr_img_grp: Erased 0x32000 bytes of image slot
    00> [00:01:42.426,025] <inf> mcumgr_img_grp: Erased 0x1000 bytes of image slot trailer
    00> *** Booting nRF Connect SDK v2.5.1 ***
    00> Starting Bluetooth Peripheral LBS example
    00> [00:00:00.006,408] <inf> fs_nvs: 2 Sectors of 4096 bytes
    00> [00:00:00.006,408] <inf> fs_nvs: alloc wra: 0, f88
    00> [00:00:00.006,439] <inf> fs_nvs: data wra: 0, c4
    00> [00:00:00.038,909] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    00> [00:00:00.038,940] <inf> bt_hci_core: HW Variant: nRF53x (0x0003)
    00> [00:00:00.038,970] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 197.47763 Build 2370639017
    00> [00:00:00.041,229] <inf> bt_hci_core: No ID address. App must call settings_load()
    00> Bluetooth initialized
    00> [00:00:00.044,067] <inf> bt_hci_core: Identity: E1:C7:E4:D3:7E:A3 (random)
    00> [00:00:00.044,097] <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x2102, manufacturer 0x0059
    00> [00:00:00.044,128] <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x2102
    00> Advertising successfully started
    00> Connected
    00> Security changed: C4:93:D9:69:DF:A4 (public) level 4
    00> [00:00:01.507,965] <err> mcumgr_img_grp: Failed to open flash area ID 1: -2
    00> Disconnected (reason 19)
    00> *** Booting nRF Connect SDK v2.5.1 ***
    00> Starting Bluetooth Peripheral LBS example
    00> [00:00:00.006,408] <inf> fs_nvs: 2 Sectors of 4096 bytes
    00> [00:00:00.006,439] <inf> fs_nvs: alloc wra: 0, f88
    00> [00:00:00.006,439] <inf> fs_nvs: data wra: 0, c4
    00> [00:00:00.039,031] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    00> [00:00:00.039,062] <inf> bt_hci_core: HW Variant: nRF53x (0x0003)
    00> [00:00:00.039,093] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 197.47763 Build 2370639017
    00> [00:00:00.041,351] <inf> bt_hci_core: No ID address. App must call settings_load()
    00> Bluetooth initialized
    00> [00:00:00.044,219] <inf> bt_hci_core: Identity: E1:C7:E4:D3:7E:A3 (random)
    00> [00:00:00.044,250] <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x2102, manufacturer 0x0059
    00> [00:00:00.044,281] <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x2102
    00> Advertising successfully started

  • Hello,

    Luis said:
    This did not work at first. However, if I changed the SCK line from P0.03 to P0.12, it works. I believe this is due to the P0.03 pin being shared with the NFC antenna. It's unclear what needs to be modified to allow P0.03 to behave properly as the SPI SCK on the DK board. Do I need to remove R43 and R46 and short R42/R45?

    By default P0.02 and P0.03 are NFC pins . I think NFC feature should be disabled inside UICR,NFCPINS. You can enable the config, CONFIG_NFCT_PINS_AS_GPIO=y

    Kind Regards,

    Abhijith

  • Hello @Krishnachandran,

    Please create a new devzone ticket explaining your issue. I recommend you include all the details of your issue, including the SDK version and the Nordic device you are using. I won't be able to look into your issue in this thread as the issues for different users are different and need to be approached differently.

    Kind Regards,

    Abhijith 

Related