diff --git a/features/FEATURE_LWIP/lwip-interface/lwipopts.h b/features/FEATURE_LWIP/lwip-interface/lwipopts.h index ca5afcdd93..54e92eaa05 100644 --- a/features/FEATURE_LWIP/lwip-interface/lwipopts.h +++ b/features/FEATURE_LWIP/lwip-interface/lwipopts.h @@ -105,36 +105,52 @@ #define LWIP_RAM_HEAP_POINTER lwip_ram_heap +// Number of pool pbufs. +// Each requires 684 bytes of RAM. #ifndef PBUF_POOL_SIZE -/// Each requires 684 bytes of RAM. #define PBUF_POOL_SIZE 5 #endif -#ifndef MEMP_NUM_TCP_PCB_LISTEN -/// One is needed for each TCPServer. -/// Each requires 72 bytes of RAM. + +// One tcp_pcb_listen is needed for each TCPServer. +// Each requires 72 bytes of RAM. +#ifdef MBED_CONF_LWIP_TCP_SERVER_MAX +#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX +#else #define MEMP_NUM_TCP_PCB_LISTEN 4 #endif -#ifndef MEMP_NUM_TCP_PCB -/// One is needed for each TCPSocket. -/// Each requires 196 bytes of RAM. + +// One is tcp_pcb needed for each TCPSocket. +// Each requires 196 bytes of RAM. +#ifdef MBED_CONF_LWIP_TCP_SOCKET_MAX +#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX +#else #define MEMP_NUM_TCP_PCB 4 #endif -#ifndef MEMP_NUM_UDP_PCB -/// One is needed for each UDPSocket. -/// Each requires 84 bytes of RAM (rounded to multiple of 512). + +// One udp_pcb is needed for each UDPSocket. +// Each requires 84 bytes of RAM (total rounded to multiple of 512). +#ifdef MBED_CONF_LWIP_UDP_SOCKET_MAX +#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX +#else #define MEMP_NUM_UDP_PCB 4 #endif + +// Number of non-pool pbufs. +// Each requires 92 bytes of RAM. #ifndef MEMP_NUM_PBUF -/// Each requires 92 bytes of RAM. #define MEMP_NUM_PBUF 8 #endif + +// Each netbuf requires 64 bytes of RAM. #ifndef MEMP_NUM_NETBUF -/// Each requires 64 bytes of RAM. #define MEMP_NUM_NETBUF 8 #endif -#ifndef MEMP_NUM_NETCONN -/// One netconn is needed for each UDPSocket, TCPSocket or TCPServer. -/// Each requires 236 bytes of RAM (rounded to multiple of 512). + +// One netconn is needed for each UDPSocket, TCPSocket or TCPServer. +// Each requires 236 bytes of RAM (total rounded to multiple of 512). +#ifdef MBED_CONF_LWIP_SOCKET_MAX +#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX +#else #define MEMP_NUM_NETCONN 4 #endif diff --git a/features/FEATURE_LWIP/lwip-interface/mbed_lib.json b/features/FEATURE_LWIP/lwip-interface/mbed_lib.json index 5cb060e9bf..a594e4e4a0 100644 --- a/features/FEATURE_LWIP/lwip-interface/mbed_lib.json +++ b/features/FEATURE_LWIP/lwip-interface/mbed_lib.json @@ -16,6 +16,22 @@ "addr-timeout": { "help": "On dual stack system how long to wait preferred stack's address in seconds", "value": 5 + }, + "socket-max": { + "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", + "value": 4 + }, + "tcp-server-max": { + "help": "Maximum number of open TCPServer instances allowed. Each requires 72 bytes of pre-allocated RAM", + "value": 4 + }, + "tcp-socket-max": { + "help": "Maximum number of open TCPSocket instances allowed. Each requires 196 bytes of pre-allocated RAM", + "value": 4 + }, + "udp-socket-max": { + "help": "Maximum number of open UDPSocket instances allowed, including one used internally for DNS. Each requires 84 bytes of pre-allocated RAM", + "value": 4 } } }