Im having trouble setting up and using flash on nRF5340dk.
Is there any example on how to use LittleFS on external flash that is on the dev kit?
Im having trouble setting up and using flash on nRF5340dk.
Is there any example on how to use LittleFS on external flash that is on the dev kit?
Hi,
Here is the example https://github.com/nrfconnect/sdk-zephyr/tree/main/samples/subsys/fs/littlefs.
Please duplicate this https://github.com/nrfconnect/sdk-zephyr/blob/main/samples/subsys/fs/littlefs/boards/nrf52840dk_nrf52840_qspi.conf config file and rename it to nrf5340dk_nrf5340_cpuapp.conf.
Duplicate https://github.com/nrfconnect/sdk-zephyr/blob/main/samples/subsys/fs/littlefs/boards/nrf52840dk_nrf52840_qspi.overlay overlay file, rename it to nrf5340dk_nrf5340_cpuapp.overlay and update with the following content:
/* * Copyright (c) 2019 Peter Bigot Consulting, LLC * * SPDX-License-Identifier: Apache-2.0 */ /delete-node/ &storage_partition; / { chosen { nordic,pm-ext-flash = &mx25r64; }; 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>; }; }; };
Then, you could get the output like this
Regards,
Amanda H.
Hi,
Here is the example https://github.com/nrfconnect/sdk-zephyr/tree/main/samples/subsys/fs/littlefs.
Please duplicate this https://github.com/nrfconnect/sdk-zephyr/blob/main/samples/subsys/fs/littlefs/boards/nrf52840dk_nrf52840_qspi.conf config file and rename it to nrf5340dk_nrf5340_cpuapp.conf.
Duplicate https://github.com/nrfconnect/sdk-zephyr/blob/main/samples/subsys/fs/littlefs/boards/nrf52840dk_nrf52840_qspi.overlay overlay file, rename it to nrf5340dk_nrf5340_cpuapp.overlay and update with the following content:
/* * Copyright (c) 2019 Peter Bigot Consulting, LLC * * SPDX-License-Identifier: Apache-2.0 */ /delete-node/ &storage_partition; / { chosen { nordic,pm-ext-flash = &mx25r64; }; 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>; }; }; };
Then, you could get the output like this
Regards,
Amanda H.
Thank you, It's working. I can now see all 8mb of flash. But there is an issue.
When running the littlefs example I get
Area 0 at 0x0 on mx25r6435f@0 for 8388608 bytes - Which is correct
but when I transfer that code, exact code, to my app I get
Area 2 at 0xfa000 on flash-controller@39000 for 24576 bytes
Ive been going over whats different but cant find it, Maybe Im missing something?
I also tried moving my code to littlefs example and everything was going fine until I added
It switched to flash flash-controller@39000, after commenting it out it stayed with flash and I cant get it to go back to mx25??
Ok, an Update. As soon as I add
nrf5340dk_nrf5340_cpuapp.overlay
/delete-node/ &storage_partition; / { chosen { nordic,pm-ext-flash = &mx25r64; }; 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 0x00800000>; }; }; };
added CONFIG_PM_PARTITION.... to prj.conf
CONFIG_MAIN_STACK_SIZE=2048 # Let __ASSERT do its job CONFIG_DEBUG=y CONFIG_LOG=y CONFIG_LOG_MODE_MINIMAL=y CONFIG_FLASH=y CONFIG_FLASH_MAP=y CONFIG_FLASH_PAGE_LAYOUT=y CONFIG_FILE_SYSTEM=y CONFIG_FILE_SYSTEM_LITTLEFS=y CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL=y
pm_static.yml is:
littlefs_storage: address: 0 end_address: 0x800000 placement: before: - end region: external_flash size: 0x800000
Now Im getting:
I: LittleFS version 2.5, disk version 2.0
I: FS at mx25r6435f@0:0x0 is 6 0x1000-byte blocks with 512 cycle
I: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
I: /lfs1 mounted
I: Automount /lfs1 succeeded
*** Booting Zephyr OS build v3.2.99-ncs2 ***
Sample program to r/w files on littlefs
Area 1 at 0x0 on mx25r6435f@0 for 24576 bytes
/lfs1 automounted
/lfs1: bsize = 16 ; frsize = 4096 ; blocks = 6 ; bfree = 3
at least its on mx25, but the size is wrong, it should be 8mb
found what was wrong. There were several issues. First and most stupid was that directive in CMakeLists.txt was set to root of project and not to boards folder.
littlefs_storage: address: 0x0 end_address: 0x800000 placement: before: - end device: mx25r64 region: external_flash size: 0x800000 filesystem: littlefs