Skip to content

DO NOT MERGE: Wifi ap debug - #3

Open
tyeth wants to merge 1427 commits into
mainfrom
wifi-ap-debug
Open

DO NOT MERGE: Wifi ap debug#3
tyeth wants to merge 1427 commits into
mainfrom
wifi-ap-debug

Conversation

@tyeth

@tyeth tyeth commented Sep 2, 2026

Copy link
Copy Markdown
Owner

dpgeorge and others added 30 commits February 5, 2026 10:42
This is an internal helper function that assumes the argument is of type
`mp_obj_fun_bc_t`, so has a better home in `py/objfun.h`.

Signed-off-by: Damien George <damien@micropython.org>
And change the argument to `const mp_obj_fun_bc_t *`.  This makes it clear
that it requires that specific type, rather than a general `mp_obj_t`.

Signed-off-by: Damien George <damien@micropython.org>
These helper functions assume their argument is of type `mp_obj_list_t` so
they have a better home in `py/objlist.h`.

Signed-off-by: Damien George <damien@micropython.org>
This can be done now these functions are declared in `py/objlist.h`, where
the `mp_obj_list_t` struct is defined.

This changes code size by -24 bytes on bare-arm, and by -56 bytes on stm32.

Signed-off-by: Damien George <damien@micropython.org>
These helper functions assume their argument is of type `mp_obj_tuple_t` so
they have a better home in `py/objtuple.h`.

Also remove `mp_obj_tuple_hash()` because it doesn't have a corresponding
function defined anywhere (nor is it ever used).

Signed-off-by: Damien George <damien@micropython.org>
This can be done now that it's declared in `py/objtuple.h`, where the
`mp_obj_tuple` struct is defined.

This allows much better code generation for users of `mp_obj_tuple_get()`
where the caller uses len/items immediately (which is most uses), because
the compiler no longer needs to allocate the return values on the stack.

Changes code size by -36 bytes on bare-arm and -56 bytes on stm32.

Signed-off-by: Damien George <damien@micropython.org>
This commit refactors handling of opcodes whose composition can be easily
defined as an entry in a table, so there's only one bit of code handling
those opcodes rather than several small bits with overlapping
functionalities.

Two opcodes, RER and WER have been added to that table for completeness,
although they're gated behind the uncommon opcodes configuration define.
Still, despite two new opcodes, the final binary is smaller by about 160
bytes.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
As per the implementation of m_malloc0, if
MICROPY_GC_CONSERVATIVE_CLEAR is set then all RAM is guaranteed to be
zero-init by gc_alloc.

py/objarray.c: Guard the explicit zero init in bytearray_make_new
against being run, initialising the RAM to zero a second time, if this
flag is set.

Note that MICROPY_GC_CONSERVATIVE_CLEAR is default enabled by
MICROPY_ENABLE_GC, and no ports currently override this value.

Co-authored-by: Mike Bell <mdb036@gmail.com>
Signed-off-by: Phil Howard <github@gadgetoid.com>
As per the implementation of m_malloc0, if
MICROPY_GC_CONSERVATIVE_CLEAR is set then all RAM is guaranteed to be
zero-init by gc_alloc.

py/objstr.c: Guard the explicit zero init in bytes_make_new
against being run, initialising the RAM to zero a second time, if this
flag is set.

Signed-off-by: Phil Howard <github@gadgetoid.com>
This is a follow up to 6436f8b that
catches more cases of a failed raw REPL.

If the target device is broken in a certain way then it can have a serial
write error instead of just not returning any data.  In that case the error
raised by `pyboard.py` is "could not enter raw repl: Write timeout", which
is slightly different to "could not enter raw repl" (the latter is raised
when a serial read fails to return the correct data).

The patch here accounts for all cases of a failed raw REPL by using
`str.startswith()` instead of a string equality.

This can be tested on RPI_PICO_W and RPI_PICO2_W which currently crash in
the specific way needed to trigger the write timeout when running the
`tests/extmod/socket_badconstructor.py` test.  In particular adding the
following code to the end of a test (eg `tests/extmod/random_extra.py`)
will trigger the issue:

    import socket
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_RAW, None)
    except TypeError:
        pass

With the fix here, the `run-tests.py` and `run-natmodtests.py` will abort
early if that code is added (prior to the fix they would continue to run
all tests and take a long time).

Signed-off-by: Damien George <damien@micropython.org>
This commit adds support for the LDO driver for ESP32-P4 SOCs.

Signed-off-by: Artem Makarov <gh@artemy.nl>
The esp32 port (and esp8266) doesn't read from dupterm in
`mp_hal_stdin_rx_chr()` is because it uses `os.dupterm_notify()` instead,
which forces a read of the dupterm sources from Python.  That function
should be called when it's known that there is input to read.

Nevertheless, this commit adds code to explicitly poll dupterm in
`mp_hal_stdin_rx_chr()`, following other ports like rp2.

Signed-off-by: Matthias Urlichs <matthias@urlichs.de>
ESP-IDF v5.5.x requires min 3.16

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
As we add the object files to the linker command line directly,
they go after the other library dependencies and therefore don't
resolve their dependencies. Turns out the only dependent symbol of
the btree library is abort_, so explicitly include it in the link.

The old way of linking the entire library is cleaner, but stopped working
with ESP-IDF V5.5...

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
This argument isn't expected to be passed from Python code, but - as
pointed out - it doesn't make sense how the irq() mechanism works
otherwise.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
Following commits adbdded and
0c7726a.

Signed-off-by: Damien George <damien@micropython.org>
An ioctl should not have any side effects if the request is unknown.

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
Both mbedTLS and axTLS have support for producing more detailed error
strings.  However, these are not used if the error is raised in stream
protocol functions (read/write/ioctl).

This commit adds support for more detailed error messages from streams.
Under the hood it's using a new MP_STREAM_RAISE_ERROR ioctl request to pass
the error code back to the stream implementation which can raise a more
detailed error.  If the ioctl is not implemented, we fall back to the old
behaviour and raise an OSError with the error code.

Currently the detailed messages are only implemented for TLS sockets since
those already had helper functions for raising detailed exceptions, but can
be easily implemented in any other stream.

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
This is the only location in the code base that uses `mp_obj_tuple_del()`,
so we can reduce code size by reworking the iter code not to use that
function.

The zip iter implementation should now have slightly better GC behaviour:
it only allocates the return tuple if needed, instead of allocating it and
then freeing it when the zip iterator is exhausted.

Signed-off-by: Damien George <damien@micropython.org>
Since the parent commit, this is now unused.

Signed-off-by: Damien George <damien@micropython.org>
This provides the DEBUG_printf definition which is needed when
defining MICROPY_DEBUG_VERBOSE, and is consistent with all other ports.

Signed-off-by: stijn <stijn@ignitron.net>
Otherwise only those in gc_mark_subtree get logged, which is
incomplete and hence not very useful.

Signed-off-by: stijn <stijn@ignitron.net>
This is more informative when debugging possible gc issues.

Signed-off-by: stijn <stijn@ignitron.net>
Explicitly specify the wanted cast otherwise this results in

    warning C4244: '=': conversion from 'unichar' to 'char',
    possible loss of data

when building with msvc with most warnings enabled.

Signed-off-by: stijn <stijn@ignitron.net>
This commit introduces support for writing inline assembler code
snippets when targeting Xtensa cores that use register windows (eg.
the whole ESP32 family).

Opcodes support is still limited to what the ESP8266 supports (as in,
LX3 cores opcodes), however each LX core version is guaranteed to
support all previous versions' opcodes as well.  The ESP32 does not have
the inline assembler enabled by default, following the existing
expectations when it comes to firmware footprint.

Since now emitted functions may have one of two possible exit sequences,
the L32I test had to be fixed.  It would return the word containing the
L32I opcode itself, but the upper 8 bits of the word came from the
following opcode - which can change depending on the exit code sequence.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit migrates handling of certain narrow (ie. 16-bits) opcodes
from a per-opcode dedicated code snippet to the existing table-driven
opcode handler.

The final ESP8266 firmware binary is 64 bytes shorter, without any
change in the existing behaviour and with a reduced source code lines
count too.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
If the return value is set only when certain condition are true,
the compiler sometimes raises an error.

Signed-off-by: robert-hh <robert@hammelrath.com>
Zephyr and MicroPython both have a variant of FatFs, but having both
enabled leads to build fails.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
By putting the heap in the noinit area instead of the bss area, zephyr
won't memset it to zero during start.  This improves startup time, in
particular if the heap is very big.  The system heap of zephyr is also in
the same section.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Add additional sensor type constants.
Commonly used by power and current measurement sensors.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
mikeysklar and others added 29 commits September 10, 2026 14:36
Move CIRCUITPY_LOAD_NATIVE from five board files to the raspberrypi
port default, so every RP2040 and RP2350 board gets it. Other ports
stay off and can be turned on one chip family at a time.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jNwbykarVuwvQYHaPZS3Y
pimoroni_badger2040w, pimoroni_inky_frame_5_7, pimoroni_inky_frame_7_3
and pimoroni_plasma2040w run out of flash with it on.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jNwbykarVuwvQYHaPZS3Y
This reverts commit 8b85925. The overflow only happened with
GCC 14.2.1. With the GCC 15.2.1 that CI uses, all four fit with the
loader on in every language; the tightest, ja, leaves about 2.5 KB free.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jNwbykarVuwvQYHaPZS3Y
Every espressif board job ran apt-get update and installed ninja-build,
about 10 seconds of the job's 50 seconds of setup, 257 times per full
run. The IDF tools know ninja (an on_request tool in tools.json), so
install it next to the toolchain, where export.sh already looks.
Without this every job keeps downloading the ninja zip until the next
IDF bump changes the key.
ports/mimxrt10xx/mpconfigport.mk turns on CIRCUITPY_AUDIOMP3, but the
port's dependency list didn't have lib/mp3. The boards built anyway
because the common submodule cache happens to contain it; a board job
that missed that cache failed on lib/mp3/src/mp3common.h.
ci: get ninja from the IDF tools instead of apt
zephyr-tests is the last job to finish on most pull requests, 46 minutes
since native_sim_asan joined. 85 % of the test time is the bsim BLE suite,
run once per bsim board, one after the other: 504 s on nrf54lm20bsim,
365 s on nrf5340bsim, then the native_sim suites.

Split it by board family: native_sim (both builds), nrf5340bsim and
nrf54lm20bsim, each job building only its boards and running only its
tests through the same make target with TEST_BOARDS and PYTEST_ARGS.
The longest job should come in around 16 minutes.
The module is not enabled in any CircuitPython build. Remove it from the
toctree and exclude the page so the -W docs build does not fail on an
orphaned document. The upstream page is left unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Qu5DsShHZxKjosZ1NDqzv
The note described MicroPython port availability, which does not apply to
CircuitPython.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Qu5DsShHZxKjosZ1NDqzv
Conflict in py/emitglue.c resolved by keeping the v1.28 side. Upstream
d41b8dc (in v1.28.0) selects the cache flush code with compiler
defines, which supersedes the equivalent CircuitPython fix c3ecca3
that main carries on top of the backported loader.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Qu5DsShHZxKjosZ1NDqzv
This reverts commit 568bfb7. adafruit#11335 gave slot0 the unused 32 KB
storage partition, so the temporary gate is no longer needed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Qu5DsShHZxKjosZ1NDqzv
The cache flush selection is upstream d41b8dc verbatim, so it is not a
CircuitPython change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Qu5DsShHZxKjosZ1NDqzv
…xrt-mp3

ci_fetch_deps: mimxrt10xx needs lib/mp3
…hards

ci: run the Zephyr tests as three jobs, one per board family
…ergecommit

Update MicroPython to v1.28.0
With MICROPY_GC_SPLIT_HEAP_AUTO the Python heap grows into the largest free
IDF block until nothing is left. The wifi driver, lwIP and NimBLE allocate at
runtime (TX buffers, station association, DHCP replies, ESP-NOW frames), so a
Python program that fills its heap silently breaks the radio: esp_now_send()
fails with ESP_ERR_ESPNOW_NO_MEM, softAP clients associate but never get a
DHCP lease (udp_sendto fails), and start_ap() can hard fault.

Reserve CIRCUITPY_ESP_RADIO_HEAP_RESERVE (32 KB, board-overridable) of the IDF
heap whenever the wifi radio or the BLE adapter is enabled, by capping what
port_heap_get_largest_free_size() reports to the GC. Programs that never turn a
radio on keep the whole heap.

Measured on an ESP32-C6 devkit (no PSRAM) running a wifi+ESP-NOW collector:
before, every ESP-NOW send failed 0x3067 with idf_free=7884 largest=7680 and
phones stuck at "obtaining IP address" (DHCP ACK udp_sendto -> -1); after,
sends succeed (idf_free ~31 KB) and phones get leases.
A server-side SSLSocket did a full handshake for every connection. Browsers
open several connections per page, and on a small MCU with an RSA-2048
certificate each handshake costs ~1.3 s of CPU (ESP32-C6), so pages stalled
and speculative connections were abandoned.

Configure mbedTLS session tickets (AES-256-GCM via PSA, 24 h lifetime, one
process-wide key) on server-side contexts when MBEDTLS_SSL_SESSION_TICKETS and
MBEDTLS_SSL_TICKET_C are available (ESP-IDF enables them by default), so
returning clients resume with an abbreviated handshake and no public-key
operation. Client-side behaviour is unchanged.
…mic mbedTLS buffers

(cherry picked from commit 3b6d77d)
The sdkconfig half of 216c71c ("ssl: server-side TLS session tickets
(abbreviated handshakes); opt-console: HW SHA/AES"), whose SSLSocket.c half now
comes from the base branch. Both halves were reverted together at 3cab908
while bisecting HTTPS sessions that died right after the handshake; the cause
turned out to be the collector's 2.5 s no-request idle timeout (fixed at
e881526 in the project repo), not this commit. Restored here so the bisect
tickets-vs-HW-crypto can actually be run.
Uncommitted bench state from the HIL sessions:
- C6/S3 devkits: console mirrored onto UART0 (the USB-UART bridge survives a
  reset, so a fault is still recorded after native USB drops off the bus);
  C6 also needs CIRCUITPY_ESP_USB_SERIAL_JTAG=0 since the two consoles are
  mutually exclusive.
- wifi/__init__.c: log 8BIT and INTERNAL free/largest either side of
  esp_wifi_init, which runs before user code can reach gc.mem_free().
- opt-console sdkconfig: PANIC_PRINT_HALT instead of SILENT_REBOOT, which is
  also what surfaces "Brownout detector was triggered".
- build_bench.sh: clean-rebuild both devkits (a file, because wsl -- bash -lc
  mangles $VAR and $(...)).

(cherry picked from commit ed9ae7c1c36fa2259e0635b0d91d47e87a329dcf)
…and bench devkits

The base branch defaults CIRCUITPY_ESP_RADIO_HEAP_RESERVE to 32 KB, which is
what a plain softAP + ESP-NOW workload needs. Adding a TLS server on top needs
more: at 32 KB the C6 hub still hit MemoryError starting a handshake and lost
DHCP replies. Override to 40 KB on the Adafruit ESP32 / ESP32-S3 / ESP32-C6
Feathers, Metro S3, QT Py ESP32 / ESP32-S3, and the two bench devkits. Other
Adafruit ESP32/S3 boards (ItsyBitsy, MatrixPortal, Sparkle Motion, Qualia,
cameras) are deliberately left on the 32 KB default for now.

Replaces the branch's old global 58140f6 ("radio heap reserve 40KB"), which
raised the port-wide default instead of overriding per board.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.