Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r9af6fc3e5afc442a877bd5e23ecfa6872a3ad5a4 -r84f337383202622f14cd6148e26bab8f68333847 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 9af6fc3e5afc442a877bd5e23ecfa6872a3ad5a4) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 84f337383202622f14cd6148e26bab8f68333847) @@ -11,18 +11,18 @@ #include "CommBuffers.h" #include "ModeStandby.h" +#include "NVDataMgmt.h" #include "OperationModes.h" #include "Timers.h" +#include "Utilities.h" #define WAIT_FOR_UPDATE_FROM_UI_MS 1000 static SW_UPDATE_CMD_STATUS_T SWUpdateCmdStatus; static MODE_STANDBY_STATE_T standbyCurrentState; -static U32 waitForUpdateMsgStarTimeMS; +static U32 waitForUpdateMsgStartTimeMS; -static const U32 jumpAd = (U32)FIRMWARE_START_ADDRESS; - static MODE_STANDBY_STATE_T handleStandbyModeCheckForUpdateState( void ); static MODE_STANDBY_STATE_T handleStandbyModeCheckFWAndFPGAImages( void ); static MODE_STANDBY_STATE_T handleStandbyModeIdleState( void ); @@ -33,7 +33,7 @@ void initStandbyMode( void ) { standbyCurrentState = STANDBY_CHECK_FOR_UPDATE_STATE; - waitForUpdateMsgStarTimeMS = getMSTimerCount(); + waitForUpdateMsgStartTimeMS = getMSTimerCount(); memset( &SWUpdateCmdStatus, 0x0, sizeof( SW_UPDATE_CMD_STATUS_T ) ); } @@ -102,7 +102,7 @@ clearSWUpdateBuffer( SW_UPDATE_COMMAD ); - if ( TRUE == didTimeout( waitForUpdateMsgStarTimeMS, 20000 /*WAIT_FOR_UPDATE_FROM_UI_MS*/ ) ) // TODO a high number if timeout for development + if ( TRUE == didTimeout( waitForUpdateMsgStartTimeMS, 3000 /*WAIT_FOR_UPDATE_FROM_UI_MS*/ ) ) // TODO a high number if timeout for development { state = STANDBY_CHECK_FW_AND_FPGA_IMAGES_STATE; } @@ -113,14 +113,17 @@ static MODE_STANDBY_STATE_T handleStandbyModeCheckFWAndFPGAImages( void ) { MODE_STANDBY_STATE_T state = STANDBY_CHECK_FW_AND_FPGA_IMAGES_STATE; - BOOL areImagesOk = FALSE; + BOOL isFirmwareImageValid = FALSE; + BOOL isFPGAImageValid = TRUE; // TODO check this later with FPGA stuff - // TODO check the FW integrity and FPGA version or something else - // TODO for testing only - areImagesOk = TRUE; - // TODO for testing only remove + _disable_IRQ(); + if ( TRUE == isFWCRCTableValid() ) + { + isFirmwareImageValid = runFWIntegrityTest(); + } + _enable_IRQ(); - if ( TRUE == areImagesOk ) + if ( ( TRUE == isFirmwareImageValid ) && ( TRUE == isFPGAImageValid ) ) { // All good, jump to application jumpToApplication(); @@ -146,6 +149,8 @@ static void jumpToApplication( void ) { + U32 jumpAddress = (U32)FIRMWARE_START_ADDRESS; + // TODO uncomment // Disable various memory protections _coreDisableRamEcc_(); @@ -157,7 +162,7 @@ _disable_IRQ_interrupt_(); _disable_FIQ_interrupt_(); - ((void (*)(void))jumpAd)(); + ((void (*)(void))jumpAddress)(); while(1); }