diff --git a/GD32E50X_BOOT/sys/OTA.cpp b/GD32E50X_BOOT/sys/OTA.cpp index 080ade4..6d4e879 100644 --- a/GD32E50X_BOOT/sys/OTA.cpp +++ b/GD32E50X_BOOT/sys/OTA.cpp @@ -1,4 +1,4 @@ -#include "OTA.h" +#include "OTA.h" #include "Can.h" #include "SpiOta.h" #include "aes128.h" @@ -297,10 +297,6 @@ void OTAHandler::process() { drainFlashBuffer(); if (pending_finish_ack && flash_buf_cnt == 0U) { pending_finish_ack = false; -#if DEBUG_PRINT - printf("[OTA] flash drain done, send FINISH ACK\r\n"); -#endif - send_structured_ack(0xFFFFFFFFU); } if (pending_app_jump) { @@ -625,7 +621,7 @@ void OTAHandler::handleLinkMessage(ota_link_msg_type_t type, u8 *data, u8 len) { return; } else { u32 offset = receive_packet_num * OTA_PACKET_SIZE; - if (offset + OTA_PACKET_SIZE > APP_MAX_SIZE) { + if (offset >= expected_size) { ota_error = OTA_ERROR_INVALID_SIZE; ota_state = OTA_STATE_IDLE; send_error_frame(receive_packet_num, OTA_ERROR_INVALID_SIZE); @@ -652,8 +648,7 @@ void OTAHandler::handleLinkMessage(ota_link_msg_type_t type, u8 *data, u8 len) { if (receive_IFEND == 0xFFFFFFFFU) { ota_state = OTA_STATE_FINISHED; pending_finish_ack = true; - u8 wait_hint[1] = {0x04}; - send_wait_frame(1, wait_hint); + send_structured_ack(0xF0F0F0F0U); return; }