Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rc74c1d99a011dd0fb7f98f183faecda675221fce -radea34db9066bdc0dbb20f49bdf66c9331a7037c --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision c74c1d99a011dd0fb7f98f183faecda675221fce) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision adea34db9066bdc0dbb20f49bdf66c9331a7037c) @@ -19,7 +19,7 @@ // ********** private definitions ********** -#define WAIT_FOR_UPDATE_FROM_UI_MS 1000 ///< Wait for update timeout in milliseconds. +#define WAIT_FOR_UPDATE_FROM_UI_MS 3000000 ///< Wait for update timeout in milliseconds. // ********** private data ********** @@ -58,7 +58,7 @@ { initStandbyMode(); - return 0; + return standbyCurrentState; } /*********************************************************************//** @@ -70,8 +70,7 @@ *************************************************************************/ U32 execStandbyMode( void ) { - // If the bootloader is the standby mode and and update request is received at any time, request a transition to update mode - // TODO what if we are in the check image process, should we transition to update upon the request? + // If the bootloader is in standby mode and update request is received at any time, request a transition to update mode if ( ( UPDATE_CMD_START == getSWUpdateCommandState() ) || ( TRUE == hasUpdateBeenRequested() ) ) { // TODO if we are here because of the FPGA register, clear it so it won't be called again. @@ -114,8 +113,9 @@ static MODE_STANDBY_STATE_T handleStandbyModeCheckForUpdateState( void ) { MODE_STANDBY_STATE_T state = STANDBY_CHECK_FOR_UPDATE_STATE; + SW_UPDATE_CMD_T cmd = getSWUpdateCommandState(); - switch ( getSWUpdateCommandState() ) + switch ( cmd ) { case UPDATE_CMD_ABORT: state = STANDBY_IDLE_STATE; @@ -130,7 +130,7 @@ break; } - if ( TRUE == didTimeout( waitForUpdateMsgStartTimeMS, 3000000 /*WAIT_FOR_UPDATE_FROM_UI_MS*/ ) ) // TODO a high number if timeout for development + if ( TRUE == didTimeout( waitForUpdateMsgStartTimeMS, WAIT_FOR_UPDATE_FROM_UI_MS ) ) { state = STANDBY_CHECK_FW_AND_FPGA_IMAGES_STATE; } @@ -144,42 +144,34 @@ * check firmware and FPGA images state. * This state checks the integrity of the firmware as well as the FPGA header * to make sure the images are valid. - * @details \b Inputs: waitForUpdateMsgStartTimeMS + * @details \b Inputs: none * @details \b Outputs: none * @return next state of the standby mode state machine *************************************************************************/ static MODE_STANDBY_STATE_T handleStandbyModeCheckFWAndFPGAImages( void ) { - MODE_STANDBY_STATE_T state = STANDBY_CHECK_FW_AND_FPGA_IMAGES_STATE; + MODE_STANDBY_STATE_T state = STANDBY_IDLE_STATE; BOOL isFirmwareImageValid = FALSE; BOOL isFPGAImageValid = FALSE; - // TODo timeout and wait for a while prior to transitioning // TODO why a bad code passes the CRC? - _disable_IRQ(); + // TODO send the results back (pass/fail) up to be sent to the cloud. if ( TRUE == isFWCRCTableValid() ) { isFirmwareImageValid = runFWIntegrityTest(); } - _enable_IRQ(); if ( TRUE == isFPGAIDValid() ) { isFPGAImageValid = TRUE; } + // NOTE: If either of the images (firmware or FPGA) failed, go to the idle state until another update request is received if ( ( TRUE == isFirmwareImageValid ) && ( TRUE == isFPGAImageValid ) ) { // All good, jump to application jumpToApplication(); } - else - { - // TODO do we need to try a few times prior to tansitioning to Idle? - // If either of the images (firmware or FPGA) failed, go to the idle state until another update request is received - state = STANDBY_IDLE_STATE; - } - return state; }