I am using a nrf5340 DK and trying to get littlefs working with the external flash using qspi. I started with the blinky sample so I could try to understand each step, but I'm having a lot of problems.
In the main.c I added:
#include <stdio.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/fs/fs.h>
#include <zephyr/fs/littlefs.h>
#include <zephyr/logging/log.h>
#include <zephyr/storage/flash_map.h>
LOG_MODULE_REGISTER(main, LOG_LEVEL_DBG);
#define MAX_PATH_LEN 255
#define PARTITION_NODE DT_NODELABEL(lfs1_part)
FS_FSTAB_DECLARE_ENTRY(PARTITION_NODE);
struct fs_mount_t *mp = &FS_FSTAB_ENTRY(PARTITION_NODE);
int main(void)
{
struct fs_statvfs sbuf;
int rc;
rc = fs_mount(mp);
if (rc < 0) {
LOG_DBG("FAIL: mount id %" PRIuPTR " at %s: %d", (uintptr_t)mp->storage_dev, mp->mnt_point, rc);
return rc;
}
LOG_DBG("%s mount: %d\n", mp->mnt_point, rc);
rc = fs_statvfs(mp->mnt_point, &sbuf);
if (rc < 0) {
LOG_DBG("FAIL: statvfs: %d", rc);
}
return 0;
}
/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>;
};
};
};
&mx25r64 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
lfs1_part: partition@0 {
label = "storage";
reg = <0x00000000 0x00010000>;
};
};
};CONFIG_GPIO=y CONFIG_MAIN_STACK_SIZE=2048 # logging CONFIG_LOG=y CONFIG_LOG_MODE_IMMEDIATE=y CONFIG_DEBUG=y # flash CONFIG_FLASH=y CONFIG_FLASH_MAP=y CONFIG_FLASH_PAGE_LAYOUT=y # file system CONFIG_FILE_SYSTEM=y CONFIG_FILE_SYSTEM_LITTLEFS=y # Need this when storage is on flash CONFIG_MPU_ALLOW_FLASH_WRITE=y # Need this when storage is on MX25R64 CONFIG_NORDIC_QSPI_NOR=y CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
main.c:20: undefined reference to `z_fsmp_DT_N_S_soc_S_peripheral_50000000_S_qspi_2b000_S_mx25r6435f_0_S_partitions_S_partition_0' collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.