From f5b52d5bdeb27848d71daf581e3a46e67d47aaea Mon Sep 17 00:00:00 2001 From: wangfq Date: Wed, 12 Aug 2026 18:42:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(vd960DBN):=20=E5=90=AF=E5=8A=A8=E8=AF=8A?= =?UTF-8?q?=E6=96=AD=E6=89=93=E5=8D=B0=20+=20snap=5Fflush=20=E6=97=A0?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E6=8C=82=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 现场: 懒擦后仍起不来 (200ms 乱码后死机), 需定位复位/卡死点 - main 开头打印 RST_REASON (RCC_RSTSCKR): 一锤定音区分 IWDG死锁(bit31) / POR掉电(bit25) / NRST外部复位(bit26) / 软复位(bit24) - 各 init 步骤加标记 (storage/offlog/snap ok), 定位卡死位置 - snap_flush 从 iot_enable 分支移到 Main_Circulation 无条件调用: 原实现 TCP 模式(iot_enable=0)下快照永不落盘, RAM 暂存满丢新 --- vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/iot_mqtt_srv.c | 4 ---- .../BLE/OnlyUpdateApp_Peripheral/APP/peripheral_main.c | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/iot_mqtt_srv.c b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/iot_mqtt_srv.c index dabf066..3836733 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/iot_mqtt_srv.c +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/iot_mqtt_srv.c @@ -776,10 +776,6 @@ void iot_mqtt_publish_sensor(void) { } } - /* 快照落盘: 主循环上下文 (Step1 直读帧 + 回调帧都已在 ingest 入队); - 放在 READY/enable 检查之前 → 断网/未使能期间照常落 (脱机取证语义) */ - snap_flush(); - /*--- 事件上报状态机: 发送/重发/重连补报 ---*/ iot_evt_process(); diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/peripheral_main.c b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/peripheral_main.c index 3be6451..2a8135c 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/peripheral_main.c +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/peripheral_main.c @@ -268,6 +268,7 @@ void Main_Circulation(void) } uart_srv(); + snap_flush(); /* 快照落盘: 无条件挂主循环 (原在 iot_enable 分支, TCP 模式不落盘) */ poll_dbn_ble(); @@ -300,12 +301,18 @@ int main(void) // USART_Printf_Init( 115200 ); USART_Printf_Init( 256000 ); #endif + /* 诊断: 复位原因寄存器 (bit31=IWDG bit30=WWDG bit29=LPWR bit26=NRST bit25=POR bit24=软复位) + 每次上电必打, 区分看门狗死锁 vs 掉电 vs 外部复位 */ + PRINT("RST_REASON: 0x%08lx\n", (unsigned long)OFFLOG_RCC_RSTSCKR); PRINT("%s\n", VER_LIB); PRINT("SystemCoreClock:%d\n", SystemCoreClock); GetMacAddr(gMacAddr); storage_init(); + PRINT("INIT: storage ok\n"); offlog_init(); + PRINT("INIT: offlog ok\n"); snap_init(); + PRINT("INIT: snap ok\n"); /* 复位原因: 必须在初始化后立即读 (离复位时刻最近), 并清除标志, 保证下次上电只反映本次复位原因 (RCC_RSTSCKR, STM32F1/CH32V20x 兼容) */