Index: firmware/App/Services/Download.c =================================================================== diff -u -r2823873d5790228595fb991e52e78e2fd0d5987c -rb887b4a2796de3b26be07619809f8f4146955867 --- firmware/App/Services/Download.c (.../Download.c) (revision 2823873d5790228595fb991e52e78e2fd0d5987c) +++ firmware/App/Services/Download.c (.../Download.c) (revision b887b4a2796de3b26be07619809f8f4146955867) @@ -23,15 +23,6 @@ // ********** private data ********** -/// Software update response status structure -typedef struct -{ - U16 msgID; ///< Message ID. - U08 msgAckNackStatus; ///< Message ack or nack status. - U08 spareSpace; ///< Message spare byte. - U32 msgCRC; ///< Message CRC. -} SW_UPDATE_RESP_STATUS_T; - /// Software update command status structure typedef struct { @@ -199,6 +190,19 @@ return SWUpdateRCVStatus.msgID; } +/*********************************************************************//** + * @brief + * The getCurrentCmdMessageID function returns the current command message + * ID that has been received with command payload. + * @details \b Inputs: SWUpdateCmdStatus + * @details \b Outputs: none + * @return the current command message ID with update payload + *************************************************************************/ +U16 getCurrentCmdMessageID() +{ + return SWUpdateCmdStatus.msgID; +} + // ********** private functions ********** /*********************************************************************//** @@ -233,31 +237,28 @@ SWUpdateSpecs.dest = (SW_UPDATE_DESINTATION_T)SWUpdateCmdStatus.destination; ackStatus = ACK; - if ( UPDATE_FPGA == SWUpdateSpecs.dest ) + switch ( SWUpdateSpecs.cmd ) { - switch ( SWUpdateSpecs.cmd ) - { - case UPDATE_CMD_START: - // If the update destination is FPGA, signal FPGA to prepare for the update. - signalFPGAToPrepareForUpdate(); - break; + case UPDATE_CMD_START: + // If the update destination is FPGA, signal FPGA to prepare for the update. + signalFPGAToPrepareForUpdate(); + break; - case UPDATE_CMD_CONFIG_FPGA: - // Signal FPGA to self configure after the update is finished. - signalFPGAToSelfConfigure(); - break; + case UPDATE_CMD_CONFIG_FPGA: + // Signal FPGA to self configure after the update is finished. + signalFPGAToSelfConfigure(); + break; - default: - // Do nothing for the rest of the commands - break; - } + default: + // Do nothing for the rest of the commands + break; } } - if ( SWUpdateSpecs.dest != UPDATE_FPGA ) + if ( ( UPDATE_CMD_START == SWUpdateSpecs.cmd ) && ( SWUpdateSpecs.dest != UPDATE_FPGA ) ) { - // Send the result of the command received for firmware. - // FPGA is delayed and it takes a while to prepare it so ack is not sent immediately + // If the command is start send the ack immediately. The rest of the commands are delayed (e.g. verify - because action is needed) + // The start command in FPGA also needs the FPGA to be prepare itself so it will have a delayed start prepareAndSendBootLoaderResponseMessage( msgID, ackStatus ); } @@ -390,7 +391,7 @@ resp.spareSpace = 0; resp.msgCRC = crc32( calcCRC, (U08*)&resp, sizeof( SW_UPDATE_RESP_STATUS_T ) - sizeof( U32 ) ); - sendAckNackStatusFromFirmware( (U08*)&resp ); // TODO do we have to retry if send failed? + sendAckNackStatusFromBootloader( (U08*)&resp ); // TODO do we have to retry if send failed? } /*********************************************************************//** @@ -446,13 +447,6 @@ status = signalFPGAToWriteToFlash( SWUpdateRCVStatus.SWUpdateBuffer, fpgaPayloadLengthBytes ); - // TODO remove this code - //if ( fpgaPayloadLengthBytes < SW_UPDATE_FLASH_BUFFER_SIZE ) - //{ - // // TODO this should be a command and not the last buffer because what if the last payload is 256 bytes? - // signalFPGAToSelfConfigure(); - //} - if ( TRUE == status ) { // The update payload has been enqueued successfully, clear the raw buffer but keep the receive buffer since the enqueue