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:

added in Cmakelist.txt:

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

What is wrong?

Thanks

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:

     

    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

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

    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:

    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:

    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

  • I sent link to project in private msg. Thanks.

  • Hi,

     

    Thanks for the project.

     

    I am sorry, but I have misinformed you earlier. When a pm_static.yml file is present, the build-system assumes to use PartitionManager, even for single-image builds. The problem is that the firmware requires an added kconfig.

    In your prj.conf, try to add:

     

     

    PS: You need to set aside a minimum of two flash pages for the settings subsys:

     

    Kind regards,

    Håkon

  • I tried, but no joy yet.

    I added in prj.conf:

    CONFIG_PM_SINGLE_IMAGE=y

    and fixed:

    CONFIG_SETTINGS_NVS_SECTOR_COUNT=2

    in pm_static.yml:

    Configuration build is OK but still have that build error:

    BTW did you try to build the project?

    Thanks

    Johanan

Reply
  • I tried, but no joy yet.

    I added in prj.conf:

    CONFIG_PM_SINGLE_IMAGE=y

    and fixed:

    CONFIG_SETTINGS_NVS_SECTOR_COUNT=2

    in pm_static.yml:

    Configuration build is OK but still have that build error:

    BTW did you try to build the project?

    Thanks

    Johanan

Children
  • Your offset address is incorrect in the pm_static.yml, shall be:

    address: 0x7e000

    for a size of 0x2000.

     

    Kind regards,

    Håkon

  • Well, that was rather silly of me :-), I should know HEX numbers already.

    Now it builds OK, I will test the setting save/load later today.

    Thanks very much.

    Johanan

  • The following creates a hard error:

    However, if I call save_settings()  just at main() , before anything else, like bt_enable() , it works OK, and writes the setting in memory.

    What can be the reason?

    Thanks.

    Johanan

  • I resolved the save_settings issue by taking it to the main loop from the write cb function, using a queue.

    So now it works, but I would like to know why it does not work from inside the char write cb function.

    BR

    Johanan

  • Hi,

     

    BT callbacks are running in interrupt context, and you should not call such functions directly from interrupts.

     

    Kind regards,

    Håkon