Settings subsystem fails initialization on the nrf5340DK

I found an issue with a settings subsystem implementation on an nrf5340DK board I'm working with. I originally implemented the settings subsystem on an nrf52840DK which worked fine there. Later I needed to port that functionality over to the nrf5340DK where things fell apart. I debugged the issue down to a flash read command called from nvs_flash_rd() (ncs\v2.3.0\zephyr\subsys\fs\nvs\nvs.c). The failure is an access violation which triggers a reboot. I ran the settings subsystem sample on the nrf5340Dk and that worked fine. So I started working to pin down config settings that may be exposing this issue. I found that CONFIG_BOOTLOADER_MCUBOOT=y along with CONFIG_FILE_SYSTEM=y and CONFIG_FILE_SYSTEM_LITTLEFS=y will cause the settings subsystem initialization to fail. Setting CONFIG_BOOTLOADER_MCUBOOT or the file system settings by themselves will work but, setting them together causes an access violation. Will you please take a look at the v2.3.0 settings subsystem sample along with my modified prj.config file and see if you can figure out what the problem is?

6366.prj.conf

Parents
  • Hi,

    We've picked up your case today and will be looking into the sample and your configuration for the nRF5340DK

    I will get back to you as soon as I have something constructive for you

    Kind regards,
    Andreas

  • Hi,

    It looks like you will need to enable CONFIG_NVS=y as well.

    This setting is enabled by default for the nRF52840, while it is disabled for the nRF5340. I will look into if this is a bug or intended.

    While you don't have CONFIG_NVS=y enabled, you can see from the partition report that the settings_storage partition is not created, which results in the initialization error

    Adding CONFIG_NVS=y the settings storage partition will be added to the partitioning

    Let me know if that resolves the issue you're seing

    Kind regards,
    Andreas

  • In the sample prj.config I provided CONFIG_NVS=y is already there. It is set as part of the 'settings subsystem' sample. It is also set in my target project, so no, unfortunately this doesn't resolve my issue. 

    Where you able to reproduce the issue using the 'settings subsystem' sample and the prj.config I provided built for the nrf5340DK?

    Thanks,

    Kyle

  • You are absolutely correct, the config is already present in the configuration you provided. Wow, that's interesting. It is however not present in a pristine version of the settings subsystem sample for NCS v2.3.0

    What I did was to take a pristine settings subsystem sample, which has the configuration like this 

    CONFIG_STDOUT_CONSOLE=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    
    CONFIG_SETTINGS=y
    CONFIG_SETTINGS_RUNTIME=y
    

    Then I added 

    ############### Added Configs ################
    
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_FILE_SYSTEM=y
    CONFIG_FILE_SYSTEM_LITTLEFS=y
    

    which resulted in  the following result for the 52840DK (nrf52840dk_nrf52840) and the 5340DK (nrf5340dk_nrf5340_cpuapp)

    After that I added CONFIG_NVS=y to the bottom of the prj.conf

    which added the settings_storage partition to the partitioning as well as successfully initialized the settings subsys (from the device terminal output)

    So I find it interesting that this does not work on your end

    1. Have you made any other modifications to the project?
    2. Which build target did you build for?
    3. What revision is the 5340DK you have available?
    4. Could you check the partition map for the modified to see if settings_storage is located there?

    Here's the zip of the project I built and ran. Firmware for 5340 with modifications is in build_2 (can be flashed through west flash -d build_2)

    2063.settings_with_NVS.zip

    Kind regards,
    Andreas

  • Another developer on the project was having similar flash issues and found he could create a pm_static.yml partition file. He also added the settings subsystem mapping as well. This appears to have resolved the issue although admittedly I still don't why the auto gen'd partition.yml didn't work.

    Best regards,

    Kyle   

  • I agree,

    I will write this issue down as a potential bug and investigate it closer when I have time. Do also note that this might've been patched in NCS v2.4.x or v2.5.0. I find it strange that the dynamic partitioning works for me and not for you and your colleague.

    Nonetheless, glad to hear that a static partitioning resolved the issue.

    Do you have any other questions related to this topic, or can I mark this as resolved for now?

    Kind regards,
    Andreas

Reply
  • I agree,

    I will write this issue down as a potential bug and investigate it closer when I have time. Do also note that this might've been patched in NCS v2.4.x or v2.5.0. I find it strange that the dynamic partitioning works for me and not for you and your colleague.

    Nonetheless, glad to hear that a static partitioning resolved the issue.

    Do you have any other questions related to this topic, or can I mark this as resolved for now?

    Kind regards,
    Andreas

Children
Related