How to use virtual EEPROM Interface to store factory config data?

Hello,

I am currently working with the Virtual EEPROM Interface to store factory configuration data that I need to persist across firmware upgrades. The write operation appears to be functioning correctly, as it returns FSP_SUCCESS. However, I am encountering an issue when attempting to read the reference data, receiving an FSP_ERR_NOT_FOUND error.

My Implementation

The write function successfully writes the data and returns FSP_SUCCESS:

fsp_err_t vee_write_ref_data(uint8_t *buffer, size_t size)
{   
	uint16_t write_time_out = UINT16_MAX;
    if (size != REF_DATA_SIZE){
        return FSP_ERR_INVALID_SIZE ;
    }
    fsp_err_t err = RM_VEE_FLASH_RefDataWrite(&g_vee0_ctrl, buffer);

        if (FSP_SUCCESS != err){
        return err;
    }

    /* Wait for the Virtual EEPROM callback to indicate completion */
    while (!g_write_flag && --write_time_out){
        /* Timeout handling to avoid infinite loop */
        if (RESET_VALUE == write_time_out){
            return FSP_ERR_TIMEOUT;
        }
    }

    g_write_flag = false;
    return FSP_SUCCESS;
}


However, when I attempt to read the reference data, the following function returns an FSP_ERR_NOT_FOUND error:
fsp_err_t vee_get_ref_data_ptr(uint8_t **ref_data)
{
    return RM_VEE_FLASH_RefDataPtrGet(&g_vee0_ctrl, ref_data);
}


Here’s the configuration I’m using for the VEE interface:
const rm_vee_cfg_t g_vee0_cfg = { 
    .start_addr = BSP_FEATURE_FLASH_DATA_FLASH_START, 
    .num_segments = 2, 
    .total_size = BSP_DATA_FLASH_SIZE_BYTES, 
    .ref_data_size = 256, 
    .record_max_id = 16,
    .rec_offset = &g_vee0_record_offset[0], 
    .p_callback = vee_callback,
    .p_context = NULL, 
    .p_extend = &g_vee0_cfg_ext 
};



I’m unsure if I’m missing something in the configuration or if there’s an issue with my read function.
Any insights or suggestions would be greatly appreciated!

Thank you in advance.

Parents
  • When you format VEE, did you include the reference data?  Was it retrievable after format? What about after adding other data, is it still readable? Did it becomes un-readable after you write ref data for the 2nd time?

    I thought reference data is written once, to identify that VEE and not to be updated again. You can always use other records to update data that changes over time. (my personal opinion)

  • Thank you for the reply  

    I want to write the hardware version and model number in the reference data section. and I only want to write it once before shipping it. and the idea is to make the firmware configure itself based on reference data, when we send an update/ flash again.

    I would greatly appreciate it if you could suggest any efficient or reliable methods to implement this approach.

Reply
  • Thank you for the reply  

    I want to write the hardware version and model number in the reference data section. and I only want to write it once before shipping it. and the idea is to make the firmware configure itself based on reference data, when we send an update/ flash again.

    I would greatly appreciate it if you could suggest any efficient or reliable methods to implement this approach.

Children