Part Number:LAUNCHXL-CC1352R1
sdk:simplelink_cc13xx_cc26xx_sdk_6_10_00_29
請問使用NVS_write是否無法部分erase?
我的buffer是uint8_t[16], 但我只想要寫入前面4個byte, 所以bufferSize = 4, flag = NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY
int_fast16_t status = NVS_write(nvsHandle, 0, (void *) buffer, 4,
NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);
但我發現前面4個byte確實有寫入成功, 但是其他12個byte全部被erase了.
請問這是正確的嗎? 我原本以為只有要寫入的byte會erase而已
* @param buffer A buffer containing data to write to
* the NVS region.
*
* @param bufferSize The size of the buffer (number of bytes to write).
*
* @param flags Write flags (#NVS_WRITE_ERASE, #NVS_WRITE_PRE_VERIFY,
* #NVS_WRITE_POST_VERIFY).
extern int_fast16_t NVS_write(NVS_Handle handle, size_t offset, void *buffer,
size_t bufferSize, uint_fast16_t flags);
Nick Sun:
您好,
收到您的问题了,我们升级到英文论坛给工程师看下,有答复尽快给到您。
,
Nick Sun:
您好,
从NVS driver的文档中,我们可以看到如下内容:
"Erase write flag.
If NVS_WRITE_ERASE is set in the flags passed to NVS_write(), the affected destination flash sectors will be erased prior to the start of the write operation."
这意味着这将擦除整个部分,而不仅仅是您要写入的字节。
具体信息您可以参考:NVS.h File Reference
您还可以参考 NVSCC26XX.c file中的代码:
/* If erase is set, erase destination sector(s) first */ if (flags & NVS_WRITE_ERASE) {size = bufferSize & sectorBaseMask;if (bufferSize & (~sectorBaseMask)){size += sectorSize;}retval = doErase(handle, offset & sectorBaseMask, size);if (retval != NVS_STATUS_SUCCESS){SemaphoreP_post(writeSem);return (retval);} }希望能够帮助到您。
TI中文支持网

