Best way to write persistent data in factory

Hi, team.

I am trying to find a way to write some persistent data in factory.

The data is a couple of certificates and should be written differently for each devices.

What is the best way to achieve this?

I am considering to use NVS and zephyr settings libraries to save certificates, but want to know whether the better/recommended way exists.

And also, let me know some guideline how to make suitable format (like .hex, maybe?) for writing to flash with well-known flash writing tools like nrfprog or Programmer.

I tried to make my own CLI interface via UART, etc., but currently, target device is lack of resources, and can't afford for it.

Parents Reply Children
  • Hi,

     

    choehyunho said:
    1. Writing certs in NCS CLI via UART. With this way, I can easily adapt my settings code and just implement proper shell command. But I am not sure current CONFIG_SHELL feature in zephyr is properly handling thousands of bytes certificates or not.

    This is one way of doing it. It is very similar to the "at_client", where we have the option to write certificates to the nRF9160 modem.

    choehyunho said:
    2. Writing small PC utility for making HEX fitted in settings partition. I found https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/matter/nrfconnect_factory_data_configuration.html document and looking into settings_ncs.c in NCS. It is quite a large work and I am still suspicious it is worthy.

    A solution similar to this will probably be the quickest way, as you're writing the data directly into flash.

    This is a solution that is tailored towards matter applications. You can try to adjust the parameters to make it match your setup, but this will require tuning on your side.

     

    I would recommend that you test this to see if it can be used for your exact use-case.

     

    Kind regards,

    Håkon

  • This is one way of doing it. It is very similar to the "at_client", where we have the option to write certificates to the nRF9160 modem.

    I tried this, and basically confirmed it possible. But, my current board is almost out of memory (it occupies 120KB out of 128KB), and I determined to use the second way.

    A solution similar to this will probably be the quickest way, as you're writing the data directly into flash.

    This is a solution that is tailored towards matter applications. You can try to adjust the parameters to make it match your setup, but this will require tuning on your side.

     

    I would recommend that you test this to see if it can be used for your exact use-case.

    I spent some times to review the structure of Zephyr settings module, but eventually it seems to be to redundant and waste of flash space for my specific usage.

    Currently, I am tied to another urgent work and need some more time to solve this issue.

    So, I will update my experience after a while.

    BTW, I found some interesting document (https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/storage/nvs_partition_gen.html) in ESP32.

    Is it related to zephyr? It looks quite similar.

  • Hi,

     

    "NV" is a generic term for non-volatile memory, so I am not sure if those two libraries are compatible. The link you provided is to a library that also supports encrypted storage, which zephyr's NVS does not support.

     

    Kind regards,

    Håkon

Related