Обновление
This commit is contained in:
parent
eba6bec97e
commit
27a0114906
96
CanUds.c
96
CanUds.c
|
|
@ -208,23 +208,6 @@ bool ReceivedCan_func(void *arg, can_rx_message_type *canFrame) {
|
|||
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) {
|
||||
env->dataResponsePending[0] = 0x7F;
|
||||
|
|
@ -1032,9 +1015,11 @@ static uint16_t vUDS_routine_Erase_Memory(tCanUds *env, eUdsRoutineControlType u
|
|||
env->udsBlock = UDS_BlockInit;
|
||||
|
||||
|
||||
if (eraseMemory->memoryAddress == ADR_HEX_BlockBoot) {
|
||||
env->udsBlock = UDS_BlockBoot;
|
||||
} else if (eraseMemory->memoryAddress == ADR_HEX_BlockMain) {
|
||||
// if (eraseMemory->memoryAddress == ADR_HEX_BlockBoot) {
|
||||
// env->udsBlock = UDS_BlockBoot;
|
||||
// } else
|
||||
|
||||
if (eraseMemory->memoryAddress == ADR_HEX_BlockMain) {
|
||||
env->udsBlock = UDS_BlockMain;
|
||||
} else if (eraseMemory->memoryAddress == ADR_HEX_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);
|
||||
|
||||
|
||||
if (env->udsBlock == UDS_BlockBoot) {
|
||||
env->timeoutPendingClear = SystemGetMs() + 200;
|
||||
bool result1 = env->clear_flash_func(ADR_HEX_Mapped_BlockBoot, SIZE_HEX_BlockBoot, SendUpdatePendingFlashClear,
|
||||
env);
|
||||
|
||||
if (result1) {
|
||||
env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
||||
|
||||
return 4 + 1;
|
||||
}
|
||||
}
|
||||
// if (env->udsBlock == UDS_BlockBoot) {
|
||||
// env->timeoutPendingClear = SystemGetMs() + 200;
|
||||
// bool result1 = env->clear_flash_func(ADR_HEX_Mapped_BlockBoot, SIZE_HEX_BlockBoot, SendUpdatePendingFlashClear,
|
||||
// env);
|
||||
// if (result1) {
|
||||
// env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
||||
// return 4 + 1;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (env->udsBlock == UDS_BlockMain) {
|
||||
env->timeoutPendingClear = SystemGetMs() + 200;
|
||||
|
|
@ -1102,18 +1085,38 @@ vUDS_routine_Check_Programming_Dependancies(tCanUds *env, eUdsRoutineControlType
|
|||
|
||||
setResponseErrorPending(env, UDS_RoutineControl, UDS_error_requestCorrectlyReceived_ResponsePending);
|
||||
|
||||
uint32_t crc32_calc = UdsCrc32Update_Hardware(0xFFFFFFFF, (uint8_t *) ADR_HEX_Mapped_BlockBoot,
|
||||
SIZE_HEX_BlockBoot - 4,
|
||||
SendUpdatePendingCrc, env, 200);
|
||||
bool result = P_bInternalFlashPage_CopyRange(ADR_HEX_Mapped_BlockBoot, ADR_HEX_BlockBoot, SIZE_HEX_BlockBoot,
|
||||
NULL, NULL);
|
||||
|
||||
uint32_t crc32_file = (*(uint32_t *) (ADR_HEX_Mapped_BlockBoot + SIZE_HEX_BlockBoot - 4));
|
||||
|
||||
if (crc32_calc != crc32_file) {
|
||||
if (result == false) {
|
||||
env->dataResponse[4] = UDS_routine_RoutineStartStopFailure;
|
||||
|
||||
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);
|
||||
crc32_calc = UdsCrc32Update_Hardware(0xFFFFFFFF, (uint8_t *) ADR_HEX_Mapped_BlockMain, SIZE_HEX_BlockMain - 4,
|
||||
SendUpdatePendingCrc, env, 200);
|
||||
|
|
@ -1148,7 +1151,7 @@ vUDS_routine_Check_Programming_Dependancies(tCanUds *env, eUdsRoutineControlType
|
|||
NumberBank = 0;
|
||||
}
|
||||
|
||||
bool result = D_bInternalFlashPage_Clear(0x04000000, NULL, NULL);
|
||||
result = D_bInternalFlashPage_Clear(0x04000000, NULL, NULL);
|
||||
|
||||
if (result == false) {
|
||||
env->dataResponse[4] = UDS_routine_RoutineStartStopFailure;
|
||||
|
|
@ -1460,9 +1463,9 @@ static uint16_t RequestDownload_34(tCanUds *env) {
|
|||
|
||||
env->udsBlock = UDS_BlockInit;
|
||||
|
||||
if (com->memoryAddress == ADR_HEX_BlockBoot) {
|
||||
env->udsBlock = UDS_BlockBoot;
|
||||
}
|
||||
// if (com->memoryAddress == ADR_HEX_BlockBoot) {
|
||||
// env->udsBlock = UDS_BlockBoot;
|
||||
// }
|
||||
|
||||
if (com->memoryAddress == ADR_HEX_BlockMain) {
|
||||
env->udsBlock = UDS_BlockMain;
|
||||
|
|
@ -1483,12 +1486,11 @@ static uint16_t RequestDownload_34(tCanUds *env) {
|
|||
env->SizeWriteFlash = 0;
|
||||
env->DownloadFirmwareSize = com->memorySize;
|
||||
|
||||
if (env->udsBlock == UDS_BlockBoot) {
|
||||
|
||||
if (com->memorySize > SIZE_HEX_BlockBoot) {
|
||||
return setResponseError(env, UDS_RequestDownload, UDS_error_requestOutOfRange);
|
||||
}
|
||||
}
|
||||
// if (env->udsBlock == UDS_BlockBoot) {
|
||||
// if (com->memorySize > SIZE_HEX_BlockBoot) {
|
||||
// return setResponseError(env, UDS_RequestDownload, UDS_error_requestOutOfRange);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (env->udsBlock == UDS_BlockMain) {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue