Index: firmware/App/Services/Download.c =================================================================== diff -u -rfc9a9244cf4288ff0623c3e02455ac565bf60cdd -r09e6320e3f3c3c973de0b66e5799d710db8cc427 --- firmware/App/Services/Download.c (.../Download.c) (revision fc9a9244cf4288ff0623c3e02455ac565bf60cdd) +++ firmware/App/Services/Download.c (.../Download.c) (revision 09e6320e3f3c3c973de0b66e5799d710db8cc427) @@ -7,22 +7,20 @@ #include "Download.h" #include "FPGA.h" #include "NVDataMgmt.h" +#include "OperationModes.h" #include "SystemComm.h" #include "Utilities.h" -#include "OperationModes.h" - /** * @addtogroup Download * @{ */ // ********** private definitions ********** -#define SW_UPDATE_FINAL_MSG_INDEX 0xFFFF // TODO remove ///< Software update final message index. #define SHIFT_BITS_TO_GET_TARGET 4 ///< Shift bits by 4 to get the update target. -static const U32 NUM_OF_CAN_BYTES_FOR_UPDATE = SW_UPDATE_FLASH_BUFFER_SIZE + CAN_MESSAGE_FRAME_SIZE; ///< Number of CAN bytes for update. +static const U32 NUM_OF_CAN_BYTES_FOR_UPDATE = SW_UPDATE_FLASH_BUFFER_SIZE + CAN_MESSAGE_FRAME_SIZE; ///< Number of CAN bytes for update. // ********** private data ********** @@ -79,7 +77,7 @@ *************************************************************************/ void initDownload( void ) { - thisStackMailBox = RECEIVE_MSG_ID[ BL_STACK_ID ]; + thisStackMailBox = RECEIVE_MSG_ID[ BL_STACK_ID ][ FW_STACKS_RCV_MAIL_BOX_INDEX ]; clearSWUpdateBuffer(); clearSWUpdateCommandState(); @@ -193,7 +191,7 @@ ackStatus = ACK; SWUpdateCommandState = (SW_UPDATE_CMD_T)( SWUpdateCmdStatus.updateCmd & MASK_OFF_NIBBLE_MSB ); - if ( UPDATE_FPGA == dest ) + if ( UPDATE_FPGA == dest ) // TODO once verify command is received for FPGA, make sure the prepare signal is not sent again { // If the update destination is FPGA, signal FPGA to prepare for the update. signalFPGAToPrepareForUpdate(); @@ -321,13 +319,10 @@ ACK_NACK_STATUS_T ackStatus = ACK; BOOL status = FALSE; - if ( SWUpdateRCVStatus.updatePayloadLen != SW_UPDATE_FINAL_MSG_INDEX ) - { - _disable_IRQ(); - status = handleUpdatingFlash( SWUpdateRCVStatus.SWUpdateBuffer ); - ackStatus = ( TRUE == status ? ACK : NACK ); - _enable_IRQ(); - } + _disable_IRQ(); + status = handleUpdatingFlash( SWUpdateRCVStatus.SWUpdateBuffer ); + ackStatus = ( TRUE == status ? ACK : NACK ); + _enable_IRQ(); return ackStatus; } @@ -347,6 +342,8 @@ // TODO why the firmware handler is slightly different? Make them consistent. +#define SW_UPDATE_FINAL_MSG_INDEX 0xFFFF // TODO: Remove. NOTE: once FPGA is ready investigate and remove 0xFFFF + if ( SWUpdateRCVStatus.updatePayloadLen != SW_UPDATE_FINAL_MSG_INDEX ) { sizeToWrite = SWUpdateRCVStatus.updatePayloadLen;