With nRF5340 : How to use internal and external flash both as Littlefs to store data

Hi All,

In nRF5340DK board, with ncs SDK(v1.9.1), we can use internal flash partition as Littlefs and store data into it. we are able to find sample demo for external flash as littlefs.

Now we want to add external Flash(MX25R64) and internal flash both as littlefs and use both to store data into it for different purpose.

Question:

1) Can we use both internal flash storage partition and external flash as littlefs to store data ?

2) Is there any demo sample which describes to configure and use internal and external flash both as littlefs ?

Parents
  • Hi

    1. I think this should be possible, although I'm not aware of anyone who has tested this in the past. It will be necessary with two instances of littlefs though, as I don't think you can seamlessly move between internal and external storage like that.

    2. Unfortunately, there are no demos available doing this in the official nRF Connect SDK, but if there is one, I would think it is available somewhere on Github. Feel free to search for a Zephyr project doing this there.

    Best regards,

    Simon

  • 1) For External flash support with Littlefs, we used ncs\v1.9.1\zephyr\samples\subsys\fs\littlefs demos for nRF5340 board. We are able to successfully run internal and external flash both as littlefs with few changes.

    With enabling both internal and external flash as littlefs, when we enable MCUBOOT(CONFIG_BOOTLOADER_MCUBOOT=y) then it stopped compiling. It gives PM ID related error. Any idea for this ?

    2) We didn't find any demos on Github related to littlefs. Could you please share a link of it ?

  • Greetings,

    Hi I am trying to do exactly the same thing and it would be extremely helpful if you could post a small excerpt that shows how you configured your dts so that you have two instances working for the internal and external flash. What labels did you use in your nodes etc. ?

    Thank you and I look forward to hearing from you!

  • Add into .overlay file for enable the ext flash

    / {
        chosen {
            nordic,pm-ext-flash = &mx25r64;
            zephyr,flash-controller = &flash_controller;
        };
    };
    

    Add pm_static.yml file

    external_flash:
      address: 0x0
      end_address: 0x800000
      region: external_flash
      size: 0x800000
    mcuboot_secondary:
      address: 0x0
      device: /soc/peripheral@50000000/qspi@2b000/mx25r6435f@0
      end_address: 0xeb000
      placement:
        align:
          start: 0x4
      region: external_flash
      share_size:
      - mcuboot_primary
      size: 0xeb000
    mcuboot_secondary_1:
      address: 0xeb000
      device: /soc/peripheral@50000000/qspi@2b000/mx25r6435f@0
      end_address: 0x12b000
      region: external_flash
      share_size:
      - mcuboot_primary_1
      size: 0x40000
    storage_ext:
      address: 0x12b000
      size: 0x6D5000
      device: /soc/peripheral@50000000/qspi@2b000/mx25r6435f@0
      region: external_flash

    For the c code, you can access this partition 
    internal : FLASH_AREA_ID(littlefs_storage)

    external : FLASH_AREA_ID(storage_ext)

    storage_ext name you can find in .yml file

  • Hello,

    Thank you very much for your immediate response.

    I have a follow-up question on your setup.

    Do I have to define the partitions as static with a pm_static.yml file do to this? or do I have to just setup the pm_static.yml only for the external memory partitions?

    Also, would it be possible for you to show how you setup of the internal storage in your dts. . The line where you placed the "littlefs_storage" label, for example, any fstab nodes used and the partitions defined in your .dts .

    Thank you very much your help is appreciated!

Reply
  • Hello,

    Thank you very much for your immediate response.

    I have a follow-up question on your setup.

    Do I have to define the partitions as static with a pm_static.yml file do to this? or do I have to just setup the pm_static.yml only for the external memory partitions?

    Also, would it be possible for you to show how you setup of the internal storage in your dts. . The line where you placed the "littlefs_storage" label, for example, any fstab nodes used and the partitions defined in your .dts .

    Thank you very much your help is appreciated!

Children
Related