summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2025-08-15tests: Require SSL certificate file to be available for test to run.Damien George
Previously, any test needing an SSL certificate file would automatically skip if the file could not be found. But that makes it too easy to accidentally skip tests. Instead, change it so that the test fails if the certificate file doesn't exist. That matches, for example, the fact that the test fails if networking (LAN, WiFi) is not active. Signed-off-by: Damien George <damien@micropython.org>
2025-08-15tests: Add .native.exp output files for tests that differ with native.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-08-15tests/micropython/opt_level_lineno.py: Force test func to use bytecode.Damien George
So that the test can run the same on all targets when used with the native emitter. Signed-off-by: Damien George <damien@micropython.org>
2025-08-15tests/misc/print_exception.py: Use "raise e" instead of no-arg "raise".Damien George
This allows the test to run with the native emitter. The test semantics remain the same. Signed-off-by: Damien George <damien@micropython.org>
2025-08-15tests/run-tests.py: Add support for .native.exp expected output files.Damien George
There are currently a few tests that are excluded when using the native emitter because they test printing of exception tracebacks, which includes line numbers. And the native emitter doesn't store line numbers, so gets these tests wrong. But we'd still like to run these tests using the native emitter, because they test useful things even if the line number info is not in the traceback (eg that threads which crash print out their exception). This commit adds support for native-specific .exp files, which are of the form `<test>.py.native.exp`. If such an .exp file exists then it take precedence over any normal `<test>.py.exp` file. (Actually, the implementation here is general enough that it also supports `<test>.py.bytecode.exp` as well, if bytecode ever needs a specific exp file.) Signed-off-by: Damien George <damien@micropython.org>
2025-08-15tests/misc/rge_sm.py: Remove unused code from the test.Damien George
This cleans up the test to remove all unused code, making it smaller, a bit faster to deploy to a target to run, and also use less RAM on the target (which may help it run on targets that are just slightly out of memory running it). Signed-off-by: Damien George <damien@micropython.org>
2025-08-15webassembly: Enable C-stack checking.Damien George
This gets the recursive stress-tests working on this port. For relatively small Python functions the maximum recursive depth is about 150 nested calls. Signed-off-by: Damien George <damien@micropython.org>
2025-08-15github/workflows: Run webassembly and zephyr workflows if tests/ change.Damien George
Because these ports run tests as part of CI, and need to be run if any of the tests change, to check those changes. Signed-off-by: Damien George <damien@micropython.org>
2025-08-15tests/basics: Skip tests of io module individually using SKIP.Damien George
Instead of using a feature check. This is more consistent with how other optional modules are skipped. Signed-off-by: Damien George <damien@micropython.org>
2025-08-15tests/run-tests.py: Autodetect if the target has unicode support.Damien George
The unicode tests are now run on all targets that enable unicode. And other unicode tests (namely `extmod/json_loads.py`) are now properly skipped if the target doesn't have unicode support. Signed-off-by: Damien George <damien@micropython.org>
2025-08-15tests/run-tests.py: Generalise addition of port specific test directory.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-08-15tests/run-tests.py: Always include stress/ tests directory in tests.Damien George
Ports that now run the stress tests, that didn't prior to this commit are: cc3200, esp8266, minimal, nrf, renesas-ra, samd, qemu, webassembly. Signed-off-by: Damien George <damien@micropython.org>
2025-08-15tests/run-tests.py: Automatically include float tests when possible.Damien George
This simplifies the code by removing the explicit addition of the "float/" test directory for certain targets. It also means the tests won't be added incorrectly, eg on a unix build without float. Signed-off-by: Damien George <damien@micropython.org>
2025-08-13py/misc: Add explicit dependency on py/mpconfig.h.Angus Gratton
Macros in misc.h depend on values defined by including mpconfig.h. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-08-12py/binary: Add MICROPY_PY_STRUCT_UNSAFE_TYPECODES.Jeff Epler
This adds a compile-time flag to disable some "unsafe" and non-standard typecodes in struct, array and related modules. This is useful to turn off when fuzzing, as improper use of these typecodes can crash MicroPython. Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-08-11py/asmrv32: Make lt/le comparisons emitter shorter.Alessandro Gatti
This commit simplifies the emitter code in charge of generating opcodes performing less-than and less-than-or-equal comparisons. By rewriting the SLT/SLTU opcode generator (handling less-than comparisons) and de-inlining the less-than comparison generator call in the less-than-or-equal generator, the output binary is ~80 bytes smaller (measurements taken from the QEMU port). Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-08-11tests/micropython: Remove big ints dependence for viper boundary tests.Alessandro Gatti
This commit provides an implementation for viper boundary tests that can work even without big int support. Since it uses a fixed-size buffer to hold values to work with, this should work on any platform as long as its integers are at least 32 bits wide, regardless its configuration on how big integers can get. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-08-11extmod/modlwip: Support `family` specification in getaddrinfo.Jared Hancock
`socket.getaddrinfo()` supports the specification of an address family; however, the LwIP implementation does not use it. This change allows the application to specify the address family request in DNS resolution. If no family is specified, it falls back to the default preference configured with `network.ipconfig()`. Signed-off-by: Jared Hancock <jared.hancock@centeredsolutions.com>
2025-08-11extmod/modre: Add support for start- and endpos.Jared Hancock
Pattern objects have two additional parameters for the ::search and ::match methods to define the starting and ending position of the subject within the string to be searched. This allows for searching a sub-string without creating a slice. However, one caveat of using the start-pos rather than a slice is that the start anchor (`^`) remains anchored to the beginning of the text. Signed-off-by: Jared Hancock <jared@greezybacon.me>
2025-08-11tools/codeformat.py: Print filename + linenumber when dedenting fails.Daniël van de Giessen
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2025-08-11tools/codeformat.py: Iterate lines instead of modifying list in-place.Daniël van de Giessen
Co-authored-by: David Lechner <david@pybricks.com> Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2025-08-11tools/mpremote: Fix encoding error in PyboardCommand.Jos Verlinde
This is a fix for utf-8 decoding errors that are thrown when non-utf-8 content is received. For instance during a reboot of an ESP8266 module. The fix is to handle conversion errors by replacing illegal characters. Note that these illegal characters most often occur during an MCU reboot sequence when the MCU is using baudrates different from 115200. Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
2025-08-11esp32/network_ppp: Correctly clean up PPP PCB after close.Daniël van de Giessen
If PPP is still connected, freeing the PCB will fail and thus instead we should trigger a disconnect and wait for the lwIP callback to actually free the PCB. When PPP is not connected we should check if the freeing failed, warn the user if so, and only mark the connection as inactive if not. When all this happens during garbage collection the best case is that the PPP connection is already dead, which means the callback will be called immediately and cleanup will happen correctly. The worst case is that the connection is still alive, thus we are unable to free the PCB (lwIP won't let us) and it remains referenced in the netif_list, meaning a use-after-free happens later when lwIP traverses that linked list. This change does not fully prevent that, but it *does* improve how the PPP.active(False) method on the ESP32 port behaves: It no longer immediately tries to free (and fails), but instead triggers a disconnect and lets the cleanup happen correctly through the status callback. Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2025-08-11esp32/network_ppp: Use non-thread-safe API inside status callback.Daniël van de Giessen
The status callback runs on the lwIP tcpip_thread, and thus must use the non-thread-safe API because the thread-safe API would cause a deadlock. Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2025-08-11esp32/network_ppp: Use thread-safe API for PPPoS input.Daniël van de Giessen
A small follow-up to 3b1e22c66947271e8b60eddf4e8aa6dadc6d9a7d, in which the entire PPP implementation was reworked to more closely resemble the extmod version. One of the differences between extmod and the ESP32 port is that the ESP32 port uses the thread-safe API, but in that changeset the PPP input function was accidentally changed to use the non-safe API. Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2025-08-11esp32: Support building against IDFv5.5.Daniël van de Giessen
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2025-08-10tests/run-tests.py: Run tests-with-regex-output as normal tests.Damien George
Some tests (currently given by the `special_tests` list) have output which must be mached via a regex, because it can change from run to run (eg the address of an object is printed). These tests are currently classified as `is_special` in the test runner, which means they get special treatment. In particular they don't set the emitter as specified by `args.emit`. That means these tests do not run via .mpy or using the native emitter, even if those options are given on the command line. This commit fixes that by considering `is_special` as different to `tests_with_regex_output`. The former is used for things like target feature detection (which are not really tests) and when extra command line options need to be passed to the unix micropython executable. The latter (now called `tests_with_regex_output`) are specifically for tests that have output to be matched via regex. The `thread_exc2.py` test now needs to be excluded when running using the native emitter, because the native emitter doesn't print traceback info. And the `sys_settrace_cov.py` test needs to be excluded because set-trace output is different with the native emitter. Signed-off-by: Damien George <damien@micropython.org>
2025-08-10tests/run-tests.py: Move tests to skip with native emitter to a list.Damien George
This makes `run-tests.py` a little more organised, by putting all the tests-to-skip-when-using-the-native-emitter in a dedicated list. This should make it easier to maintain the list, and understand why a test is there. Signed-off-by: Damien George <damien@micropython.org>
2025-08-10all: Bump version to 1.27.0-preview.v1.27.0-previewDamien George
Signed-off-by: Damien George <damien@micropython.org>
2025-08-09all: Bump version to 1.26.0.v1.26.0Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-08-07esp32/machine_timer: Fix machine.Timer() tick frequency on ESP32C2,C6.Angus Gratton
Also future-proofs this code for other chips. Apart form C6 and C2, all currently supported chips use APB clock for GPTIMER_CLK_SRC_DEFAULT. ESP32-C2 uses 40MHz PLL but APB_CLK_FREQ was 26MHz. ESP32-C6 uses 80MHz PLL but APB_CLK_FREQ was 40MHz. Implementation now gets the correct frequency from ESP-IDF. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-08-07esp32/machine_timer: Enable timer clock source for ESP32C6.Angus Gratton
Otherwise the PLL is not enabled. These changes are adapted from `timer_legacy.h` in ESP-IDF. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-08-07ports: Allow MICROPY_PY_MACHINE_I2C_TARGET to be disabled by board cfg.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-08-04renesas-ra/mpconfigport: Enable MICROPY_TIME_SUPPORT_Y1969_AND_BEFORE.Damien George
This setting was missed in df05caea6c6437a8b4756ec502a5e6210f4b6256. It's needed for this port to pass its `tests/ports/renesas-ra/modtime.py` test. Signed-off-by: Damien George <damien@micropython.org>
2025-08-04lib/micropython-lib: Update submodule to latest.Damien George
This brings in: - lora: fix SNR value in SX126x received packets - utop: add initial implementation for ESP32 - utop: print MicroPython memory info - utop: print IDF heap details - urllib.urequest: add support for headers to urequest.urlopen - aiorepl: use blocking reads for raw REPL and raw paste - errno: add ENOTCONN constant - logging: allow logging.exception helper to handle tracebacks - aioble-l2cap: raise correct error if l2cap disconnects during send - abc: add ABC base class - aiohttp: fix partial reads by using readexactly - aiorepl: handle stream shutdown Signed-off-by: Damien George <damien@micropython.org>
2025-08-03py/parse: Fix missing nlr_pop call in complex path of binary_op_maybe.Jeff Epler
Reproducer (needs to be run as one compilation unit): ans = (-1) ** 2.3 aa Fixes issue #17815. Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-08-02github/workflows: Add a CI job to build ESP32-C2 and ESP32-C6 boards.Damien George
So that all six supported SoCs are built by CI. Signed-off-by: Damien George <damien@micropython.org>
2025-08-02esp32/mpconfigport: Disable I2CTarget on ESP32-C6 to reduce code size.Damien George
I2CTarget costs about 8k of flash size on ESP32-S2, and about 11k on ESP32-C6. The ESP32-C6 only has about 8k remaining, so disable I2CTarget on that SoC until more flash can be made available. Signed-off-by: Damien George <damien@micropython.org>
2025-08-02rp2/rp2_flash: Add binary info for ROMFS.Phil Howard
This describes the ROMFS location and size in Pico SDK's binary declaration format, so it can be read from a .uf2 file for use with various tools. Signed-off-by: Phil Howard <github@gadgetoid.com>
2025-08-02docs/reference/mpremote: Document location of config file.Jos Verlinde
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
2025-08-02tools/mpremote: Locate config.py location across different host OSes.Jos Verlinde
Use `platformdirs.user_config_dir()` (see https://platformdirs.readthedocs.io/en/latest/api.html#user-config-directory) to provide portability across many different OSes and configuration styles. Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
2025-08-02tools/mpremote: Add platformdirs dependency to requirements.txt.Jos Verlinde
Needed to easily find the user configuration file. Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
2025-08-02tests/extmod_hardware: Add basic tests for machine.Counter and Encoder.Angus Gratton
These don't test any advanced features, just the basics. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-08-02docs/library/machine: Add docs for Counter and Encoder.Jonathan Hogg
Add documentation for `machine.Counter` and `machine.Encoder` as currently implemented by the esp32 port, but intended to be implemented by other ports. Originally authored by: Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com> and Jonathan Hogg <me@jonathanhogg.com>. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2025-08-01esp32/modules/machine.py: Add Counter and Encoder classes.Jonathan Hogg
Adds a Python override of the `machine` module, which delegates to the built-in module and adds an implementation of `Counter` and `Encoder`, based on the `esp32.PCNT` class. Original implementation by: Jonathan Hogg <me@jonathanhogg.com> Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2025-08-01docs/esp32: Add documentation for esp32.PCNT.Jonathan Hogg
Document the new `esp32.PCNT` class for hardware pulse counting. Originally authored by: Jonathan Hogg <me@jonathanhogg.com> Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2025-08-01esp32/modesp32: Add esp32.PCNT class.Jonathan Hogg
Add a new `esp32.PCNT` class that provides complete, low-level support to the ESP32 PCNT pulse counting hardware units. This can be used as a building block to implement the higher-level `machine.Counter` and `machine.Encoder` classes. This is enabled by default on all OG, S2, S3, C6 boards, but not on C3 (as the PCNT peripheral is not supported). Original implementation by: Jonathan Hogg <me@jonathanhogg.com> Signed-off-by: Jim Mussared <jim.mussared@gmail.com> Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-08-01docs/library: Document the new machine.I2CTarget class.Damien George
With some working examples that show how to use all the features. Signed-off-by: Damien George <damien@micropython.org>
2025-08-01tests/multi_extmod: Add I2CTarget multi tests.Damien George
These require two boards wired together, SCL-SCL and SDA-SDA. Signed-off-by: Damien George <damien@micropython.org>
2025-08-01tests/extmod_hardware: Add self unittest for I2CTarget.Damien George
This test uses a SoftI2C controller wired to an I2CTarget on the one board, and tests all functionality of the I2CTarget class. Signed-off-by: Damien George <damien@micropython.org>