Skip to content

nrf: Properly configure asyncio at the makefile level.#19219

Open
dpgeorge wants to merge 3 commits into
micropython:masterfrom
dpgeorge:nrf-enable-asyncio
Open

nrf: Properly configure asyncio at the makefile level.#19219
dpgeorge wants to merge 3 commits into
micropython:masterfrom
dpgeorge:nrf-enable-asyncio

Conversation

@dpgeorge
Copy link
Copy Markdown
Member

Summary

Prior to this change some of the smaller boards (eg MICROBIT, most nRF51 boards) would have the .py asyncio code frozen but be missing both the select module and the core C-level _asyncio module, making asyncio unusable.

This PR lets asyncio be configured at the makefile level, in order to freeze the correct code and include the correct modules. 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.

For MICROBIT, this change removes the unusable, partial frozen asyncio code, freeing up 7800 bytes on that board.

Related side change: MICROPY_PY_SELECT_SELECT is now enabled only at the extra feature level, matching the setting for MICROPY_PY_SELECT. That helps keep code size down for boards that want asyncio but don't want the full select module.

Testing

Built all nrf boards. They all build, ie fit in flash.

Ran the test suite on PCA10028, which now includes fully working asyncio. Prior to this fix extmod/asyncio_as_uasyncio.py would fail. Now it passes, along with all other asyncio tests that don't use floats (because this board doesn't have float enabled, those tests are skipped).

Trade-offs and Alternatives

This increases code size for all nRF51 boards (except MICROBIT) by +2100 bytes. But the code still fits and having a working asyncio is very useful.

Alternative would be to fully disable asyncio on nRF51, but IMO it's worth having.

Generative AI

No generative AI tools used when creating this PR.

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 <damien@micropython.org>
dpgeorge added 2 commits May 14, 2026 11:37
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 <damien@micropython.org>
To match other ports, and allow the `pyproject.toml` F821 ignore rule to
cover it.

Signed-off-by: Damien George <damien@micropython.org>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.47%. Comparing base (7d77d3e) to head (fc6638b).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #19219   +/-   ##
=======================================
  Coverage   98.47%   98.47%           
=======================================
  Files         176      176           
  Lines       22845    22845           
=======================================
  Hits        22497    22497           
  Misses        348      348           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dpgeorge dpgeorge force-pushed the nrf-enable-asyncio branch from 5075116 to fc6638b Compare May 14, 2026 01:44
@github-actions
Copy link
Copy Markdown

Code size report:

Reference:  stm32/main: Init network stack before boot.py. [7d77d3e]
Comparison: nrf: Move manifest.py from modules/ to boards/ directory. [merge of fc6638b]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant