From 34097b776e00e81bcf2fdd3a2b13472a6085dee9 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Sat, 10 Feb 2024 14:59:26 -0800 Subject: [PATCH] esp32/network_ppp: Make PPP support optional. PPP is not that commonly used, let it be turned off in the board config to save space. It is still on by default. On an basic ESP32-S3 build, turning off PPP with LWIP still on saves ~35 kB of codend 4 kB of data. text data bss dec hex filename 1321257 304296 2941433 4566986 45afca before-ppp-off.elf 1285101 299920 2810305 4395326 43113e after-ppp-off.elf ------------------------------- -36156 -4376 -56 Note that the BSS segment size includes all NOBITS sections in ELF file. Some of these are aligned to 64kB chunk sized dummy blocks, I think for alignment to MMU boundaries, and these went down by 1 block each, so 128 kiB of BSS is not really part of the binary size reduction. Signed-off-by: Trent Piepho --- ports/esp32/modnetwork_globals.h | 2 ++ ports/esp32/network_ppp.c | 4 ++++ ports/esp32/ppp_set_auth.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ports/esp32/modnetwork_globals.h b/ports/esp32/modnetwork_globals.h index c6369ab9a7..56e5341915 100644 --- a/ports/esp32/modnetwork_globals.h +++ b/ports/esp32/modnetwork_globals.h @@ -7,7 +7,9 @@ #if MICROPY_PY_NETWORK_LAN { MP_ROM_QSTR(MP_QSTR_LAN), MP_ROM_PTR(&esp_network_get_lan_obj) }, #endif +#if defined(CONFIG_ESP_NETIF_TCPIP_LWIP) && defined(CONFIG_LWIP_PPP_SUPPORT) { MP_ROM_QSTR(MP_QSTR_PPP), MP_ROM_PTR(&esp_network_ppp_make_new_obj) }, +#endif { MP_ROM_QSTR(MP_QSTR_phy_mode), MP_ROM_PTR(&esp_network_phy_mode_obj) }, #if MICROPY_PY_NETWORK_WLAN diff --git a/ports/esp32/network_ppp.c b/ports/esp32/network_ppp.c index 0d8046c97d..08443752cc 100644 --- a/ports/esp32/network_ppp.c +++ b/ports/esp32/network_ppp.c @@ -43,6 +43,8 @@ #include "lwip/dns.h" #include "netif/ppp/pppapi.h" +#if defined(CONFIG_ESP_NETIF_TCPIP_LWIP) && defined(CONFIG_LWIP_PPP_SUPPORT) + #define PPP_CLOSE_TIMEOUT_MS (4000) typedef struct _ppp_if_obj_t { @@ -341,3 +343,5 @@ MP_DEFINE_CONST_OBJ_TYPE( MP_TYPE_FLAG_NONE, locals_dict, &ppp_if_locals_dict ); + +#endif diff --git a/ports/esp32/ppp_set_auth.c b/ports/esp32/ppp_set_auth.c index 88ab668d48..dc2a3dcd78 100644 --- a/ports/esp32/ppp_set_auth.c +++ b/ports/esp32/ppp_set_auth.c @@ -9,7 +9,7 @@ #include "ppp_set_auth.h" -#ifdef CONFIG_ESP_NETIF_TCPIP_LWIP +#if defined(CONFIG_ESP_NETIF_TCPIP_LWIP) && defined(CONFIG_LWIP_PPP_SUPPORT) #include "netif/ppp/pppapi.h"