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.

  • Hi Abhijith,

    I tried running the supplied nRF5340 bootloader samples, but got the following errors on bootup:

    I: Starting bootloader
    W: Failed reading sectors; BOOT_MAX_IMG_SECTORS=256 - too small?
    W: Cannot upgrade: slots are not compatible
    W: Failed reading sectors; BOOT_MAX_IMG_SECTORS=256 - too small?
    W: Cannot upgrade: slots are not compatible
    I: Bootloader chainload address offset: 0xc000
    [00:00:00.000,732] <err> qspi_nor: JEDEC id [00 00 00] expect [c2 28 17]
    *** Booting nRF Connect SDK v2.5.99-dev1 ***
    Change this to see it change.
    [00:00:00.029,602] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    [00:00:00.029,632] <inf> bt_hci_core: HW Variant: nRF53x (0x0003)
    [00:00:00.029,663] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 161.54902 Build 901303921
    [00:00:00.031,250] <inf> bt_hci_core: Identity: C5:E1:A2:57:DC:F1 (random)
    [00:00:00.031,280] <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x211a, manufacturer 0x0059
    [00:00:00.031,280] <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x211a
    Bluetooth initialized
    Advertising successfully started
    

    This is running on the nRF5340-DK board. I tried two different boards, each had the same result.

    Have you tried running this on the DK board? Was it written to run on different hardware? I'm not aware of anything preventing external flash from identifying correctly. I haven't touched any of the solder bridges (SB10-15, nor SB20-25).

  • Hello,

    I think this warning might be because you did not configure the external flash for the MCUboot. I am attaching a sample with this response, which I have tested here inside SDK v2.5.1.

    Please try the attached sample and see whether the same is happening or not. Also, what swap type are you choosing from the nRF Connect app? Could you try the "confirm only" tag if you are trying with "Test and confirm"?

    8875.peripheral_lbs.zip

    Kind Regards,

    Abhijith

  • I tried your sample code (8875.peripheral_lbs.zip). Built using SDK 2.5.1 and Toolchain 2.5.1. Unmodified on my end.

    I see the following output upon bootup:

    E: JEDEC id [00 00 00] expect [c2 28 17]
    *** Booting nRF Connect SDK v2.5.1 ***
    Starting Bluetooth Peripheral LBS example
    I: 2 Sectors of 4096 bytes
    I: alloc wra: 0, fe8
    I: data wra: 0, 0
    I: HW Platform: Nordic Semiconductor (0x0002)
    I: HW Variant: nRF53x (0x0003)
    I: Firmware: Standard Bluetooth controller (0x00) Version 197.47763 Build 2370639017
    I: No ID address. App must call settings_load()
    Bluetooth initialized
    I: Identity: EB:CD:5F:09:6D:8C (random)
    I: HCI: version 5.4 (0x0d) revision 0x2102, manufacturer 0x0059
    I: LMP: version 5.4 (0x0d) subver 0x2102
    Advertising successfully started
    

    So it can't seem to read the JEDEC id from external flash.

    Further, I don't even see the option to perform a DFU from the nRF Connect app:

    I tried this on 2 different nRF5340-DK boards and get the same result.

    As for the external flash error on bootup, I'm not aware of any required solder bridge modification to get the MX25R to work. Is this correct? I'm powering the board via USB (J2). All switches are left in their factory state. When I measure pins 4 and 8 on the MX25R, I see 3V, so I know it's powered on. What could be happening here? Is there perhaps some non-volatile register that needs to be tweaked somewhere?

  • Whoops. I had failed to add app.overlay to the build in my last response.

    After adding it, the output changed a bit but still did not succeed.

    Message on bootup:

    *** Booting nRF Connect SDK v2.5.1 ***
    I: Starting bootloader
    W: Failed reading sectors; BOOT_MAX_IMG_SECTORS=256 - too small?
    W: Cannot upgrade: slots are not compatible
    W: Failed reading sectors; BOOT_MAX_IMG_SECTORS=256 - too small?
    W: Cannot upgrade: slots are not compatible
    I: Bootloader chainload address offset: 0xc000
    ▒E: JEDEC id [00 00 00] expect [c2 28 17]
    *** Booting nRF Connect SDK v2.5.1 ***
    Starting Bluetooth Peripheral LBS example
    I: 2 Sectors of 4096 bytes
    I: alloc wra: 0, fc8
    I: data wra: 0, 2c
    I: HW Platform: Nordic Semiconductor (0x0002)
    I: HW Variant: nRF53x (0x0003)
    I: Firmware: Standard Bluetooth controller (0x00) Version 197.47763 Build 2370639017
    I: No ID address. App must call settings_load()
    Bluetooth initialized
    I: Identity: C5:E1:A2:57:DC:F1 (random)
    I: HCI: version 5.4 (0x0d) revision 0x2102, manufacturer 0x0059
    I: LMP: version 5.4 (0x0d) subver 0x2102
    Advertising successfully started
    

    The DFU option did appear on the nRF Connect app this time. Message after attempting to perform DFU:

    Connected
    I: Secondary image of image pair (0.) is unreachable. Treat it as empty
    I: Image index: 0, Swap type: none
    E: Failed to open flash area ID 2: -19
    I: Secondary image of image pair (1.) is unreachable. Treat it as empty
    I: Image index: 1, Swap type: none
    E: Failed to open flash area ID 1: -2
    E: Failed to open flash area ID 8: -19
    I: Secondary image of image pair (0.) is unreachable. Treat it as empty
    I: Image index: 0, Swap type: none
    E: Failed to open flash area ID 2: -19
    E: Image upload inspect failed: 10
    E: Failed to open flash area ID 2: -19
    

  • I modified your LBS sample overlay files (both app.overlay and mcuboot.overlay) for our custom board. I don't see the Jedec ID errors on bootup. It seemed to make more progress than before. Here's the output from an attempted DFU, choosing the 'Confirm Only' option:

    00> *** Booting nRF Connect SDK v2.5.1 ***
    00> Starting Bluetooth Peripheral LBS example
    00> [00:00:00.006,530] <inf> fs_nvs: 2 Sectors of 4096 bytes
    00> [00:00:00.006,561] <inf> fs_nvs: alloc wra: 0, fd0
    00> [00:00:00.006,561] <inf> fs_nvs: data wra: 0, 1c
    00> [00:00:00.039,184] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    00> [00:00:00.039,215] <inf> bt_hci_core: HW Variant: nRF53x (0x0003)
    00> [00:00:00.039,245] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 197.47763 Build 2370639017
    00> [00:00:00.041,473] <inf> bt_hci_core: No ID address. App must call settings_load()
    00> Bluetooth initialized
    00> [00:00:00.043,945] <inf> bt_hci_core: Identity: E1:C7:E4:D3:7E:A3 (random)
    00> [00:00:00.043,975] <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x2102, manufacturer 0x0059
    00> [00:00:00.044,006] <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x2102
    00> Advertising successfully started
    00> Connected
    00> Passkey for 52:DA:C9:F6:0A:9C (random): 763478
    00> Security changed: 52:DA:C9:F6:0A:9C (random) level 4
    00> Pairing completed: C4:93:D9:69:DF:A4 (public), bonded: 1
    00> [00:01:20.379,486] <inf> mcuboot_util: Image index: 0, Swap type: none
    00> [00:01:20.380,035] <inf> mcuboot_util: Image index: 1, Swap type: none
    00> [00:01:20.380,035] <err> mcumgr_img_grp: Failed to open flash area ID 1: -2
    00> [00:01:20.528,839] <inf> mcuboot_util: Image index: 0, Swap type: none
    00> [00:01:20.809,906] <inf> mcumgr_img_grp: Erased 0xc2000 bytes of image slot
    00> [00:01:20.829,162] <inf> mcumgr_img_grp: Erased 0x1000 bytes of image slot trailer
    00> [00:02:45.751,037] <inf> mcuboot_util: Image index: 1, Swap type: none
    00> [00:02:45.991,302] <inf> mcumgr_img_grp: Erased 0x34000 bytes of image slot
    00> [00:02:46.010,528] <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,347] <inf> fs_nvs: 2 Sectors of 4096 bytes
    00> [00:00:00.006,347] <inf> fs_nvs: alloc wra: 0, f88
    00> [00:00:00.006,378] <inf> fs_nvs: data wra: 0, c4
    00> [00:00:01.007,385] <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)

    Updated app.overlay for custom board:

    /delete-node/ &mx25r64;
    
    / {
    	aliases {
    		spi-flash0 = &sst26vf;
    	};
    };
    
    &qspi {
    	status = "disabled";
    };
    
    &pinctrl {
    
    	spi4_default: spi4_default {
    		group1 {
    			psels = <NRF_PSEL(SPIM_SCK, 0, 3)>,
    			        <NRF_PSEL(SPIM_MISO, 1, 11)>,
    			        <NRF_PSEL(SPIM_MOSI, 1, 14)>;
    			nordic,drive-mode = <NRF_DRIVE_H0H1>;
    		};
    	};
    
    	spi4_sleep: spi4_sleep {
    		group1 {
    			psels = <NRF_PSEL(SPIM_SCK, 0, 3)>,
    			        <NRF_PSEL(SPIM_MISO, 1, 11)>,
    			        <NRF_PSEL(SPIM_MOSI, 1, 14)>;
    			low-power-enable;
    		};
    	};
    };
    
    &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 */
    	};
    };
    
    &uicr {
    	nfct-pins-as-gpios;
    };
    
    
    / {
    	chosen {
    		nordic,pm-ext-flash = &sst26vf;
    	};
    };
    
    /* original */
    // / {
    // 	chosen {
    // 		nordic,pm-ext-flash = &mx25r64;
    // 	};
    // };

    Updated prj.conf for custom board:

    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    CONFIG_NCS_SAMPLES_DEFAULTS=y
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Abhi_test_lbs"
    
    # Enable the LBS service
    CONFIG_BT_LBS=y
    CONFIG_BT_LBS_POLL_BUTTON=y
    CONFIG_DK_LIBRARY=y
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    #BOOTLOADER CONFIGURATION
    CONFIG_BOOTLOADER_MCUBOOT=y
    
    #FOTA CONFIGURATIONS
    # CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
    
    
    CONFIG_NRF53_UPGRADE_NETWORK_CORE=y
    CONFIG_UPDATEABLE_IMAGE_NUMBER=2
    
    # LUIS
    # Replacement for CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y, but without QSPI_NOR
    CONFIG_MCUMGR=y
    CONFIG_NET_BUF=y
    CONFIG_ZCBOR=y
    CONFIG_CRC=y
    CONFIG_MCUMGR_TRANSPORT_BT=y
    CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y
    CONFIG_IMG_MANAGER=y
    CONFIG_STREAM_FLASH=y
    CONFIG_FLASH_MAP=y
    CONFIG_FLASH=y
    CONFIG_MCUMGR_GRP_IMG=y
    CONFIG_MCUMGR_GRP_OS=y
    CONFIG_MCUMGR_GRP_OS_BOOTLOADER_INFO=y
    CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY=y
    # CONFIG_NORDIC_QSPI_NOR if $(dt_chosen_enabled,$(DT_CHOSEN_EXT_FLASH))
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP=y
    
    CONFIG_LOG=y
    CONFIG_LOG_MODE_DEFERRED=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_DEFAULT_LEVEL=3
    CONFIG_NORDIC_QSPI_NOR=n
    CONFIG_SPI_NOR=y
    CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096

Related