Enabling Bluetooth to the Littlefs sample app will make the littlefs **NOT** use external flash.


I built the littlefs zephyr example found in "/zephyr/samples/subsys/fs/littlefs"and then modified it to use the external  flash "MX25R64" by adding an app.overlay file. I have also added to the prj.conf the following:

  • CONFIG_NORDIC_QSPI_NOR=y
  • CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096

That worked great and the example code worked as expected.

The example code will NOT use the qspi flash if I add "CONFIG_BT" to the prj.conf


Below is my setup:

  •  Base code:  "/zephyr/samples/subsys/fs/littlefs"
  •  Building:  west build -b nrf5340dk_nrf5340_cpuapp
  •  Eval board:  NRF5340DK
  •  Zephyr:  build v3.0.99-ncs1

prj.conf


# Copyright (c) 2019 Peter Bigot Consulting, LLC
#
# SPDX-License-Identifier: Apache-2.0
#

# Optionally force the file system to be recreated
#CONFIG_APP_WIPE_STORAGE=y

# fs_dirent structures are big.
CONFIG_MAIN_STACK_SIZE=2048
#CONFIG_BT=y

# Let __ASSERT do its job
CONFIG_DEBUG=y

CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y

# enable QSPI flash
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096

CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y

CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_LITTLEFS=y

# My options
CONFIG_COMPILER_COLOR_DIAGNOSTICS=n

```

app.overlay

```
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/ {
    chosen {
       nordic,nus-uart = &uart0;
    };
};

/delete-node/ &storage_partition;

/ {
       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>;
       };
    };
};

// add QSPI flash partition and use the "storage"
// label so LittleFS will reference it
&mx25r64 {
    partitions {
       compatible = "fixed-partitions";
       #address-cells = <1>;
       #size-cells = <1>;

      lfs1_part: partition@0 {
          label = "storage";
          reg = <0x00000000 0x00010000>;
       };
    };
};

Output with: "#CONFIG_BT=y"

(Commented out) Works using external flash (DESIRED OUTPUT)

I: littlefs partition at /lfs
I: LittleFS version 2.4, disk version 2.0
I: FS at MX25R64:0x0 is 16 0x1000-byte blocks with 512 cycle
I: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
I: /lfs mounted
I: Automount /lfs succeeded
*** Booting Zephyr OS build v3.0.99-ncs1 ***
Sample program to r/w files on littlefs
Area 0 at 0x0 on MX25R64 for 65536 bytes
/lfs automounted
/lfs: bsize = 16 ; frsize = 4096 ; blocks = 16 ; bfree = 12


Output with: "CONFIG_BT=y"

(Bluetooth Enabled) Uses internal flash (BAD OUTPUT)


I: littlefs partition at /lfs
I: LittleFS version 2.4, disk version 2.0
I: FS at NRF_FLASH_DRV_NAME:0xfa000 is 6 0x1000-byte blocks with 512 cycle
I: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
I: /lfs mounted
I: Automount /lfs succeeded
*** Booting Zephyr OS build v3.0.99-ncs1 ***
Sample program to r/w files on littlefs
Area 7 at 0xfa000 on NRF_FLASH_DRV_NAME for 24576 bytes
/lfs automounted
/lfs: bsize = 16 ; frsize = 4096 ; blocks = 6 ; bfree = 1

  • Hello jodiem,

    Just letting you know that I am looking into this, and I will get back to you soon.

    Kind regards,

    Maria

  • Hello again jodiem,

    The example code will NOT use the qspi flash if I add "CONFIG_BT" to the prj.conf

    The cause for this is setting CONFIG_BT=y on the nRF5340 will implicitly cause the child image hci_rpmsg to be built for the network core. The existence of a child image again invokes the partition manager which will cause the flash partitions set in the devicetree to be ignored. This reply to an older case contains further explanation and some useful links. A more recent reply in the same case contains a sample which demonstrates statically defining the flash partitions.

    This pull request also provides a partial solution to your issue.

    I hope some of this information may be of help to you.

    Best regards,

    Maria

  • Hello Maria, 

    Thanks for looking into this.

    Just for clarification:

    1. Is there a limitation using Version 2.0.0 nrf_sdk with the v3.0.99-ncs1 to share the partition manager with the child image?

    2. Should I Just look at Pull 7927 and modify the v2.0.0 branch ... Instead of merging it.

    3. Is there a planned release of the SDK with pull 7927?

    I have merged https://github.com/nrfconnect/sdk-nrf/pull/7927 locally into the nrf_sdk directory. This has caused other issues I needed to checkout the main branch for both the nrf and the zephyr... which cause more build issues.

    Thanks,

    Jodie

  • Hello Jodie,

    1. nRF Connect SDK v2.0.0 and Zephyr SDK v3.0.99 are compatible. The partition manager should function correctly and take child images into account as well.

    2. The pull request was for the latest state of development, not for v2.0.0, so I suggest you edit the files in your local repository.

    3. I can't provide you with an exact release date, but it is under evaluation, and should be included in an upcoming release of NCS.

    jodiem said:
    I have merged https://github.com/nrfconnect/sdk-nrf/pull/7927 locally into the nrf_sdk directory. This has caused other issues I needed to checkout the main branch for both the nrf and the zephyr... which cause more build issues.

    If you need any assistance to figure out your new issues, I am happy to help.

    BR,

    Maria

  • Sorry, I was on vacation last week and did not get to investigate this until now.

    So the issue was that I did not have the pm_static.yml, and added a line to the "chosen" section of the app.overlay.

    pm_static.yml:

    littlefs_storage:
    address: 0
    end_address: 0x800000
    placement:
    before:
    - end
    region: external_flash
    size: 0x800000

    Modification of the app.overlay:

    diff --git a/app.overlay b/app.overlay
    index 3d289d8..9cf4d83 100644
    --- a/app.overlay
    +++ b/app.overlay
    @@ -6,6 +6,7 @@

    / {
    chosen {
    + nordic,pm-ext-flash = &mx25r64;
    nordic,nus-uart = &uart0;
    };
    };

    Thanks for your assistance!

    Jodie

Related