Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3e1841b
nvm: nvm flash log based implementation
rizlik Sep 23, 2025
aa96a6f
test: generalize whTest_NvmFlashCfg
rizlik Sep 23, 2025
b2acfc2
test: test nvm flash log backend
rizlik Sep 23, 2025
789c049
test: use nvm_flash_log to do test if compiled it
rizlik Sep 29, 2025
d197dbb
test: generalize tests to use both NVM backends
rizlik Sep 29, 2025
360fcf4
nvm_flash_log: fix and refactor List callback
rizlik Sep 29, 2025
c1a27fc
nvm_flash_log: rename and add arg checking to local functions
rizlik Sep 29, 2025
180aada
nvm_flash_log: check context is initialized in public functions
rizlik Sep 29, 2025
aaa0f83
nvm_flash_log: fix mem clean on obj destroy + minors
rizlik Sep 29, 2025
94148cd
nvm_flash_log: allow NULL metadata in GetMetadata
rizlik Sep 29, 2025
568cf10
nvm_flash_log: read-back current partition if update fails
rizlik Sep 29, 2025
6763db9
nvm_flash_log: add performance consideration in header
rizlik Sep 29, 2025
c90da70
nvm_flash_log: verify program and erase
rizlik Sep 29, 2025
876b347
nvm_flash_log: fix from cppcheck
rizlik Sep 29, 2025
c68809f
widetree: fix clang-format error
rizlik Sep 29, 2025
a92ecaa
nvm_flash_log: move configuration define in test/config/wolfhsm_cfg.h
rizlik Oct 13, 2025
2dc6af5
nvm_flash_log: better naming for test structure and functions
rizlik Oct 13, 2025
419c2cb
nvm_flash_log: erase inactive partition on partition commit
rizlik Oct 13, 2025
948b3d9
nvm_flash_log: fix object limit in addObject
rizlik Oct 13, 2025
1ff33d3
git-clang-format fixes
rizlik Oct 13, 2025
e544f3c
nvm_flash_log: test: remove useless assert
rizlik Oct 15, 2025
fb86046
nvm_flash_log: test: rename nvm backend enums
rizlik Oct 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/wh_nvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ int wh_Nvm_DestroyObjects(whNvmContext* context, whNvmId list_count,


int wh_Nvm_Read(whNvmContext* context, whNvmId id, whNvmSize offset,
whNvmSize data_len, uint8_t* data)
whNvmSize data_len, uint8_t* data)
{
if ( (context == NULL) ||
(context->cb == NULL) ) {
Expand Down
52 changes: 19 additions & 33 deletions src/wh_nvm_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ static int nfObject_Program(whNvmFlashContext* context, int partition,
int object_index, uint32_t epoch, whNvmMetadata* meta, uint32_t start,
const uint8_t* data);
static int nfObject_ReadDataBytes(whNvmFlashContext* context, int partition,
int object_index, uint32_t byte_offset, uint32_t byte_count,
uint8_t* out_data);
int object_index, uint32_t byte_offset,
uint32_t byte_count, uint8_t* out_data);
static int nfObject_Copy(whNvmFlashContext* context, int object_index,
int partition, uint32_t *inout_next_object, uint32_t *inout_next_data);

Expand Down Expand Up @@ -652,8 +652,8 @@ static int nfObject_Program(whNvmFlashContext* context, int partition,
}

static int nfObject_ReadDataBytes(whNvmFlashContext* context, int partition,
int object_index,
uint32_t byte_offset, uint32_t byte_count, uint8_t* out_data)
int object_index, uint32_t byte_offset,
uint32_t byte_count, uint8_t* out_data)
{
int start = 0;
uint32_t startOffset = 0;
Expand All @@ -676,18 +676,16 @@ static int nfObject_ReadDataBytes(whNvmFlashContext* context, int partition,
}

/* Ensure we don't read off the end of the active partition */
if (WH_ERROR_OK != nfPartition_CheckDataRange(context, partition,
startOffset * WHFU_BYTES_PER_UNIT + byte_offset,
byte_count)) {
if (WH_ERROR_OK != nfPartition_CheckDataRange(
context, partition,
startOffset * WHFU_BYTES_PER_UNIT + byte_offset,
byte_count)) {
return WH_ERROR_BADARGS;
}

return wh_FlashUnit_ReadBytes(
context->cb,
context->flash,
startOffset * WHFU_BYTES_PER_UNIT + byte_offset,
byte_count,
out_data);
context->cb, context->flash,
startOffset * WHFU_BYTES_PER_UNIT + byte_offset, byte_count, out_data);
}

static int nfObject_Copy(whNvmFlashContext* context, int object_index,
Expand Down Expand Up @@ -728,13 +726,8 @@ static int nfObject_Copy(whNvmFlashContext* context, int object_index,
}

/* Read the data from the old object. */
ret = nfObject_ReadDataBytes(
context,
context->active,
object_index,
data_offset,
this_len,
buffer);
ret = nfObject_ReadDataBytes(context, context->active, object_index,
data_offset, this_len, buffer);
if (ret != 0) return ret;

/* Write the data to the new object. */
Expand Down Expand Up @@ -1243,30 +1236,23 @@ int wh_NvmFlash_DestroyObjects(void* c, whNvmId list_count,
}

/* Read the data of the object starting at the byte offset */
int wh_NvmFlash_Read(void* c, whNvmId id, whNvmSize offset,
whNvmSize data_len, uint8_t* data)
int wh_NvmFlash_Read(void* c, whNvmId id, whNvmSize offset, whNvmSize data_len,
uint8_t* data)
{
whNvmFlashContext* context = c;
int ret = 0;
int object_index = -1;
int object_index = -1;

if ( (context == NULL) ||
((data_len > 0) && (data == NULL)) ){
return WH_ERROR_BADARGS;
}

ret = nfMemDirectory_FindObjectIndexById(
&context->directory,
id,
&object_index);
ret = nfMemDirectory_FindObjectIndexById(&context->directory, id,
&object_index);
if (ret == 0) {
ret = nfObject_ReadDataBytes(
context,
context->active,
object_index,
offset,
data_len,
data);
ret = nfObject_ReadDataBytes(context, context->active, object_index,
offset, data_len, data);
}
return ret;
}
Loading