Hi Rick,
Please add the code below to restore the data.
#define NVDS_START_STORAGE_AREA_ADDRESS_OFFSET 4
extern struct nvds_env_tag nvds_env;
extern const struct nvds_if fw_nvds_api;
const uint8_t nvds_magic_word[] = {0x4e, 0x56, 0x44, 0x53};
const uint8_t nvds_default_data[] = {
0x01, 0x06, 0x06, 0x00, 0x70, 0x00, 0x00, 0xbe, 0x7c, 0x08, 0xff, 0xff,
0x02, 0x06, 0x07, 0x00, 0x4e, 0x58, 0x50, 0x20, 0x42, 0x4c, 0x45, 0xff, 0x03, 0x06, 0x02, 0x00,
0x64, 0x00, 0xff, 0xff, 0x05, 0x06, 0x02, 0x00, 0x84, 0x03, 0xff, 0xff, 0x10, 0x06, 0x01, 0x00,
0x08, 0xff, 0xff, 0xff, 0x11, 0x06, 0x01, 0x00, 0x30, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
uint8_t nvds_get(uint8_t tag, uint16_t *lengthPtr, uint8_t *buf);
uint8_t nvds_put(uint8_t tag, nvds_tag_len_t length, uint8_t *buf);
static uint8_t nvds_restore_default(void);
* Private functions
*************************************************************************************
************************************************************************************/
static uint8_t nvds_restore_default(void)
{
struct nvds_env_tag nvds_env_local = nvds_env;
uint8_t status = NVDS_OK;
nvds_env_local.nvds_space = (uint8_t*)CFG_NVDS_ADDRESS;
#ifdef NVDS_RESTORE_BACKUP_AREA
nvds_env_local.nvds_backup = (uint8_t*)CFG_NVDS_BACKUP_ADDRESS;
#endif
nvds_env_local.total_size = CFG_NVDS_SIZE;
if(NULL != fw_nvds_api.erase)
{
fw_nvds_api.erase((uint32_t)nvds_env_local.nvds_space, nvds_env_local.total_size);
#ifdef NVDS_RESTORE_BACKUP_AREA
fw_nvds_api.erase((uint32_t)nvds_env_local.nvds_backup, nvds_env_local.total_size);
#endif
}
else
{
status = NVDS_FAIL;
}
if(NULL != fw_nvds_api.write)
{
fw_nvds_api.write((uint32_t)nvds_env_local.nvds_space + NVDS_START_STORAGE_AREA_ADDRESS_OFFSET,
sizeof(nvds_default_data), (uint8_t*)nvds_default_data);
#ifdef NVDS_RESTORE_BACKUP_AREA
fw_nvds_api.write((uint32_t)nvds_env_local.nvds_backup + NVDS_START_STORAGE_AREA_ADDRESS_OFFSET,
sizeof(nvds_default_data), (uint8_t*)nvds_default_data);
#endif
fw_nvds_api.write((uint32_t)nvds_env_local.nvds_space,
(uint32_t)sizeof(nvds_magic_word),
(uint8_t*)nvds_magic_word);
#ifdef NVDS_RESTORE_BACKUP_AREA
fw_nvds_api.write((uint32_t)nvds_env_local.nvds_backup,
(uint32_t)sizeof(nvds_magic_word),
(uint8_t*)nvds_magic_word);
#endif
}
else
{
status = NVDS_FAIL;
}
return status;
}
Call the nvds_restore_default function in the hardware_init().
Please let me know if you still have the issue.
Regards,
Mario