While I am able to properly read and write to the NOR flash with the flash API from zephyr, I am not able to mount the file system littlefs. The written bytes are read out and checked accordingly.
To properly set up the overlay file, I used the JESD216 flash API and received trough my communication, which properly works the following parameters from the flash.
Summary of BFP content:
DTR Clocking supported
Addressing: 3-Byte only
4-KiBy erase: uniform
Support QSPI XIP
Support 1-1-1
Support 1-1-2: instr 3Bh, 1 mode clocks, 7 waits
Support 1-1-4: instr 6Bh, 1 mode clocks, 7 waits
Support 1-2-2: instr BBh, 1 mode clocks, 7 waits
Support 1-4-4: instr EBh, 1 mode clocks, 9 waits
Support 2-2-2: instr BBh, 1 mode clocks, 7 waits
Support 4-4-4: instr EBh, 1 mode clocks, 9 waits
Flash density: 16777216 bytes
ET1: instr 20h for 4096 By; typ 48 ms, max 480 ms
ET2: instr D8h for 65536 By; typ 160 ms, max 1600 ms
ET3: instr 52h for 32768 By; typ 112 ms, max 1120 ms
Chip erase: typ 40000 ms, max 960000 ms
Byte program: type 15 + 1 * B us, max 360 + 24 * B us
Page program: typ 120 us, max 2880 us
Page size: 256 By
Suspend: 75h ; Resume: 7Ah
DPD: Enter B9h, exit ABh ; delay 30000 ns ; poll 0x3e
HOLD or RESET Disable: supported
QER: 0
0-4-4 Mode methods: entry 0x2 ; exit 0x03
4-4-4 Mode sequences: enable 0x14 ; disable 0xa
Soft Reset and Rescue Sequence support: 0x3d
Status Register 1 support: 0x01
size = <134217728>;
sfdp-bfp = [
e5 20 f9 ff ff ff ff 07 29 eb 27 6b 27 3b 27 bb
ff ff ff ff ff ff 27 bb ff ff 29 eb 0c 20 10 d8
0f 52 00 00 24 4a 99 00 8b 8e 03 c9 ac 01 27 38
7a 75 7a 75 fb bd d5 5c 4a 0f 82 ff 81 3d 00 00
];
PH1: ff84 rev 1.0: 2 DW @ 80
sfdp-ff84 = [
00 00 f0 ff ff ff ff ff
];
jedec-id = [20 bb 18];
Through these information I built the following overlay file.
&mx25r64 {
status = "disabled";
};
&qspi { /* dedicated MT25Q */
status = "okay";
compatible = "nordic,nrf-qspi";
pinctrl-0 = <&qspi_default>;
pinctrl-1 = <&qspi_sleep>;
pinctrl-names = "default", "sleep";
mt25qu02: mt25qu02gcbb@0 {
compatible = "nordic,qspi-nor";
reg = < 0 >;
writeoc = "pp4o";//quad input output pp4io works as well
readoc = "read4o";//quad input output, check https://devzone.nordicsemi.com/f/nordic-q-a/74394/2gbit-nor-flash-at-qspi-has-shifted-read-data-from-flash
status = "okay";
sck-frequency = <8000000>;//probably could even go up to 166000000 in STR, but not supported by nRF5340 QSPI?
jedec-id = [20 BB 18];
size = <134217728>;
//size-in-bytes = <16777216>;//16MB /*128 Mb in hex flash capacity in bits 2,147,483,648 bits = 2 Gb*/
sck-delay = <3>;//active setup time 2.7
rx-delay = <6>; // Data in setup time 2.5//clock low to to ouput valid
//address-size-32; //not used because we only access 128 Mb, only supports 3 byte
quad-enable-requirements = "NONE";
has-dpd;
t-enter-dpd = <3000>; //3000 required, without safety margin
t-exit-dpd = <35000>;//30000 required before ready after deep power down mode
// three bytes address size by default, conflicts by 4 bytes with qspi
has-lock = <0x5C>;//01011100
//<01011110>;01111010
sfdp-bfp = [
e5 20 f9 ff ff ff ff 07 29 eb 27 6b 27 3b 27 bb
ff ff ff ff ff ff 27 bb ff ff 29 eb 0c 20 10 d8
0f 52 00 00 24 4a 99 00 8b 8e 03 c9 ac 01 27 38
7a 75 7a 75 fb bd d5 5c 4a 0f 82 ff 81 3d 00 00
];
page-size = <256>; //usually ignored if sfdp-bfp used
};
};
/delete-node/ &storage_partition;
/ {
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>;
};
};
aliases {
extflash = &mt25qu02;
};
chosen {
zephyr,flash-controller = &mt25qu02;
zephyr,pm-ext-flash = &mt25qu02;
};
};
&mt25qu02 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
lfs1_part: partition@0 {
label = "storage";
reg = <0x000000 0x800000>;
//use the entire flash 0x8000000
};
};
};Here is my prj.conf file as well:
# Optionally force the file system to be recreated CONFIG_APP_WIPE_STORAGE=y # fs_dirent structures are big. #4096 #8192 CONFIG_MAIN_STACK_SIZE=2048 CONFIG_MAIN_THREAD_PRIORITY=1 # Let __ASSERT do its job CONFIG_DEBUG=y #Logging CONFIG_LOG=y CONFIG_SERIAL=y CONFIG_LOG_MODE_MINIMAL=y #disable SPI CONFIG_SPI=n #QSPI Flash CONFIG_FLASH=y CONFIG_FLASH_MAP=y CONFIG_FLASH_PAGE_LAYOUT=y CONFIG_FILE_SYSTEM=y CONFIG_FILE_SYSTEM_LITTLEFS=y # Need this when storage is on flash CONFIG_MPU_ALLOW_FLASH_WRITE=y CONFIG_NORDIC_QSPI_NOR=y CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE= 4096
Independent if I automount the filesystem or do it manually following the example from littlefs, I receive always the same error codes:
I: LittleFS version 2.8, disk version 2.1
I: FS at mt25qu02gcbb@0:0x0 is 256 0x1000-byte blocks with 512 cycle
I: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
E: WEST_TOPDIR/modules/fs/littlefs/lfs.c:1351: Corrupted dir pair at {0x0, 0x1}
W: can't mount (LFS -84); formatting
W: WEST_TOPDIR/modules/fs/littlefs/lfs.c:2059: Superblock 0x0 has become unwritable
E: format failed (LFS -28)
E: fs mount error (-28)
FAIL: mount id 0 at /lfs1: -28
E: LittleFS mount failed: -28
I am a bit confused, because I can manually write to the flash, I can properly communicate with it, but I can somehow not mount the filesystem on it. Various approaches I already tried out, such as erasing the entire flash before mounting, following exactly the littlefs example etc. Additionally, I was able to mount littlefs to the MX24R64 external flash which is on the dk, but with this external flash it is not possible.
I use zephyr v2.5.1 on the nrf5340dk
What could be reasons? I would be really glad for the help! If you need any more details, please let me know.
