ZHCAEM6 October   2024 TPS25751 , TPS26750

 

  1.   1
  2.   摘要
  3.   商标
  4. 1引言
  5. 2EEPROM 引导流程
    1. 2.1 引导过程
    2. 2.2 更新 EEPROM 映像
    3. 2.3 命令
    4. 2.4 EEPROM 更新示例
  6. 3源代码示例
    1. 3.1 UpdateRegionOfEeprom()
    2. 3.2 UpdateRegionOfEeprom_Step1
    3. 3.3 UpdateRegionOfEeprom_Step2()
    4. 3.4 UpdatingRegionOfEeprom_Step3()
    5. 3.5 UpdatingRegionOfEeprom_Step4()
    6. 3.6 WriteRegionPointer()
  7. 4从 EEPROM 故障中恢复
  8. 5结语
  9. 6参考资料

UpdateRegionOfEeprom()

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;
}