using persistent data storage, NRF Connect.

I am trying to save some data in flash.

it works, but it corrupts the Bluetooth thread .

If  I call my_settings_init(), then bt_enable(NULL) never returns.

in prj.conf I added:

--------------------------------------------------------

# config using settings store and load:
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y
# in file my.overlay the storage allocated is 8 pages = 32K (8 x 0x1000)
CONFIG_SETTINGS_NVS_SECTOR_COUNT=8

------------------------------------------------------------------------

the my.overlay is as so:

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

       storage_partition: partition@78000 {
           label = "storage";
           reg = <0x00078000 0x00008000>;  // Allocate 32K for settings storage
       };
   };
};

added in Cmakelist.txt:

set(DTC_OVERLAY_FILE "my.overlay")

 BT working is no setting system is used, setting working but currups BT.

What is wrong?

Thanks

void read_settings(void)
{
	settings_load();
}

int my_settings_init(void)
{
	int err = settings_subsys_init();
	if (err) {
		LOG_INF("Can't init settings subsys (%d)\n", err);
		return err;
	}
	
	err = settings_register(&my_conf);
	if (err) {
		LOG_INF("Can't register my settings handler (%d)\n", err);
		return err;
		
	}
	/* Load settings from persistent storage */
	read_settings();
	return 0;
}

Parents
  • Hi,

     

    If a single-image build is being performed, zephyr's DT defined partition layout is used.

    If a multi-image (for instance with MCUBoot) is performed, then the Partition Manager is used for defining the partition layout.

     

    The latter uses a yml-based layout (check if build-folder/partitions.yml is present), and requires a different syntax.

    One can create a my_application/pm_static.yml file containing:

    storage:
        address: 0x78000
        size: 0x8000
        region: flash_primary

     

    For the same functionality as you have set in the overlay.

     

    If you're not using partition manager, can you please share the build-folder/zephyr/zephyr.dts file?

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    If a single-image build is being performed, zephyr's DT defined partition layout is used.

    If a multi-image (for instance with MCUBoot) is performed, then the Partition Manager is used for defining the partition layout.

     

    The latter uses a yml-based layout (check if build-folder/partitions.yml is present), and requires a different syntax.

    One can create a my_application/pm_static.yml file containing:

    storage:
        address: 0x78000
        size: 0x8000
        region: flash_primary

     

    For the same functionality as you have set in the overlay.

     

    If you're not using partition manager, can you please share the build-folder/zephyr/zephyr.dts file?

     

    Kind regards,

    Håkon

Children
  • Hi Håkon,

    Obviously, my knowledge map of Zephyr and NRF Connect has many white spots. Current project will need a bootloader for firmware update via mobile DFU. So should I develop the project for multi image from start, or should I develop as singly image, and later do the partition for application and bootloader?

    If the correct approach is to go for multi-image at the development stage, how do I test the application without a debugger connected ?(I do it every step I take, removing the debugger and restarting, in order to check that power consumption has not jumped due to some added new code)

    I tried to set that pm_static.yml, but then setting_init() failed and the bl_enable() also never returned.. I need to get better understanding of the whole  system configurations.

    Thanks for your help.

    Johanan

  • Hi,

     

    Johan.h said:
    So should I develop the project for multi image from start, or should I develop as singly image, and later do the partition for application and bootloader?

    You can do both, if you'd like. You need to keep the two aligned, to ensure that one does not overwrite the other.

    Johan.h said:
    I tried to set that pm_static.yml, but then setting_init() failed and the bl_enable() also never returned..

    Try declaring it as "settings_storage:" instead of "storage:", and also delete the folder and re-generate the build from vscode after.

    If it still fails, can you share the build_folder/zephyr/zephyr.dts?

     

    Kind regards,

    Håkon

  • Hi,

    To recap: (note: I reduced size to 1 page eeprom simulation =0x1000, as I need only 3 numbers to store)

    Now, I get a Cmake error when I add pm_static.yml to the project directory:

    CMake Error at E:/ncs/v2.3.0/nrf/cmake/partition_manager.cmake:304 (message):
      Partition Manager failed, aborting.  Command:
      C:/ncs/toolchains/v2.3.0/opt/bin/python.exe;E:/ncs/v2.3.0/nrf/scripts/partition_manager.py;--input-files;E:/MyWork/FeedSens_NRF_Connect/fdSensV2/build/nrf52dk_nrf52832/Debug/zephyr/include/generated/pm.yml;E:/MyWork/FeedSens_NRF_Connect/fdSensV2/build/nrf52dk_nrf52832/Debug/modules/nrf/subsys/partition_manager/pm.yml.settings;--regions;sram_primary;flash_primary;--output-partitions;E:/MyWork/FeedSens_NRF_Connect/fdSensV2/build/nrf52dk_nrf52832/Debug/partitions.yml;--output-regions;E:/MyWork/FeedSens_NRF_Connect/fdSensV2/build/nrf52dk_nrf52832/Debug/regions.yml;--static-config;E:/MyWork/FeedSens_NRF_Connect/fdSensV2/pm_static.yml;--sram_primary-size;0x10000;--sram_primary-base-address;0x20000000;--sram_primary-placement-strategy;complex;--sram_primary-dynamic-partition;sram_primary;--flash_primary-size;0x80000;--flash_primary-base-address;0x0;--flash_primary-placement-strategy;complex;--flash_primary-device;flash_controller;--flash_primary-default-driver-kconfig;CONFIG_SOC_FLASH_NRF
    Call Stack (most recent call first):

    in prj.conf:

    # config using settings store and load:
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y
    CONFIG_SETTINGS_NVS_SECTOR_COUNT=1

    The pm_static.yml:

    settings_storage:
        address: 0x7E000
        size: 0x1000
        region: flash_primary
    

    The build/zephyr.dts is here.

    If I remove pm_static.yml from the directory, I can build the project with no errors.

    BR

    Johanan

  • Hi,

     

    Could you share the full error log?

     

    Kind regards,

    Håkon

Related