After enabling MCUBoot in NCS, external flash doesn't get picked up by littleFS

Hello:

I am using an nrf52840 on a custom board with W25Q01NV NOR Flash with the Nordic QSPI-NOR driver. Programming is with NCS v 1.8.0 (upgraded yesterday) and the VS Code extension.  I am using the external Flash partition only for storage of data collected by the device and not for use with MCUBoot or for anything else. This setup was previously working with nrf5 SDK and recently moved to NCS.

When the CONFIG_BOOTLOADER_MCUBOOT option is not enabled, the code works fine, mounts the parittion and starts recording the data, but when I enable MCUBoot, LittleFS mounts on an internal flash parition. I found this related issue here: https://devzone.nordicsemi.com/f/nordic-q-a/62212/external-spi-flash-to-use-with-littlefs-on-nrf9160-w-mcuboot, but that was from a year ago and there was no resolution to that issue.

Again, I do not want to store MCUBoot images on the external flash, but I want to still use it for storage and I need MCUBoot enabled for upgrades as usual with the internal flash only. 

Any help is appreciated. 

Ashwin

  • Could you run the command below from the build folder and upload the result here?

    ninja partition_manager_report

    Best regards,

    Simon 

  • Thanks Simon. This is the output of the patition manager report. 


    flash_primary (0x100000 - 1024kB):
    +-------------------------------------------------+
    | 0x0: mcuboot (0xc000 - 48kB) |
    +---0xc000: mcuboot_primary (0x77000 - 476kB)-----+
    | 0xc000: mcuboot_pad (0x200 - 512B) |
    +---0xc200: mcuboot_primary_app (0x76e00 - 475kB)-+
    | 0xc200: app (0x76e00 - 475kB) |
    +-------------------------------------------------+
    | 0x83000: mcuboot_secondary (0x77000 - 476kB) |
    | 0xfa000: littlefs_storage (0x6000 - 24kB) |
    +-------------------------------------------------+

    sram_primary (0x40000 - 256kB):
    +--------------------------------------------+
    | 0x20000000: sram_primary (0x40000 - 256kB) |
    +--------------------------------------------+
  • These are my DTS definitions of the parittions:

    &flash0 {

    partitions {
    compatible = "fixed-partitions";
    #address-cells = <1>;
    #size-cells = <1>;

    boot_partition: partition@0 {
    label = "mcuboot";
    reg = <0x000000000 0x0000C000>;
    };
    slot0_partition: partition@c000 {
    label = "image-0";
    reg = <0x0000C000 0x00067000>;
    };
    slot1_partition: partition@73000 {
    label = "image-1";
    reg = <0x00073000 0x00067000>;
    };
    scratch_partition: partition@da000 {
    label = "image-scratch";
    reg = <0x000da000 0x0001e000>;
    };

    /*
    * The flash starting at 0x000f8000 and ending at
    * 0x000fffff is reserved for use by the application.
    */

    /*
    * Storage partition will be used by FCB/LittleFS/NVS
    * if enabled.
    */
    storage_partition: partition@f8000 {
    label = "storage";
    reg = <0x000f8000 0x0008000>;
    };
    };
    };
    And the overlay definition for the external flash is:
    /delete-node/ &storage_partition;

    / {
    fstab {
    compatible = "zephyr,fstab";
    lfs1: lfs1 {
    compatible = "zephyr,fstab,littlefs";
    mount-point = "/lfs1";
    partition = <&lfs1_part>;
    //automount;
    read-size = <32>;
    prog-size = <32>;
    cache-size = <64>;
    lookahead-size = <32>;
    block-cycles = <512>;
    };
    };
    };

    &w25q01jv {
    partitions {
    compatible = "fixed-partitions";
    #address-cells = <1>;
    #size-cells = <1>;

    lfs1_part: partition@0 {
    label = "storage";
    reg = <0 0x8000000 >;
    };
    };
    };
    Am I missing something in the definitions? The above DTS works fine without MCUBoot.
  • Try setting CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=n in the prj.conf of your application. Then the secondary slot will no longer be located in the external flash

    If you have enabled external flash and mcuboot, the secondary slot will automatically be placed in the ext. flash. The config PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY will get the value 'y'.


    An important thing to be aware of is that the flash partitions from the DTS will be ignored if the sample have child images. The partitions from the Partition Manager will be used instead. For example when you enable MCUboot, your application will add MCUboot as a child image (see <application>/build/mcuboot) and the DTS flash partitions will get ignored.

    The partitions from the Partition Mangager will be generated dynamically bases on pm.yml files, for example:

    or they can be set statically, like it's done in the matter/lock sample:

    https://github.com/nrfconnect/sdk-nrf/blob/v1.8.0/samples/matter/lock/configuration/nrf52840dk_nrf52840/pm_static.yml

    Read more about the Partition Manager in the documentation:

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/nrf/scripts/partition_manager/partition_manager.html

  • Thank you Simon, for your detailed reply. Let me try all of these points and get back with the result. 

Related