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.

  • Update 1:

    I built the vanilla matter lock sample application for the nRF5340-dk target. Added CONFIG_CHIP_OTA_REQUESTOR=y and CONFIG_CHIP_DFU_OVER_BT_SMP=y to prj.conf.

    This also doesn't work. Errors are below:

    uart:~$ E: Failed to open flash area ID 2: -19
    E: Failed to open flash area ID 1: -2
    E: Failed to open flash area ID 8: -19
    E: Failed to open flash area ID 2: -19
    E: Image upload inspect failed: 10
    E: Failed to open flash area ID 2: -19
    

    Which configurations are missing to get Bluetooth DFU working with Android nRF Connect application?

  • Update 2:

    I found this guide: https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/ncs-dfu#mcetoc_1h90k6ei40 which will supposedly add DFU over bluetooth easily.

    Still working from the sample matter lock application, I added to following to prj.conf since I'm working with sdk 2.5.99:

    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

    This gets me a compile error due to a build-time assertion:

    In file included from C:/ncs/v2.5.99-dev1/zephyr/include/zephyr/toolchain.h:50,
                     from C:/ncs/v2.5.99-dev1/zephyr/include/zephyr/kernel_includes.h:19,
                     from C:/ncs/v2.5.99-dev1/zephyr/include/zephyr/kernel.h:17,
                     from C:/ncs/v2.5.99-dev1/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c:7:
    C:/ncs/v2.5.99-dev1/zephyr/include/zephyr/toolchain/gcc.h:81:36: error: static assertion failed: "Missing partitions?"
       81 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG)
          |                                    ^~~~~~~~~~~~~~
    C:/ncs/v2.5.99-dev1/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c:38:1: note: in expansion of macro 'BUILD_ASSERT'
       38 | BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT2_PARTITION) &&
          | ^~~~~~~~~~~~

    So it looks like the partition mcuboot_primary_1 is missing. The sample app uses a static partition file (pm_static_dfu.yml):

    mcuboot:
      address: 0x0
      size: 0x8000
      region: flash_primary
    mcuboot_pad:
      address: 0x8000
      size: 0x200
    app:
      address: 0x8200
      size: 0xeee00
    mcuboot_primary:
      orig_span: &id002
      - mcuboot_pad
      - app
      span: *id001
      address: 0x8000
      size: 0xef000
      region: flash_primary
    mcuboot_primary_app:
      orig_span: &id002
      - app
      span: *id002
      address: 0x8200
      size: 0xeee00
    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: MX25R64
      region: external_flash
    mcuboot_secondary_1:
      address: 0xef000
      size: 0x40000
      device: MX25R64
      region: external_flash
    external_flash:
      address: 0x12f000
      size: 0x6D1000
      device: MX25R64
      region: external_flash
    pcd_sram:
      address: 0x20000000
      size: 0x2000
      region: sram_primary
    

    mcuboot_primary_1 is clearly defined, but it's placed in the ram_flash region. Huh? I don't know what that means, but the resulting file at build/zephyr/include/generated/pm_config.h has no mention of mcuboot_primary_1 at all. Should this partition be placed in external flash?

  • Hello,

    Could you have a look at this sample for testing the external flash? Try to run this sample and see if the external flash works fine. There is also an unofficial sample from my colleague that deals with external flash. Try testing these samples and see if the external flash works fine.

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

    Kind Regards,

    Abhijith

  • Thanks for the response.

    I'm not ruling out the external flash. But what I'd like to do first is get the software working correctly on known good hardware. In my case, that is the nRF5340-DK.

    I'm using the "matter lock" sample project.

    I've made the following additions to prj.conf:

    CONFIG_CHIP_OTA_REQUESTOR=y
    CONFIG_CHIP_DFU_OVER_BT_SMP=y
    CONFIG_LOG_DEFAULT_LEVEL=3

    Everything else is left as-is.

    Using this, when I try a DFU using the nRF Connect Android app, I get the following errors from the DK:

    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 (1.) is unreachable. Treat it as empty
    I: Image index: 1, Swap type: none
    E: Failed to open flash area ID 8: -19
    E: Image upload inspect failed: 10
    E: Failed to open flash area ID 2: -19
    

    So, mixtures of ENOENT and ENODEV.

    Is this something that's supported? Is there any other configuration needed to get this working with the DK board?

  • Hello,

    Luis said:
    I'm not ruling out the external flash. But what I'd like to do first is get the software working correctly on known good hardware. In my case, that is the nRF5340-DK.

    Could you clarify a few things? Are you able to do a BLE DFU with internal flash? If you haven't tried that, I recommend doing so.

    Try the nRF5340 bootloader samples, and then try the external flash sample; this will help narrow down where the error is.

    Luis said:
    Using this, when I try a DFU using the nRF Connect Android app, I get the following errors from the DK

    Is this the complete log? If not, could you share the whole log?

    Are you trying to do a device firmware upgrade over matter?

    Kind Regards,

    Abhijith

Related