Index: firmware/App/BLCommon.h =================================================================== diff -u -r0c085209bea23f66011059a7c19796c1e4b246fa -r09e6320e3f3c3c973de0b66e5799d710db8cc427 --- firmware/App/BLCommon.h (.../BLCommon.h) (revision 0c085209bea23f66011059a7c19796c1e4b246fa) +++ firmware/App/BLCommon.h (.../BLCommon.h) (revision 09e6320e3f3c3c973de0b66e5799d710db8cc427) @@ -11,7 +11,6 @@ /* * TD = 0 * DD = 1 - * RO = 2 */ #define BL_STACK_ID 0 // TODO de we need to check the value to make sure it is range (e.g. it is not set to 20?) Index: firmware/App/Common.h =================================================================== diff -u -rfc9a9244cf4288ff0623c3e02455ac565bf60cdd -r09e6320e3f3c3c973de0b66e5799d710db8cc427 --- firmware/App/Common.h (.../Common.h) (revision fc9a9244cf4288ff0623c3e02455ac565bf60cdd) +++ firmware/App/Common.h (.../Common.h) (revision 09e6320e3f3c3c973de0b66e5799d710db8cc427) @@ -15,6 +15,8 @@ // ********** public definitions ********** #define NUM_OF_FW_STACKS 2 ///< Number of firmware stacks (TD, DD). +#define FW_STACKS_RCV_MAIL_BOX_INDEX 0 ///< Firmware stacks table receive mail box index. +#define FW_STACKS_RESP_MAIL_BOX_INDEX 1 ///< Firmware stacks table response mail box index. #define CAN_MESSAGE_FRAME_SIZE 8 ///< CAN message frame size in bytes. #define FIRMWARE_START_ADDRESS 0x00010000 ///< Firmware start address. #define FIRMWARE_CRC_TABLE_ADDRESS 0x10020 ///< The starting address of CRC table for firmware image. @@ -140,10 +142,10 @@ } ACK_NACK_STATUS_T; /// Software update corresponding stack mailbox -static const SW_UPDATE_CAN_MAIL_BOX_T RECEIVE_MSG_ID[ NUM_OF_FW_STACKS ] = +static const SW_UPDATE_CAN_MAIL_BOX_T RECEIVE_MSG_ID[ NUM_OF_FW_STACKS ][ NUM_OF_FW_STACKS ] = { - SW_UPDATE_TD_UPDATE, ///< Software update TD. - SW_UPDATE_DD_UPDATE, ///< Software update DD. + { SW_UPDATE_TD_UPDATE, SW_UPDATE_TD_RESP }, ///< Software update TD. + { SW_UPDATE_DD_UPDATE, SW_UPDATE_DD_RESP }, ///< Software update DD. }; /**@}*/ Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r0c085209bea23f66011059a7c19796c1e4b246fa -r09e6320e3f3c3c973de0b66e5799d710db8cc427 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 0c085209bea23f66011059a7c19796c1e4b246fa) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 09e6320e3f3c3c973de0b66e5799d710db8cc427) @@ -73,7 +73,6 @@ // 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. requestNewOperationMode( MODE_UPDATE ); } Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r292265111b911fa79c52bb4589911dfb60c921bf -r09e6320e3f3c3c973de0b66e5799d710db8cc427 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 292265111b911fa79c52bb4589911dfb60c921bf) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 09e6320e3f3c3c973de0b66e5799d710db8cc427) @@ -91,6 +91,13 @@ } } +/*********************************************************************//** + * @brief + * The getCurrentOpMode function returns the current operation mode. + * @details \b Inputs: currentMode + * @details \b Outputs: none + * @return current operation mode + *************************************************************************/ BL_OP_MODE_T getCurrentOpMode( void ) { return currentMode; 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; Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -rfc9a9244cf4288ff0623c3e02455ac565bf60cdd -r09e6320e3f3c3c973de0b66e5799d710db8cc427 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision fc9a9244cf4288ff0623c3e02455ac565bf60cdd) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 09e6320e3f3c3c973de0b66e5799d710db8cc427) @@ -56,7 +56,7 @@ } else { - if ( RECEIVE_MSG_ID[ BL_STACK_ID ] == mailBox ) + if ( RECEIVE_MSG_ID[ BL_STACK_ID ][ FW_STACKS_RCV_MAIL_BOX_INDEX ] == mailBox ) { if ( FALSE != canIsRxMessageArrived( canREG1, mailBox ) ) { @@ -82,9 +82,10 @@ *************************************************************************/ BOOL sendAckNackStatusFromFirmware( U08* data ) { - BOOL status = FALSE; + BOOL status = FALSE; + U32 respMailBox = RECEIVE_MSG_ID[ BL_STACK_ID ][ FW_STACKS_RESP_MAIL_BOX_INDEX ]; - if ( 0 != canTransmit( canREG1, (U32)SW_UPDATE_TD_RESP, data ) ) + if ( 0 != canTransmit( canREG1, respMailBox, data ) ) { status = TRUE; }