This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2652R: Nonvol Usage

Part Number: CC2652R


Hello,


We have a simple app running on the CC2652R using the SimpleLink CC13x2 26x2 SDK v4.20.01.04.  It uses both the BLE radio and Zigbee.  We have been using the zclport APIs to create and manage several NV items in flash, which is a layer above the NVOCMP drivers.  Recently, we ran across an article that says the application should not use the NVOCMP drivers directly, but should use the osal_snv API to manage flash items.

Flash — SimpleLinkTm CC13x2 / CC26x2 SDK BLE5-Stack User's Guide 2.01.00.00 documentation

If that is correct, then it sounds like we should migrate our NV interface to use the osal_snv() API.  Is that correct?

I started down that path and ran into a couple questions.

1. The same link I posted above seems to indicate we can only use token ID values from 0x80 to 0x8F - which only supports up to 16 application tokens.  Is that correct?

2. The osal_snv_init() function seems to be called very late in the initialization - after our application init functions have been called.  Can I call osal_svn_init() before the stack calls it so I can use the osal_svn_read() and _write() function during our initialization?  If not, am I not able to use the osal_snv_read() and write() functions until the stack initialization is done?  Is there any kind of event or notification I can use to know when the OSAL SNV system is ready for use?

3. I did write a simple function during my initialization to just try initializing the OSAL SNV (before the stack does), then reading and writing a new value.  The code is as follows:

static my_struct_typedef_t  my_struct = {0};
uint8_t status = osal_snv_init();
status = osal_snv_read(0x80, sizeof(my_struct), &my_struct);
// set values into my_struct
status = osal_svn_write(0x80, sizeof(my_struct), &my_struct);

--

I printed all 3 status values and got the following:

* osal_snv_init() - returned 0

* osal_snv_read() - returned 2 (INVALIDPARAMETER ?)

* osal_snv_write() - returned 5 (INVALID_MSG_POINTER ?)

Why are these simple calls failing?

Thank you

  • Hi,

    Thank you for reaching out.

    When using the non-volatile storage with the BLEStack, you actually have two options.
    First option is to leverage the same NVS region as the stack and follow the documentation you have pointed out. This approach is recommended when looking at storing little amount of data.
    Second option is to define the application's own NVS region. This offers more freedom to developers (and more storage space). The drawback is that the memory consumption is larger as a least one flash page is allocated to the new NVS region.

    In your case, it sounds like you should go for the NVS region approach. There is no specific guidance in the user's guide for this approach as it is quite stack agnostic - the stack does not access the application's NVS region, and the NVS region does not interface with the stack. If needed, I recommend you reference to the NVS driver documentation and examples.

    I'll answer the other questions with little details - let me know if I should expand my answers:

    1. It is true, on SDK 4.20, only 16 NVS tokens are left to the application. Note that newer SDK versions have increased the maximum number of token to a higher number. Here is the download link to the newer SDKs: https://www.ti.com/tool/download/SIMPLELINK-LOWPOWER-F2-SDK
    2. osal_snv_init() should be called prior to any other OSAL SNV function. osal_snv_init() should be called after ICall_enrollService(). Other than this, you should be able to call it fairly early in the initialization process.
    3. I believe the first osal_snv_read() fails because you are trying to read a non-initialized SNV ID - SNV IDs are initialized by writing them with osal_snv_write()
      The osal_snv_write() operation maybe failing because of the type of "my_struct" (should be a table of uint8_t).

    I hope this will help,

    Best regards,

  • Hello,

    Thank you for your response!  Regarding #3, you said the "my_struct" type should be a table of uint8_t.  What does that mean?  Does that mean each of the 16 NVS tokens can only be a single u8?  The OSAL NV system does not support structures?  Or could I create a single U8 array token with a length of say, 40-60 bytes?

    The OSAL SNV system seems to be pretty easy to use and well-documented, but if we are limited to 16 bytes, it is definitely too restrictive, and I will have to figure out the NVS region approach you suggested.  Would you mind pointing me to the NVS driver documentation and examples that you had in mind?  Is this available online, or in the SDK?  Sorry for the newbie questions.  I really appreciate your help!

  • Hi,

    Tokens can definitely be used to point on data larger than 1-byte. Here, I am not sure which size "my_struct" has, nor if it is aligned.

    NVS examples can be found in the SDK: <SDK>\examples\rtos\CC26X2R1_LAUNCHXL\drivers\nvsinternal
    NVS documentation can be found in the docs folder of the SDK, or online: https://dev.ti.com/tirex/explore/content/simplelink_cc13xx_cc26xx_sdk_7_40_00_77/docs/drivers/doxygen/html/_n_v_s_8h.html

    Best regards,

  • I changed my structure (that was 4-byte aligned) to a 64-byte array but am still getting the same error status codes.  However, I then tried this on a second board, and it worked correctly.  I'm guessing there must be some NV corruption on the first board, so I will try erasing it later.  Anyway, the osal_nv approach appears to be working now, so I think that takes care of my questions.  Thank you!