From aeef9c690e13f2e8537cc8b8b74a54f721c09fdb Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 13 May 2026 23:52:06 +1000 Subject: [PATCH 1/3] py/mpconfig: Enable select.select at the extra feature level. Instead of unconditionally (ie when the `select` module is enabled). This way, a minimal board can enable the `select` module (eg for asyncio) but still have `select.select()` disabled by default to save size. Signed-off-by: Damien George --- py/mpconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/mpconfig.h b/py/mpconfig.h index 1553c28ae4d32..1574243e8ea99 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1887,7 +1887,7 @@ typedef time_t mp_timestamp_t; // implementation). This is present for compatibility but can be disabled to // save space. #ifndef MICROPY_PY_SELECT_SELECT -#define MICROPY_PY_SELECT_SELECT (1) +#define MICROPY_PY_SELECT_SELECT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide the "time" module From b316ad5fc5c99ea736a2508d23543217ab69487d Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 13 May 2026 23:53:21 +1000 Subject: [PATCH 2/3] nrf: Properly configure asyncio at the makefile level. Prior to this change some of the smaller boards (eg nRF51) would have the .py asyncio code frozen but be missing both the `select` module and the core C-level `_asyncio` module, making `asyncio` useless. This commit lets asyncio be configured at the makefile level, in order to freeze the correct code. Both the `select` and `_asyncio` modules will be enabled if asyncio is enabled. asyncio is now enabled by default on all boards except MICROBIT (which is too small due to the other modules is has). This costs about +2100 bytes on boards that did not already have it enabled, eg PCA10028. Signed-off-by: Damien George --- ports/nrf/Makefile | 7 +++++++ ports/nrf/boards/MICROBIT/mpconfigboard.mk | 2 ++ ports/nrf/boards/manifest_minimal.py | 1 + ports/nrf/mpconfigport.h | 4 ++++ 4 files changed, 14 insertions(+) create mode 100644 ports/nrf/boards/manifest_minimal.py diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index e39bf9639b800..e8a92898c99d0 100644 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -58,7 +58,14 @@ ifeq ($(DEBUG), 0) MICROPY_ROM_TEXT_COMPRESSION ?= 1 endif +# Enable asyncio by default and select appropriate manifest. +MICROPY_PY_ASYNCIO ?= 1 +ifeq ($(MICROPY_PY_ASYNCIO),1) FROZEN_MANIFEST ?= modules/manifest.py +else +FROZEN_MANIFEST ?= boards/manifest_minimal.py +endif +CFLAGS += -DMICROPY_PY_ASYNCIO=$(MICROPY_PY_ASYNCIO) # include py core make definitions include ../../py/py.mk diff --git a/ports/nrf/boards/MICROBIT/mpconfigboard.mk b/ports/nrf/boards/MICROBIT/mpconfigboard.mk index 6c7e1b46b93c3..f44da7aaabe7b 100644 --- a/ports/nrf/boards/MICROBIT/mpconfigboard.mk +++ b/ports/nrf/boards/MICROBIT/mpconfigboard.mk @@ -10,6 +10,8 @@ else MICROPY_VFS_LFS2 = 1 endif +MICROPY_PY_ASYNCIO = 0 + LD_FILES += boards/nrf51x22_256k_16k.ld FLASHER = pyocd diff --git a/ports/nrf/boards/manifest_minimal.py b/ports/nrf/boards/manifest_minimal.py new file mode 100644 index 0000000000000..674e0245271b5 --- /dev/null +++ b/ports/nrf/boards/manifest_minimal.py @@ -0,0 +1 @@ +module("_boot.py", base_path="$(PORT_DIR)/modules/scripts", opt=3) diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index d5cbab7310336..62e56fa1ebf13 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -97,6 +97,10 @@ #define MICROPY_PY_BINASCII (CORE_FEAT) #endif +#ifndef MICROPY_PY_SELECT +#define MICROPY_PY_SELECT (MICROPY_PY_ASYNCIO) +#endif + #ifndef MICROPY_PY_NRF #define MICROPY_PY_NRF (CORE_FEAT) #endif From fc6638be155408dba670d079bc71b01ea609a5ea Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 14 May 2026 11:37:59 +1000 Subject: [PATCH 3/3] nrf: Move manifest.py from modules/ to boards/ directory. To match other ports, and allow the `pyproject.toml` F821 ignore rule to cover it. Signed-off-by: Damien George --- ports/nrf/Makefile | 2 +- ports/nrf/boards/ARDUINO_NANO_33_BLE_SENSE/manifest.py | 2 +- ports/nrf/{modules => boards}/manifest.py | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename ports/nrf/{modules => boards}/manifest.py (100%) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index e8a92898c99d0..40537e50c1424 100644 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -61,7 +61,7 @@ endif # Enable asyncio by default and select appropriate manifest. MICROPY_PY_ASYNCIO ?= 1 ifeq ($(MICROPY_PY_ASYNCIO),1) -FROZEN_MANIFEST ?= modules/manifest.py +FROZEN_MANIFEST ?= boards/manifest.py else FROZEN_MANIFEST ?= boards/manifest_minimal.py endif diff --git a/ports/nrf/boards/ARDUINO_NANO_33_BLE_SENSE/manifest.py b/ports/nrf/boards/ARDUINO_NANO_33_BLE_SENSE/manifest.py index 1e35ae8c4dd34..a196f931b3947 100644 --- a/ports/nrf/boards/ARDUINO_NANO_33_BLE_SENSE/manifest.py +++ b/ports/nrf/boards/ARDUINO_NANO_33_BLE_SENSE/manifest.py @@ -1,4 +1,4 @@ -include("$(PORT_DIR)/modules/manifest.py") +include("$(PORT_DIR)/boards/manifest.py") require("hts221") require("lps22h") require("lsm9ds1") diff --git a/ports/nrf/modules/manifest.py b/ports/nrf/boards/manifest.py similarity index 100% rename from ports/nrf/modules/manifest.py rename to ports/nrf/boards/manifest.py