Thread 中讨论的其他器件: UNIFLASH、 BLE-STACK
工具/软件:
您好:
我正尝试将一些数据存储在 NVS 存储器区域。
为了运行代码、我使用了 nvsinternal_CC1352R1_LAUNCHXL_tirtos_ccs 示例工程中的代码。
此工程使用 NVS.h 驱动程序函数。
写入和读取工作正常、但 电源复位后存储器区域会被更改。
我没有使用调试模式、因为我读到它会将 NVS 区域作为默认值终止、但连接到已运行的目标以观察数组和变量

}
bool nvs(void)
{
uint16_t offset = 0x50; //how do I know this does not clash with the bonding table?
uint8_t readnvsData[8];
static const uint8_t data[8] =
{0x0F, 0x42, 0x3F, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A};
bool res = true;
NVS_Handle nvsHandle;
NVS_Attrs regionAttrs;
NVS_Params nvsParams;
NVS_init();
NVS_Params_init(&nvsParams);
nvsParams2 = nvsParams;
nvsHandle = NVS_open(CONFIG_NVSINTERNAL, &nvsParams);
if (nvsHandle == NULL) {
res = false;
}
NVS_getAttrs(nvsHandle, ®ionAttrs);
int_fast16_t resRead = NVS_read(nvsHandle, offset, (void *) readnvsData, sizeof(readnvsData)); // on first boot the bytes read here are all 0xFF, after power reset they should match the ones written below
resRead = NVS_write(nvsHandle, offset, (void *) arrayToWrite, 8, NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);
resRead = NVS_read(nvsHandle, offset, (void *) readnvsData, sizeof(readnvsData)); // matches the written data from a column above
NVS_close(nvsHandle);
return res;
}
电源复位后读取数组的内容:

我是在启动后的 BIOS_start() 之前立即调用这个函数;
我不知道这里 NVS 驱动程序的使用是否正确,因为我看到论坛中的大多数人似乎使用的 oasl 功能,这对我来说不起作用。
我在某些器件只允许写入操作的倍数或 4 个字节的地方读取数据。
CC1352R 是如此吗?
到目前为止、我看到没有其他模块在使用 NVS 驱动程序、是否可以在某个地方设置一些可能会扰乱我的内存? 也许是债券经理?
我还使用了偏移值、将其设置为 0x2000 或 0x50、但结果保持不变。
在电源复位之前、我是否需要做些什么来永久锁定存储器?
我们使用 SimpleLink CC13x2 26x2 SDK v5.20.0.52、无法更新到较新的版本。
感谢您的支持
Miriam



