SWRU271I October 2010 – January 2020 CC2540 , CC2540T , CC2541 , CC2541-Q1 , CC2640R2F
The SNV area of flash securely stores persistent data, such as encryption keys from bonding or custom parameters. The protocol stack reserves two 2-kB flash pages for SNV. These pages are the last two pages of flash by default. To minimize the number of erase cycles on the flash, the SNV manager performs compactions on the flash sector when the sector has 80% invalidated data. A compaction is copying valid data to a temporary area then erasing the sector where the data was stored. The SNV driver uses the hal_flash driver.
SNV can be read from or written to using the following APIs:
id – valid NV item
len – Length of data to read
pBuf – pointer to buffer to store data read
SUCCESS: NV item read successfully
NV_OPER_FAILED: failure reading NV item
id – valid NV item
len – Length of data to write
pBuf – pointer to buffer containing data to be written
SUCCESS: NV item read successfully
NV_OPER_FAILED: failure reading NV item
Because SNV is shared with other modules in the Bluetooth Low Energy SDK such as the GAPBondMgr, carefully manage the IDs of the NV item. The available IDs are defined in bcomdef.h by default: