feat(vd960DBN): Loop MCU 远程 OTA 固件实现 (MQTT V1.08, ROADMAP P1.4 ①)
先存后刷: MQTT 分片下载 → W25Qxx OTA 暂存区 (0x010000 512KB) → 全镜像 CRC32 复核 → 本地 0x9F ISP 透传刷写 Loop MCU (AT32F421) - 新增 ota_srv.c/h: CRC32(ISO-HDLC 逐位零表)/OtaMeta 双备份(节流 4KB flush)/ 会话状态机(begin/data/end/abort/flash)/本地刷写状态机(非阻塞 tick: A5→A6→A7 停等 ACK 1s×3)/安全窗口(有车拒绝 force 跳过)/失败 event_report ota_error - iot_mqtt_srv.c: 6 个 ota_* 命令分发 + 会话静默(event_report 积压/offlog·快照 落盘暂停, 结束补发) + IOT_EVT_OTA_ERROR + iot_any_car - usart_biz.c: uart_srv OTA 分支 ACK 分发 (本地刷写→ota_flash_feed_ack, BLE 透传不变) - peripheral_main.c: ota_init + ota_poll 挂主循环 - offlog: OTA_START 0x60/OTA_RESULT 0x61 审计事件 - tests/test_ota_srv.c: gcc 隔离单测 9 组全过 (mock NOR/UART2/时钟, 嵌入真实实现) 抓到 2 个真 bug: ①A7 序号未递减(bootloader 等不到末包) ②重发时 retry 清零(超时永不失败) - 语法检查: ota_srv/iot_mqtt_srv/usart_biz/offlog 0 新增错误 (基线 interrupt 假阳性除外) - devlog 置顶条目 + 待板上验证清单
This commit is contained in:
@@ -342,6 +342,28 @@ void offlog_coil(uint8_t sub, uint8_t ch, uint32_t value)
|
||||
offlog_evt(OFFLOG_EVT_COIL, p, 6);
|
||||
}
|
||||
|
||||
void offlog_ota_start(uint8_t slot, uint32_t size)
|
||||
{
|
||||
uint8_t p[6];
|
||||
p[0] = slot;
|
||||
p[1] = 0; /* target: 0=loop */
|
||||
p[2] = (uint8_t)(size >> 24);
|
||||
p[3] = (uint8_t)(size >> 16);
|
||||
p[4] = (uint8_t)(size >> 8);
|
||||
p[5] = (uint8_t)size;
|
||||
offlog_evt(OFFLOG_EVT_OTA_START, p, 6);
|
||||
}
|
||||
|
||||
void offlog_ota_result(uint32_t code)
|
||||
{
|
||||
uint8_t p[4];
|
||||
p[0] = (uint8_t)(code >> 24);
|
||||
p[1] = (uint8_t)(code >> 16);
|
||||
p[2] = (uint8_t)(code >> 8);
|
||||
p[3] = (uint8_t)code;
|
||||
offlog_evt(OFFLOG_EVT_OTA_RESULT, p, 4);
|
||||
}
|
||||
|
||||
void offlog_time_anchor(uint32_t unix_ts)
|
||||
{
|
||||
offlog_evt_ts(OFFLOG_EVT_TIME_ANCHOR, NULL, 0, unix_ts); /* 严格用平台下发值 */
|
||||
@@ -398,6 +420,8 @@ const char *offlog_type_str(uint8_t type)
|
||||
case OFFLOG_EVT_EVT_GIVEUP: return "evt_giveup";
|
||||
case OFFLOG_EVT_COIL: return "coil";
|
||||
case OFFLOG_EVT_TIME_ANCHOR: return "time_anchor";
|
||||
case OFFLOG_EVT_OTA_START: return "ota_start";
|
||||
case OFFLOG_EVT_OTA_RESULT: return "ota_result";
|
||||
case OFFLOG_EVT_LOG_CLEAR: return "log_clear";
|
||||
default: return "unknown";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user