Closed MY201314MY closed 2 months ago
And you probably want to configure CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE
to 4096 rather than default 65k, the smallest possible erase sector for the device.
OK,let me update my config and overlay. Thank you very much.
CONFIG_LOG=y
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_MKFS=y
CONFIG_FS_FATFS_MOUNT_MKFS=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_SHELL=y
CONFIG_FLASH=y
CONFIG_FLASH_JESD216_API=y
CONFIG_SPI_NOR_SFDP_RUNTIME=y
CONFIG_SPI_NOR_SFDP_MINIMAL=n
CONFIG_FLASH_SHELL=y
CONFIG_HEAP_MEM_POOL_SIZE=2048
CONFIG_FILE_SYSTEM_SHELL=y
CONFIG_FLASH_MAP_SHELL=y
CONFIG_FS_LOG_LEVEL_DBG=y
CONFIG_DISK_LOG_LEVEL_DBG=y
CONFIG_DISK_DRIVER_FLASH=y
CONFIG_FLASHDISK_LOG_LEVEL_DBG=y
CONFIG_FLASH_LOG_LEVEL_DBG=y
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_MAIN_STACK_SIZE=10240
/ {
msc_disk0 {
compatible = "zephyr,flash-disk";
partition = <&fatfs_storage_partition>;
disk-name = "NAND";
cache-size = <4096>;
};
};
&spi2 {
status = "okay";
w25q16bv: w25q16bv@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <DT_SIZE_M(32)>;
size = <DT_SIZE_M(16)> ;
jedec-id = [ef 40 15];
has-dpd;
t-enter-dpd = <3500>;
t-exit-dpd = <3500>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
fatfs_storage_partition: partition@0 {
label = "fatfs";
reg = <0x00000000 DT_SIZE_M(2)>;
};
};
};
};
[00:00:01.000,000] <inf> flashdisk: Initialize device NAND
[00:00:01.008,000] <inf> flashdisk: offset 0, sector size 512, page size 4096, volume size 2097152
[00:00:01.368,000] <inf> main: Format successful
uart:~$ fs mount fat /NAND:
[00:00:19.109,000] <dbg> fs: fs_mount: fs mounted at /NAND:
Successfully mounted fat fs:/NAND:
uart:~$ fs write /NAND:/123.txt 01 04 08
[00:00:27.733,000] <dbg> flashdisk: disk_flash_access_status: status : okay
[00:00:27.741,000] <dbg> flashdisk: disk_flash_access_status: status : okay
[00:00:27.748,000] <dbg> flashdisk: disk_flash_access_status: status : okay
[00:00:27.828,000] <dbg> flashdisk: disk_flash_access_status: status : okay
[00:00:28.024,000] <dbg> flashdisk: disk_flash_access_status: status : okay
uart:~$ fs read /NAND:/123.txt
[00:00:37.172,000] <dbg> flashdisk: disk_flash_access_status: status : okay
File size: 3
[00:00:37.181,000] <dbg> flashdisk: disk_flash_access_status: status : okay
[00:00:37.188,000] <dbg> flashdisk: disk_flash_access_status: status : okay
00000000 01 04 08 ...
[00:00:37.202,000] <dbg> flashdisk: disk_flash_access_status: status : okay
[00:00:37.209,000] <dbg> flashdisk: disk_flash_access_status: status : okay
[00:00:37.216,000] <dbg> flashdisk: disk_flash_access_status: status : okay
uart:~$ fs ls /NAND:
[00:00:46.519,000] <dbg> flashdisk: disk_flash_access_status: status : okay
[00:00:46.526,000] <dbg> flashdisk: disk_flash_access_status: status : okay
123.TXT
[00:00:46.534,000] <dbg> flashdisk: disk_flash_access_status: status : okay
[00:00:46.542,000] <dbg> flashdisk: disk_flash_access_status: status : okay
uart:~$ fs statvfs /NAND:/123.TXT
[00:01:10.321,000] <dbg> flashdisk: disk_flash_access_status: status : okay
bsize 512, frsize 1024, blocks 2028, bfree 97
uart:~$ fs statvfs /NAND:
[00:01:14.854,000] <dbg> flashdisk: disk_flash_access_status: status : okay
bsize 512, frsize 1024, blocks 2028, bfree 97
Thanks for log @MY201314MY. Do you consider issue resolved? If yes, then close the issue. Thanks.
Describe the bug I did not find any examples of mounting a FATFS file system based on W25QXX NOR FLASH in the samples/subsys/fs directory, so I made some try, but the formatting always failed. Has anyone successfully formatted or mounted it?
To Reproduce 1.check zephyr version
2.prj.conf
3.stm32f4_disco.overlay
4.main.c
5.build & flash
Additional information