fix(vd960DBN): 栈溢出修复闭环 — 打印恢复 + 字符串0终止保险 (2026-08-17)
RAM 瘦身后栈 1.9KB→~4.75KB (END 0x2000f834→0x2000ed3c 实测), printf 峰值安全: - cfig_flash.c: 恢复 load_cfg 3 处调试 PRINT (magic mismatch×2 + Sub_Code) - cfig_flash.c: 字符串 0 终止保险 (remote_addr/client_id/username/password/topic_pub/sub 末字节强制 '\0', 防 Flash 字符串不足定长时 %s 越界打印) - peripheral_main.c: 恢复 output_cfg_from_flash() (调试配置打印) - 注释更新为修复闭环说明 设备实测: 无复位, MQTT 连 159.75.137.141:1883, BLE 广播正常
This commit is contained in:
@@ -245,8 +245,8 @@ void load_cfg_from_flash(void)
|
||||
现场: SPI_Flash_Write(参数区 0x00, 512B) → RST=0x00000000 硬件复位
|
||||
→ magic 写不进 → 无限复位循环。SPI 写触发硬件复位实锤(与快照区无关)。
|
||||
临时方案: 不写 Flash, 用内存默认配置继续 (恢复原逻辑删本块即可) */
|
||||
/* 2026-08-17 栈溢出修复: 调试 PRINT 栈峰值触顶(1.9KB栈), #if 0 */
|
||||
/* PRINT("CFG: magic mismatch - MEMORY DEFAULTS (factory SPI write disabled)\n"); */
|
||||
/* 2026-08-17 栈溢出修复后恢复 (栈~4.75KB) */
|
||||
PRINT("CFG: magic mismatch - MEMORY DEFAULTS (factory SPI write disabled)\n");
|
||||
memset(g_dev_number, 0, 6);
|
||||
memcpy(g_dev_number, gMacAddr, 6);
|
||||
sprintf(g_dev_number_str, "%02X%02X%02X%02X%02X%02X",
|
||||
@@ -290,8 +290,8 @@ void load_cfg_from_flash(void)
|
||||
g_sub_code_enable.dgdus_enable = 0;
|
||||
g_sub_code_enable.wbdus_enable = 0;
|
||||
g_sub_code_enable.radar_enable = 0;
|
||||
/* 2026-08-17 栈溢出修复: #if 0 */
|
||||
/* PRINT("CFG: memory defaults OK (no factory write)\n"); */
|
||||
/* 2026-08-17 栈溢出修复后恢复 */
|
||||
PRINT("CFG: memory defaults OK (no factory write)\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -352,6 +352,16 @@ void load_cfg_from_flash(void)
|
||||
|
||||
|
||||
|
||||
|
||||
/* 2026-08-17: 字符串 0 终止保险 — Flash 中字符串若不足定长且后续 0xFF,
|
||||
%s 打印会越界(历史乱码根因之一)。强制定长缓冲末字节为 '\0' */
|
||||
iot_net_info.remote_addr[63] = '\0';
|
||||
iot_net_info.client_id[63] = '\0';
|
||||
iot_net_info.username[63] = '\0';
|
||||
iot_net_info.password[31] = '\0';
|
||||
g_iot_topic.topic_pub[63] = '\0';
|
||||
g_iot_topic.topic_sub[63] = '\0';
|
||||
|
||||
free(mBuff);
|
||||
|
||||
g_sub_code_enable.net_enable = g_sub_code_enable.code_set & 0x01;
|
||||
@@ -362,8 +372,8 @@ void load_cfg_from_flash(void)
|
||||
g_sub_code_enable.wbdus_enable = (g_sub_code_enable.code_set >> 5) & 0x01;
|
||||
g_sub_code_enable.radar_enable = (g_sub_code_enable.code_set >> 6) & 0x01;
|
||||
|
||||
/* 2026-08-17 栈溢出修复: #if 0 */
|
||||
/* PRINT("\nSub_Code: 0x%04X, net_enable:%d, iot_enable:%d\n", g_sub_code_enable.code_set, g_sub_code_enable.net_enable, g_sub_code_enable.iot_enable); */
|
||||
/* 2026-08-17 栈溢出修复后恢复 */
|
||||
PRINT("\nSub_Code: 0x%04X, net_enable:%d, iot_enable:%d\n", g_sub_code_enable.code_set, g_sub_code_enable.net_enable, g_sub_code_enable.iot_enable);
|
||||
|
||||
// g_sub_code_enable.laser_enable = (g_sub_code_enable.code_set >> 9) & 0x01;
|
||||
// g_sub_code_enable.lora_enable = (g_sub_code_enable.code_set >> 15) & 0x01;
|
||||
|
||||
Reference in New Issue
Block a user