Skip to content

Commit 8b05a2a

Browse files
authored
Merge pull request #3078 from infinnovation/lwip-config
lwip: Allow several configuration macros to be set externally (bis)
2 parents 6d250a9 + b516503 commit 8b05a2a

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

features/FEATURE_LWIP/lwip-interface/lwipopts.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,54 @@
105105

106106
#define LWIP_RAM_HEAP_POINTER lwip_ram_heap
107107

108+
// Number of pool pbufs.
109+
// Each requires 684 bytes of RAM.
110+
#ifndef PBUF_POOL_SIZE
108111
#define PBUF_POOL_SIZE 5
112+
#endif
113+
114+
// One tcp_pcb_listen is needed for each TCPServer.
115+
// Each requires 72 bytes of RAM.
116+
#ifdef MBED_CONF_LWIP_TCP_SERVER_MAX
117+
#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX
118+
#else
109119
#define MEMP_NUM_TCP_PCB_LISTEN 4
120+
#endif
121+
122+
// One is tcp_pcb needed for each TCPSocket.
123+
// Each requires 196 bytes of RAM.
124+
#ifdef MBED_CONF_LWIP_TCP_SOCKET_MAX
125+
#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX
126+
#else
110127
#define MEMP_NUM_TCP_PCB 4
128+
#endif
129+
130+
// One udp_pcb is needed for each UDPSocket.
131+
// Each requires 84 bytes of RAM (total rounded to multiple of 512).
132+
#ifdef MBED_CONF_LWIP_UDP_SOCKET_MAX
133+
#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX
134+
#else
111135
#define MEMP_NUM_UDP_PCB 4
136+
#endif
137+
138+
// Number of non-pool pbufs.
139+
// Each requires 92 bytes of RAM.
140+
#ifndef MEMP_NUM_PBUF
112141
#define MEMP_NUM_PBUF 8
142+
#endif
143+
144+
// Each netbuf requires 64 bytes of RAM.
145+
#ifndef MEMP_NUM_NETBUF
113146
#define MEMP_NUM_NETBUF 8
147+
#endif
148+
149+
// One netconn is needed for each UDPSocket, TCPSocket or TCPServer.
150+
// Each requires 236 bytes of RAM (total rounded to multiple of 512).
151+
#ifdef MBED_CONF_LWIP_SOCKET_MAX
152+
#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX
153+
#else
154+
#define MEMP_NUM_NETCONN 4
155+
#endif
114156

115157
#define TCP_QUEUE_OOSEQ 0
116158
#define TCP_OVERSIZE 0

features/FEATURE_LWIP/lwip-interface/mbed_lib.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616
"addr-timeout": {
1717
"help": "On dual stack system how long to wait preferred stack's address in seconds",
1818
"value": 5
19+
},
20+
"socket-max": {
21+
"help": "Maximum number of open TCPServer, TCPSocket and UDPSocket instances allowed, including one used internally for DNS. Each requires 236 bytes of pre-allocated RAM",
22+
"value": 4
23+
},
24+
"tcp-server-max": {
25+
"help": "Maximum number of open TCPServer instances allowed. Each requires 72 bytes of pre-allocated RAM",
26+
"value": 4
27+
},
28+
"tcp-socket-max": {
29+
"help": "Maximum number of open TCPSocket instances allowed. Each requires 196 bytes of pre-allocated RAM",
30+
"value": 4
31+
},
32+
"udp-socket-max": {
33+
"help": "Maximum number of open UDPSocket instances allowed, including one used internally for DNS. Each requires 84 bytes of pre-allocated RAM",
34+
"value": 4
1935
}
2036
}
2137
}

0 commit comments

Comments
 (0)