CC2340R5: After writing data using nvs, the data cannot be read after restarting the device.

Part Number: CC2340R5
Other Parts Discussed in Thread: SYSCONFIG

I want to utilize the NVS function in Zigbee. I attempted to perform the operation in the example "nvsinternal" (the code is above). I will use the following code: NVS_write(nvsHandle, 0, (void *)signature, sizeof(signature), NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY); After this function is executed, the data can be seen in the memory. When I call NVS_write(nvsHandle, 0, (void *)signature, sizeof(signature), NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY); After the comments are removed and re-written into the memory, there is no content in the memory. Why is this so? Isn't NVS a power-off non-volatile device? Or is it because I missed some operation somewhere? The address is also in the 512KB programmable flash memory.

5493fd4ba39b48a5fff4affeb79ea922.png

7518dfd9873596de5d7077a68da298fc.png

  • Hi bin,

    Please be aware first of all that the CONFIG_NVSINTERNAL_ZB space in Zigbee examples is directly accessed by ZBOSS and therefore should only be interacted with through NVRAM APIs. You could also consider creating a second internal NVS storage space in SysConfig but you would need to make sure and modify your command linker file (.cmd) accordingly.

    Each time you program the device, flash memory which is not protected by the CCFG is erased.  The entire flash is erased by default, including your current NVS allocated flash memory.  In the instance you've described, when you describe how "comments are removed and re-written into the memory" then you are implying that the device has been re-programmed so the flash memory is erased before loading.  There are settings in the Device Configuration module of SysConfig which could address this, see my relevant E2E response.

    Regards,
    Ryan