#include "BootLoader.h" | |
#include "obm2osl.h" | |
#include "fota.h" | |
#include "serial.h" | |
extern FOTA_Info FOTAInfo; | |
UINT_T dfota_upgrade(pTIM pTIM_h, pFUSE_SET pFuses) | |
{ | |
UINT_T Retval = NoError; | |
P_FOTA_Firmware pFOTA_T = OTAGetConfig(pTIM_h); | |
if (!pFOTA_T) | |
return NotFoundError; | |
if (pFOTA_T->Upgrade_Method == 4) /* DFOTA or SDFOTA */ | |
{ | |
#if DFOTA | |
Retval = DFOTA_Upgrade(pFOTA_T, pTIM_h); | |
#endif | |
#if SDFOTA | |
Retval = SDFOTA_Upgrade(pFOTA_T, pTIM_h); | |
#endif | |
} else { | |
obm_printf("Updater only support DFOTA/SDFOTA now\n\r"); | |
Retval = FOTA_MethodMismatchError; | |
} | |
if (Retval != NoError){ | |
pFOTA_T->Upgrade_Flag = 2; | |
} else { | |
obm_printf("FOTA Upgrade Done\n\r"); | |
pFOTA_T->Upgrade_Flag = 0; | |
} | |
if (OTA_Save_Config(pTIM_h)) | |
{ | |
obm_printf("%s %d: Save ASR Flag Error\n\r", __FUNCTION__, __LINE__); | |
} | |
return Retval; | |
} | |
VOID UpdaterMain(pTIM pTIM_h, pFUSE_SET pFuses) | |
{ | |
UINT_T Retval = NoError; | |
/* OBM prepare hardware for updater */ | |
OBM_HeapInit(); | |
PlatformInitFlash(pTIM_h); | |
Retval = SecurityInitialization(0); | |
if(Retval != NoError) | |
{ | |
FatalError(Retval, NULL, NULL); | |
} | |
#if SPI_LCD | |
asr_lcd_init(); | |
#endif | |
Retval = dfota_upgrade(pTIM_h, pFuses); | |
Finalize_Flashes(BOOT_FLASH); | |
obm_printf("FOTA return: 0x%x\n\r", Retval); | |
obm_printf("Reboot...\n\r"); | |
do_wdt_reset(); | |
} |