Обновление платы на V2
This commit is contained in:
parent
fdef801256
commit
8412a5f63b
48
CanUds.c
48
CanUds.c
|
|
@ -948,6 +948,10 @@ static uint16_t vUDS_check_Programming_Preconditions(tCanUds *env, eUdsRoutineCo
|
||||||
return 0xFF00 | UDS_error_sub_functionNotSupported;
|
return 0xFF00 | UDS_error_sub_functionNotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
env->CheckSum_BlockMain = false;
|
||||||
|
env->CheckSum_BlockCalib = false;
|
||||||
|
env->CheckSum_BlockMeta = false;
|
||||||
|
|
||||||
// env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
// env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
||||||
// return 4 + 1;
|
// return 4 + 1;
|
||||||
return 4;
|
return 4;
|
||||||
|
|
@ -985,8 +989,33 @@ static uint16_t vUDS_routine_Compare_Checksum(tCanUds *env, eUdsRoutineControlTy
|
||||||
|
|
||||||
if (crc32_calc == crc32_received) {
|
if (crc32_calc == crc32_received) {
|
||||||
env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
||||||
|
|
||||||
|
if (env->udsBlock == UDS_BlockMain) {
|
||||||
|
env->CheckSum_BlockMain = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (env->udsBlock == UDS_BlockCalib) {
|
||||||
|
env->CheckSum_BlockCalib = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (env->udsBlock == UDS_BlockMeta) {
|
||||||
|
env->CheckSum_BlockMeta = true;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
env->dataResponse[4] = UDS_routine_RoutineStartStopFailure;
|
env->dataResponse[4] = UDS_routine_RoutineStartStopFailure;
|
||||||
|
|
||||||
|
if (env->udsBlock == UDS_BlockMain) {
|
||||||
|
env->CheckSum_BlockMain = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (env->udsBlock == UDS_BlockCalib) {
|
||||||
|
env->CheckSum_BlockCalib = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (env->udsBlock == UDS_BlockMeta) {
|
||||||
|
env->CheckSum_BlockMeta = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1052,6 +1081,8 @@ static uint16_t vUDS_routine_Erase_Memory(tCanUds *env, eUdsRoutineControlType u
|
||||||
return 4 + 1;
|
return 4 + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern const char version_id[];
|
||||||
|
|
||||||
static uint16_t
|
static uint16_t
|
||||||
vUDS_routine_Check_Programming_Dependancies(tCanUds *env, eUdsRoutineControlType udsRoutineControlType) {
|
vUDS_routine_Check_Programming_Dependancies(tCanUds *env, eUdsRoutineControlType udsRoutineControlType) {
|
||||||
|
|
||||||
|
|
@ -1059,7 +1090,19 @@ vUDS_routine_Check_Programming_Dependancies(tCanUds *env, eUdsRoutineControlType
|
||||||
return 0xFF00 | UDS_error_sub_functionNotSupported;
|
return 0xFF00 | UDS_error_sub_functionNotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *version_id_main = (char *) (ADR_HEX_BlockMain + 0x400);
|
||||||
|
int result = memcmp(version_id_main, version_id, 9);
|
||||||
|
|
||||||
|
|
||||||
|
if ((env->CheckSum_BlockMain == false) || (env->CheckSum_BlockCalib) || (env->CheckSum_BlockMeta == false)) {
|
||||||
|
LoggerErrorStatic(LOGGER, LOG_SIGN, "At least one logical block missing");
|
||||||
|
env->dataResponse[4] = 4;
|
||||||
|
} else if (result != 0) {
|
||||||
|
LoggerErrorStatic(LOGGER, LOG_SIGN, "Software incompatibility");
|
||||||
|
env->dataResponse[4] = 3;
|
||||||
|
} else {
|
||||||
env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
return 4 + 1;
|
return 4 + 1;
|
||||||
}
|
}
|
||||||
|
|
@ -1352,6 +1395,7 @@ static uint16_t RequestDownload_34(tCanUds *env) {
|
||||||
return setResponseError(env, UDS_RequestDownload, UDS_error_requestOutOfRange);
|
return setResponseError(env, UDS_RequestDownload, UDS_error_requestOutOfRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
env->udsBlock = UDS_BlockInit;
|
||||||
|
|
||||||
if (com->memoryAddress == ADR_HEX_BlockMain) {
|
if (com->memoryAddress == ADR_HEX_BlockMain) {
|
||||||
env->udsBlock = UDS_BlockMain;
|
env->udsBlock = UDS_BlockMain;
|
||||||
|
|
@ -1365,6 +1409,10 @@ static uint16_t RequestDownload_34(tCanUds *env) {
|
||||||
env->udsBlock = UDS_BlockMeta;
|
env->udsBlock = UDS_BlockMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (env->udsBlock == UDS_BlockInit) {
|
||||||
|
return setResponseError(env, UDS_RequestDownload, UDS_error_requestSequenceError);
|
||||||
|
}
|
||||||
|
|
||||||
env->AdrFlash = com->memoryAddress + 0x00100000 - (128 * 1024);
|
env->AdrFlash = com->memoryAddress + 0x00100000 - (128 * 1024);
|
||||||
env->SizeWriteFlash = 0;
|
env->SizeWriteFlash = 0;
|
||||||
env->DownloadFirmwareSize = com->memorySize;
|
env->DownloadFirmwareSize = com->memorySize;
|
||||||
|
|
|
||||||
5
CanUds.h
5
CanUds.h
|
|
@ -212,6 +212,10 @@ typedef struct {
|
||||||
uint32_t DownloadFirmwareSize;
|
uint32_t DownloadFirmwareSize;
|
||||||
eUdsBlock udsBlock;
|
eUdsBlock udsBlock;
|
||||||
|
|
||||||
|
bool CheckSum_BlockMain;
|
||||||
|
bool CheckSum_BlockCalib;
|
||||||
|
bool CheckSum_BlockMeta;
|
||||||
|
|
||||||
uint32_t CurrentBlockAdr;
|
uint32_t CurrentBlockAdr;
|
||||||
uint32_t CurrentBlockSize;
|
uint32_t CurrentBlockSize;
|
||||||
|
|
||||||
|
|
@ -230,7 +234,6 @@ typedef struct {
|
||||||
} eUds_com;
|
} eUds_com;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CanUds_Init(
|
void CanUds_Init(
|
||||||
tCanUds *env,
|
tCanUds *env,
|
||||||
tDiagnostic *Diagnostic,
|
tDiagnostic *Diagnostic,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue