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

Parents
  • 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

  • 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

Reply
  • 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

Children
Related