Обновление
This commit is contained in:
parent
ad06832d60
commit
ffea4d3d23
42
CanUds.c
42
CanUds.c
|
|
@ -234,6 +234,8 @@ void SendUpdatePendingFlashClear(void *env) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setDefaultSecurityAccess(tCanUds *env) {
|
static void setDefaultSecurityAccess(tCanUds *env) {
|
||||||
|
env->udsFirmwareStepsMain = UDS_Firmware_Step_None;
|
||||||
|
env->udsFirmwareStepsCalib = UDS_Firmware_Step_None;
|
||||||
env->SA.requestSequenceRequestSeed = false;
|
env->SA.requestSequenceRequestSeed = false;
|
||||||
env->SA.stateSecurityAccess = false;
|
env->SA.stateSecurityAccess = false;
|
||||||
env->SA.counter_max_attempts_default = 0;
|
env->SA.counter_max_attempts_default = 0;
|
||||||
|
|
@ -949,6 +951,9 @@ static uint16_t vUDS_check_Programming_Preconditions(tCanUds *env, eUdsRoutineCo
|
||||||
return 0xFF00 | UDS_error_sub_functionNotSupported;
|
return 0xFF00 | UDS_error_sub_functionNotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
env->udsFirmwareStepsMain = UDS_Firmware_Step_Preconditions;
|
||||||
|
env->udsFirmwareStepsCalib = UDS_Firmware_Step_Preconditions;
|
||||||
|
|
||||||
// env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
// env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
||||||
// return 4 + 1;
|
// return 4 + 1;
|
||||||
return 4;
|
return 4;
|
||||||
|
|
@ -1006,8 +1011,12 @@ static uint16_t vUDS_routine_Erase_Memory(tCanUds *env, eUdsRoutineControlType u
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env->data->len < 13) {
|
if (env->data->len < 13) {
|
||||||
return setResponseError(env, UDS_Communication_Control,
|
return 0xFF00 | UDS_error_incorrectMessageLengthOrInvalidFormat;
|
||||||
UDS_error_incorrectMessageLengthOrInvalidFormat);
|
}
|
||||||
|
|
||||||
|
if ((env->udsFirmwareStepsMain != UDS_Firmware_Step_Preconditions) ||
|
||||||
|
((env->udsFirmwareStepsCalib != UDS_Firmware_Step_Preconditions))) {
|
||||||
|
return 0xFF00 | UDS_error_conditionsNotCorrect;
|
||||||
}
|
}
|
||||||
|
|
||||||
tEraseMemory *eraseMemory = (tEraseMemory *) env->data->data;
|
tEraseMemory *eraseMemory = (tEraseMemory *) env->data->data;
|
||||||
|
|
@ -1021,7 +1030,9 @@ static uint16_t vUDS_routine_Erase_Memory(tCanUds *env, eUdsRoutineControlType u
|
||||||
|
|
||||||
if (eraseMemory->memoryAddress == ADR_HEX_BlockMain) {
|
if (eraseMemory->memoryAddress == ADR_HEX_BlockMain) {
|
||||||
env->udsBlock = UDS_BlockMain;
|
env->udsBlock = UDS_BlockMain;
|
||||||
} else if (eraseMemory->memoryAddress == ADR_HEX_BlockCalib) {
|
}
|
||||||
|
|
||||||
|
if (eraseMemory->memoryAddress == ADR_HEX_BlockCalib) {
|
||||||
env->udsBlock = UDS_BlockCalib;
|
env->udsBlock = UDS_BlockCalib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1053,6 +1064,8 @@ static uint16_t vUDS_routine_Erase_Memory(tCanUds *env, eUdsRoutineControlType u
|
||||||
if ((result1) && (result2)) {
|
if ((result1) && (result2)) {
|
||||||
env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
||||||
|
|
||||||
|
env->udsFirmwareStepsMain = UDS_Firmware_Step_EraseMemory;
|
||||||
|
|
||||||
return 4 + 1;
|
return 4 + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1066,6 +1079,8 @@ static uint16_t vUDS_routine_Erase_Memory(tCanUds *env, eUdsRoutineControlType u
|
||||||
if (result1) {
|
if (result1) {
|
||||||
env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
||||||
|
|
||||||
|
env->udsFirmwareStepsCalib = UDS_Firmware_Step_EraseMemory;
|
||||||
|
|
||||||
return 4 + 1;
|
return 4 + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1083,10 +1098,15 @@ vUDS_routine_Check_Programming_Dependancies(tCanUds *env, eUdsRoutineControlType
|
||||||
return 0xFF00 | UDS_error_sub_functionNotSupported;
|
return 0xFF00 | UDS_error_sub_functionNotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((env->udsFirmwareStepsMain != UDS_Firmware_Step_EraseMemory) ||
|
||||||
|
((env->udsFirmwareStepsCalib != UDS_Firmware_Step_EraseMemory))) {
|
||||||
|
return 0xFF00 | UDS_error_conditionsNotCorrect;
|
||||||
|
}
|
||||||
|
|
||||||
setResponseErrorPending(env, UDS_RoutineControl, UDS_error_requestCorrectlyReceived_ResponsePending);
|
setResponseErrorPending(env, UDS_RoutineControl, UDS_error_requestCorrectlyReceived_ResponsePending);
|
||||||
|
|
||||||
bool result = P_bInternalFlashPage_CopyRange(ADR_HEX_Mapped_BlockBoot, ADR_HEX_BlockBoot, SIZE_HEX_BlockBoot,
|
bool result = P_bInternalFlashPage_CopyRange(ADR_HEX_Mapped_BlockBoot, ADR_HEX_BlockBoot, SIZE_HEX_BlockBoot,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
if (result == false) {
|
if (result == false) {
|
||||||
env->dataResponse[4] = UDS_routine_RoutineStartStopFailure;
|
env->dataResponse[4] = UDS_routine_RoutineStartStopFailure;
|
||||||
|
|
@ -1114,14 +1134,14 @@ vUDS_routine_Check_Programming_Dependancies(tCanUds *env, eUdsRoutineControlType
|
||||||
// return 4 + 1;
|
// 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,
|
uint32_t crc32_calc = UdsCrc32Update_Hardware(0xFFFFFFFF, (uint8_t *) ADR_HEX_Mapped_BlockMain,
|
||||||
SendUpdatePendingCrc, env, 200);
|
SIZE_HEX_BlockMain - 4,
|
||||||
|
SendUpdatePendingCrc, env, 200);
|
||||||
|
|
||||||
crc32_file = (*(uint32_t *) (ADR_HEX_Mapped_BlockMain + SIZE_HEX_BlockMain - 4));
|
uint32_t crc32_file = (*(uint32_t *) (ADR_HEX_Mapped_BlockMain + SIZE_HEX_BlockMain - 4));
|
||||||
|
|
||||||
if (crc32_calc != crc32_file) {
|
if (crc32_calc != crc32_file) {
|
||||||
env->dataResponse[4] = UDS_routine_RoutineStartStopFailure;
|
env->dataResponse[4] = UDS_routine_RoutineStartStopFailure;
|
||||||
|
|
@ -1167,6 +1187,10 @@ vUDS_routine_Check_Programming_Dependancies(tCanUds *env, eUdsRoutineControlType
|
||||||
return 4 + 1;
|
return 4 + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
env->udsFirmwareStepsMain = UDS_Firmware_Step_Dependancies;
|
||||||
|
env->udsFirmwareStepsCalib = UDS_Firmware_Step_Dependancies;
|
||||||
|
|
||||||
env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
||||||
|
|
||||||
return 4 + 1;
|
return 4 + 1;
|
||||||
|
|
|
||||||
11
CanUds.h
11
CanUds.h
|
|
@ -35,6 +35,15 @@
|
||||||
|
|
||||||
#define LEN_DEBUG_UDS_BUFF 128
|
#define LEN_DEBUG_UDS_BUFF 128
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
UDS_Firmware_Step_None = 0,
|
||||||
|
UDS_Firmware_Step_Preconditions = 1,
|
||||||
|
UDS_Firmware_Step_EraseMemory = 2,
|
||||||
|
UDS_Firmware_Step_Dependancies = 3
|
||||||
|
|
||||||
|
} eUdsFirmwareSteps;
|
||||||
|
|
||||||
// Время (логарифмическая шкала)
|
// Время (логарифмическая шкала)
|
||||||
// │
|
// │
|
||||||
// ├── StMin (0.1-127 мс) ← Между КАДРАМИ
|
// ├── StMin (0.1-127 мс) ← Между КАДРАМИ
|
||||||
|
|
@ -213,6 +222,8 @@ typedef struct {
|
||||||
uint32_t DownloadFirmwareSize;
|
uint32_t DownloadFirmwareSize;
|
||||||
eUdsBlock udsBlock;
|
eUdsBlock udsBlock;
|
||||||
|
|
||||||
|
eUdsFirmwareSteps udsFirmwareStepsMain;
|
||||||
|
eUdsFirmwareSteps udsFirmwareStepsCalib;
|
||||||
|
|
||||||
uint32_t CurrentBlockAdr;
|
uint32_t CurrentBlockAdr;
|
||||||
uint32_t CurrentBlockSize;
|
uint32_t CurrentBlockSize;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue