diff --git a/core/include/sysparam.h b/core/include/sysparam.h index b4b2337..ce7edc0 100644 --- a/core/include/sysparam.h +++ b/core/include/sysparam.h @@ -1,18 +1,22 @@ #ifndef _SYSPARAM_H_ #define _SYSPARAM_H_ +#include + /** @file sysparam.h * * Read/write "system parameters" to persistent flash. * * System parameters are stored as key/value pairs. Keys are string values * between 1 and 255 characters long. Values can be any data up to 255 bytes - * in length (but are most commonly also strings). + * in length (but are most commonly also text strings). Up to 126 key/value + * pairs can be stored at a time. * + * Keys and values are stored in flash using a progressive list structure + * which allows space-efficient storage and minimizes flash erase cycles, + * improving write speed and increasing the lifespan of the flash memory. */ -#include - #ifndef SYSPARAM_REGION_SECTORS /** Number of (4K) sectors that make up a sysparam region. Total sysparam data * cannot be larger than this. Note that the full sysparam area is two diff --git a/core/sysparam.c b/core/sysparam.c index b664dbd..ced4ad8 100644 --- a/core/sysparam.c +++ b/core/sysparam.c @@ -577,6 +577,7 @@ sysparam_status_t sysparam_set_data(const char *key, const uint8_t *value, size_ if (!value) value_len = 0; + debug(1, "updating value for '%s' (%d bytes)", key, value_len); if (value_len && ((intptr_t)value & 0x3)) { // The passed value isn't word-aligned. This will be a problem later // when calling `sdk_spi_flash_write`, so make a word-aligned copy. @@ -709,6 +710,8 @@ sysparam_status_t sysparam_set_data(const char *key, const uint8_t *value, size_ _sysparam_info.end_addr = write_ctx.addr; } + debug(1, "new addr is 0x%08x (%d bytes remaining)", _sysparam_info.end_addr, _sysparam_info.cur_base + _sysparam_info.region_size - _sysparam_info.end_addr - 4); + // Delete old value (if present) by setting it's id to 0x00 if (old_value_addr) { status = _delete_entry(old_value_addr);