Commit Graph

17297 Commits

Author SHA1 Message Date
Andrew Leech
5e965618be tests/run-tests.py: Add support for ctrl keys in REPL tests.
This allows having {\xDD} in tests, which will be expanded to the given
hex character.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2025-06-19 17:23:39 +10:00
Phil Howard
c16a4db151 rp2/CMakeLists.txt: Make linker script configurable.
Some checks failed
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Add `MICROPY_BOARD_LINKER_SCRIPT` to specify a custom linker script for rp2
boards/variants.

This may, for example, include a PSRAM region so that C buffers or
otherwise can be allocated into PSRAM.

Signed-off-by: Phil Howard <github@gadgetoid.com>
2025-06-19 11:00:10 +10:00
Phil Howard
1a060e87cd rp2/CMakeLists.txt: Make board's pins.csv configurable.
Allow `mpconfigboard.cmake` to specify a custom `MICROPY_BOARD_PINS` to
override `${MICROPY_BOARD_DIR}/pins.csv`.

Signed-off-by: Phil Howard <github@gadgetoid.com>
2025-06-19 10:47:50 +10:00
Phil Howard
dc8daad3c9 rp2/rp2_flash: Add default MICROPY_HW_FLASH_MAX_FREQ.
Some checks failed
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Set a default MICROPY_HW_FLASH_MAX_FREQ if PICO_FLASH_SPI_CLKDIV
is unset.

Use a divider of 4, which is the default in boot2_generic_03h.S.

Signed-off-by: Phil Howard <github@gadgetoid.com>
2025-06-17 15:17:12 +01:00
Phil Howard
b725c26b4e rp2/rp2_flash: Add MICROPY_HW_FLASH_MAX_FREQ to replace fixed max freq.
Some checks failed
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Assuming a 133MHz capable flash in 91cff8e4f1
caused `rp2_flash_set_timing_internal` to set out of range dividers for
some boards (anything with value of 4 and flash that doesn't tolerate
higher speeds).

This affected (at least) the XIAO RP2350 board, making it non-bootable.

Since Pico SDK's `PICO_FLASH_SPI_CLKDIV` is entirely unreliable on a system
with a variable system clock (users can change it at runtime) then use it
only to work out a default `MICROPY_HW_FLASH_MAX_FREQ`.

This value can be overridden in board config.

Note that RP2350's default clock is 150MHz, RP2040's is 125MHz and it has
been certified at 200MHz so it's quite possible that
`PICO_FLASH_SPI_CLKDIV` is unreliable even at standard RP2 clocks.

(If flash timings are marginal then this can manifest as instability rather
than outright failure.)

Fixes issue #17375.

Signed-off-by: Phil Howard <github@gadgetoid.com>
2025-06-17 11:40:42 +10:00
Meir Armon
c1196cadb1 esp32/modesp32: Fix access to ext0_pin only if defined.
In different functions `machine_rtc_config.ext0_pin` is accessed where
SOC_PM_SUPPORT_EXT0_WAKEUP is not defined, fix that.

Signed-off-by: Meir Armon <meirarmon@gmail.com>
2025-06-17 10:31:41 +10:00
Jeff Epler
b6b7d64bd9 py/modio: Fix the case where write fails in BufferedWriter.flush.
Previously, there was no test coverage of the "write failed" path.  In
fact, the assertion would fire instead of gracefully raising a Python
exception.

Slightly re-organize the code to place the assertion later.  Add a test
case which exercises all paths, and update the expected output.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-17 10:15:59 +10:00
Jeff Epler
5ade8b7058 tests/extmod: Add platform_basic.py for basic coverage test of platform.
Some checks failed
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-16 23:37:17 +10:00
Jeff Epler
5901b8d149 tests/cpydiff: Document complex() parsing difference.
In #17384 it was decided that fixing this difference was not worth the code
size increase.  So document it instead.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-16 23:34:34 +10:00
Jeff Epler
841acb9df1 github/workflows: Add sanitize_undefined workflow to unix port CI.
gcc's "undefined behavior" sanitizer can catch a range of misbehaviors at
runtime that normally go unnoticed.  These include integer and pointer
operations that are "undefined" per the relevant C specification.

This commit enables undefined behavior detection during a new unix
coverage-like build.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-16 23:28:34 +10:00
Jeff Epler
268264fe64 tools/ci.sh: Add functions for sanitizer builds.
Includes both undefined and address sanitizer configurations.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-16 23:28:08 +10:00
Jeff Epler
2c8ccd3ee8 py: Fix undefined left shift operations.
By ensuring the value to be shifted is an unsigned of the appropriate type.

This fixes several runtime diagnostics such as:

    ../../py/binary.c:199:28: runtime error:
     left shift of 32768 by 16 places
     cannot be represented in type 'int'

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-16 23:27:50 +10:00
Chris Webb
816246836e docs/rp2: Document the new rp2 Timer hard= option.
Signed-off-by: Chris Webb <chris@arachsys.com>
2025-06-16 12:35:51 +01:00
Chris Webb
8f85edad86 tests/ports/rp2: Add tests for rp2-specific timer options.
Add tests for both one-shot and periodic timers using the rp2-specific
tick_hz= and hard= parameters.

Signed-off-by: Chris Webb <chris@arachsys.com>
2025-06-16 12:35:51 +01:00
Chris Webb
7816b1f513 rp2/machine_timer: Support hard IRQ timer callbacks.
Unlike some boards like stm32, timer callbacks on the rp2 port are
unconditionally dispatched via mp_sched_schedule(), behaving like
soft IRQs with consequent GC jitter and delays.

Add a 'hard' keyword argument to the rp2 Timer constructor and init.
This defaults to False but if it is set True, the timer callback will
be dispatched in hard IRQ context rather than queued.

Signed-off-by: Chris Webb <chris@arachsys.com>
2025-06-16 12:35:51 +01:00
Andrew Leech
cfcc53da72 drivers/esp-hosted: Replace EVENT_POLL_HOOK with mp_event_wait_ms.
Some checks failed
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Signed-off-by: Andrew Leech <andrew@alelec.net>
2025-06-16 16:36:39 +10:00
Andrew Leech
573180f788 renesas-ra: Replace MICROPY_EVENT_POLL_HOOK with mp_event_wait.
Basic update to the renesas-ra port to replace the traditional
`MICROPY_EVENT_POLL_HOOK` with the newer mp_event_wait API as appropriate.

Signed-off-by: Andrew Leech <andrew@alelec.net>
2025-06-16 16:36:31 +10:00
Damien George
d9467b07cb tools/mpremote: Improve df command to use new no-arg vfs.mount() query.
The existing `mpremote df` command is not very good, because it needs to
assume that all directories in the root directory are mount points, and
also doesn't correctly stat filesystems when the current directory is not
the root. This leads to wrong results

With the introduction of `vfs.mount()` to return a list of mounted
filesystems and their path, a much better df can be implemented, as done in
this commit.

The new df will also fall back to using the old approach of listing the
root directory if the no-arg `vfs.mount()` query is not supported.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-16 15:11:24 +10:00
Meir Armon
171d751242 esp32/modesp32: Make wake_on_ext1 available only on SoCs supporting it.
The `esp32.wake_on_ext1()` method should only be available on boards that
have SOC_PM_SUPPORT_EXT1_WAKEUP=y.  And update docs to reflect this.

Signed-off-by: Meir Armon <meirarmon@gmail.com>
2025-06-16 14:18:02 +10:00
Meir Armon
4697a06fdb esp32/modesp32: Make wake_on_ext0 available only on SoCs supporting it.
The `esp32.wake_on_ext0()` method should only be available on boards that
have SOC_PM_SUPPORT_EXT0_WAKEUP=y.  And update docs to reflect this.

Signed-off-by: Meir Armon <meirarmon@gmail.com>
2025-06-16 14:17:14 +10:00
Meir Armon
cb315bb8e4 esp32/modesp32: Make wake_on_touch available only on SoCs supporting it.
The `esp32.wake_on_touch()` method should only be available on boards that
have SOC_TOUCH_SENSOR_SUPPORTED=y.  And update docs to reflect this.

Signed-off-by: Meir Armon <meirarmon@gmail.com>
2025-06-16 14:16:16 +10:00
Jeff Epler
5ff2ae5a6c py/asmbase: Fix assertion error with viper code.
In the case of viper code it's possible to reach MP_ASM_PASS_EMIT with a
code size of 0 bytes.  Update the assertion accordingly.

After this change, `mpy-cross -march=debug' on viper tests no longer
crashes.

Fixes issue #17467.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-16 14:02:30 +10:00
Jeff Epler
fc6205c4f0 unix/coverage: Add coverage test for left adjusted print.
Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-16 13:59:57 +10:00
Jeff Epler
1a8f4b290b py/mpprint: Remove unused "PF_FLAG_NO_TRAILZ" flag.
Looking at the git history, there's no indication that the
`PF_FLAG_NO_TRAILZ` flag was ever implemented or that "%!" was used as an
`mp_printf` format string in practice.

So remove the flag and re-number the other flags.

Leave `PF_FLAG_SEP_POS` at 9 (the highest position that probably works with
16-bit integers like the pic16bit port).

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-16 13:58:13 +10:00
Jeff Epler
73b1cbc17a py/objlist: Reduce code size in slice operations.
By refactoring the code to separate out the slicing operation from the
regular indexing operation, code can be shared between the various types of
slice operations (read/assign/delete).

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-16 13:43:47 +10:00
Jeff Epler
0ef5ede382 py/mpz: Avoid undefined behavior decrementing NULL.
In the case where an mpz number is zero, its `len` is 0 and its `dig` is
NULL.  In that case, decrementing NULL via `d--` is undefined behavior
according to the C specification.

Restructuring the loops in this way avoids undefined behavior.

Also, ensure that these cases are tested in the coverage test.  This
doesn't make much difference now, but would otherwise cause errors later
when the undefined behavior sanitizer is employed in CI.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-16 12:11:07 +10:00
Meir Armon
42404b5588 esp32/modesp32: Make wake_on_ulp available only on SoCs that support it.
Some checks failed
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
The `esp32.wake_on_ulp()` method should only be available on boards that
have SOC_ULP_SUPPORTED=y.  Update docs to reflect this.

Signed-off-by: Meir Armon <meirarmon@gmail.com>
2025-06-16 11:24:25 +10:00
Damien George
fa393feaed esp32/README: Update README to describe auto filesystem sizing.
Some checks failed
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Signed-off-by: Damien George <damien@micropython.org>
2025-06-14 01:06:27 +10:00
Damien George
6201e77999 esp32/boards: Convert all boards to auto detect flash size.
Remove the "vfs" entry from all partitions-*.csv files, and then remove
duplicated files.

And remove the ESP32_GENERIC_S3-FLASH_4M variant, because it's no longer
needed.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-14 01:06:12 +10:00
Damien George
2a0e2b5782 esp32/main: Auto detect the size of flash and auto create vfs partition.
Currently in the esp32 port the size of the SPI flash must be configured at
build time, eg 4MiB, 8MiB, etc.  Also, the esp32 partition table must be
configured at build time, which depends on the size of the SPI flash.  A
bigger flash means more can be allocated to the user filesystem.

This commit makes it so the SPI flash size is automatically determined at
runtime, and the filesystem size is automatically set to take up as much
room as possible (a "vfs" partition is created automatically if it doesn't
exist).

This works by:
- Setting the SPI flash size to be 4MiB in the build (or some other value,
  as long as the firmware app fits).
- Removing the vfs partition from the esp32 partition table (only nvs,
  phy_init and firmware, and maybe romfs, remain in the partition table).
- At boot, query the physical size of the SPI flash and use that as the
  actual size in the code.
- If it doesn't already exist, automatically create a "vfs" partition which
  takes up the flash from the end of all existing partitions to the end of
  flash.

This allows simplifying a lot of board configurations, and removing some
board variants that just change the flash size (to be done in a following
commit).

It's also fully backwards compatible, in the following sense:
- Existing boards with MicroPython firmware will continue to work with the
  same filesystem, ie the filesystem won't be erased when the firmware is
  updated.
- If a user has a custom esp32 partition table and installs MicroPython as
  a bare app into the app partition, the new MicroPython firmware will
  honour the esp32 partition table and use either "vfs" or "ffat"
  partitions as the filesystem.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-14 01:03:44 +10:00
Damien George
398da22492 esp8266/modmachine: Use common machine_time_pulse_us implementation.
Some checks failed
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Testing shows that for frequencies which the esp8266 can handle -- up to
about 1kHz -- `machine.time_pulse_us()` now gives more accurate results.

Prior to this commit it would measure on average about 1us lower, but now
the average is much closer to the true value.  For example a pulse that is
1000us long, it would measure between 998 and 1000us.  Now it measures
between 999us and 1001us.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-13 16:27:35 +10:00
Damien George
ef21ade602 extmod/machine_pulse: Optimise time_pulse_us for code size.
This implementation is based on the esp8266 custom implementation, and
further optimised for size and accuracy.

Testing on PYBD_SF2 and RPI_PICO2_W shows that it is at least as good as
the original implementation in performance.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-13 16:27:35 +10:00
Damien George
5676b45cbb tests/run-natmodtests.py: Consider a test skipped if mpy doesn't exist.
Some checks failed
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
This is different to a test not being run because there is no corresponding
natmod at all.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-12 21:53:31 +10:00
Damien George
63701c2e94 tests/run-perfbench.py: Create a _result.json at end of run.
Reuse the `create_test_report()` function from `run-tests.py` to generate a
`_result.json` file summarising the test run.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-12 21:53:31 +10:00
Damien George
09b058559b tests/run-natmodtests.py: Create a _result.json at end of run.
Reuse the `create_test_report()` function from `run-tests.py` to generate a
`_result.json` file summarising the test run.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-12 21:53:31 +10:00
Damien George
6db9c80856 tests/run-multitests.py: Create a _result.json at end of run.
Reuse the `create_test_report()` function from `run-tests.py` to generate a
`_result.json` file summarising the test run.  If there's more than one
permutation of the test run, only the last result is saved.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-12 21:53:25 +10:00
Damien George
2bc5af6945 tests/run-tests.py: Factor out helper function to create test report.
This commit factors existing code in `run-tests.py` into a new helper
function `create_test_report()`.  That function prints out a summary of the
test run (eg number of tests passed, number failed, number skipped) and
creates the corresponding `_results.json` file.

This is done so `create_test_report()` can be reused by the other test
runners.

The `test_count` counter is now gone, and instead the number of passed plus
number of failed tests is used as an equivalent count.

For consistency this commit makes a minor change to the printed output of
`run-tests.py`: instead of printing a shorthand name for tests that failed
or skipped, it now prints the full name.  Eg what was previously printed as
`attrtuple2` is now printed as `basics/attrtuple2.py`.  This makes the
output a little longer (when there are failed/skipped tests) but helps to
disambiguate the test name, eg which directory it's in.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-12 21:47:20 +10:00
Damien George
e4d556b149 tests/extmod/random_extra_float.py: Skip when funcs not available.
This test was factored out from `random_extra.py` back in commit
6572029dc0, and the skip logic copied from
that file.  But the skip logic needs to test that the `random` and
`uniform` functions exist, not `randint`.

This commit fixes that skip logic.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-12 21:45:40 +10:00
Damien George
9bde12597a github/workflows: Use windows-latest runner for all Windows CI jobs.
Some checks failed
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
The windows-2019 runner has been deprecated by GitHub, so stop using that.
Also take the chance to stop using windows-2022 and just use windows-latest
everywhere.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-11 00:43:40 +10:00
Damien George
ca80aabf21 py/objfloat: Change MSVC workaround for NAN being a constant.
It's actually a bug in the Windows SDK, not MSVC, as per
https://stackoverflow.com/questions/79195142/recent-msvc-versions-dont-treat-nan-as-constant-workaround/79324199#79324199

Thanks to @stinos.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-11 00:43:31 +10:00
Jeff Epler
2ce63b1420 py/parsenum: Fix parsing complex literals with negative real part.
Some checks failed
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
If a complex literal had a negative real part and a positive imaginary
part, it was not parsed properly because the imaginary part also came out
negative.

Includes a test of complex parsing, which fails without this fix.

Co-authored-by: ComplexSymbol <141301057+ComplexSymbol@users.noreply.github.com>
Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-10 15:41:24 +10:00
Jeff Epler
0a98f3a911 py/objarray: Allow extending array with any iterable.
As suggested by @dpgeorge, factor out part of array_construct to allow it
to be used for construction & extension.

Note that extending with a known-length list (or tuple) goes through the
slow path of calling array_extend once per element.

Fixes issue #7408.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-10 15:32:54 +10:00
Jeff Epler
c1629dc2ff py/parsenum: Further reduce code size in check for inf/nan.
A few more bytes can be saved by not using nested `if`s (4 bytes for
`build-MICROBIT/py/parsenum.o`, 8 bytes for RPI_PICO firmware).

This commit is better viewed with whitespace changes hidden, because
two blocks were reindented (e.g., `git show -b`).

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-10 15:22:34 +10:00
Jeff Epler
5eb9755259 py/parsenum: Reduce code size in check for inf/nan.
By avoiding two different checks of the string length, code size is reduced
without changing behavior: Some invalid float/complex strings like "ix"
will get handled just like "xx" in the main number literal parsing code
instead.

The optimizer alone couldn't remove the reundant comparisons because it
couldn't make a transformation that let an invalid string like "ix" pass
into the generic number parsing code.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-10 15:21:18 +10:00
Jeff Epler
745bec9ce3 extmod/modre: Use specific error message if regex is too complex.
If the error reporting mode is at least "normal", report a failure due to a
complex regex with a different message.

Fixes issue #17150.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-06-10 15:14:56 +10:00
Damien George
17951cee87 py/dynruntime.mk: Enable single-precision float by default on armv6/7m.
Soft float now works on these ARM targets thanks to the parent commit.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-10 13:43:03 +10:00
Damien George
718ff4fdd5 tools/mpy_ld.py: Support R_ARM_ABS32 relocation in text.
Add support for R_ARM_ABS32 relocations in native .mpy files.  These can be
rewritten in the same way that data relocations are.

Fixes issue #14430.

Signed-off-by: Damien George <damien@micropython.org>
2025-06-10 13:40:11 +10:00
Damien George
5f4abeb385 py/asmthumb: Implement long jumps on Thumb/armv6m architecture.
With this change, all tests (except thread tests) now pass on RPI_PICO when
using the native emitter:

    (plug in RPI_PICO)
    $ cd tests
    $ ./run-tests.py -t a0 --via-mpy --emit native

Signed-off-by: Damien George <damien@micropython.org>
2025-06-10 13:14:06 +10:00
Alessandro Gatti
43f6013294 py/asmxtensa: Extend BCC range to 18 bits.
This commit lets the native emitter backend extends the range of the
BCC family of opcodes (BALL, BANY, BBC, BBS, BEQ, BGE, BGEU, BLT,
BLTU, BNALL, BNE, BNONE) from 8 bits to 18 bits.

The test suite contains some test files that, when compiled into native
code, would require BCC jumps outside the (signed) 8 bits range.  In
this case either the MicroPython interpreter or mpy-cross would raise an
exception, not running the test when using the "--via-mpy --emit native"
command line options with the test runner.

This comes with a 3 bytes penalty on each forward jump, bringing the
footprint of those jumps to 6 bytes each, as a longer opcode sequence
has to be emitted to let jumps access a larger range.  However, this is
slightly offset by the fact that backward jumps can be emitted with a
single opcode if the range is small enough (8-bits offset).

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-06-10 12:28:29 +10:00
Alessandro Gatti
80b823bca1 py/asmxtensa: Extend BCCZ range to 18 bits.
This commit lets the native emitter backend extends the range of the
BCCZ family of opcodes (BEQZ, BNEZ, BLTZ, BGEZ) from 12 bits to 18
bits.

The test suite contains some test files that, when compiled into native
code, would require BCCZ jumps outside the (signed) 12 bits range.  In
this case either the MicroPython interpreter or mpy-cross would raise an
exception, not running the test when using the "--via-mpy --emit native"
command line options with the test runner.

This comes with a 3 bytes penalty on each forward jump, bringing the
footprint of those jumps to 6 bytes each, as a longer opcode sequence
has to be emitted to let jumps access a larger range.  However, this is
slightly offset by the fact that backward jumps can be emitted with a
single opcode if the range is small enough (3 bytes for a 12-bits
offset).

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-06-10 12:28:29 +10:00