|
|
@@ -41,7 +41,7 @@ USBD_CDC_HandleTypeDef* hcdc;
|
|
|
uint32_t ucdcRcvLength = 0;
|
|
|
uint8_t ucdcRcvOverFlag = 1;
|
|
|
uint32_t ucdcRcvLastTime = 0;
|
|
|
-uint8_t ucdcRcvBuffer[APP_RX_DATA_SIZE] = {0};
|
|
|
+uint8_t ucdcRcvBuffer[PACKET_1K_SIZE + PACKET_DATA_INDEX + PACKET_TRAILER_SIZE] = {0};
|
|
|
#endif
|
|
|
|
|
|
void All_Reset(void)
|
|
|
@@ -157,7 +157,7 @@ HAL_StatusTypeDef Interface_Receive(uint8_t* bytes, uint16_t size, uint32_t time
|
|
|
ucdcRcvOverFlag = 1;
|
|
|
}
|
|
|
|
|
|
- if(ucdcRcvLength > 0 && ucdcRcvLength <= APP_RX_DATA_SIZE){
|
|
|
+ if(ucdcRcvLength > 0 && ucdcRcvLength <= PACKET_1K_SIZE + PACKET_DATA_INDEX + PACKET_TRAILER_SIZE){
|
|
|
uint16_t copySize = (ucdcRcvLength > size) ? size : ucdcRcvLength;
|
|
|
memcpy(bytes, ucdcRcvBuffer, copySize);
|
|
|
ucdcRcvLength -= copySize;
|
|
|
@@ -305,13 +305,13 @@ void Main_Cycle(void)
|
|
|
Interface_PutString("\r\n\r\nS to start\r\n\r\n");
|
|
|
while(1)
|
|
|
{
|
|
|
- #ifdef IAP_YMODEM_ATY_USB
|
|
|
+#ifdef IAP_YMODEM_ATY_USB
|
|
|
if(hcdc->RxLength > 1024){
|
|
|
uint8_t t[1] = {0};
|
|
|
Interface_Receive(t, 1, 10);
|
|
|
continue;
|
|
|
}
|
|
|
- #endif
|
|
|
+#endif
|
|
|
if(1)
|
|
|
{
|
|
|
if(Interface_Receive(sKey, 2, IAP_S_TIME) == HAL_OK)
|
|
|
@@ -398,6 +398,7 @@ COM_StatusTypeDef Interface_Download(void)
|
|
|
COM_StatusTypeDef result;
|
|
|
|
|
|
Interface_PutString("\r\nWaiting for the file to be sent... (press 'a' to abort)\r\n");
|
|
|
+ Interface_PutByte(CRC16);
|
|
|
result = Ymodem_Receive(&size);
|
|
|
if(result == COM_OK)
|
|
|
{
|
|
|
@@ -771,8 +772,8 @@ uint8_t aFileName[FILE_NAME_LENGTH];
|
|
|
* @retval HAL_OK: normally return
|
|
|
* HAL_BUSY: abort by user
|
|
|
*/
|
|
|
- uint8_t byteOneTmp = 0;
|
|
|
- HAL_StatusTypeDef statusA;
|
|
|
+uint8_t byteOneTmp = 0;
|
|
|
+HAL_StatusTypeDef statusA;
|
|
|
static HAL_StatusTypeDef ReceivePacket(uint8_t* p_data, uint32_t* p_length, uint32_t timeout)
|
|
|
{
|
|
|
uint32_t crc;
|
|
|
@@ -1002,12 +1003,13 @@ uint8_t CalcChecksum(const uint8_t* p_data, uint32_t size)
|
|
|
* @retval COM_StatusTypeDef result of reception/programming
|
|
|
*/
|
|
|
HAL_StatusTypeDef statA = HAL_OK;
|
|
|
+uint16_t packets_received;
|
|
|
COM_StatusTypeDef Ymodem_Receive(uint32_t* p_size)
|
|
|
{
|
|
|
uint32_t i, packet_length, session_done = 0, file_done, errors = 0, session_begin = 0;
|
|
|
uint32_t flashdestination, ramsource, filesize;
|
|
|
uint8_t* file_ptr;
|
|
|
- uint8_t file_size[FILE_SIZE_LENGTH], tmp, packets_received;
|
|
|
+ uint8_t file_size[FILE_SIZE_LENGTH], tmp;
|
|
|
COM_StatusTypeDef result = COM_OK;
|
|
|
|
|
|
/* Initialize flashdestination variable */
|
|
|
@@ -1038,7 +1040,7 @@ COM_StatusTypeDef Ymodem_Receive(uint32_t* p_size)
|
|
|
break;
|
|
|
default:
|
|
|
/* Normal packet */
|
|
|
- if(aPacketData[PACKET_NUMBER_INDEX] != packets_received)
|
|
|
+ if(aPacketData[PACKET_NUMBER_INDEX] != (packets_received % 256))
|
|
|
{
|
|
|
Interface_PutByte(NAK);
|
|
|
}
|