Update Scripts Copy Files
This is a modified update script that copies the entire contents of USER_Partition to the USB Drive.
It also has some examples on how to single copy files.
Best editor to look at this is Notepad++ (google it)
Open the file and select language = C
The script only copies files and doesn't attempt to do any other update (just exits).
If you don't see the final question screen when the script ends then something is wrong)
This script is based on the original one, so it has much more code that it is really used.
A simplified version should be available soon…
//********************************************************************* // // SYSTEM_UPGRADE.CMD - Command script to upgrade from BootROM // // // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // // NOTE: Set values in UPGRADE FLAGS to enable or disable // upgrade sequences // // 1 = ENABLE // 0 = DISABLE // // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // //********************************************************************* /*** UPGRADE FLAGS ***/ #define FORCE_SOFTWARE_UPGRADE 0 // delete everything on /F/Application /C/Application and /C/Data_base #define FORCE_EXTERNAL_UPGRADE 0 #define ENABLE_CRC_CHECK 1 // saves time if = 0 #define ENABLE_RECOVERY 1 /*** GLOBAL DEFINES ****/ // Upgrade types typedef enum { NORMAL = 0, BOOTROM, RECOVERY }t_UPGType; typedef int (*FUNCPTR)(char *sourcedrive, int reboot_at_end); // Script Types typedef int STATUS; typedef void DIR; typedef int BOOL; typedef int size_t; typedef void FILE; typedef void *MODULE_ID; #define TRUE (1) #define FALSE (0) #define OK (0) #define ERROR (-1) #define NULL (void*) 0 #define O_RDONLY (0) #define O_RDWR (2) // Constants #define MAX_DRIVE_NAME_LENGTH 10 #define MAX_FILENAME_LENGTH 50 #define MAX_PATH_LENGTH 100 #define MAX_VERSION_LENGTH 95 #define MAX_CRC_LENGTH 20 #define MAX_QUESTION_LENGTH 50 #define MAX_DATE_CLOCK_LENGTH 100 #define MODULE_NO_VERSION "0000" #define TEMP_UPGRADE_DIR "/UPG" #define RECOVERY_FILE "/recovery.lst" #define BACKUP_DIR "/C/BACKUP" #define BACKUP_BR_DIR "/C/BACKUP_BR" #define FSEARCH_TABLE_FILE "/bd0/UPG/Table/table_upgrade_excl.dat" #define DB_DWNL_FILE "db_dwnl_ppc.out" #define BOOTROM_PATH "/Application/Boot/N3/BOOTROM.DAT" #define FLASHER_OUT_PATH "/UPG/Flasher/FLASHER.OUT" #define FLASHER_OUT_START_FUNC "Prog_flash_ask_reboot__FPci" #define LOAD_NO_SYMBOLS 2 #define LOAD_LOCAL_SYMBOLS 4 #define LOAD_GLOBAL_SYMBOLS 8 #define LOAD_ALL_SYMBOLS 12 // Drive letters #define DRIVE_CDROM "/D" #define DRIVE_HDD "/C" #define DRIVE_TFFS "/F" #define DRIVE_USB "/bd0" #define DRIVE_NAV "/H" #define DRIVE_USER "/I" /*** SOFTWARE UPGRADE DEFINES ***/ typedef struct { int m_iIsNew; char m_pVersion[MAX_VERSION_LENGTH]; char m_pFileName[MAX_PATH_LENGTH]; char m_pTargetPath[MAX_PATH_LENGTH]; int m_iSize; } t_SoftUpgData; #define MAX_APPLI_FILES 1000 /*** EXTERNAL UPGRADE DEFINES ***/ // Module IDs typedef enum { MODULE_ID_FP = 0, MODULE_ID_CT = 1, MODULE_ID_RADIO = 2, MODULE_ID_FP_LOADER = 3, MODULE_ID_WISMO = 4, MAX_MODULE_NUM } t_ModuleId; typedef struct { int m_iUpgRequired; char m_pGateway[MAX_PATH_LENGTH]; char m_pFlasher[MAX_PATH_LENGTH]; char m_pComFile1[MAX_PATH_LENGTH]; char m_pComFile2[MAX_PATH_LENGTH]; } t_ExtUpgData; #define MAX_MODULE_ID_LENGTH 10 #define GW_LAUNCH_SYM "LaunchUpgrade__FPcN30PFUiUi_viUi" #define GW_STATUS_SYM "GetGatewayStatus__Fv" /*** EXTERN FUNCTION DECLARATIONS ***/ // File operations VxWorks int open (const char * name, int flags, int mode); STATUS close (int fd); char* fgets(char * buf, size_t n, FILE * fp); int fputs(char * s, FILE * fp); FILE* fopen(char * file, char * mode ); int fclose(FILE * fp); int feof(FILE * fp); DIR* opendir (char * dirName); STATUS closedir (DIR *dir); STATUS xdelete (const char * source); STATUS mv(char * src, char * dest); STATUS xcopy ( char *src, char *dst ); // File operations builtins STATUS UPGCopy (char* p_source, char* p_dest, int p_cut); STATUS UPGDelete (char* p_file); STATUS UPGMKDir (char* p_dir); STATUS UPGMKDelete (char* p_dir); int SearchAndTargetFileExclu ( char *Filename, char *Tablename, char *Param[], int NbParams, char *RootDir, char *TargetDir ); STATUS GetSearchResult(int index , char *SearchResult, char *targetPath ); int UPGSearchFile(char *Filename, char *RootDir, char *Param, char *TableDir ); STATUS UPGGetSearchResult(int index , char *SearchResult ); STATUS GetFileSize(char *file, int *size); STATUS GetFileVersion (char *l_pBynaryFileName, char *l_pVersion); STATUS ReadFileCRC(char *l_pBynaryFileName, char *l_pCRC); STATUS CheckCRCFile(char *l_file); // String operations STATUS strcpy (char* target, char* source); STATUS strcat (char* target, char* source); int strcmp (char* str1, char* str2); int strncmp (char* str1, char* str2, int n); STATUS strlen (char* str); char* strstr(char* str, char* substr); // External upgrade built ins STATUS GatewayExecute ( char* p_GatewayFile, char* p_FlasherFile, char* p_GatewayStartFunction, char* p_GatewayStatusFunc, char* p_DataFile1, char* p_DataFile2, char* p_DataFileVersion, int p_fromAppli, int p_iGwId ); STATUS GatewayWaitForAllTerminations (void); STATUS StopCOMModule (unsigned int p_iModuleId); STATUS GetModuleId (int p_iModule, char* p_pTrueId); STATUS GetModuleVersion (int p_iModule, char* p_pVersion); STATUS SetDBBootNewModuleVersionString(int p_iModule, char* p_pVersion); STATUS SetBDBootUPGInProgress(int module_ID); int IsFpInLoader(void); // MMI UPG Panel management STATUS ShowBargraph(void); STATUS ClearScreen(void); STATUS StepBargraph(char *text, int index); STATUS ShowCDVerification(void); STATUS ShowCDProblem(void); STATUS ShowGSMCallInProgress(void); STATUS ShowQuestionScreen(char *text, int *answer); // CD ROM STATUS UPGCDEject(void); STATUS LockCDEject(int TrueFalse); // Boot flags STATUS SetBootromUpgFlag(int stayInBootromUpg); STATUS SetBootLoaderFlag(int stayInBootLoader); // Logging STATUS SetUpgradeLogging( int TRUEFALSE ); STATUS EnableHistoryHandler ( int TRUEFALSE ); STATUS AddUPGHistoryHeader(char *p_CDNum, char *p_TargetDrive, char *p_Action); STATUS UPGLogMsg(char* str,int p1,int p2,int p3,int p4,int p5,int p6); // Others VxWorks unsigned long tickGet (void); STATUS taskDelay (int ticks); int logMsg (char* str,int p1,int p2,int p3,int p4,int p5,int p6); MODULE_ID loadModule(int fd, int loadFlag); // Other Builtins STATUS SetCDVersion(char *cdVersion); STATUS GetCDVersion(char *cdVersion); STATUS GetBootromVersion( char *p_version ); STATUS EmergencyReboot( void ); void SetRebootAfterScript( int truefalse); void* UPGFindSymbol( char *symbol ); STATUS ExecuteFlasherOut( void *funcPtr, char *sourceDrive, int rebootAtEnd ); STATUS GetSourceDrive( char *srcDrive ); STATUS GetUpgradeType( char *upgType ); STATUS SetPower( int stayOn); STATUS CheckCRCDrive ( char *p_pSourceDrive ); int IsUpgCheatCodeActivated ( void ); STATUS GetCurrentDateClock(char *l_pDateClock); STATUS SetUPGInProgressInCDD ( int TRUEFALSE ); int GsmCallInProgress(void); STATUS UpdateFSImage(void); STATUS ComputeCRCFile(char *l_pFileName, char *l_pCRC); STATUS StopHDDActivity (void); STATUS SetRedLedOn(void); STATUS SetMasterFlashingOn(void); STATUS Execute( void *funcPtr ); int IsPartitionUnderRepair(void); STATUS SetPartitionRepairState( int true_False); STATUS EnableSetPowerOffHandler(void); STATUS InstallHDDTestFiles(void); STATUS BootRomFormatTffs(void); int atoi(char * s); //added STATUS DumpDBSystem(void); STATUS FlashMemoryShow(void); STATUS BackupDBSystem(char *l_pFileName); void PrintText(char *text); STATUS CreateInfFile(char *l_file); /*** INTERN FUNCTION DECLARATION ***/ STATUS PrepareSoftUpg(t_SoftUpgData *p_pSoftUpgList, char *p_pSourceDrive, char *p_pRootDir, char *p_pMask, char *p_pTargetDrive, char *p_pSearchParams[], int p_pNbSearchParams, int p_iCheckVersion, unsigned long *p_totalSize ); STATUS InstallSoftList( t_SoftUpgData *p_pList, unsigned long p_totalSize, t_UPGType p_upgType, unsigned long *p_completedSize, BOOL p_use_temp_names_for_recovery ); STATUS SaveSoftUpgList(t_SoftUpgData *p_pList, char *ListFile); STATUS SetOKInListFile(char *ListFile); STATUS ValidateSoftChanges(t_SoftUpgData *p_pList); int FileExists(char *p_pPath); STATUS CleanRecoveryFiles(t_SoftUpgData *p_pList); void VerueExtUpgCdrom ( char *p_pPath ); STATUS PrepareExtUpg(t_ExtUpgData *p_pList, char *p_pSourceDrive, char *p_pTargetDrive, t_UPGType p_iUpgType, char *p_pFPIdent, char *p_pFPVersion ); STATUS EndUpgrade(char *p_SourceDrive); STATUS PrepareDbDwnlUpg( t_SoftUpgData *p_list, char *p_source_drive, char *p_root, unsigned long *p_totalSize); void BackupBootScreen(void); void RestoreBootScreen(void); /****************************** MAIN ******************************/ int main(int argc, char **argv) { // Local variables for general purpose STATUS l_script_status = OK; char l_pSourceDrive[MAX_DRIVE_NAME_LENGTH]; char l_pTargetDrive[MAX_DRIVE_NAME_LENGTH]; char l_pSourceVersion[MAX_VERSION_LENGTH]; char l_pTargetVersion[MAX_VERSION_LENGTH]; int l_i=0; t_UPGType l_tUpgType; char l_pPath[MAX_PATH_LENGTH]; char l_pSourcePath[MAX_PATH_LENGTH]; char l_pTargetPath[MAX_PATH_LENGTH]; char l_pCDVersion[MAX_VERSION_LENGTH]; char l_pOldCDVersion[MAX_VERSION_LENGTH]; char l_pQuestionText[MAX_QUESTION_LENGTH]; int l_iIsUpgRequired = FALSE; char l_pDateClock[MAX_DATE_CLOCK_LENGTH]; int l_IsPartitionUnderRepair = FALSE; // Software upgrade variables unsigned long l_lTotalSize = 0; unsigned long l_lCompletedSize = 0; char l_pString[MAX_PATH_LENGTH]; DIR* l_pDir; t_SoftUpgData l_pSoftList[MAX_APPLI_FILES]; t_SoftUpgData l_pTffsList[MAX_APPLI_FILES]; t_SoftUpgData l_pSpyCopyList[MAX_APPLI_FILES]; int l_iNbSearchParams = 0; char* l_pSearchParams[2]; char l_pSearchParam1[MAX_PATH_LENGTH]; char l_pSearchParam2[MAX_PATH_LENGTH]; BOOL l_enable_recovery = FALSE; //Added stuff char l_computeCrc[MAX_PATH_LENGTH]; char l_rdCrc[MAX_PATH_LENGTH]; char l_CRC_target_path[MAX_PATH_LENGTH]; // External upgrade variables int l_iFromAppli = FALSE; t_ExtUpgData l_pExtUpgList[MAX_MODULE_NUM]; char l_pVersion[MAX_VERSION_LENGTH]; int l_FpInLoader = FALSE; char l_pFPIdent[MAX_MODULE_ID_LENGTH]; char l_pFPVersion[MAX_VERSION_LENGTH]; // Bootrom upgrade variable int l_iBootromUpgRequired = FALSE; int l_iFd = 0; MODULE_ID l_pModuleId = NULL; FUNCPTR l_pFuncPtr =NULL; l_pSearchParams[0] = l_pSearchParam1; l_pSearchParams[1] = l_pSearchParam2; /*** SCRIPT INITIALIZATION ***/ SetUpgradeLogging( TRUE ); EnableHistoryHandler( TRUE ); //In case of power failure, switch off mainboard EnableSetPowerOffHandler(); //Force Mainboard power supply in case of FP Reboot SetPower( TRUE ); UPGLogMsg("Script initialization +, Time = %ld\n",tickGet(),0,0,0,0,0); if ( ERROR == GetCurrentDateClock(l_pDateClock) ) { UPGLogMsg("Unable to determine current date\n",0,0,0,0,0,0); } else { UPGLogMsg("Current date is %s\n",l_pDateClock,0,0,0,0,0); } UPGLogMsg("******start hacks***************************************\n", 0,0,0,0,0,0); //replace usr settings //UPGDelete ("/I/USER_DATA/User_profile/User_com.dat"); //UPGDelete ("/I/USER_DATA/User_profile/User_com.dat.inf"); //UPGCopy ("/bd0/PUT/User_com.dat","/I/USER_DATA/User_profile/User_com.dat",FALSE); //UPGMKDir ( "/bd0/start"); //BackupDBSystem("/bd0/DBSystem.bak"); //restarts! //DumpDBSystem(); //FlashMemoryShow(); //restarts! //PrintText("Hello RT4!"); //Restarts! //UPGDelete ("/F/USER_DATA/User_profile/User_com.dat.inf"); //UPGCopy ("/bd0/PUT/User_com.dat","/I/USER_DATA/User_profile/User_com.dat",FALSE); //UPGDelete ("/F/Application/Boot/Bootscreen.bmp"); //UPGDelete ("/F/Application/Boot/Bootscreen.bmp.inf"); //UPGCopy ("/bd0/PUT/C4Picasso.bmp","/F/Application/Boot/Bootscreen.bmp",FALSE); //UPGCopy ("/bd0/PUT/C4Picasso.bmp.inf","/F/Application/Boot/Bootscreen.bmp.inf",FALSE); // UPGCopy ("/bd0/PUT/Peugeot.bmp","/C/BACKUP/Bootscreen.bmp",FALSE); // UPGCopy ("/bd0/PUT/Peugeot.bmp.inf","/C/BACKUP/Bootscreen.bmp.inf",FALSE); // UPGCopy ("/bd0/PUT/Fiat.bmp","/C/Data_Base/Graphics/Logo/Citroen.bmp",FALSE); // UPGCopy ("/bd0/PUT/Fiat.bmp.inf","/C/Data_Base/Graphics/Logo/Citroen.bmp.inf",FALSE); //UPGCopy ("/F/USER_DATA/User_Profile/User_com.dat","/bd0/GET/User_Profile.dat",FALSE); // 1. copiar ficheiro // 2. alterar ficheiro no sistema // 3. voltar a copiar e comparar alteracao no CRC! /* UPGCopy ("/F/USER_DATA/User_Profile/User_com.dat","/bd0/GET/F/User_Profile.dat",FALSE); UPGCopy ("/F/USER_DATA/User_Profile/User_com.dat.inf","/bd0/GET/F/User_Profile.dat.inf",FALSE); UPGCopy ("/F/USER_DATA/User_Profile/User_4.dat","/bd0/GET/F/User_4.dat",FALSE); UPGCopy ("/F/USER_DATA/User_Profile/User_4.dat.inf","/bd0/GET/F/User_4.dat.inf",FALSE); UPGCopy ("/F/USER_DATA/User_Profile/User_default.dat","/bd0/GET/F/User_default.dat",FALSE); UPGCopy ("/F/USER_DATA/User_Profile/User_default.dat.inf","/bd0/GET/F/User_default.dat.inf",FALSE); //I UPGCopy ("/I/USER_DATA/User_Profile/User_com.dat","/bd0/GET/I/User_Profile.dat",FALSE); UPGCopy ("/I/USER_DATA/User_Profile/User_com.dat.inf","/bd0/GET/I/User_Profile.dat.inf",FALSE); UPGCopy ("/I/USER_DATA/User_Profile/User_4.dat","/bd0/GET/I/User_4.dat",FALSE); UPGCopy ("/I/USER_DATA/User_Profile/User_4.dat.inf","/bd0/GET/I/User_4.dat.inf",FALSE); UPGCopy ("/I/USER_DATA/User_Profile/User_default.dat","/bd0/GET/I/User_default.dat",FALSE); UPGCopy ("/I/USER_DATA/User_Profile/User_default.dat.inf","/bd0/GET/I/User_default.dat.inf",FALSE); */ // Duplicate the content of I folder on USB l_tUpgType = NORMAL; strcpy ( l_pSearchParams[0], "N3" ); strcpy ( l_pSearchParams[1], "Normal" ); l_iNbSearchParams = 2; if ( ERROR == PrepareSoftUpg(l_pSpyCopyList,DRIVE_USER,"","*.*","/bd0/I",l_pSearchParams,2,FALSE,&l_lTotalSize) ) { UPGLogMsg ( "PrepareSoftUpg ERROR\n",0,0,0,0,0,0 ); } else if ( ERROR == InstallSoftList ( l_pSpyCopyList, l_lTotalSize, l_tUpgType, &l_lCompletedSize, FALSE ) ) { UPGLogMsg ( "Install l_pSoftList error\n",0,0,0,0,0,0 ); } //UPGCopy ("/bd0/PUT/User_com.dat","/I/USER_DATA/User_profile/User_com.dat",FALSE); //UPGCopy ("/bd0/PUT/User_com.dat.inf","/I/USER_DATA/User_profile/User_com.dat.inf",FALSE); EnableHistoryHandler( FALSE ); SetUpgradeLogging( FALSE ); UPGCopy ("/I/SPY/UPG/UPG_History.txt","/bd0/LOG/UPG_History.txt",FALSE); UPGCopy ("/I/SPY/UPG/UPG_logs.txt_1","/bd0/LOG/UPG_logs.txt_1",FALSE); UPGCopy ("/I/SPY/UPG/UPG_logs.txt_2","/bd0/LOG/UPG_logs.txt_2",FALSE); UPGCopy ("/I/SPY/UPG/UPG_logs.txt_3","/bd0/LOG/UPG_logs.txt_3",FALSE); UPGCopy ("/I/SPY/UPG/UPG_logs.txt_4","/bd0/LOG/UPG_logs.txt_4",FALSE); UPGCopy ("/I/SPY/UPG/UPG_logs.txt_5","/bd0/LOG/UPG_logs.txt_5",FALSE); //UPGMKDir ( "/bd0/done"); UPGLogMsg("******end hacks***************************************\n", 0,0,0,0,0,0); UPGLogMsg("*************************************************************\n", 0,0,0,0,0,0); if ( NORMAL == l_tUpgType ) { SetRebootAfterScript( TRUE ); } /*** SECURITY CHECK ***/ if ( ( OK == l_script_status ) && ( NORMAL == l_tUpgType ) ) { if ( TRUE == GsmCallInProgress() ) { ShowGSMCallInProgress(); taskDelay(100); l_script_status = ERROR; SetRebootAfterScript(FALSE); EndUpgrade( l_pSourceDrive ); return ( l_script_status ); } else { SetRebootAfterScript(TRUE); } } /*** MEDIA CHECK ***/ if ( OK == l_script_status ) { if ( !strcmp ( DRIVE_CDROM, l_pSourceDrive) ) { LockCDEject(TRUE); } // Ask user permission if ( NORMAL == l_tUpgType ) { if ( TRUE == l_FpInLoader ) { l_iIsUpgRequired = TRUE; } else { strcpy ( l_pQuestionText, "Script Ended Correctly!" ); ShowQuestionScreen(l_pQuestionText, &l_iIsUpgRequired); } UPGLogMsg ( "Script ended\n", 0,0,0,0,0,0 ); SetRebootAfterScript(FALSE); EndUpgrade( l_pSourceDrive ); return ( l_script_status ); } else { ShowCDVerification(); } } } /********************** INTERN FUNCTION DEFINITION **********************/ void BackupBootScreen(void) { UPGCopy ("/F/Application/Boot/Bootscreen.bmp","/C/BACKUP/BootScreen.bmp",FALSE); UPGCopy ("/F/Application/Boot/Bootscreen.bmp.inf","/C/BACKUP/BootScreen.bmp.inf",FALSE); } void RestoreBootScreen(void) { UPGCopy ("/C/BACKUP/BootScreen.bmp","/F/Application/Boot/Bootscreen.bmp",FALSE); UPGCopy ("/C/BACKUP/BootScreen.bmp.inf","/F/Application/Boot/Bootscreen.bmp.inf",FALSE); } STATUS EndUpgrade(char *p_SourceDrive) { char l_pPath[MAX_PATH_LENGTH]; // Clean temp directory strcpy ( l_pPath, DRIVE_HDD ); strcat ( l_pPath, TEMP_UPGRADE_DIR ); xdelete ( l_pPath ); UPGMKDelete( l_pPath ); // CD ejection if ( !strcmp(p_SourceDrive,DRIVE_CDROM) ) { LockCDEject(FALSE); UPGCDEject(); // Give 3 seconds to eject the CD taskDelay ( 500 * 3 ); } // Stop logging EnableHistoryHandler( FALSE ); SetUpgradeLogging( FALSE ); // Disable set power SetPower ( FALSE ); return ( OK ); } STATUS PrepareSoftUpg ( t_SoftUpgData *p_pList, char *p_pSourceDrive, char *p_pRootDir, char *p_pMask, char *p_pTargetDrive, char *p_pSearchParams[], int p_iNbSearchParams, int p_pCheckVersion, unsigned long *p_pTotalSize ) { STATUS l_status = OK; int l_bIsNew = FALSE; int l_i; int l_iCountInserted; BOOL l_bUpgRequired; char l_pSearchRootDir[MAX_PATH_LENGTH]; char l_pTargetDir[MAX_PATH_LENGTH]; char l_pSearchResult[MAX_PATH_LENGTH]; int l_iNumSearchResult = 0; char l_pTablePath[MAX_PATH_LENGTH]; char l_pTargetPath[MAX_PATH_LENGTH]; char l_pSourceVersion[MAX_VERSION_LENGTH]; char l_pTargetVersion[MAX_VERSION_LENGTH]; char l_pSourceCRC[MAX_CRC_LENGTH]; char l_pTargetCRC[MAX_CRC_LENGTH]; int l_iSize; char l_pInfPath[MAX_PATH_LENGTH]; static long l_total_size_examined = 0; int l_percentage = 0; UPGLogMsg("PrepareUPGSoft +, Time = %ld\n",tickGet(),0,0,0,0,0); // Set counter of files inserted in list for(l_iCountInserted=0; (p_pList[l_iCountInserted].m_iSize) && (l_iCountInserted<MAX_APPLI_FILES); l_iCountInserted++); if ( MAX_APPLI_FILES == l_iCountInserted ) { UPGLogMsg ( "FATAL ERROR: Too many files in list\n",0,0,0,0,0,0 ); return(ERROR); } // Search all soft files on source drive // strcpy ( l_pTablePath, p_pSourceDrive ); strcat ( l_pTablePath, FSEARCH_TABLE_FILE ); strcpy ( l_pSearchRootDir, p_pSourceDrive ); strcat ( l_pSearchRootDir, p_pRootDir ); strcpy ( l_pTargetDir, p_pTargetDrive ); strcat ( l_pTargetDir, p_pRootDir ); l_iNumSearchResult = SearchAndTargetFileExclu ( p_pMask, l_pTablePath, p_pSearchParams, p_iNbSearchParams, l_pSearchRootDir, l_pTargetDir ); if ( 0 == l_iNumSearchResult ) { UPGLogMsg ( "WARNING : %s 0 occurences found on\n",p_pMask,l_pSearchRootDir,0,0,0,0 ); } // Process search result for (l_i=0; (l_i<l_iNumSearchResult) && (OK==l_status); l_i++) { l_bUpgRequired = FALSE; l_bIsNew = FALSE; l_pSourceVersion[0]='\0'; if ( ERROR == GetSearchResult ( l_i , l_pSearchResult, l_pTargetPath ) ) { UPGLogMsg ( "UPGGetSearchResult error\n",0,0,0,0,0,0 ); l_status = ERROR; } else { if ( strlen(l_pSearchResult) && (NULL == strstr(l_pSearchResult, ".inf" )) ) { if ( FALSE == p_pCheckVersion ) { if ( FALSE == FileExists(l_pTargetPath) ) { l_bIsNew = TRUE; } l_bUpgRequired = TRUE; UPGLogMsg ( "<%s> will be installed (NO VERSION CHECK)\n",l_pTargetPath,0,0,0,0,0 ); } else if ( ERROR == GetFileVersion( l_pSearchResult, l_pSourceVersion ) ) { UPGLogMsg ( "WARNING: GetFileVersion on <%s>\n",l_pSearchResult,0,0,0,0,0 ); if ( FALSE == FileExists(l_pTargetPath) ) { l_bIsNew = TRUE; } l_bUpgRequired = TRUE; UPGLogMsg ( "<%s> will be installed (NO VERSION CHECK)\n",l_pTargetPath,0,0,0,0,0 ); } else if ( ERROR == GetFileVersion( l_pTargetPath, l_pTargetVersion ) ) { if ( FALSE == FileExists(l_pTargetPath) ) { l_bIsNew = TRUE; } l_bUpgRequired = TRUE; UPGLogMsg ( "<%s> will be installed (%s)\n",l_pTargetPath,l_pSourceVersion,0,0,0,0 ); } else if ( strcmp(l_pSourceVersion,l_pTargetVersion) || (FORCE_SOFTWARE_UPGRADE == 1) ) { l_bUpgRequired = TRUE; UPGLogMsg ( "<%s> need update from %s to %s\n",l_pTargetPath,l_pTargetVersion,l_pSourceVersion,0,0,0 ); } // Also check CRCs in case of same version number else { if ( ERROR == ReadFileCRC( l_pSearchResult, l_pSourceCRC ) ) { UPGLogMsg ( "ERROR: Cannot read CRC of %s\n",l_pSearchResult,0,0,0,0,0 ); l_status = ERROR; } else if ( ERROR == ReadFileCRC( l_pTargetPath, l_pTargetCRC ) ) { l_bUpgRequired = TRUE; UPGLogMsg ( "WARNING: Cannot read CRC of %s\n",l_pTargetPath,0,0,0,0,0 ); UPGLogMsg ( "<%s> will be installed (%s)\n",l_pTargetPath,l_pSourceVersion,0,0,0,0 ); } else if ( strcmp( l_pSourceCRC, l_pTargetCRC ) ) { l_bUpgRequired = TRUE; UPGLogMsg ( "<%s> CRC differs from source (%s to %s)\n",l_pTargetPath,l_pTargetCRC,l_pSourceCRC,0,0,0 ); UPGLogMsg ( "File will be updated (%s)\n",l_pTargetVersion,0,0,0,0,0 ); } // Also check file on HDD else if ( ERROR == CheckCRCFile( l_pTargetPath ) ) { l_bUpgRequired = TRUE; UPGLogMsg ( "CheckCRCFile failed on <%s>\n",l_pTargetPath,0,0,0,0,0 ); UPGLogMsg ( "<%s> will be installed (%s)\n",l_pTargetPath,l_pSourceVersion,0,0,0,0 ); } else { UPGLogMsg ( "<%s> is up to date (%s)\n",l_pTargetPath,l_pTargetVersion,0,0,0,0 ); } } } } // Get file size if ( OK == l_status ) { if ( ERROR == GetFileSize(l_pSearchResult, &l_iSize) ) { UPGLogMsg ( "GetFileSize ERROR on %s\n",l_pSearchResult,0,0,0,0,0 ); l_status = ERROR; } else { l_total_size_examined += l_iSize; l_percentage = (int)((((long double)(l_total_size_examined)) / ((long double)525000000))*100); StepBargraph( "CRC", l_percentage ); taskDelay(100); } } // If the file needs an update if ( TRUE == l_bUpgRequired ) { // Check file coherency if ( ( OK == l_status ) && ( ENABLE_CRC_CHECK == 1 ) ) { strcpy ( l_pInfPath, l_pSearchResult ); strcat ( l_pInfPath, ".inf" ); if ( TRUE == FileExists ( l_pInfPath ) ) { if ( ERROR == CheckCRCFile( l_pSearchResult ) ) { UPGLogMsg ( "FATAL ERROR : CheckCRCFile ERROR on %s\n", l_pSearchResult,0,0,0,0,0 ); ShowCDProblem(); //taskDelay(1500); l_status = ERROR; } } } // Insert into soft upg list if ( OK == l_status ) { p_pList[l_iCountInserted].m_iIsNew = l_bIsNew; p_pList[l_iCountInserted].m_iSize = l_iSize; *p_pTotalSize += l_iSize; strcpy (p_pList[l_iCountInserted].m_pFileName, l_pSearchResult); strcpy (p_pList[l_iCountInserted].m_pTargetPath, l_pTargetPath); strcpy (p_pList[l_iCountInserted].m_pVersion, l_pSourceVersion); l_iCountInserted++; // If there is an associated inf file, insert it in list if ( TRUE == FileExists(l_pInfPath) ) { if ( TRUE == l_bIsNew ) { UPGLogMsg ( "<%s.inf> will be installed\n",l_pTargetPath,0,0,0,0,0 ); } else { UPGLogMsg ( "<%s.inf> will be updated\n",l_pTargetPath,0,0,0,0,0 ); } p_pList[l_iCountInserted].m_iIsNew = l_bIsNew; if ( ERROR == GetFileSize(l_pInfPath, &l_iSize) ) { UPGLogMsg ( "GetFileSize ERROR on %s\n",l_pInfPath,0,0,0,0,0 ); l_status = ERROR; } else { p_pList[l_iCountInserted].m_iSize = l_iSize; *p_pTotalSize += l_iSize; strcpy (p_pList[l_iCountInserted].m_pFileName, l_pSearchResult); strcat (p_pList[l_iCountInserted].m_pFileName, ".inf"); strcpy (p_pList[l_iCountInserted].m_pTargetPath, l_pTargetPath); strcat (p_pList[l_iCountInserted].m_pTargetPath, ".inf"); strcpy (p_pList[l_iCountInserted].m_pVersion, l_pSourceVersion); l_iCountInserted++; } } } } } UPGLogMsg("PrepareUPGSoft -, Time = %ld\n",tickGet(),0,0,0,0,0); return ( l_status ) ; } STATUS InstallSoftList( t_SoftUpgData *p_pList, unsigned long p_lTotalSize, t_UPGType p_tUpgType, unsigned long *p_pCompletedSize, BOOL p_use_temp_names_for_recovery ) { STATUS l_status = OK; int l_i; unsigned long l_lCompletedSize = *p_pCompletedSize; unsigned long l_lPercentage = 0; unsigned int l_percentage = 0; char l_target_path[MAX_PATH_LENGTH]; char l_actualCRC[MAX_PATH_LENGTH]; char l_readCRC[MAX_PATH_LENGTH]; int l_CopyIntegrity = ERROR; int l_retry = 0; //Go through file list for ( l_i=0; 0 != p_pList[l_i].m_iSize;l_i++ ) { //Try and retry to install l_CopyIntegrity = ERROR; for ( l_retry=0; (l_retry < 3) && (ERROR == l_CopyIntegrity); l_retry++) { //Construct the target path in case of recovery strcpy( l_target_path, p_pList[l_i].m_pTargetPath ); if ( ( TRUE == p_use_temp_names_for_recovery ) && ( NORMAL == p_tUpgType ) ) { strcat( l_target_path, ".UPG" ); } //File copy if ( ERROR == UPGCopy( p_pList[l_i].m_pFileName, l_target_path, FALSE) ) { UPGLogMsg ( "Error copying %s\n",(char*)p_pList[l_i].m_pFileName,0,0,0,0,0 ); l_status = ERROR; break; } else { //Check that source and target CRC matches if( ( NULL == strstr( p_pList[l_i].m_pFileName, ".inf" ) ) && ( NULL == strstr( p_pList[l_i].m_pFileName, ".ini" ) ) && ( NULL == strstr( p_pList[l_i].m_pFileName, ".INI" ) ) ) { //Compute target file CRC if ( ERROR == ComputeCRCFile(l_target_path,l_actualCRC) ) { UPGLogMsg( "WARNING: Cannot compute CRC on file %s\n",(char*)l_target_path,0,0,0,0,0 ); l_CopyIntegrity = OK; } else { //Read source file CRC if ( ERROR == ReadFileCRC(p_pList[l_i].m_pFileName, l_readCRC) ) { UPGLogMsg( "WARNING: Cannot read CRC of file %s\n",(char*)p_pList[l_i].m_pFileName,0,0,0,0,0 ); l_CopyIntegrity = OK; } else { //Compare if ( strcmp(l_readCRC, l_actualCRC) ) { UPGLogMsg( "ERROR: CRC of file %s differs after copy (%s -> %s)\n", (char*)l_target_path,(char*)l_readCRC,(char*)l_actualCRC,0,0,0 ); } else { //Copy succeded l_CopyIntegrity = OK; //Progress bargraph l_lCompletedSize += p_pList[l_i].m_iSize; l_percentage = (int) ( (l_lCompletedSize*100.0)/p_lTotalSize ); StepBargraph("1/2", l_percentage); taskDelay(50); } } } } else { l_CopyIntegrity = OK; } } } if (ERROR == l_CopyIntegrity) { UPGLogMsg( "FATAL COPY ERROR!!!\n",0,0,0,0,0,0 ); l_status = ERROR; break; } } if ( OK == l_status ) { *p_pCompletedSize = l_lCompletedSize; } return ( l_status ); } STATUS SaveSoftUpgList(t_SoftUpgData *p_pList, char *p_pFilePath) { STATUS l_status = OK; FILE* l_pFile = NULL; int l_i; if ( NULL == (l_pFile = fopen(p_pFilePath , "a") ) ) { UPGLogMsg ( "Error opening %s\n",p_pFilePath,0,0,0,0,0 ); l_status = ERROR; } else { for (l_i=0; (l_i<MAX_APPLI_FILES)&&((p_pList[l_i].m_iSize)>0) ; l_i++) { if( TRUE == p_pList[l_i].m_iIsNew ) { fputs("NEW\n", l_pFile); } else { fputs("UPDATE\n", l_pFile); } fputs(p_pList[l_i].m_pTargetPath, l_pFile); fputs("\n", l_pFile); } fclose( l_pFile ); } return ( l_status ); } STATUS SetOKInListFile(char* p_pFilePath) { STATUS l_status = OK; FILE* l_pFile; if ( NULL == (l_pFile = fopen( p_pFilePath , "a" ) ) ) { UPGLogMsg ( "Error opening %s\n",p_pFilePath,0,0,0,0,0 ); l_status = ERROR; } else { fputs("OK\n", l_pFile); fclose( l_pFile ); } return ( l_status ); } STATUS ValidateSoftChanges(t_SoftUpgData *p_pList) { STATUS l_status = OK; int l_i; char l_pPath[MAX_PATH_LENGTH]; char l_pPathOLD[MAX_PATH_LENGTH]; char l_pPathUPG[MAX_PATH_LENGTH]; for(l_i=0; p_pList[l_i].m_iSize; l_i++) { strcpy ( l_pPath , p_pList[l_i].m_pTargetPath ); strcpy ( l_pPathOLD , p_pList[l_i].m_pTargetPath ); strcat ( l_pPathOLD , ".OLD" ); strcpy ( l_pPathUPG , p_pList[l_i].m_pTargetPath ); strcat ( l_pPathUPG , ".UPG" ); if( FALSE == p_pList[l_i].m_iIsNew ) { if ( ERROR == mv(l_pPath,l_pPathOLD) ) { UPGLogMsg ( "ERROR mv %s %s\n",l_pPath,l_pPathOLD,0,0,0,0 ); } } if ( ERROR == mv(l_pPathUPG,l_pPath) ) { UPGLogMsg ( "ERROR mv %s %s\n",l_pPathUPG,l_pPath,0,0,0,0 ); } } return ( l_status ); } int FileExists(char *p_pPath) { FILE* l_pFich = NULL; if ( NULL == ( l_pFich = fopen (p_pPath,"r") ) ) { return(FALSE); } else { fclose(l_pFich); return(TRUE); } } STATUS CleanRecoveryFiles(t_SoftUpgData *p_pList) { STATUS l_status = OK; int l_i; char l_pPath[MAX_PATH_LENGTH]; for( l_i=0; (l_i<MAX_APPLI_FILES) && (p_pList[l_i].m_iSize ) ; l_i++) { if ( FALSE == p_pList[l_i].m_iIsNew ) { strcpy( l_pPath, p_pList[l_i].m_pTargetPath ); strcat( l_pPath, ".OLD" ); xdelete( l_pPath ); } } return(l_status); } /* TO AVOID TIMEOUT ON GATEWAYS FROM CDROM */ STATUS GetFileName( char *p_pPath, char *p_pFileName ) { STATUS l_status = OK; int l_i = strlen(p_pPath); while ( l_i>0 ) { if ( '/' == p_pPath[l_i] ) { strcpy( p_pFileName, p_pPath+l_i+1 ); break; } else { l_i--; } } return(l_status); } void VerueExtUpgCdrom ( char *p_pPath ) { char l_pFileName[MAX_PATH_LENGTH]; char l_pTargetPath[MAX_PATH_LENGTH]; char l_pSourcePath[MAX_PATH_LENGTH]; char l_pTargetInfPath[MAX_PATH_LENGTH]; char l_pSourceInfPath[MAX_PATH_LENGTH]; //Local copy strcpy ( l_pSourcePath, p_pPath ); //Compute target path GetFileName ( p_pPath, l_pFileName ); strcpy ( l_pTargetPath, DRIVE_HDD ); strcat ( l_pTargetPath, TEMP_UPGRADE_DIR ); strcat ( l_pTargetPath, "/" ); strcat ( l_pTargetPath, l_pFileName ); //Source INF path strcpy ( l_pSourceInfPath, l_pSourcePath); strcat ( l_pSourceInfPath, ".inf"); //Target INF path strcpy ( l_pTargetInfPath, l_pTargetPath); strcat ( l_pTargetInfPath, ".inf"); //Set current path to target path strcpy(p_pPath, l_pTargetPath); EnableHistoryHandler(FALSE); UPGCopy(l_pSourcePath, l_pTargetPath, 0); if ( TRUE == FileExists(l_pSourceInfPath) ) { UPGCopy(l_pSourceInfPath, l_pTargetInfPath, 0); } EnableHistoryHandler(TRUE); } STATUS PrepareExtUpg(t_ExtUpgData *p_pList, char *p_pSourceDrive, char *p_pTargetDrive, t_UPGType p_iUpgType, char *p_pFPIdent, char *p_pFPVersion ) { STATUS l_status = OK; int l_i; char l_pSearchRoot[MAX_PATH_LENGTH]; char l_pModuleVersion[MAX_VERSION_LENGTH]=""; char l_pFileVersion[MAX_VERSION_LENGTH]=""; char* l_str_after_dot_1=NULL; char* l_str_after_dot_2=NULL; char* l_str_after_diez=NULL; UPGLogMsg ( "PrepareExtUpg +, Time = %ld\n",tickGet(),0,0,0,0,0 ); // Set FP upgrade file paths strcpy ( p_pList[MODULE_ID_FP].m_pFlasher, ""); strcpy ( p_pList[MODULE_ID_FP].m_pGateway, p_pSourceDrive ); strcat ( p_pList[MODULE_ID_FP].m_pGateway, "/UPG/Gateway/G_FP_com.CD" ); strcpy ( l_pSearchRoot, p_pSourceDrive ); strcat ( l_pSearchRoot, "/Application/FP/" ); if ( 0 == strlen(p_pFPIdent) ) { UPGLogMsg ( "Invalid FP ident\n",0,0,0,0,0,0 ); return(ERROR); } else { UPGLogMsg ( "Front panel is %s\n",p_pFPIdent,0,0,0,0,0 ); strcat ( l_pSearchRoot , p_pFPIdent ); if ( 1 == UPGSearchFile ( "*.0", l_pSearchRoot, NULL, NULL ) ) { UPGGetSearchResult ( 0, p_pList[MODULE_ID_FP].m_pComFile1 ); UPGLogMsg ( "ComFile1 %s\n",(char*)p_pList[MODULE_ID_FP].m_pComFile1,0,0,0,0,0 ); } else { UPGLogMsg ( "Cannot find FP com file 1\n",0,0,0,0,0,0 ); } if ( 1 == UPGSearchFile ( "*.1", l_pSearchRoot, NULL, NULL ) ) { UPGGetSearchResult ( 0, p_pList[MODULE_ID_FP].m_pComFile2 ); UPGLogMsg ( "ComFile2 %s\n",(char*)p_pList[MODULE_ID_FP].m_pComFile2,0,0,0,0,0 ); } else { UPGLogMsg ( "Cannot find FP com file 2\n",0,0,0,0,0,0 ); } } // Set RADIO upgrade file paths strcpy(p_pList[MODULE_ID_RADIO].m_pGateway, p_pSourceDrive); strcat(p_pList[MODULE_ID_RADIO].m_pGateway, "/UPG/Gateway/G_RADIO_com.CD"); strcpy(p_pList[MODULE_ID_RADIO].m_pComFile1, p_pSourceDrive); strcat(p_pList[MODULE_ID_RADIO].m_pComFile1, "/Application/Radio/Radio_SW.CD"); strcpy(p_pList[MODULE_ID_RADIO].m_pComFile2, ""); strcpy(p_pList[MODULE_ID_RADIO].m_pFlasher, ""); // Set WISMO upgrade file paths strcpy(p_pList[MODULE_ID_WISMO].m_pGateway, p_pSourceDrive); strcat(p_pList[MODULE_ID_WISMO].m_pGateway, "/UPG/Gateway/G_PHONE_files.CD"); strcpy(p_pList[MODULE_ID_WISMO].m_pFlasher, p_pSourceDrive); strcat(p_pList[MODULE_ID_WISMO].m_pFlasher, "/Application/Wismo/xdwl2.bin"); strcpy(p_pList[MODULE_ID_WISMO].m_pComFile1, p_pSourceDrive); strcat(p_pList[MODULE_ID_WISMO].m_pComFile1, "/Application/Wismo/dwl.dwl"); strcpy(p_pList[MODULE_ID_WISMO].m_pComFile2, p_pSourceDrive); strcat(p_pList[MODULE_ID_WISMO].m_pComFile2, "/Application/Wismo/appli.dwl"); // TO AVOID TIMEOUT ON GATEWAYS WITH CDROM VerueExtUpgCdrom( p_pList[MODULE_ID_FP].m_pGateway ); VerueExtUpgCdrom( p_pList[MODULE_ID_FP].m_pComFile1 ); VerueExtUpgCdrom( p_pList[MODULE_ID_FP].m_pComFile2 ); VerueExtUpgCdrom( p_pList[MODULE_ID_RADIO].m_pGateway ); VerueExtUpgCdrom( p_pList[MODULE_ID_RADIO].m_pComFile1 ); VerueExtUpgCdrom( p_pList[MODULE_ID_WISMO].m_pGateway ); VerueExtUpgCdrom( p_pList[MODULE_ID_WISMO].m_pFlasher ); VerueExtUpgCdrom( p_pList[MODULE_ID_WISMO].m_pComFile1 ); VerueExtUpgCdrom( p_pList[MODULE_ID_WISMO].m_pComFile2 ); // Check if upgrade is required for(l_i=0; l_i<MAX_MODULE_NUM; l_i++) { p_pList[l_i].m_iUpgRequired = FALSE; // Check module version only if BCMs are opened if ( NORMAL == p_iUpgType) { //for FP bypass this step as version and ID are determined at the beggining if ( MODULE_ID_FP == l_i ) { if ( 0 == strlen( p_pFPVersion ) ) { strcpy ( l_pModuleVersion, MODULE_NO_VERSION ); } else { strcpy ( l_pModuleVersion, p_pFPVersion ); } } else { if ( ERROR == GetModuleVersion ( l_i, l_pModuleVersion ) ) { UPGLogMsg ( "Error GetModuleVersion %d\n",l_i,0,0,0,0,0 ); strcpy ( l_pModuleVersion, MODULE_NO_VERSION ); } } } else { strcpy ( l_pModuleVersion, MODULE_NO_VERSION ); } if ( ERROR == GetFileVersion ( p_pList[l_i].m_pComFile1 , l_pFileVersion ) ) { UPGLogMsg("Error GetFileVersion %d %s\n",l_i,(char*)p_pList[l_i].m_pComFile1,0,0,0,0); } //Exception for WISMO as first version number is not significant else if ( MODULE_ID_WISMO == l_i ) { if ( NORMAL == p_iUpgType ) { l_str_after_dot_1 = strstr(l_pFileVersion,"."); UPGLogMsg("File version = %s\n",l_pFileVersion,0,0,0,0,0); l_str_after_dot_2 = strstr(l_pModuleVersion,"."); UPGLogMsg("Module version = %s\n",l_pModuleVersion,0,0,0,0,0); if( strcmp(l_pFileVersion+1,l_pModuleVersion+1) || (FORCE_EXTERNAL_UPGRADE == 1) ) { if (( NULL != l_str_after_dot_1) && ( NULL != l_str_after_dot_2)) { if ( l_str_after_dot_1[1]==l_str_after_dot_2[1]) { UPGLogMsg("Module %d version need update %s -> %s\n", l_i,l_pModuleVersion,l_pFileVersion,0,0,0); p_pList[l_i].m_iUpgRequired = TRUE; } else { UPGLogMsg("Incompatibility version error\n",0,0,0,0,0,0); } } } else { UPGLogMsg("Module %d is up to date (%s -> %s)\n",l_i,l_pModuleVersion,l_pFileVersion,0,0,0); // In case of discordance between DBBOOT and module versions if ( ERROR == SetDBBootNewModuleVersionString(l_i, l_pFileVersion) ) { UPGLogMsg("SetDBBootNewModuleVersionString error\n",0,0,0,0,0,0); } } } } //Exception for radio as upgrade from version < 584 is forbiden exept if 0000 else if ( ( MODULE_ID_RADIO == l_i ) && ( 0>strncmp(l_pModuleVersion,"584",3) ) ) { if ( !strcmp("0000", l_pModuleVersion) || !strcmp("", l_pModuleVersion) ) { UPGLogMsg("Module %d version need update %s -> %s\n",l_i,l_pModuleVersion,l_pFileVersion,0,0,0); p_pList[l_i].m_iUpgRequired = TRUE; } else { UPGLogMsg("WARNING: Radio update from version %s is strictly forbidden!\n",l_pModuleVersion,0,0,0,0,0); } } else if ( strcmp(l_pModuleVersion, l_pFileVersion) || (FORCE_EXTERNAL_UPGRADE == 1) ) { UPGLogMsg("Module %d version need update %s -> %s\n",l_i,l_pModuleVersion,l_pFileVersion,0,0,0); // Check gateway integrity if ( TRUE == FileExists ( p_pList[l_i].m_pGateway ) ) { if ( ERROR == CheckCRCFile( p_pList[l_i].m_pGateway ) ) { UPGLogMsg("CheckCRCFile ERROR on %s\n",(char*)p_pList[l_i].m_pGateway,0,0,0,0,0); return ( ERROR ); } } // Check comfile1 integrity if ( TRUE == FileExists ( p_pList[l_i].m_pComFile1 ) ) { if ( ERROR == CheckCRCFile( p_pList[l_i].m_pComFile1 ) ) { UPGLogMsg("CheckCRCFile ERROR on %s\n",(char*)p_pList[l_i].m_pComFile1,0,0,0,0,0); return ( ERROR ); } } // Check comfile2 integrity if ( TRUE == FileExists ( p_pList[l_i].m_pComFile2 ) ) { if ( ERROR == CheckCRCFile( p_pList[l_i].m_pComFile2 ) ) { UPGLogMsg("CheckCRCFile ERROR on %s\n",(char*)p_pList[l_i].m_pComFile2,0,0,0,0,0); return ( ERROR ); } } // Check flasher integrity if ( TRUE == FileExists ( p_pList[l_i].m_pFlasher ) ) { if ( ERROR == CheckCRCFile( p_pList[l_i].m_pFlasher ) ) { UPGLogMsg("CheckCRCFile ERROR on %s\n",(char*)p_pList[l_i].m_pFlasher,0,0,0,0,0); return ( ERROR ); } } p_pList[l_i].m_iUpgRequired = TRUE; } else { if ( NORMAL == p_iUpgType ) { UPGLogMsg("Module %d is up to date (%s -> %s)\n",l_i,l_pModuleVersion,l_pFileVersion,0,0,0); // In case of discordance between DBBOOT and modules version if ( ERROR == SetDBBootNewModuleVersionString(l_i, l_pFileVersion) ) { UPGLogMsg("SetDBBootNewModuleVersionString error\n",0,0,0,0,0,0); } } } // Added conditions in order to force FP upgrade from bootrom if ( ( BOOTROM == p_iUpgType) && ( MODULE_ID_FP != l_i ) ) { p_pList[l_i].m_iUpgRequired = FALSE; } } UPGLogMsg ( "PrepareExtUpg -, Time = %ld\n",tickGet(),0,0,0,0,0 ); return ( l_status ); } STATUS PrepareDbDwnlUpg( t_SoftUpgData *p_list, char *p_source_drive, char *p_root, unsigned long *p_total_size) { char l_source_path[MAX_PATH_LENGTH]; char l_target_path[MAX_PATH_LENGTH]; char l_source_version[MAX_VERSION_LENGTH]; char l_target_version[MAX_VERSION_LENGTH]; STATUS l_status = OK; BOOL l_upg_required = FALSE; int l_is_new = FALSE; int l_size = 0; int l_i; int l_is_new; if ( TRUE == FileExists("/H/CD.INF") ) { UPGDelete("/H/CD.INF"); UPGLogMsg("/H/CD.INF has been deleted\n",0,0,0,0,0,0 ); } strcpy( l_target_version ,""); UPGLogMsg ( "PrepareDbDwnlUpg +, Time = %ld\n",tickGet(),0,0,0,0,0 ); //Compute source path strcpy( l_source_path, p_source_drive ); if( NULL != p_root ) { if ( strlen( p_root ) > 1 ) { strcat( l_source_path, p_root ); } } strcat( l_source_path, "/" ); strcat( l_source_path, DB_DWNL_FILE ); //Compute target path strcpy( l_target_path, DRIVE_NAV ); strcat( l_target_path, "/" ); strcat( l_target_path, DB_DWNL_FILE ); //Get CD file version if ( ERROR == GetFileVersion( l_source_path, l_source_version ) ) { UPGLogMsg("PrepareDbDwnlUpg unable to check version of file <%s>\n", l_source_path,0,0,0,0,0); if ( TRUE == FileExists(l_source_path) ) { l_status = ERROR; } else { UPGLogMsg("PrepareDbDwnlUpg skipped\n",0,0,0,0,0,0); } } else { //Check current target file integrity if ( OK == CheckCRCFile( l_target_path ) ) { //Test versions if ( OK == GetFileVersion( l_target_path, l_target_version ) ) { if ( atoi(l_source_version) > atoi(l_target_version) ) { l_upg_required = TRUE; } } else { l_upg_required = TRUE; } } else { l_upg_required = TRUE; } } //if update required... if ( ( OK == l_status ) && ( TRUE == l_upg_required ) ) { //check new file integrity if ( OK == CheckCRCFile ( l_source_path ) ) { for ( l_i=0; (l_i<MAX_APPLI_FILES) && (p_list[l_i].m_iSize) ; l_i++ ) {} if ( MAX_APPLI_FILES <= l_i+2 ) { UPGLogMsg("PrepareDbDwnlUpg too much file in list\n",0,0,0,0,0,0); l_status = ERROR; } else { if ( OK == GetFileSize( l_source_path, &l_size) ) { if ( FALSE == FileExists( l_target_path ) ) { l_is_new = TRUE; } p_list[l_i].m_iIsNew = l_is_new; p_list[l_i].m_iSize = l_size; *p_total_size += l_size; strcpy (p_list[l_i].m_pFileName, l_source_path); strcpy (p_list[l_i].m_pTargetPath, l_target_path); strcpy (p_list[l_i].m_pVersion, l_source_version); l_i++; strcpy (p_list[l_i].m_pFileName, l_source_path); strcpy (p_list[l_i].m_pTargetPath, l_target_path); strcpy (p_list[l_i].m_pVersion, l_source_version); strcat (p_list[l_i].m_pFileName, ".inf"); strcat (p_list[l_i].m_pTargetPath, ".inf"); p_list[l_i].m_iSize = 100; l_i++; p_list[l_i].m_iSize = 0; } else { UPGLogMsg("PrepareDbDwnlUpg unable to read the size of file <%s>\n", l_source_path,0,0,0,0,0); l_status = ERROR; } } } else { UPGLogMsg("PrepareDbDwnlUpg unable to check CRC of file <%s>\n", l_source_path,0,0,0,0,0); l_status = ERROR; } } if ( OK == l_status ) { if ( TRUE == l_upg_required ) { if ( (TRUE == l_is_new) || (0==strlen(l_target_version)) ) { UPGLogMsg("<%s> will be installed (%s)\n", l_target_path, l_source_version, 0, 0, 0, 0); } else { UPGLogMsg("<%s> need update from %s to %s\n", l_target_path, l_target_version, l_source_version, 0, 0, 0); } } else { if ( 0 != strlen ( l_target_version ) ) { UPGLogMsg("<%s> is up to date (%s)\n", l_target_path, l_target_version, 0, 0, 0, 0); } } } UPGLogMsg ( "PrepareDbDwnlUpg - Time = %ld\n",tickGet(),0,0,0,0,0 ); return ( l_status ); }
page revision: 4, last edited: 24 Jan 2008 00:46





