Using NVS settings for BLE in external flash with nrf5340 (ncs 2.0.2)

Hello,

I have an issue when trying to use NVS backend for BLE settings with the settings_storage partition in defined external flash region. As we are doing a multi-image build, the partition manager is enabled and adds the settings_storage partition automatically when building with settings enabled, which defaults to flash_primary region. What we want to achieve is be able to put this partition in external flash to save space in internal flash.

I'm using nrf5340 custom board, but I tried it on nrf5340 DK and I observed the exact same issue, so I doubt it is related to hardware. I'm using NCS 2.0.2.

The issue :

When calling bt_enable() with settings enabled, the device seems to get stuck in sysworkq thread (observed with SystemView) for a few minutes without crashing. See here : 

As you can observe, the logging that tells to call settings_load gets preempted for a few minutes (around 10 minutes), and then initialization continues, bt_enable() returns with success, so we call settings_load() which fails with this error that is spammed in logs :

What I did in my pm_static.yml file is that I redefined settings_storage partition to be in external flash, like this:

data:
  address: 0x0
  size: 0x60000
  device: MX25R64
  region: external_flash
settings_storage:
  address: 0x60000
  size: 0x20000
  device: MX25R64
  region: external_flash
mcuboot_secondary:
  address: 0x80000
  size: 0xec000
  device: MX25R64
  region: external_flash  
mcuboot_secondary_1:
  address: 0x16c000
  size: 0x40000
  device: MX25R64
  region: external_flash  
littlefs_storage:
  address: 0x1ac000
  size: 0xe54000
  device: MX25R64
  region: external_flash
external_flash:
  address: 0x1000000
  size: 0x0
  device: MX25R64
  region: external_flash

I can use all these partitions without any issue, perform MCUboot DFU on both cores with images on external flash, use filesystem (LittleFS) and data partition with flash_area API. If we use file system backend for settings it works well, but we would to prefer not using the filesystem for that.

I tried to erase the QSPI external flash completely see if it solves any issues, but I still have the same issue.

If I leave the partition to flash_primary with NVS settings backend, I don't observe any of these issues, everything works as expected. I saw that every NCS sample keeps this partition in flash_primary in the PM static config, and I was wondering if it has been tested with external flash and if it's supposed to work or even recommended.

And also, if we have to go with internal flash, by default the settings_partition in only 8 kB. Is that enough if it's only used for BLE settings ?

Parents
  • Hi,

    Due to summer vacation we are short staffed, and some delays are expected.

    I have started looking into your issue, but I will have to ask the development team. I will get back to you tomorrow.

    Best regards,

    Marte

  • Hi,

    Thank you for your patience. I have not gotten a response from the development team yet, but I did test this myself as well.

    I was not able to reproduce the same error as you are seeing, and when I tested the settings was loaded without issue. In addition to setting the regions in pm_static.yml I also created an overlay file for nRF5340 DK where I added the following

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

    Then I added this to prj.conf:

    CONFIG_NORDIC_QSPI_NOR=y
    CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16

    Can you try adding this to your project and see if there is a difference?

    Have you tested with a minimal sample to see if you get the same error there? For example the Peripheral LBS sample.

    Best regards,

    Marte

  • Hi Marte, thank you for taking the time to try that out.

    I'm already using these configs in prj.conf, and also have this overlay/dts definition for external flash since it is required to mount littleFS on external flash which works without issues.

    I will try to do if I can make it work with the sample you suggested and putting settings in external flash. I will share results.

    Kind regards,

    Jimmy

Reply
  • Hi Marte, thank you for taking the time to try that out.

    I'm already using these configs in prj.conf, and also have this overlay/dts definition for external flash since it is required to mount littleFS on external flash which works without issues.

    I will try to do if I can make it work with the sample you suggested and putting settings in external flash. I will share results.

    Kind regards,

    Jimmy

Children
Related