Hi, I'm working on a project using Zephyr with LittleFS mounted on a QSPI flash device. However, I'm encountering an issue when trying to erase the flash area. Here are the details:
System Configuration:
MCU: nRF52840 (Seeed studio xiao ble)
Zephyr Version: v3.5.99-ncs1-1 (nRF Connect SDK)
Flash Device: p25q16h (16 MiB QSPI flash)
File System: LittleFS
Device Tree Configuration:
/ {
fstab {
compatible = "zephyr,fstab";
lfs1: lfs1 {
compatible = "zephyr,fstab,littlefs";
mount-point = "/lfs1";
partition = <&lfs1_part>;
automount;
read-size = <16>;
prog-size = <16>;
cache-size = <64>;
lookahead-size = <32>;
block-cycles = <512>;
};
};
};
&qspi {
p25q16h: p25q16h@0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
lfs1_part: partition@0 {
label = "storage";
reg = <0x00000000 0x01000000>; // 16 MiB partition for LittleFS
};
};
};
};
Problem:
When I try to erase the LittleFS partition, I encounter the following error:
[00:00:00.330,688] <err> qspi_nor: erase error: address or size exceeds expected values. Addr: 0x0 size 16777216 [00:00:00.330,718] <err> main: Erasing flash area ... -22
Here’s the relevant code snippet where the error occurs:
LOG_PRINTK("Area %u at 0x%x on %s for %u bytes\n",
id, (unsigned int)pfa->fa_off, pfa->fa_dev->name,
(unsigned int)pfa->fa_size);
if (IS_ENABLED(CONFIG_APP_WIPE_STORAGE)) {
rc = flash_area_erase(pfa, 0, pfa->fa_size);
LOG_ERR("Erasing flash area ... %d", rc);
}
Questions:
- Is there a specific alignment requirement for the flash_area_erase() function on QSPI flash in Zephyr?
- Do I need to adjust any of the LittleFS or partition settings in the device tree to match the QSPI flash memory’s erase block size?
- Has anyone encountered a similar issue with QSPI flash erasing in Zephyr, and how did you resolve it?
Any help or suggestions on how to properly erase this flash area would be greatly appreciated!
Thanks in advance for your support!