Обновление

This commit is contained in:
cfif 2026-06-20 18:24:57 +03:00
parent eba6bec97e
commit 27a0114906
2 changed files with 50 additions and 48 deletions

View File

@ -208,23 +208,6 @@ bool ReceivedCan_func(void *arg, can_rx_message_type *canFrame) {
return false; return false;
} }
/*
void ReceivedTP_func(void *arg, tCanTP_data *data) {
tCanUds *env = arg;
osStatus_t status = osMessageQueuePut(env->queue, data, 0, 0U);
// LoggerFormatInfo(LOGGER, LOG_SIGN, "Add queue (UDS): %d", data[0])
if (status != osOK) {
#if (LOG_UDS == 1)
LoggerInfoStatic(LOGGER, LOG_SIGN, "Error addCommandQueue")
#endif
}
}
*/
void setResponseErrorPending(tCanUds *env, eUdsServices service, eUdsResponseError error) { void setResponseErrorPending(tCanUds *env, eUdsServices service, eUdsResponseError error) {
env->dataResponsePending[0] = 0x7F; env->dataResponsePending[0] = 0x7F;
@ -1032,9 +1015,11 @@ static uint16_t vUDS_routine_Erase_Memory(tCanUds *env, eUdsRoutineControlType u
env->udsBlock = UDS_BlockInit; env->udsBlock = UDS_BlockInit;
if (eraseMemory->memoryAddress == ADR_HEX_BlockBoot) { // if (eraseMemory->memoryAddress == ADR_HEX_BlockBoot) {
env->udsBlock = UDS_BlockBoot; // env->udsBlock = UDS_BlockBoot;
} else if (eraseMemory->memoryAddress == ADR_HEX_BlockMain) { // } else
if (eraseMemory->memoryAddress == ADR_HEX_BlockMain) {
env->udsBlock = UDS_BlockMain; env->udsBlock = UDS_BlockMain;
} else if (eraseMemory->memoryAddress == ADR_HEX_BlockCalib) { } else if (eraseMemory->memoryAddress == ADR_HEX_BlockCalib) {
env->udsBlock = UDS_BlockCalib; env->udsBlock = UDS_BlockCalib;
@ -1047,17 +1032,15 @@ static uint16_t vUDS_routine_Erase_Memory(tCanUds *env, eUdsRoutineControlType u
setResponseErrorPending(env, UDS_RoutineControl, UDS_error_requestCorrectlyReceived_ResponsePending); setResponseErrorPending(env, UDS_RoutineControl, UDS_error_requestCorrectlyReceived_ResponsePending);
if (env->udsBlock == UDS_BlockBoot) { // if (env->udsBlock == UDS_BlockBoot) {
env->timeoutPendingClear = SystemGetMs() + 200; // env->timeoutPendingClear = SystemGetMs() + 200;
bool result1 = env->clear_flash_func(ADR_HEX_Mapped_BlockBoot, SIZE_HEX_BlockBoot, SendUpdatePendingFlashClear, // bool result1 = env->clear_flash_func(ADR_HEX_Mapped_BlockBoot, SIZE_HEX_BlockBoot, SendUpdatePendingFlashClear,
env); // env);
// if (result1) {
if (result1) { // env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess; // return 4 + 1;
// }
return 4 + 1; // }
}
}
if (env->udsBlock == UDS_BlockMain) { if (env->udsBlock == UDS_BlockMain) {
env->timeoutPendingClear = SystemGetMs() + 200; env->timeoutPendingClear = SystemGetMs() + 200;
@ -1102,18 +1085,38 @@ vUDS_routine_Check_Programming_Dependancies(tCanUds *env, eUdsRoutineControlType
setResponseErrorPending(env, UDS_RoutineControl, UDS_error_requestCorrectlyReceived_ResponsePending); setResponseErrorPending(env, UDS_RoutineControl, UDS_error_requestCorrectlyReceived_ResponsePending);
uint32_t crc32_calc = UdsCrc32Update_Hardware(0xFFFFFFFF, (uint8_t *) ADR_HEX_Mapped_BlockBoot, bool result = P_bInternalFlashPage_CopyRange(ADR_HEX_Mapped_BlockBoot, ADR_HEX_BlockBoot, SIZE_HEX_BlockBoot,
SIZE_HEX_BlockBoot - 4, NULL, NULL);
SendUpdatePendingCrc, env, 200);
uint32_t crc32_file = (*(uint32_t *) (ADR_HEX_Mapped_BlockBoot + SIZE_HEX_BlockBoot - 4)); if (result == false) {
if (crc32_calc != crc32_file) {
env->dataResponse[4] = UDS_routine_RoutineStartStopFailure; env->dataResponse[4] = UDS_routine_RoutineStartStopFailure;
return 4 + 1; return 4 + 1;
} }
setResponseErrorPending(env, UDS_RoutineControl, UDS_error_requestCorrectlyReceived_ResponsePending);
int resultBoot = memcmp((uint8_t *) ADR_HEX_Mapped_BlockBoot, (uint8_t *) ADR_HEX_BlockBoot, SIZE_HEX_BlockBoot);
if (resultBoot != 0) {
env->dataResponse[4] = UDS_routine_RoutineStartStopFailure;
return 4 + 1;
}
// uint32_t crc32_calc = UdsCrc32Update_Hardware(0xFFFFFFFF, (uint8_t *) ADR_HEX_Mapped_BlockBoot,
// SIZE_HEX_BlockBoot - 4,
// SendUpdatePendingCrc, env, 200);
// uint32_t crc32_file = (*(uint32_t *) (ADR_HEX_Mapped_BlockBoot + SIZE_HEX_BlockBoot - 4));
// if (crc32_calc != crc32_file) {
// env->dataResponse[4] = UDS_routine_RoutineStartStopFailure;
// return 4 + 1;
// }
uint32_t crc32_calc;
uint32_t crc32_file;
setResponseErrorPending(env, UDS_RoutineControl, UDS_error_requestCorrectlyReceived_ResponsePending); setResponseErrorPending(env, UDS_RoutineControl, UDS_error_requestCorrectlyReceived_ResponsePending);
crc32_calc = UdsCrc32Update_Hardware(0xFFFFFFFF, (uint8_t *) ADR_HEX_Mapped_BlockMain, SIZE_HEX_BlockMain - 4, crc32_calc = UdsCrc32Update_Hardware(0xFFFFFFFF, (uint8_t *) ADR_HEX_Mapped_BlockMain, SIZE_HEX_BlockMain - 4,
SendUpdatePendingCrc, env, 200); SendUpdatePendingCrc, env, 200);
@ -1148,7 +1151,7 @@ vUDS_routine_Check_Programming_Dependancies(tCanUds *env, eUdsRoutineControlType
NumberBank = 0; NumberBank = 0;
} }
bool result = D_bInternalFlashPage_Clear(0x04000000, NULL, NULL); result = D_bInternalFlashPage_Clear(0x04000000, NULL, NULL);
if (result == false) { if (result == false) {
env->dataResponse[4] = UDS_routine_RoutineStartStopFailure; env->dataResponse[4] = UDS_routine_RoutineStartStopFailure;
@ -1460,9 +1463,9 @@ static uint16_t RequestDownload_34(tCanUds *env) {
env->udsBlock = UDS_BlockInit; env->udsBlock = UDS_BlockInit;
if (com->memoryAddress == ADR_HEX_BlockBoot) { // if (com->memoryAddress == ADR_HEX_BlockBoot) {
env->udsBlock = UDS_BlockBoot; // env->udsBlock = UDS_BlockBoot;
} // }
if (com->memoryAddress == ADR_HEX_BlockMain) { if (com->memoryAddress == ADR_HEX_BlockMain) {
env->udsBlock = UDS_BlockMain; env->udsBlock = UDS_BlockMain;
@ -1483,12 +1486,11 @@ static uint16_t RequestDownload_34(tCanUds *env) {
env->SizeWriteFlash = 0; env->SizeWriteFlash = 0;
env->DownloadFirmwareSize = com->memorySize; env->DownloadFirmwareSize = com->memorySize;
if (env->udsBlock == UDS_BlockBoot) { // if (env->udsBlock == UDS_BlockBoot) {
// if (com->memorySize > SIZE_HEX_BlockBoot) {
if (com->memorySize > SIZE_HEX_BlockBoot) { // return setResponseError(env, UDS_RequestDownload, UDS_error_requestOutOfRange);
return setResponseError(env, UDS_RequestDownload, UDS_error_requestOutOfRange); // }
} // }
}
if (env->udsBlock == UDS_BlockMain) { if (env->udsBlock == UDS_BlockMain) {

View File

@ -150,7 +150,7 @@ typedef enum {
} eUdsRequestRoutineResult; } eUdsRequestRoutineResult;
typedef enum { typedef enum {
UDS_BlockBoot = 0, // UDS_BlockBoot = 0,
UDS_BlockMain = 1, UDS_BlockMain = 1,
UDS_BlockCalib = 2, UDS_BlockCalib = 2,
UDS_BlockInit = 0xff UDS_BlockInit = 0xff