This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

52840 dfu with firmware stored in external flash

Hello,

I am trying to use the dfu library to update the nrf52840 with a firmware stored in a littlefs file in an external qspi flash. I can successfully read the entire firmware and store it in a buffer and then update the application with the dfu library, but it does corrupt my file system. It seems to me that the dfu library tried to store the firmware in the qspi external flash (at the same place that the file system). In fact, if I read the firmware file chunk by chunk, and pass each chunk to the dfu library, my file system is corrupted in the middle of the update. If I do not use the dfu library, I am able to read and write in the file system without any problem. This problem happened only when using the dfu library.

Below is the part of the device tree where I include the qspi flash:

 

&qspi {
	status = "okay";
	sck-pin = <19>;
	io-pins = <20>, <21>, <22>, <23>;
	csn-pins = <17>;
	mx25r32_qspi: mx25r3235fm2il0@0 {
		compatible = "nordic,qspi-nor";
		reg = <0>;
		/* MX25R64 supports only pp and pp4io */
		writeoc = "pp4io";
		/* MX25R64 supports all readoc options */
		readoc = "read4io";
		sck-frequency = <8000000>;
		label = "MX25R32";
		jedec-id = [c2 28 16];
		sfdp-bfp = [
			e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
			ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
			10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
			30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
		];
		size = <33554432>;
		has-dpd;
		t-enter-dpd = <10000>;
		t-exit-dpd = <30000>;
	};
};

&mx25r32_qspi {
	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;
		partition@0 {
			label = "storage_qspi";
			reg = <0x00000000 0x00050000>;
		};
	};
};


Below is the part where I defined the file system:

FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage);
static struct fs_mount_t lfs_storage_mnt = {
    .type = FS_LITTLEFS,
    .fs_data = &storage,
    .storage_dev = (void *)DT_FIXED_PARTITION_ID(DT_NODE_BY_FIXED_PARTITION_LABEL(storage_qspi)), 
    .mnt_point = MOUNT_POINT,
};

Finally, the relevant part in my prj.conf:

# DFU Target
CONFIG_DFU_TARGET=y

# Image manager
CONFIG_IMG_MANAGER=y
CONFIG_FLASH=y
CONFIG_IMG_ERASE_PROGRESSIVELY=y

CONFIG_DFU_TARGET_MCUBOOT=y
CONFIG_BOOTLOADER_MCUBOOT=y

CONFIG_SPI=y
CONFIG_SPI_NOR=n
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096

CONFIG_FLASH=y

CONFIG_FILE_SYSTEM=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y

CONFIG_FILE_SYSTEM_LITTLEFS=y

To read the file system, I use the littlefs library, and to write to the dfu, I use the dfu_target library.

Do you have maybe some hints as to why this problem can occur ?

Kind regards

Related