Обновление платы на V2

This commit is contained in:
cfif 2026-05-27 14:44:50 +03:00
parent fdef801256
commit 8412a5f63b
2 changed files with 298 additions and 247 deletions

View File

@ -948,6 +948,10 @@ static uint16_t vUDS_check_Programming_Preconditions(tCanUds *env, eUdsRoutineCo
return 0xFF00 | UDS_error_sub_functionNotSupported;
}
env->CheckSum_BlockMain = false;
env->CheckSum_BlockCalib = false;
env->CheckSum_BlockMeta = false;
// env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess;
// return 4 + 1;
return 4;
@ -985,8 +989,33 @@ static uint16_t vUDS_routine_Compare_Checksum(tCanUds *env, eUdsRoutineControlTy
if (crc32_calc == crc32_received) {
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 {
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;
}
extern const char version_id[];
static uint16_t
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;
}
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;
}
return 4 + 1;
}
@ -1352,6 +1395,7 @@ static uint16_t RequestDownload_34(tCanUds *env) {
return setResponseError(env, UDS_RequestDownload, UDS_error_requestOutOfRange);
}
env->udsBlock = UDS_BlockInit;
if (com->memoryAddress == ADR_HEX_BlockMain) {
env->udsBlock = UDS_BlockMain;
@ -1365,6 +1409,10 @@ static uint16_t RequestDownload_34(tCanUds *env) {
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->SizeWriteFlash = 0;
env->DownloadFirmwareSize = com->memorySize;

View File

@ -212,6 +212,10 @@ typedef struct {
uint32_t DownloadFirmwareSize;
eUdsBlock udsBlock;
bool CheckSum_BlockMain;
bool CheckSum_BlockCalib;
bool CheckSum_BlockMeta;
uint32_t CurrentBlockAdr;
uint32_t CurrentBlockSize;
@ -230,7 +234,6 @@ typedef struct {
} eUds_com;
void CanUds_Init(
tCanUds *env,
tDiagnostic *Diagnostic,