Обновление
This commit is contained in:
parent
2b458113ac
commit
31badb40c3
|
|
@ -10,6 +10,7 @@
|
|||
#include "LoggerToSerialPort.h"
|
||||
#include "CmsisRtosThreadUtils.h"
|
||||
#include "SystemMutexCmsis.h"
|
||||
#include "VarsTabDumpObserver.h"
|
||||
|
||||
#define LOG_XCP 1
|
||||
|
||||
|
|
@ -106,7 +107,7 @@ typedef struct __attribute__ ((packed)) {
|
|||
uint8_t reserve5: 1;
|
||||
uint8_t reserve6: 1;
|
||||
uint8_t reserve7: 1;
|
||||
uint8_t SLAVE_BLOCK_MODE: 1;
|
||||
uint8_t _SLAVE_BLOCK_MODE: 1;
|
||||
uint8_t OPTIONAL: 1;
|
||||
|
||||
uint8_t MAX_CTO_;
|
||||
|
|
@ -152,7 +153,7 @@ typedef struct __attribute__ ((packed)) {
|
|||
|
||||
uint8_t RESERVED1;
|
||||
|
||||
uint8_t MASTER_BLOCK_MODE: 1;
|
||||
uint8_t _MASTER_BLOCK_MODE: 1;
|
||||
uint8_t INTERLEAVED_MODE: 1;
|
||||
uint8_t RESERVED2: 6;
|
||||
|
||||
|
|
@ -221,6 +222,9 @@ typedef struct __attribute__ ((packed)) {
|
|||
|
||||
#define SECT_SRAM_XCP __attribute__((section (".xcpdata")))
|
||||
|
||||
#define MASTER_BLOCK_MODE 0
|
||||
#define SLAVE_BLOCK_MODE 0
|
||||
|
||||
#define PROGRAM_MASTER_BLOCK_MODE 1
|
||||
#define PROGRAM_MAX_SECTOR 8
|
||||
#define PROGRAM_MAX_BUF 256
|
||||
|
|
@ -465,13 +469,13 @@ typedef struct __attribute__ ((packed)) {
|
|||
eXcpTypeCommand COM;
|
||||
uint8_t RESERVED1;
|
||||
|
||||
uint8_t MASTER_BLOCK_MODE: 1;
|
||||
uint8_t _MASTER_BLOCK_MODE: 1;
|
||||
uint8_t INTERLEAVED_MODE: 1;
|
||||
uint8_t RESERVED2: 1;
|
||||
uint8_t RESERVED3: 1;
|
||||
uint8_t RESERVED4: 1;
|
||||
uint8_t RESERVED5: 1;
|
||||
uint8_t SLAVE_BLOCK_MODE: 1;
|
||||
uint8_t _SLAVE_BLOCK_MODE: 1;
|
||||
uint8_t RESERVED6: 1;
|
||||
|
||||
uint8_t MAX_CTO_PGM;
|
||||
|
|
@ -548,6 +552,14 @@ typedef struct __attribute__ ((packed)) {
|
|||
|
||||
} eXcpCommand_SET_CALIBRATION_PAGE_EB;
|
||||
|
||||
typedef struct __attribute__ ((packed)) {
|
||||
eXcpTypeCommand COM;
|
||||
uint8_t VERIFICATION_MODE;
|
||||
uint16_t VERIFICATION_TYPE;
|
||||
uint32_t VERIFICATION_VALUE;
|
||||
} eXcpCommand_Program_Verify_C8;
|
||||
|
||||
|
||||
typedef bool (xcp_clear_flash_func)(uint32_t firstPageAddr, uint32_t totalSize);
|
||||
typedef bool (xcp_write_flash_func)(uint32_t beginPageAddr, void *sourceRamAddr, uint32_t size);
|
||||
|
||||
|
|
@ -555,8 +567,9 @@ typedef bool (xcp_write_flash_func)(uint32_t beginPageAddr, void *sourceRamAddr,
|
|||
typedef struct {
|
||||
tSerialPortFrameIO *ioCanFrame;
|
||||
tLoggerInterface *logger;
|
||||
tVarsTabDumpObserver *varsTabDumpObserver;
|
||||
|
||||
uint8_t RND;
|
||||
uint8_t RESOURCE;
|
||||
uint8_t ADR_EXT;
|
||||
uint32_t ADR_MTA;
|
||||
|
||||
|
|
@ -619,6 +632,7 @@ void CanSerialPortFrameXcpInit(
|
|||
uint32_t endFlashAdr,
|
||||
xcp_clear_flash_func *clear_flash_func,
|
||||
xcp_write_flash_func *write_flash_func,
|
||||
tVarsTabDumpObserver *varsTabDumpObserver,
|
||||
tLoggerInterface *logger
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -87,10 +87,13 @@ void CanSerialPortFrameXcpInit(
|
|||
uint32_t endFlashAdr,
|
||||
xcp_clear_flash_func *clear_flash_func,
|
||||
xcp_write_flash_func *write_flash_func,
|
||||
tVarsTabDumpObserver *varsTabDumpObserver,
|
||||
tLoggerInterface *logger
|
||||
) {
|
||||
env->DAQ = DAQ;
|
||||
|
||||
env->varsTabDumpObserver = varsTabDumpObserver;
|
||||
|
||||
env->ioCanFrame = ioCanFrame;
|
||||
|
||||
env->rtcIO = rtcIO;
|
||||
|
|
@ -125,7 +128,7 @@ static uint8_t XCP_COMMAND_CONNECT_FF(tCanSerialPortFrameXCP *env) {
|
|||
|
||||
xcpCommand_CONNECT->COM = XCP_COMMAND_CONNECT;
|
||||
|
||||
xcpCommand_CONNECT->CAL_PAG = 0; // Калибровка и пагинация
|
||||
xcpCommand_CONNECT->CAL_PAG = 1; // Калибровка и пагинация
|
||||
xcpCommand_CONNECT->reserve1 = 0;
|
||||
xcpCommand_CONNECT->DAQ = 1; // Поддержка DAQ
|
||||
xcpCommand_CONNECT->STIM = 1; // Стимуляция (формирование инициативных запросов)
|
||||
|
|
@ -140,7 +143,7 @@ static uint8_t XCP_COMMAND_CONNECT_FF(tCanSerialPortFrameXCP *env) {
|
|||
xcpCommand_CONNECT->reserve5 = 0;
|
||||
xcpCommand_CONNECT->reserve6 = 0;
|
||||
xcpCommand_CONNECT->reserve7 = 0;
|
||||
xcpCommand_CONNECT->SLAVE_BLOCK_MODE = 1; // Блочный режим не поддерживается
|
||||
xcpCommand_CONNECT->_SLAVE_BLOCK_MODE = SLAVE_BLOCK_MODE; // Блочный режим не поддерживается
|
||||
xcpCommand_CONNECT->OPTIONAL = 1; // Поддержка команды XCP_COMMAND_GET_STATUS
|
||||
|
||||
xcpCommand_CONNECT->MAX_CTO_ = MAX_CTO;
|
||||
|
|
@ -184,7 +187,7 @@ static uint8_t XCP_COMMAND_GET_STATUS_FD(tCanSerialPortFrameXCP *env) {
|
|||
xcpCommand_GET_STATUS->reserve7 = 0;
|
||||
xcpCommand_GET_STATUS->reserve8 = 0;
|
||||
|
||||
xcpCommand_GET_STATUS->STATE_NUMBER = 0;
|
||||
xcpCommand_GET_STATUS->STATE_NUMBER = 2;
|
||||
|
||||
xcpCommand_GET_STATUS->SESSION_CONFIGURATION_ID = 0;
|
||||
|
||||
|
|
@ -204,7 +207,7 @@ static uint8_t XCP_GET_COMM_MODE_INFO_FB(tCanSerialPortFrameXCP *env) {
|
|||
|
||||
xcpCommand_GET_COMM_MODE_INFO->RESERVED1 = 0;
|
||||
|
||||
xcpCommand_GET_COMM_MODE_INFO->MASTER_BLOCK_MODE = 0;
|
||||
xcpCommand_GET_COMM_MODE_INFO->_MASTER_BLOCK_MODE = MASTER_BLOCK_MODE;
|
||||
xcpCommand_GET_COMM_MODE_INFO->INTERLEAVED_MODE = 0;
|
||||
xcpCommand_GET_COMM_MODE_INFO->RESERVED2 = 0;
|
||||
|
||||
|
|
@ -224,8 +227,7 @@ static uint8_t XCP_GET_SEED_F8(tCanSerialPortFrameXCP *env) {
|
|||
xcpCommand_GET_SEED->COM = XCP_COMMAND_CONNECT;
|
||||
xcpCommand_GET_SEED->LEN = 4;
|
||||
xcpCommand_GET_SEED->KEY = 0x11223344;
|
||||
|
||||
env->RND = request->RESOURCE;
|
||||
env->RESOURCE = request->RESOURCE;
|
||||
|
||||
return 6;
|
||||
}
|
||||
|
|
@ -233,7 +235,7 @@ static uint8_t XCP_GET_SEED_F8(tCanSerialPortFrameXCP *env) {
|
|||
static uint8_t XCP_UNLOCK_F7(tCanSerialPortFrameXCP *env) {
|
||||
eXcpCommand_REQ_UNLOCK *request = (eXcpCommand_REQ_UNLOCK *) env->canFrame.data;
|
||||
|
||||
uint32_t securitySeedMy = SeedToKeyHVAC_NAMI(env->RND, 0x11223344);
|
||||
uint32_t securitySeedMy = SeedToKeyHVAC_NAMI(0, 0x11223344);
|
||||
|
||||
if (securitySeedMy != request->KEY) {
|
||||
env->response[0] = XCP_COMMAND_DISCONNECT;
|
||||
|
|
@ -276,6 +278,9 @@ static uint8_t XCP_COMMAND_UPLOAD_F5(tCanSerialPortFrameXCP *env) {
|
|||
|
||||
env->response[0] = XCP_COMMAND_CONNECT;
|
||||
|
||||
|
||||
if (SLAVE_BLOCK_MODE) {
|
||||
|
||||
if (request->COUNT == 0) {
|
||||
|
||||
#if (LOG_XCP == 1)
|
||||
|
|
@ -318,6 +323,11 @@ static uint8_t XCP_COMMAND_UPLOAD_F5(tCanSerialPortFrameXCP *env) {
|
|||
}
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
memcpy(&env->response[1], (uint8_t *) (env->ADR_MTA), request->COUNT);
|
||||
env->ADR_MTA += request->COUNT;
|
||||
return request->COUNT + 1;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t XCP_COMMAND_SHORT_UPLOAD_F4(tCanSerialPortFrameXCP *env) {
|
||||
|
|
@ -751,13 +761,13 @@ static uint8_t XCP_PROGRAM_START_D2(tCanSerialPortFrameXCP *env) {
|
|||
response->COM = XCP_COMMAND_CONNECT;
|
||||
response->RESERVED1 = 0;
|
||||
|
||||
response->MASTER_BLOCK_MODE = PROGRAM_MASTER_BLOCK_MODE;
|
||||
response->_MASTER_BLOCK_MODE = PROGRAM_MASTER_BLOCK_MODE;
|
||||
response->INTERLEAVED_MODE = 0;
|
||||
response->RESERVED2 = 0;
|
||||
response->RESERVED3 = 0;
|
||||
response->RESERVED4 = 0;
|
||||
response->RESERVED5 = 0;
|
||||
response->SLAVE_BLOCK_MODE = 1;
|
||||
response->_SLAVE_BLOCK_MODE = SLAVE_BLOCK_MODE;
|
||||
response->RESERVED6 = 0;
|
||||
|
||||
response->MAX_CTO_PGM = 8;
|
||||
|
|
@ -820,6 +830,22 @@ static uint8_t XCP_PROGRAM_D0(tCanSerialPortFrameXCP *env) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static uint8_t PROGRAM_VERIFY_C8(tCanSerialPortFrameXCP *env) {
|
||||
eXcpCommand_Program_Verify_C8 *request = (eXcpCommand_Program_Verify_C8 *) env->canFrame.data;
|
||||
|
||||
if (env->bufWriteFlashCount > 0) {
|
||||
bool result = env->write_flash_func(env->bufWriteFlashAdr, env->bufWriteFlash, env->bufWriteFlashCount);
|
||||
env->bufWriteFlashCount = 0;
|
||||
}
|
||||
|
||||
VarsTabDumpObserverCalib_Load(env->varsTabDumpObserver);
|
||||
|
||||
env->response[0] = XCP_COMMAND_CONNECT;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uint8_t XCP_PROGRAM_NEXT_CA(tCanSerialPortFrameXCP *env) {
|
||||
eXcpCommand_Program_ProgramNext_D0_CA *request = (eXcpCommand_Program_ProgramNext_D0_CA *) env->canFrame.data;
|
||||
|
||||
|
|
@ -837,6 +863,7 @@ static uint8_t XCP_PROGRAM_RESET_CF(tCanSerialPortFrameXCP *env) {
|
|||
|
||||
if (env->bufWriteFlashCount > 0) {
|
||||
bool result = env->write_flash_func(env->bufWriteFlashAdr, env->bufWriteFlash, env->bufWriteFlashCount);
|
||||
env->bufWriteFlashCount = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
@ -1110,7 +1137,7 @@ const eXcp_com xcp_com[256] = {
|
|||
{NULL, ""},
|
||||
{NULL, ""},
|
||||
{NULL, ""},
|
||||
{NULL, ""},
|
||||
{PROGRAM_VERIFY_C8, "PROGRAM_VERIFY_C8"},
|
||||
{NULL, ""},
|
||||
{XCP_PROGRAM_NEXT_CA, "XCP_PROGRAM_NEXT_CA"},
|
||||
{NULL, ""},
|
||||
|
|
@ -1185,7 +1212,7 @@ uint8_t vCanSerialPortFrameXcpReceive(tCanSerialPortFrameXCP *env, uint32 timeou
|
|||
if (com > 0xBF) { // CMD
|
||||
|
||||
#if (LOG_XCP == 1)
|
||||
if (com != 0xD0) {
|
||||
if ((com != 0xD0) && (com != 0xF5)) {
|
||||
PrintfDebug(env->canFrame.data, env->canFrame.dlc);
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN, "> %s [%d] %s", xcp_com[com].desc, env->canFrame.dlc, strPrintfDebug)
|
||||
}
|
||||
|
|
@ -1194,10 +1221,10 @@ uint8_t vCanSerialPortFrameXcpReceive(tCanSerialPortFrameXCP *env, uint32 timeou
|
|||
|
||||
response_size = xcp_com[com].func(env);
|
||||
|
||||
if ((response_size) && (env->response[0] != 0xF5)) {
|
||||
if (response_size) {
|
||||
|
||||
#if (LOG_XCP == 1)
|
||||
if (com != 0xD0) {
|
||||
if ((com != 0xD0) && (com != 0xF5)) {
|
||||
PrintfDebug(env->response, response_size);
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN, "< [%d] %s", response_size, strPrintfDebug)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue