perf(vd960DBN): 二轮RAM瘦身 — RECE_BUF_LEN 1024 + ARP 16 + 中断路径static (2026-08-17)
.map 分析: BLE 栈固定占 RAM 低 16KB 不可裁; 用户 48KB 内 .bss 41.7KB。 - net_config.h: RECE_BUF_LEN MSS×2(1400)→1024 (MSS=700帧+头≈740B, 5数组省~2.6KB) - net_config.h: WCHNET_NUM_ARP_TABLE 50→16 (停车场景IP少, 省~0.8KB) - tcp_json_srv.c: tmp_buf[RECE_BUF_LEN]/frame[800] 局部→static (中断上下文栈数组防溢出) 栈 4.7KB→~6.3KB, 中断栈峰值 -1.8KB。devlog 记录 .map 分析结论。
This commit is contained in:
@@ -90,7 +90,10 @@ extern "C" {
|
||||
/* If you want to achieve a higher transmission speed,
|
||||
* try to increase RECE_BUF_LEN to (WCHNET_TCP_MSS*4)
|
||||
* and increase WCHNET_NUM_TCP_SEG to (WCHNET_NUM_TCP*4)*/
|
||||
#define RECE_BUF_LEN (WCHNET_TCP_MSS*2) /* socket receive buffer size */
|
||||
/* 2026-08-17 RAM 瘦身: MSS×2(1400)→1024 — MSS=700 时完整 TCP 段+头≈740B,
|
||||
1024 足够; 5 个 RECE_BUF_LEN 数组 (SocketRecvBuf/MyBuf/tmp/_iot_wchnet_buf/
|
||||
g_json_wchnet_buf) 合计省 ~2.6KB .bss (栈空间 +2.6KB) */
|
||||
#define RECE_BUF_LEN 1024 /* socket receive buffer size */
|
||||
|
||||
#define WCHNET_NUM_PBUF WCHNET_NUM_POOL_BUF /* Number of PBUF structures */
|
||||
|
||||
@@ -98,7 +101,7 @@ extern "C" {
|
||||
|
||||
#define WCHNET_MEM_HEAP_SIZE (((WCHNET_TCP_MSS+0x10+54+8)*WCHNET_NUM_TCP_SEG)+ETH_TX_BUF_SZE+64+2*0x18) /* memory heap size */
|
||||
|
||||
#define WCHNET_NUM_ARP_TABLE 50 /* Number of ARP lists */
|
||||
#define WCHNET_NUM_ARP_TABLE 16 /* 2026-08-17: 50→16 (停车设备同时连接 IP 少, 省 ~0.8KB .bss) */
|
||||
|
||||
#define WCHNET_MEM_ALIGNMENT 4 /* 4 byte alignment */
|
||||
|
||||
|
||||
@@ -1003,13 +1003,13 @@ void tcp_json_handle_sock_int(uint8_t socketid, uint8_t intstat) {
|
||||
uint16_t space = TCP_JSON_RECV_BUF_LEN - g_json_recv_len;
|
||||
if (recv_len > space) recv_len = space;
|
||||
uint32_t rd_len = recv_len;
|
||||
uint8_t tmp_buf[RECE_BUF_LEN];
|
||||
static uint8_t tmp_buf[RECE_BUF_LEN]; /* 2026-08-17: static — 中断上下文 1KB 栈数组 (防溢出) */
|
||||
WCHNET_SocketRecv(socketid, tmp_buf, &rd_len);
|
||||
g_json_last_comm_ts = mstick(); // 有数据交互
|
||||
memcpy(g_json_recv_buf + g_json_recv_len, tmp_buf, (uint16_t)rd_len);
|
||||
g_json_recv_len += (uint16_t)rd_len;
|
||||
|
||||
char frame[TCP_JSON_MAX_FRAME];
|
||||
static char frame[TCP_JSON_MAX_FRAME]; /* 2026-08-17: static — 中断上下文 800B 栈数组 (防溢出) */
|
||||
while (json_extract_frame(g_json_recv_buf, &g_json_recv_len, frame, sizeof(frame))) {
|
||||
PRINT("JSON recv: %s\n", frame);
|
||||
json_process_frame(socketid, frame);
|
||||
|
||||
Reference in New Issue
Block a user