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.

Compiler/LAUNCHXL-CC1352R1: NVS access issue with instance 0

Part Number: LAUNCHXL-CC1352R1
Other Parts Discussed in Thread: SYSCONFIG

Tool/software: TI C/C++ Compiler

Hi Expert,

I had such a hard time opening the first NVS partition created by Syscfg regardless of its location and size.

I dig into the NV driver source code and it looks like the first NVS index (0) is already in use:

in simplelink_cc13x2_26x2_sdk_4_30_00_54/source/ti/common/nv/nvocmp.c

// Which NVS_config indice is used to initialize NVS.
#ifndef NVOCMP_NVS_INDEX
#define NVOCMP_NVS_INDEX    0
#endif // NVOCMP_NVS_INDEX


static uint8_t NVOCMP_initNvApi(void *param)
{

        // Use default NVS_Params to open this flash region
        NVOCMP_nvsHandle = NVS_open(NVOCMP_NVS_INDEX, param);

}

Also, this NVS region is never closed by the driver so could you please confirm that the first region is reserved for the NV driver?

  • Hi Jo,

    Could you elaborate on which example you base your test (if any)? Typically, the radio stacks use the NVS driver and in that case, they typically use the "first" which means you need to add a second region and use this in your user application. 

  • Hi M-W,

    In the dmm_wsnnode_ble_sp_app_CC1352R1_LAUNCHXL_tirtos_ccs example, the first NVS partition is called CONFIG_NVSINTERNAL, start address 0x3C000 and size 0x4000.

    However, if you look at the source code, this region does not seem to be used. In fact, I can rename/delete it from Syscfg without any compilation issue.

    Questions:

    1) Which radio protocol stack or module uses this CONFIG_NVSINTERNAL region?

    2) Could we reduce its size to one page (0x2000)?

    3) my understanding is that the first region is used by the NV driver preventing the application to open it. Am I wrong?

    /******************************************************************************
     * @fn      NVOCMP_initNvApi
     *
     * @brief   API function to initialize the specified NV Flash pages
     *
     * @param   param - pointer to caller's structure of NV init parameters
     *
     * @return  NVINTF_SUCCESS or specific failure code
     */
    static uint8_t NVOCMP_initNvApi(void *param)
    {
    ...
            // Use default NVS_Params to open this flash region
            NVOCMP_nvsHandle = NVS_open(NVOCMP_NVS_INDEX, param);
    
    }

    4) if the BLE OAD uses the SPI external flash, where is saved BLE bonding information?

    Thanks for your response, 

  • Hi Jo,

    The name is not really important here, the index in SysConfig is what the NVCMP layer uses. The region is used by the BLE stack which is why you see it open the "index 0" handle. You can't "just shrink it" as the size is connected to the NV layer abstraction, expecting two pages to be available. 

  • Hi M-W,

    Thanks for your clarification. 

    Lesson learned:

    • The NV layer will always open the index 0 regardless of its size and purpose.
    • The BLE stack uses 16Ko of flash regardless of the number of BLE bonds supported. 

    Thanks

  • Hi M-W,

    Just to clarify the index 0 section size is not hard-coded with the NV driver:

            NVOCMP_nvHandle.nvSize = NVOCMP_nvsAttrs.regionSize/NVOCMP_nvsAttrs.sectorSize;
            NVOCMP_nvHandle.nvSize = NVOCMP_nvHandle.nvSize > NVOCMP_NVPAGES ? NVOCMP_NVPAGES : NVOCMP_nvHandle.nvSize;
            NVOCMP_size = NVOCMP_nvHandle.nvSize;
    

    1) So reducing the first partition to one page (0x2000) should not have any side-effect (at least from my understanding).

    2) Now regarding the BLE bond information, how many bytes per device are required for saving the bond (address, encryption key,..) ? Currently, the first partition is set to 2Ko without any explanation.

    3) in a project without BLE, do we still have to reserve the index 0 for the NV driver?

    Thanks

  • Hi Jo,

    Regarding 2), the BLE bonding information is a little below 1 k per peer device. You can measure it yourself by reading this memory area before and after bonding with a peer device.

  • Hi Jo,

    On 3), the answer depends on what software you use. Many stacks for example use some version of the NV abstraction layers and in this case, you need to reserve the expected handle (easiest is to just add a new user handle after what ever is already existing in the project). If the software does not use any NV prior to your addition then you should not need to worry.