Index: firmware/App/BLCommon.h =================================================================== diff -u -r3039dac751473d0aae67192c02129cfdc37424f1 -r1541f5c438744fffa0dc3157935da528342f01e7 --- firmware/App/BLCommon.h (.../BLCommon.h) (revision 3039dac751473d0aae67192c02129cfdc37424f1) +++ firmware/App/BLCommon.h (.../BLCommon.h) (revision 1541f5c438744fffa0dc3157935da528342f01e7) @@ -28,7 +28,7 @@ * TD = 0 * DD = 1 */ -#define BL_STACK_ID 1 +#define BL_STACK_ID 0 #define BL_VERSION_MAJOR 0 #define BL_VERSION_MINOR 0 Index: firmware/App/Common.h =================================================================== diff -u -r24b4c7f4560296765373099ee83597baddc2cf94 -r1541f5c438744fffa0dc3157935da528342f01e7 --- firmware/App/Common.h (.../Common.h) (revision 24b4c7f4560296765373099ee83597baddc2cf94) +++ firmware/App/Common.h (.../Common.h) (revision 1541f5c438744fffa0dc3157935da528342f01e7) @@ -22,7 +22,7 @@ #define FIRMWARE_START_ADDRESS 0x00010000 ///< Firmware start address. #define FIRMWARE_CRC_TABLE_ADDRESS ( FIRMWARE_START_ADDRESS + 0x20 ) ///< The starting address of firmware CRC table. #define BOOTLOADER_CRC_TABLE_ADDRESS 0x00020 ///< The starting address of bootloader CRC table. -#define SW_UPDATE_FLASH_BUFFER_SIZE 512 ///< Software update flash buffer bytes. +#define SW_UPDATE_FLASH_BUFFER_SIZE 256 ///< Software update flash buffer bytes. #define MASK_OFF_MSB 0x00FF ///< Bits to mask off the most significant byte of a 2-byte word. #define MASK_OFF_LSB 0xFF00 ///< Bits to mask off the least significant byte of a 2-byte word. #define SHIFT_8_BITS_FOR_BYTE_SHIFT 8 ///< Number of bits to shift in order to shift a byte. @@ -159,6 +159,7 @@ { SW_UPDATE_DD_UPDATE, SW_UPDATE_DD_RESP }, ///< Software update DD. }; +#pragma pack(push, 1) /// Software update response status structure typedef struct { @@ -167,6 +168,7 @@ U08 spareSpace; ///< Message spare byte. U32 msgCRC; ///< Message CRC. } SW_UPDATE_RESP_STATUS_T; +#pragma pack(pop) /**@}*/ Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r5acce83ec629eff9621c0193fae57b7b63ad8de8 -r1541f5c438744fffa0dc3157935da528342f01e7 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 5acce83ec629eff9621c0193fae57b7b63ad8de8) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 1541f5c438744fffa0dc3157935da528342f01e7) @@ -38,10 +38,12 @@ // ********** private definitions ********** #define WAIT_FOR_UPDATE_FROM_UI_MS 1000 ///< Wait for update timeout in milliseconds. +#define WAIT_BEFORE_BOOTLOADER_RESET_MS 200 ///< Wait before bootloader reset in milliseconds. // ********** private data ********** static MODE_STANDBY_STATE_T standbyCurrentState; ///< Standby current state. +static U32 stateTimerMS; ///< Timeout before bootloader reset in milliseconds. // ********** private function prototypes ********** @@ -58,12 +60,13 @@ * @brief * The initStandbyMode function initializes the standby mode. * @details \b Inputs: none - * @details \b Outputs: standbyCurrentState + * @details \b Outputs: standbyCurrentState, stateTimerMS * @return none *************************************************************************/ void initStandbyMode( void ) { standbyCurrentState = STANDBY_CHECK_FOR_UPDATE_STATE; + stateTimerMS = 0; } /*********************************************************************//** @@ -234,13 +237,14 @@ *************************************************************************/ static MODE_STANDBY_STATE_T handleStandbyModeCheckUpdatedImageStates( void ) { - SW_UPDATE_RESP_STATUS_T resp; - U32 calcCRC = 0; + U16 cmdMsgID = getCurrentCmdMessageID(); MODE_STANDBY_STATE_T state = STANDBY_RESET_BOOTLOADER_STATE; SW_UPDATE_DESINTATION_T dest = getSWUpdateDestination(); ACK_NACK_STATUS_T ackStatus = ACK; BOOL status = FALSE; + stateTimerMS = getMSTimerCount(); + switch( dest ) { case UPDATE_FPGA: @@ -258,15 +262,8 @@ break; } - // NOTE: FPGA is check in self configure - resp.msgID = getCurrentCmdMessageID(); - resp.msgAckNackStatus = ackStatus; - resp.spareSpace = 0; - resp.msgCRC = crc32( calcCRC, (U08*)&resp, sizeof( SW_UPDATE_RESP_STATUS_T ) - sizeof( U32 ) ); + prepareAndSendBootLoaderResponseMessage( cmdMsgID, ackStatus ); - // If both firmware and FPGA results passed, send an ack otherwise send a nack - sendAckNackStatusFromBootloader( (U08*)&resp ); - return state; } @@ -281,11 +278,16 @@ *************************************************************************/ static MODE_STANDBY_STATE_T handleStandyModeResetBootloaderState( void ) { - MODE_STANDBY_STATE_T state = STANDBY_IDLE_STATE; + MODE_STANDBY_STATE_T state = STANDBY_RESET_BOOTLOADER_STATE; - // Reset the bootloader regardless of whether the update was successful or not - resetBootloader(); + if ( TRUE == didTimeout( stateTimerMS, WAIT_BEFORE_BOOTLOADER_RESET_MS) ) + { + state = STANDBY_IDLE_STATE; + // Reset the bootloader regardless of whether the update was successful or not + resetBootloader(); + } + return state; } Index: firmware/App/Services/Download.c =================================================================== diff -u -r5acce83ec629eff9621c0193fae57b7b63ad8de8 -r1541f5c438744fffa0dc3157935da528342f01e7 --- firmware/App/Services/Download.c (.../Download.c) (revision 5acce83ec629eff9621c0193fae57b7b63ad8de8) +++ firmware/App/Services/Download.c (.../Download.c) (revision 1541f5c438744fffa0dc3157935da528342f01e7) @@ -83,7 +83,6 @@ static void handleIncomingCmdMessage( SW_UPDATE_CAN_MAIL_BOX_T mailBox ); static void handleIncomingUpdateMessage( SW_UPDATE_CAN_MAIL_BOX_T mailBox ); static void handleIncomingBroadcastMessage( SW_UPDATE_CAN_MAIL_BOX_T mailBox ); -static void prepareAndSendBootLoaderResponseMessage( U16 respOfMsgID, ACK_NACK_STATUS_T ackNack ); static void clearSWUpdateBuffer( void ); static ACK_NACK_STATUS_T handleFirmwareUpdate( void ); static ACK_NACK_STATUS_T handleFPGAUpdate( void ); @@ -216,6 +215,29 @@ return SWUpdateCmdStatus.msgID; } +/*********************************************************************//** + * @brief + * The prepareAndSendBootLoaderResponseMessage function prepares the message + * body that is used to respond to the updater app and sends it. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message ID that is being responded for + * @param ack nack status + * @return none + *************************************************************************/ +void prepareAndSendBootLoaderResponseMessage( U16 respOfMsgID, ACK_NACK_STATUS_T ackNack ) +{ + SW_UPDATE_RESP_STATUS_T resp; + U32 calcCRC = 0; + + resp.msgID = respOfMsgID; + resp.msgAckNackStatus = ackNack; + resp.spareSpace = 0; + resp.msgCRC = crc32( calcCRC, (U08*)&resp, sizeof( SW_UPDATE_RESP_STATUS_T ) - sizeof( U32 ) ); + + sendAckNackStatusFromBootloader( (U08*)&resp ); // TODO do we have to retry if send failed? +} + // ********** private functions ********** /*********************************************************************//** @@ -386,29 +408,6 @@ /*********************************************************************//** * @brief - * The prepareAndSendBootLoaderResponseMessage function prepares the message - * body that is used to respond to the updater app and sends it. - * @details \b Inputs: none - * @details \b Outputs: none - * @param message ID that is being responded for - * @param ack nack status - * @return none - *************************************************************************/ -static void prepareAndSendBootLoaderResponseMessage( U16 respOfMsgID, ACK_NACK_STATUS_T ackNack ) -{ - SW_UPDATE_RESP_STATUS_T resp; - U32 calcCRC = 0; - - resp.msgID = respOfMsgID; - resp.msgAckNackStatus = ackNack; - resp.spareSpace = 0; - resp.msgCRC = crc32( calcCRC, (U08*)&resp, sizeof( SW_UPDATE_RESP_STATUS_T ) - sizeof( U32 ) ); - - sendAckNackStatusFromBootloader( (U08*)&resp ); // TODO do we have to retry if send failed? -} - -/*********************************************************************//** - * @brief * The clearSWUpdateBuffer function clears the software update buffer. * @details \b Inputs: none * @details \b Outputs: SWUpdateRCVStatus Index: firmware/App/Services/Download.h =================================================================== diff -u -r5acce83ec629eff9621c0193fae57b7b63ad8de8 -r1541f5c438744fffa0dc3157935da528342f01e7 --- firmware/App/Services/Download.h (.../Download.h) (revision 5acce83ec629eff9621c0193fae57b7b63ad8de8) +++ firmware/App/Services/Download.h (.../Download.h) (revision 1541f5c438744fffa0dc3157935da528342f01e7) @@ -51,6 +51,8 @@ U16 getCurrentCmdMessageID(); +void prepareAndSendBootLoaderResponseMessage( U16 respOfMsgID, ACK_NACK_STATUS_T ackNack ); + /**@}*/ #endif Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r5acce83ec629eff9621c0193fae57b7b63ad8de8 -r1541f5c438744fffa0dc3157935da528342f01e7 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 5acce83ec629eff9621c0193fae57b7b63ad8de8) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 1541f5c438744fffa0dc3157935da528342f01e7) @@ -343,7 +343,7 @@ break; } - publishDataTemp(); + //publishDataTemp(); } /*********************************************************************//**