ZHCAEM6 October 2024 TPS25751 , TPS26750
const uint32_t region_ptr_start[NUM_OF_REGIONS] = {0x0 , 0x400 };
const uint32_t region_ptr_appconfig_offset[NUM_OF_REGIONS] = {0x3FC, 0x7FC };
const uint32_t region_addr_patchbundle[NUM_OF_REGIONS] = {0x800, 0x4400};
static int32_t UpdateRegionOfEeprom()
{
s_AppContext *const pCtx = &gAppCtx;
int32_t retVal = -1;
UART_PRINT("\n\rActive Region is [%d] - Region being updated is [%d]\n\r",\
pCtx->active_region, pCtx->inactive_region);
/*
* Region-0/Region-1 is currently active, hence update Region-1/Region-0 respectively
*/
retVal = UpdateRegionOfEeprom_Step1(pCtx->inactive_region);
if(0 != retVal)
{
UART_PRINT("Region[%d] update Step 1 failed.! Next boot will happen from Region[%d]\n\r",\
pCtx->inactive_region, pCtx->active_region);
goto error;
}
/*
* Region-0/Region-1 is currently active, hence update Region-1/Region-0 respectively
*/
retVal = UpdateRegionOfEeprom_Step2(pCtx->inactive_region);
if(0 != retVal)
{
UART_PRINT("Region[%d] update Step 2 failed.! Next boot will happen from Region[%d]\n\r",\
pCtx->inactive_region, pCtx->active_region);
goto error;
}
/*
* Write is through. Now verify if the content/copy is valid.
* Update the corresponding region-pointer point to the new region.
*/
retVal = UpdateRegionOfEeprom_Step3(pCtx->inactive_region);
if(0 != retVal)
{
UART_PRINT("Region[%d] update Step 3 failed.! Next boot will happen from Region[%d]\n\r",\
pCtx->inactive_region, pCtx->active_region);
goto error;
}
/*
* Invalidate the region-pointer of the old region.
*/
retVal = UpdateRegionOfEeprom_Step4(pCtx->active_region);
if(0 != retVal) {goto error;}
error:
SignalEvent(APP_EVENT_END_UPDATE);
return retVal;
}