feat(ota): OTA功能测试通过,CANFD解包效率优化
- 添加OTA固件升级功能,包括应用程序验证和跳转机制 - 实现CANFD数据传输协议,支持加密和CRC校验 - 优化CAN通信处理,添加调试输出和错误处理 - 更新RTE组件配置,升级csolution版本到2.12.0 - 增加Flash擦除和写入的安全验证机制 - 添加应用程序区域扫描和验证功能 refactor(can): 重构CAN通信模块和OTA数据处理 - 移除未使用的常量定义和辅助函数 - 改进数据解包和加密解密流程 - 添加条件编译调试输出 - 优化Flash操作的安全性和可靠性 chore(build): 更新项目配置和忽略文件 - 添加tmp/和out/目录到.gitignore - 扩展ROM0_SIZE从0x0020000到0x08005000 - 添加bin输出格式支持
This commit is contained in:
+5
-6
@@ -22,9 +22,9 @@ class OTAHandler {
|
||||
|
||||
private:
|
||||
u16 ota_time;
|
||||
bool validateApplication();
|
||||
void eraseApplicationArea();
|
||||
void writeApplicationData(uint32_t offset, uint8_t *data, uint32_t size);
|
||||
bool verifyApplicationData(u32 offset, u8 *data, u32 size);
|
||||
typedef enum {
|
||||
OTA_STATE_IDLE = 0,
|
||||
OTA_STATE_WAITING_RANDOM, // 第二阶段等待随机数
|
||||
@@ -36,17 +36,15 @@ class OTAHandler {
|
||||
typedef enum {
|
||||
OTA_ERROR_NONE = 0,
|
||||
OTA_ERROR_TIMEOUT,
|
||||
OTA_ERROR_FLASH_ERROR,
|
||||
OTA_ERROR_INVALID_KEY,
|
||||
OTA_ERROR_INVALID_PACKET,
|
||||
OTA_ERROR_INVALID_HANDSHAKE,
|
||||
OTA_ERROR_INVALID_CRC,
|
||||
OTA_ERROR_INVALID_SIZE
|
||||
} ota_error_t;
|
||||
// 全局变量(需在安全区域存储)
|
||||
uint8_t K_master[16] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB,
|
||||
0xCD, 0xEF, 0xFE, 0xDC, 0xBA, 0x98,
|
||||
0x76, 0x54, 0x32, 0x10}; // 预置主密钥
|
||||
uint8_t device_uid[12]; // 从GD32 UID寄存器读取
|
||||
|
||||
uint8_t device_uid[12]; // 从GD32 UID寄存器读取
|
||||
uint8_t current_K_session[16];
|
||||
uint8_t nonce_server[16];
|
||||
|
||||
@@ -58,4 +56,5 @@ void getDeviceSerialNumber(uint8_t *buffer);
|
||||
void calculate_crc32_with_key(const uint8_t *key, const uint8_t *data,
|
||||
u8 *output);
|
||||
void send_error_frame(uint8_t error);
|
||||
bool validateApplication();
|
||||
#endif
|
||||
Reference in New Issue
Block a user