esp32: Support building with network and/or bluetooth disabled.

(and a smaller binary size as a result)

Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
Angus Gratton
2025-11-21 16:28:11 +11:00
committed by Damien George
parent 521b2f86be
commit 604cda5d54
3 changed files with 21 additions and 6 deletions

View File

@@ -90,7 +90,8 @@ int vprintf_null(const char *format, va_list ap) {
return 0;
}
time_t platform_mbedtls_time(time_t *timer) {
#if MICROPY_SSL_MBEDTLS
static time_t platform_mbedtls_time(time_t *timer) {
// mbedtls_time requires time in seconds from EPOCH 1970
struct timeval tv;
@@ -98,6 +99,7 @@ time_t platform_mbedtls_time(time_t *timer) {
return tv.tv_sec + TIMEUTILS_SECONDS_1970_TO_2000;
}
#endif
void mp_task(void *pvParameter) {
volatile uint32_t sp = (uint32_t)esp_cpu_get_sp();
@@ -114,8 +116,10 @@ void mp_task(void *pvParameter) {
#endif
machine_init();
#if MICROPY_SSL_MBEDTLS
// Configure time function, for mbedtls certificate time validation.
mbedtls_platform_set_time(platform_mbedtls_time);
#endif
esp_err_t err = esp_event_loop_create_default();
if (err != ESP_OK) {

View File

@@ -55,6 +55,9 @@
#include "lwip/igmp.h"
#include "esp_log.h"
// See note at bottom of file about why this isn't MICROPY_PY_SOCKET
#if MICROPY_PY_NETWORK
#define SOCKET_POLL_US (100000)
#define MDNS_QUERY_TIMEOUT_MS (5000)
#define MDNS_LOCAL_SUFFIX ".local"
@@ -1028,3 +1031,5 @@ const mp_obj_module_t mp_module_socket = {
// this will not conflict with the common implementation provided by
// extmod/mod{lwip,socket}.c.
MP_REGISTER_EXTENSIBLE_MODULE(MP_QSTR_socket, mp_module_socket);
#endif // MICROPY_PY_NETWORK

View File

@@ -92,6 +92,9 @@
#endif
#ifndef MICROPY_PY_BLUETOOTH
#define MICROPY_PY_BLUETOOTH (1)
#endif
#if MICROPY_PY_BLUETOOTH
#define MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS (1)
#define MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS_WITH_INTERLOCK (1)
// Event stack size is the RTOS stack size minus an allowance for the stack used
@@ -102,7 +105,8 @@
#define MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING (1)
#define MICROPY_BLUETOOTH_NIMBLE (1)
#define MICROPY_BLUETOOTH_NIMBLE_BINDINGS_ONLY (1)
#endif
#endif // MICROPY_PY_BLUETOOTH
#define MICROPY_PY_RANDOM_SEED_INIT_FUNC (esp_random())
#define MICROPY_PY_OS_INCLUDEFILE "ports/esp32/modos.c"
#define MICROPY_PY_OS_DUPTERM (1)
@@ -158,7 +162,9 @@
#define MICROPY_PY_MACHINE_UART_IRQ (1)
#define MICROPY_PY_MACHINE_WDT (1)
#define MICROPY_PY_MACHINE_WDT_INCLUDEFILE "ports/esp32/machine_wdt.c"
#ifndef MICROPY_PY_NETWORK
#define MICROPY_PY_NETWORK (1)
#endif
#ifndef MICROPY_PY_NETWORK_HOSTNAME_DEFAULT
#if CONFIG_IDF_TARGET_ESP32
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "mpy-esp32"
@@ -189,10 +195,10 @@
#ifndef MICROPY_HW_ESP_NEW_I2C_DRIVER
#define MICROPY_HW_ESP_NEW_I2C_DRIVER (0)
#endif
#define MICROPY_PY_SSL (1)
#define MICROPY_SSL_MBEDTLS (1)
#define MICROPY_PY_WEBSOCKET (1)
#define MICROPY_PY_WEBREPL (1)
#define MICROPY_PY_SSL (MICROPY_PY_NETWORK)
#define MICROPY_SSL_MBEDTLS (MICROPY_PY_SSL)
#define MICROPY_PY_WEBSOCKET (MICROPY_PY_NETWORK)
#define MICROPY_PY_WEBREPL (MICROPY_PY_NETWORK)
#define MICROPY_PY_ONEWIRE (1)
#define MICROPY_PY_SOCKET_EVENTS (MICROPY_PY_WEBREPL)
#define MICROPY_PY_BLUETOOTH_RANDOM_ADDR (1)