Index: firmware/App/Services/Download.c =================================================================== diff -u -r0595b4b31cef5980bc589ff7ce39a4e97bc81d8d -r012573b1913d1bfd2357acfadcad6bb20b295ad9 --- firmware/App/Services/Download.c (.../Download.c) (revision 0595b4b31cef5980bc589ff7ce39a4e97bc81d8d) +++ firmware/App/Services/Download.c (.../Download.c) (revision 012573b1913d1bfd2357acfadcad6bb20b295ad9) @@ -5,6 +5,8 @@ * Author: fw */ +#include "can.h" // TODO remove for testing only + #include // For memcpy and memset #include "CommBuffers.h" @@ -48,6 +50,10 @@ static SW_UPDATE_CMD_T SWUpdateCommandState; static SW_UPDATE_CAN_MAIL_BOX_T thisStackMailBox; +static U32 REMOVETHEVAR = 0; +static U08 REMOVETESTBUFFER[ 256 ]; +static U32 sizeToWrite; + static void processIncomingCmdMessage( SW_UPDATE_CAN_MAIL_BOX_T mailBox ); static void processIncomingUpdateMessage( SW_UPDATE_CAN_MAIL_BOX_T mailBox ); static void prepareResponseMessage( U08 respOfMsgID, ACK_NACK_STATUS_T ackNack, SW_UPDATE_RESP_STATUS_T* respBuffer ); @@ -96,7 +102,7 @@ ACK_NACK_STATUS_T ackStatus = NACK; U32 calcCRC = 0; U08 msgID = SWUpdateCmdStatus.msgID; - SW_UPDATE_DESINTATION_T dest = (SW_UPDATE_DESINTATION_T)( SWUpdateCmdStatus.updateCmd >> SHIFT_BITS_TO_GET_TARGET ); + SW_UPDATE_DESINTATION_T dest = (SW_UPDATE_DESINTATION_T)( SWUpdateCmdStatus.updateCmd >> SHIFT_BITS_TO_GET_TARGET ); // TODO add more logic for other stacks calcCRC = crc32( calcCRC, (U08*)&SWUpdateCmdStatus, MAX_CRC_CALC_DATA_SIZE ); hasCRCPassed = ( SWUpdateCmdStatus.msgCRC == calcCRC ? TRUE : FALSE ); @@ -165,7 +171,7 @@ prepareResponseMessage( SWUpdateRCVStatus.msgID, ackNackStatus, &resp ); status = sendAckNackStatusFromFirmware( (U08*)&resp ); // TODO do we have to retry if send failed? clearCommBuffer( mailBox ); // TODo does this need to be here? How about resync? - clearSWUpdateBuffer(); + //clearSWUpdateBuffer(); // TODO uncomment } } @@ -203,19 +209,53 @@ { ACK_NACK_STATUS_T ackStatus = NACK; - if ( FPGA_UPDATE_READY == getFPGAFlashState() ) + //if ( FPGA_UPDATE_READY == getFPGAFlashState() ) { if ( SWUpdateRCVStatus.cyberIndex != SW_UPDATE_FINAL_MSG_INDEX ) { U08 removeThis; + U08 index = 0; + U32 counter; + U08 test[8]; + sizeToWrite = SW_UPDATE_FLASH_BUFFER_SIZE; + BOOL done = FALSE; - for ( removeThis = 0; removeThis < SW_UPDATE_FLASH_BUFFER_SIZE; removeThis++ ) + /*for ( removeThis = 0; removeThis < SW_UPDATE_FLASH_BUFFER_SIZE; removeThis++ ) { + test[ index ] = SWUpdateRCVStatus.SWUpdateBuffer[removeThis]; + if ( index == 7 ) + { + canTransmit( canREG1, (U32)SW_TEST, test ); // Transmit the FPGA back up to make sure we totally received what we sent + for ( counter = 0; counter < 6000; counter++ ) {} + index = 0; + } + else + { + index += 1; + } + // TODO this is temporary until the ROTTING is removed from the APP - SWUpdateRCVStatus.SWUpdateBuffer[ removeThis ] = 0xFF & ( SWUpdateRCVStatus.SWUpdateBuffer[removeThis] - 27 ); + // SWUpdateRCVStatus.SWUpdateBuffer[ removeThis ] = 0xFF & ( SWUpdateRCVStatus.SWUpdateBuffer[removeThis] - 27 ); + }*/ + // 3192290 + // 1596144 + if ( ( 1596144 - REMOVETHEVAR < SW_UPDATE_FLASH_BUFFER_SIZE ) && ( REMOVETHEVAR != 0 ) ) + { + sizeToWrite = 1596144 - REMOVETHEVAR; + REMOVETHEVAR += sizeToWrite; + done = TRUE; } + else + { + REMOVETHEVAR += SW_UPDATE_FLASH_BUFFER_SIZE; + } - signalFPGAToWriteToFlash( SWUpdateRCVStatus.SWUpdateBuffer, sizeof( SWUpdateRCVStatus.SWUpdateBuffer ) ); + memcpy( REMOVETESTBUFFER, SWUpdateRCVStatus.SWUpdateBuffer, sizeToWrite); + signalFPGAToWriteToFlash( SWUpdateRCVStatus.SWUpdateBuffer, sizeToWrite ); + if ( TRUE == done ) + { + signalFPGAToSelfConfigure(); + } } }