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.

CC1352R: Protect NVS sectors during reboot / program load / etc.

Part Number: CC1352R

Currently I am using the NVS driver to read and write from a FLASH sector. When I read directly after I write, I can see the right data. However, if I read after a program load, it is gone.

How to make sure that that flash sector is not being erased when I enter debugging mode / flash it / reboot the device? I have tried to set Debug Configuration -> Flash Settings->Erase Settings during Program Load to "Do not erase sectors (program load only)", but then I get this error:

Cortex_M4_0: File Loader: Memory write failed: Timed out waiting for target flashloader to execute command.

I also tried to use the CCFG.c file and set SET_CCFG_CCFG_PROT_... to protect all sectors, and then set the Debug Configuration->Flash Settings->Erase Settings during program load to "All unprotected sectors". However, that still does not work.

What am I missing?

  • Currently I can have persistent storage using NVS to address 0x50000, if I set Project Properties->Debug->Flash Settings->Skip Sectors during Program Load. I don't even have to fill in a specific sector. If I do fill in a sector, it does not matter which one, it will always work. However, If i disable sector skipping option, it does not work anymore.

    This is not what I would expect.

    Also I tried to use CCFG_WRITE_PROT_*, and set them all to 0x00000000, which seems to do nothing. The data is still written.

    This is also not as I would expect.

  • Hello User,

    Which program do you use?

    If different parts of your code needs to placed in a sector that sector will be erased on program load.

    Did you set:

    Project Properties->Debug->Flash Settings->Program Load Settings: Necessary Sectors Only (Retain untouched content within sector)

  • Hello Eirik,

    I am using Code Composer Studio.

    Is necessary sectors only safe to use, or is it better to protect specific sectors?
    Currently I am confused as to which sectors in the CCFG and program load sections map to which addresses. The sectors in the program load settings seem to overlap, as protect sector 3 gives the same results as protecting sector 5. Moreover, even if I write protect all sectors in the CCFG, I can still use NVS to write to a sector, which is not what I would expect?

  • Hello User,

    You should be careful to edit the last sector where CCFG reside. You can potentially brick the device if you disable JTAG and flash erase.

    Show me a screen shot of your entire Project Properties->Debug->Flash Settings.

  • Currently I have them as in the attached screenshot.

    My goal: Have a few sectors of non-volatile storage (also between program loads), and have 1 section as read-only after I have written it once (which I need the CCFG settings for I believe)

  • Hello User,

    You need to change to "Necessary Sectors Only" and then you should reserve the pages in your linker cmd file.

  • Thank you Eirik.

    The last challenge now is to figure out which sector to protect using CCFG_WRIT_PROT_*. If I were to place a section on the page right under CCFG, would it be the very last sector I would have to protect? I don't want that specific sector to ever be written to again after I have written to it once.

  • Hello User,

    Each sector/page is 8 kB with a total of 44 sectors (0-43). The last sector (43) is reserved for CCFG and application code (or BIM). You could reserve sector 42 then try to modify that sector with unliflash or flash programmer 2 to verify that its write protected.

  • Hello Eirik,

    Thank you, this is all I needed to know!