refactor: 确定路径A架构(NO_SYS=0+netconn+多TCP任务),精确化任务设计与内存预算
- FreeRTOSConfig.h: 堆8->10KB, 优先级56->7, 添加lwIP sys_arch宏和任务优先级/栈大小定义 - lwipopts.h: LWIP_SOCKET=0节省RAM, LWIP_TCPIP_CORE_LOCKING=1, MEM_SIZE 8KB, PBUF_POOL 10, MEMP_NUM_NETCONN 8, TCP_SND_BUF/WND 8xMSS, 关闭DHCP/UDP, TCPIP_THREAD_STACKSIZE/PRIO明确指定 - 项目技术实现: 9+1任务架构, netconn阻塞模式每连接独立任务, 零拷贝route_msg_t, 内存精确估算49KB(RCT6超1KB需优化或换RDT6), 模块重写/复用清单 - 项目需求说明: 明确netconn API路线, 添加RDT6备选, 更新任务列表9个任务
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
/**
|
||||
* @file lwipopts.h
|
||||
* @brief LwIP configuration for STM32F103 + FreeRTOS + CH390 Ethernet
|
||||
* @brief LwIP configuration for STM32F103RCT6 + FreeRTOS + CH390 Ethernet
|
||||
*
|
||||
* This configuration is optimized for:
|
||||
* - STM32F103 with limited RAM (~20KB available)
|
||||
* - FreeRTOS integration (NO_SYS=0)
|
||||
* - TCP Server + Client dual link transparent transmission
|
||||
* - CH390 Ethernet controller
|
||||
* Path A: NO_SYS=0, netconn API, multi-task TCP architecture.
|
||||
* Optimized for STM32F103RCT6 (48KB SRAM) with pin-to-pin backup STM32F103RDT6 (64KB SRAM).
|
||||
*
|
||||
* Key design decisions:
|
||||
* - netconn API for thread-safe multi-connection TCP
|
||||
* - tcpip_thread handles all lwIP core operations
|
||||
* - LWIP_TCPIP_CORE_LOCKING=1 allows direct send from application tasks
|
||||
* - Conservative memory footprint: target ~16KB for lwIP
|
||||
*/
|
||||
|
||||
#ifndef LWIP_LWIPOPTS_H
|
||||
@@ -19,11 +22,15 @@
|
||||
/* Use FreeRTOS - this enables the sequential API (netconn, sockets) */
|
||||
#define NO_SYS 0
|
||||
|
||||
/* Enable socket API */
|
||||
#define LWIP_SOCKET 1
|
||||
/* Enable netconn API (primary), disable socket API to save RAM */
|
||||
#define LWIP_SOCKET 0
|
||||
#define LWIP_NETCONN 1
|
||||
#define LWIP_NETIF_API 0
|
||||
|
||||
/* Core locking: allows netconn_write/recv from any task without going through mbox */
|
||||
#define LWIP_TCPIP_CORE_LOCKING 1
|
||||
#define LWIP_TCPIP_CORE_LOCKING_INPUT 0
|
||||
|
||||
/* Critical section protection */
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
|
||||
@@ -35,17 +42,20 @@
|
||||
#define LWIP_PROVIDE_ERRNO 1
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Memory Configuration (optimized for STM32F103 with ~20KB RAM)
|
||||
* Memory Configuration (optimized for STM32F103RCT6 with 48KB SRAM)
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Memory alignment (ARM Cortex-M3 = 4 byte alignment) */
|
||||
#define MEM_ALIGNMENT 4
|
||||
|
||||
/* Heap size for dynamic memory allocation */
|
||||
#define MEM_SIZE (4 * 1024) /* 4KB for LwIP heap */
|
||||
/* Heap size for dynamic memory allocation.
|
||||
* With netconn: larger heap needed for netbuf allocation and connection management.
|
||||
* 8KB provides headroom for 4 concurrent TCP connections. */
|
||||
#define MEM_SIZE (8 * 1024)
|
||||
|
||||
/* Number of pbufs in pool */
|
||||
#define PBUF_POOL_SIZE 8
|
||||
/* Number of pbufs in pool.
|
||||
* 10 pools for 4 concurrent connections with some headroom. */
|
||||
#define PBUF_POOL_SIZE 10
|
||||
|
||||
/* Size of each pbuf in pool (must hold one Ethernet frame) */
|
||||
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS + 40 + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN)
|
||||
@@ -65,19 +75,20 @@
|
||||
/* Number of listening TCP connections */
|
||||
#define MEMP_NUM_TCP_PCB_LISTEN 2
|
||||
|
||||
/* Number of simultaneously queued TCP segments */
|
||||
#define MEMP_NUM_TCP_SEG 17
|
||||
/* Number of simultaneously queued TCP segments
|
||||
* Increased for 4 concurrent connections */
|
||||
#define MEMP_NUM_TCP_SEG 24
|
||||
|
||||
/* Number of simultaneously active timeouts */
|
||||
#define MEMP_NUM_SYS_TIMEOUT 8
|
||||
|
||||
/* Number of netbufs (for sequential API) */
|
||||
#define MEMP_NUM_NETBUF 4
|
||||
/* Number of netbufs (for netconn API, one per pending recv) */
|
||||
#define MEMP_NUM_NETBUF 8
|
||||
|
||||
/* Number of netconns */
|
||||
#define MEMP_NUM_NETCONN 6
|
||||
/* Number of netconns: 2 listeners + 2 accepted + 2 clients + 2 margin = 8 */
|
||||
#define MEMP_NUM_NETCONN 8
|
||||
|
||||
/* TCPIP message queue size */
|
||||
/* TCPIP message queue size (must be >= max simultaneous API calls) */
|
||||
#define MEMP_NUM_TCPIP_MSG_API 8
|
||||
#define MEMP_NUM_TCPIP_MSG_INPKT 8
|
||||
|
||||
@@ -118,15 +129,14 @@
|
||||
* DHCP Configuration
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#define LWIP_DHCP 1
|
||||
#define DHCP_DOES_ARP_CHECK 1
|
||||
#define LWIP_DHCP 0 /* Static IP only */
|
||||
#define DHCP_DOES_ARP_CHECK 0
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* UDP Configuration
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#define LWIP_UDP 1
|
||||
#define UDP_TTL 255
|
||||
#define LWIP_UDP 0 /* UDP not used in this project */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* TCP Configuration (optimized for transparent transmission)
|
||||
@@ -138,14 +148,14 @@
|
||||
/* TCP Maximum Segment Size */
|
||||
#define TCP_MSS 536 /* Conservative value for compatibility */
|
||||
|
||||
/* TCP sender buffer space (bytes) */
|
||||
#define TCP_SND_BUF (4 * TCP_MSS)
|
||||
/* TCP sender buffer space - increased for bridge throughput */
|
||||
#define TCP_SND_BUF (8 * TCP_MSS)
|
||||
|
||||
/* TCP sender buffer space (pbufs) */
|
||||
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS))
|
||||
|
||||
/* TCP receive window */
|
||||
#define TCP_WND (4 * TCP_MSS)
|
||||
/* TCP receive window - increased for bridge throughput */
|
||||
#define TCP_WND (8 * TCP_MSS)
|
||||
|
||||
/* TCP writable space threshold */
|
||||
#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1)
|
||||
@@ -188,8 +198,8 @@
|
||||
* Callback Configuration
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#define LWIP_NETIF_STATUS_CALLBACK 1
|
||||
#define LWIP_NETIF_LINK_CALLBACK 1
|
||||
#define LWIP_NETIF_STATUS_CALLBACK 0
|
||||
#define LWIP_NETIF_LINK_CALLBACK 0
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Checksum Configuration
|
||||
|
||||
Reference in New Issue
Block a user