littlefs not mount to external flash winbond w25q256

am trying to mount little fs example with my external flash  winbond w25q256  but my nrf52840 board taking internal memory and am using  qspi 

it get automount and writing in  internal memory (mx25r64) and this is my overlay
i have tried with little fs example

/ {
aliases {
qspi-flash0 = &w25q256;
ext-flash = &w25q256;
};

chosen {
zephyr,flash-controller = &w25q256;
};

fstab {
compatible = "zephyr,fstab";
lfs1: lfs1 {
compatible = "zephyr,fstab,littlefs";
mount-point = "/lfs";
partition = <&lfs1_part>;
automount;
read-size = <16>;
prog-size = <16>;
cache-size = <64>;
lookahead-size = <32>;
block-cycles = <512>;
};
};
};

/delete-node/ &storage_partition;
/delete-node/ &mx25r64;

&qspi {
status = "okay";
pinctrl-0 = <&qspi_custom>;
pinctrl-1 = <&qspi_sleep_custom>;
pinctrl-names = "default", "sleep";

w25q256: w25q256@0 {
compatible = "nordic,qspi-nor";
reg = <0>;
size = <DT_SIZE_M(32)>;
sck-frequency = <8000000>;
writeoc = "pp4o";
readoc = "read4io";

jedec-id = [ef 40 19];
has-dpd;
t-enter-dpd = <3000>;
t-exit-dpd = <30000>;

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

/* Raw flash area for test writes (0-2MB) */
test_partition: partition@0 {
label = "test-area";
reg = <0x00000000 DT_SIZE_M(2)>;
};

/* LittleFS partition (2MB-4MB) */
lfs1_part: partition@200000 {
label = "littlefs-storage";
reg = <0x00200000 DT_SIZE_M(2)>;
};

/* Reserve remaining space for future use (4MB-32MB) */
storage_partition: partition@400000 {
label = "storage";
reg = <0x00400000 DT_SIZE_M(28)>;
};
};
};
};

&pinctrl {
qspi_custom: qspi_custom {
group1 {
psels = <NRF_PSEL(QSPI_SCK, 0, 19)>,
<NRF_PSEL(QSPI_IO0, 0, 14)>,
<NRF_PSEL(QSPI_IO1, 0, 23)>,
<NRF_PSEL(QSPI_IO2, 0, 11)>,
<NRF_PSEL(QSPI_IO3, 1, 0)>,
<NRF_PSEL(QSPI_CSN, 0, 16)>;
nordic,drive-mode = <NRF_DRIVE_H0H1>;
};
};

qspi_sleep_custom: qspi_sleep_custom {
group1 {
psels = <NRF_PSEL(QSPI_SCK, 0, 19)>,
<NRF_PSEL(QSPI_IO0, 0, 14)>,
<NRF_PSEL(QSPI_IO1, 0, 23)>,
<NRF_PSEL(QSPI_IO2, 0, 11)>,
<NRF_PSEL(QSPI_IO3, 1, 0)>,
<NRF_PSEL(QSPI_CSN, 0, 16)>;
low-power-enable;
};
};
};
prj.conf
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=3

# Enable flash subsystem
CONFIG_FLASH=y

# Enable QSPI NOR flash driver
CONFIG_SPI=y
CONFIG_NORDIC_QSPI_NOR=y

# Enable flash page layout
CONFIG_FLASH_PAGE_LAYOUT=y

# Increase stack sizes for continuous operations
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

# Enable Nordic specific configurations
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16

# Optimize for reliability
CONFIG_NORDIC_QSPI_NOR_INIT_PRIORITY=80

# Debug options
CONFIG_DEBUG=y
CONFIG_DEBUG_INFO=y

# Optimize for continuous operation
CONFIG_SIZE_OPTIMIZATIONS=y

# Increase logging buffers
CONFIG_LOG_BUFFER_SIZE=4096
CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=2048

# Enable file system support
CONFIG_FILE_SYSTEM=y

# Enable LittleFS
CONFIG_FILE_SYSTEM_LITTLEFS=y

# Enable filesystem formatting support
CONFIG_FILE_SYSTEM_MKFS=y

# LittleFS configuration
CONFIG_FS_LITTLEFS_NUM_FILES=10
CONFIG_FS_LITTLEFS_NUM_DIRS=5
CONFIG_FS_LITTLEFS_CACHE_SIZE=4096
CONFIG_FS_LITTLEFS_LOOKAHEAD_SIZE=32
CONFIG_FS_LITTLEFS_BLOCK_CYCLES=512
CONFIG_FS_LITTLEFS_FMP_DEV=y

# Flash map support for LittleFS
CONFIG_FLASH_MAP=y

# Increase heap for filesystem operations
CONFIG_HEAP_MEM_POOL_SIZE=16384

# Remove problematic POSIX configurations that cause build errors
# CONFIG_POSIX_API=n

# Additional memory for LittleFS operations
CONFIG_IDLE_STACK_SIZE=1024
Parents
  • i have created pm_static.yml file in that i have configure external memory

    external_flash:
    address: 0x0
    size: 0x2000000 # 32MB
    device: w25q256ve@0
    region: external_flash
    
    littlefs_storage:
    address: 0x0
    size: 0x2000000 # 32MB for LittleFS
    device: w25q256ve@0
    region: external_flash
    

    I have changed my overlay file like removing partition and fstab .
    / {
    aliases 
    qspi-flash0 = &w25q256;
    };
    
    chosen {
    zephyr,flash-controller = &w25q256;
    // zephyr,flash = &w25q256;
    nordic,pm-ext-flash = &w25q256;
    
    };
    
    // fstab {
    // compatible = "zephyr,fstab";
    // lfs1: lfs1 {
    // compatible = "zephyr,fstab,littlefs";
    // mount-point = "/lfs";
    // partition = <&lfs1_part>;
    // // automount;
    // read-size = <16>;
    // prog-size = <16>;
    // cache-size = <64>;
    // lookahead-size = <32>;
    // block-cycles = <512>;
    // };
    // };
    };
    
    
    /delete-node/ &storage_partition;
    /delete-node/ &mx25r64;
    
    &qspi {
    status = "okay";
    pinctrl-0 = <&qspi_custom>;
    pinctrl-1 = <&qspi_sleep_custom>;
    pinctrl-names = "default", "sleep";
    
    w25q256: w25q256ve@0 {
    compatible = "nordic,qspi-nor";
    reg = <0>;
    size = <DT_SIZE_M(32)>;
    sck-frequency = <8000000>;
    writeoc = "pp4o";
    readoc = "read4io";
    
    jedec-id = [ ef 40 19 ];
    has-dpd;
    t-enter-dpd = <3000>;
    t-exit-dpd = <30000>;
    
    // partitions {
    // compatible = "fixed-partitions";
    // #address-cells = <1>;
    // #size-cells = <1>;
    
    // /* LittleFS partition (0-4MB) - CHANGED: Larger partition */
    // lfs1_part: partition@0 {
    // label = "littlefs_storage";
    // reg = <0x00000000 DT_SIZE_M(4)>;
    // };
    
    // /* Test area (4MB-8MB) */
    // test_partition: partition@400000 {
    // label = "test_area";
    // reg = <0x00400000 DT_SIZE_M(4)>;
    // };
    
    // external_storage_partition: partition@800000 {
    // label = "external_storage";
    // reg = <0x00800000 DT_SIZE_M(24)>;
    // };
    // };
    };
    };
    
    &pinctrl {
    qspi_custom: qspi_custom {
    group1 {
    psels = <NRF_PSEL(QSPI_SCK, 0, 19)>,
    <NRF_PSEL(QSPI_IO0, 0, 14)>,
    <NRF_PSEL(QSPI_IO1, 0, 23)>,
    <NRF_PSEL(QSPI_IO2, 0, 11)>,
    <NRF_PSEL(QSPI_IO3, 1, 0)>,
    <NRF_PSEL(QSPI_CSN, 0, 16)>;
    nordic,drive-mode = <NRF_DRIVE_H0H1>;
    };
    };
    
    qspi_sleep_custom: qspi_sleep_custom {
    group1 {
    psels = <NRF_PSEL(QSPI_SCK, 0, 19)>,
    <NRF_PSEL(QSPI_IO0, 0, 14)>,
    <NRF_PSEL(QSPI_IO1, 0, 23)>,
    <NRF_PSEL(QSPI_IO2, 0, 11)>,
    <NRF_PSEL(QSPI_IO3, 1, 0)>,
    <NRF_PSEL(QSPI_CSN, 0, 16)>;
    low-power-enable;
    };
    };
    };

    changed this line .storage_dev = (void *)PM_LITTLEFS_STORAGE_ID,

    #define PARTITION_NODE DT_NODELABEL(lfs1)
    
    #if DT_NODE_EXISTS(PARTITION_NODE)
    FS_FSTAB_DECLARE_ENTRY(PARTITION_NODE);
    #else
    FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage);
    static struct fs_mount_t lfs_storage_mnt = {
    .type = FS_LITTLEFS,
    .fs_data = &storage,
    .storage_dev = (void *)PM_LITTLEFS_STORAGE_ID,
    .mnt_point = "/lfs",
    };
    #endif
    



    i can see that external flash is visible in flash area.
    and this is the output in this write operation get failed 
    *** Booting nRF Connect SDK v2.9.0-7787b2649840 ***
    *** Using Zephyr OS v3.7.99-1f8f3dc29142 ***
    === 406 Byte Continuous Write Demo ===
    Writing 406 bytes to external flash every 1000 ms
    Using mount point: /lfs
    Storage device ID: 2
    Flash controller: w25q256ve@0
    Flash device ready: YES
    QSPI device: w25q256ve@0
    QSPI device ready: YES
    ✓ Using external QSPI flash
    === FLASH AREA INFO ===
    Area ID: 2
    Offset: 0x0
    Size: 33554432 bytes (32768 KB)
    Device: w25q256ve@0
    ✓ Using EXTERNAL QSPI flash
    =====================
    storage device ID to: 2
    I: LittleFS version 2.9, disk version 2.1
    I: FS at w25q256ve@0:0x0 is 512 0x10000-byte blocks with 512 cycle
    I: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
    manual mounted
    /lfs mount: 0
    Deleting existing data file to start fresh...
    === FILESYSTEM STATS ===
    Total: 32768 KB, Used: 128 KB, Free: 32640 KB
    Data written: 0 bytes (0 KB)
    ========================
    
    Listing dir /lfs ...
    [FILE] data406_001.bin (size = 0)
    
    === Starting continuous 406-byte write loop ===
    
    --- Write cycle #1 ---
    E: eras
    --- Write cycle #4 ---
    E: erase error: address or size exceeds expected values.Addr: 0x1000000 size 65536
    E: file write error (-22)
    E: FAIL: write /lfs/data406.bin: -22
    E: Failed to write 406 bytes: -22
    
    
    --- Write cycle #5 ---
    E: erase error: address or size exceeds expected values.Addr: 0x1010000 size 65536
    E: file write error (-22)
    E: FAIL: write /lfs/data406.bin: -22
    E: Failed to write 406 bytes: -22
    
Reply
  • i have created pm_static.yml file in that i have configure external memory

    external_flash:
    address: 0x0
    size: 0x2000000 # 32MB
    device: w25q256ve@0
    region: external_flash
    
    littlefs_storage:
    address: 0x0
    size: 0x2000000 # 32MB for LittleFS
    device: w25q256ve@0
    region: external_flash
    

    I have changed my overlay file like removing partition and fstab .
    / {
    aliases 
    qspi-flash0 = &w25q256;
    };
    
    chosen {
    zephyr,flash-controller = &w25q256;
    // zephyr,flash = &w25q256;
    nordic,pm-ext-flash = &w25q256;
    
    };
    
    // fstab {
    // compatible = "zephyr,fstab";
    // lfs1: lfs1 {
    // compatible = "zephyr,fstab,littlefs";
    // mount-point = "/lfs";
    // partition = <&lfs1_part>;
    // // automount;
    // read-size = <16>;
    // prog-size = <16>;
    // cache-size = <64>;
    // lookahead-size = <32>;
    // block-cycles = <512>;
    // };
    // };
    };
    
    
    /delete-node/ &storage_partition;
    /delete-node/ &mx25r64;
    
    &qspi {
    status = "okay";
    pinctrl-0 = <&qspi_custom>;
    pinctrl-1 = <&qspi_sleep_custom>;
    pinctrl-names = "default", "sleep";
    
    w25q256: w25q256ve@0 {
    compatible = "nordic,qspi-nor";
    reg = <0>;
    size = <DT_SIZE_M(32)>;
    sck-frequency = <8000000>;
    writeoc = "pp4o";
    readoc = "read4io";
    
    jedec-id = [ ef 40 19 ];
    has-dpd;
    t-enter-dpd = <3000>;
    t-exit-dpd = <30000>;
    
    // partitions {
    // compatible = "fixed-partitions";
    // #address-cells = <1>;
    // #size-cells = <1>;
    
    // /* LittleFS partition (0-4MB) - CHANGED: Larger partition */
    // lfs1_part: partition@0 {
    // label = "littlefs_storage";
    // reg = <0x00000000 DT_SIZE_M(4)>;
    // };
    
    // /* Test area (4MB-8MB) */
    // test_partition: partition@400000 {
    // label = "test_area";
    // reg = <0x00400000 DT_SIZE_M(4)>;
    // };
    
    // external_storage_partition: partition@800000 {
    // label = "external_storage";
    // reg = <0x00800000 DT_SIZE_M(24)>;
    // };
    // };
    };
    };
    
    &pinctrl {
    qspi_custom: qspi_custom {
    group1 {
    psels = <NRF_PSEL(QSPI_SCK, 0, 19)>,
    <NRF_PSEL(QSPI_IO0, 0, 14)>,
    <NRF_PSEL(QSPI_IO1, 0, 23)>,
    <NRF_PSEL(QSPI_IO2, 0, 11)>,
    <NRF_PSEL(QSPI_IO3, 1, 0)>,
    <NRF_PSEL(QSPI_CSN, 0, 16)>;
    nordic,drive-mode = <NRF_DRIVE_H0H1>;
    };
    };
    
    qspi_sleep_custom: qspi_sleep_custom {
    group1 {
    psels = <NRF_PSEL(QSPI_SCK, 0, 19)>,
    <NRF_PSEL(QSPI_IO0, 0, 14)>,
    <NRF_PSEL(QSPI_IO1, 0, 23)>,
    <NRF_PSEL(QSPI_IO2, 0, 11)>,
    <NRF_PSEL(QSPI_IO3, 1, 0)>,
    <NRF_PSEL(QSPI_CSN, 0, 16)>;
    low-power-enable;
    };
    };
    };

    changed this line .storage_dev = (void *)PM_LITTLEFS_STORAGE_ID,

    #define PARTITION_NODE DT_NODELABEL(lfs1)
    
    #if DT_NODE_EXISTS(PARTITION_NODE)
    FS_FSTAB_DECLARE_ENTRY(PARTITION_NODE);
    #else
    FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage);
    static struct fs_mount_t lfs_storage_mnt = {
    .type = FS_LITTLEFS,
    .fs_data = &storage,
    .storage_dev = (void *)PM_LITTLEFS_STORAGE_ID,
    .mnt_point = "/lfs",
    };
    #endif
    



    i can see that external flash is visible in flash area.
    and this is the output in this write operation get failed 
    *** Booting nRF Connect SDK v2.9.0-7787b2649840 ***
    *** Using Zephyr OS v3.7.99-1f8f3dc29142 ***
    === 406 Byte Continuous Write Demo ===
    Writing 406 bytes to external flash every 1000 ms
    Using mount point: /lfs
    Storage device ID: 2
    Flash controller: w25q256ve@0
    Flash device ready: YES
    QSPI device: w25q256ve@0
    QSPI device ready: YES
    ✓ Using external QSPI flash
    === FLASH AREA INFO ===
    Area ID: 2
    Offset: 0x0
    Size: 33554432 bytes (32768 KB)
    Device: w25q256ve@0
    ✓ Using EXTERNAL QSPI flash
    =====================
    storage device ID to: 2
    I: LittleFS version 2.9, disk version 2.1
    I: FS at w25q256ve@0:0x0 is 512 0x10000-byte blocks with 512 cycle
    I: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
    manual mounted
    /lfs mount: 0
    Deleting existing data file to start fresh...
    === FILESYSTEM STATS ===
    Total: 32768 KB, Used: 128 KB, Free: 32640 KB
    Data written: 0 bytes (0 KB)
    ========================
    
    Listing dir /lfs ...
    [FILE] data406_001.bin (size = 0)
    
    === Starting continuous 406-byte write loop ===
    
    --- Write cycle #1 ---
    E: eras
    --- Write cycle #4 ---
    E: erase error: address or size exceeds expected values.Addr: 0x1000000 size 65536
    E: file write error (-22)
    E: FAIL: write /lfs/data406.bin: -22
    E: Failed to write 406 bytes: -22
    
    
    --- Write cycle #5 ---
    E: erase error: address or size exceeds expected values.Addr: 0x1010000 size 65536
    E: file write error (-22)
    E: FAIL: write /lfs/data406.bin: -22
    E: Failed to write 406 bytes: -22
    
Children
No Data
Related