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.

CC2640R2F: SNV one ID 255 bytes full

Part Number: CC2640R2F

Dear friends,

SNV's each ID has maximum 255 bytes in default. So in that case, if customer keeps writing on the same SNV ID again and again and again and again, finally it will be full. If we use only one SNV ID, 80% occupation of 4K SNV will never happen, compact will not execute, so what will happen? We are not able to write to the same SNV ID anymore?

If we could not write to the SNV ID anymore, what else we can do if we still want to use the same SNV ID?

Thanks!

  • Hi Yan,

    Yan said:
    SNV's each ID has maximum 255 bytes in default

    Correct, by default, osalSnvId_t and osalSnvLen_t are type defined as uint8. But it is possible to use uint16-type definitions, you can define the preprocessor symbol OSAL_SNV_UINT16_ID in both the application and stack projects.

    Having said that, let me address your other questions:

    Yan said:
    if customer keeps writing on the same SNV ID again and again and again and again, finally it will be full. If we use only one SNV ID, 80% occupation of 4K SNV will never happen, compact will not execute, so what will happen? We are not able to write to the same SNV ID anymore?

    The SNV manager performs compaction on the flash sector (or sectors) when the sector has 80% invalidated data, so this will happen even if there is only a single ID. Depending on the OSAL_SNV, this valid data is then either placed back in the newly erased sector or remains in a new sector (after the compaction). Please take a look a this http://software-dl.ti.com/lprf/simplelink_cc2640r2_latest/docs/blestack/ble_user_guide/html/cc2640/memory_management.html?highlight=osal#using-simple-nv-for-flash-storage for more information.

    Hopefully this helps.

     David

    if customer keeps writing on the same SNV ID again and again and again and again, finally it will be full. If we use only one SNV ID, 80% occupation of 4K SNV will never happen, compact will not execute, so what will happen? We are not able to write to the same SNV ID anymore?

  • Hi David,

    Thank you very much for your reply.
    I've read the document, but still have some questions want to discuss with you.
    " this valid data is then either placed back in the newly erased sector or remains in a new sector", meaning there will be new 4KB flash sector located for SNV automatically by SNV manager? (I assume "sector" you mean here is 4KB flash page)
    For example, we set OSAL_SNV Value 2, then we have 2 sectors 8KB flash(4KB is active) in use, with compaction, if customer keeps writing on the same SNV ID again and again, finally will exceed 225 bytes of of this SNV ID, right? Then the SNV manager will allocate new 4KB flash sector somewhere in the whole 128KB flash for this SNV ID? Then customer can still keep writing data into this SNV ID, no space limitation?
    Thank you for you help, just want to make it clear.
  • Yan said:
    Then the SNV manager will allocate new 4KB flash sector somewhere in the whole 128KB flash for this SNV ID?

    You are limited to the allocated pages for SNV which is for OSAL_SNV = 2, 2 Pages Memory Range 0x0001D000 - 0x0001E000.

    What happens if you do SNV Write is it appends to the next memory location until it reaches 80% of the page where it will perform compaction.

    -kel

  • Hi Markel,

    Thank you for you reply.

    is it possible that even with the compaction, some day the one page 4KB flash will be fully written?

    thanks!

  • Yan said:
    is it possible that even with the compaction, some day the one page 4KB flash will be fully written?

    Yes, presumably. I have not confirmed that.

    Lets say you have 1 SNV ID and you write 1 byte to it. Then you set OSAL_SNV = 2. When you write to that SNV ID it will write to the next memory location +1 byte within that one page 4KB flash. When you write and write to that SNV ID it will eventually reach 80% of that one page 4KB Flash. Then it will backup that data to next one page 4KB flash, then perform compaction to the first one page 4KB flash. After compaction it will copy back again the data form the second one page 4KB flash to the first one page 4KB flash.

    -kel