Compare commits

..

19 Commits

Author SHA1 Message Date
Alessandro Gatti
6341258207 esp32/mpconfigport: Enable Zcmp opcodes for ESP32P4.
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
alif port / build_alif (alif_ae3_build) (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp32 port / build_idf (esp32_build_c2_c5_c6) (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_p4) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (bigendian) (push) Has been cancelled
qemu port / build_and_test_arm (sabrelite) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_hardfp) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_softfp) (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
qemu port / build_and_test_rv64 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / longlong (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / gil_enabled (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / repr_b (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_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, true, x86, 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, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 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, 2022, [17, 18)) (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, 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 commit enables support for Zcmp opcodes when the firmware is built
to target ESP32P4 microcontrollers.

The ESP32P4 explicitly supports the Zcmp extension for reducing the
amount of code needed for function prologues and epilogues (see section
4.1.1.1 of the ESP32P4 datasheet).

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-12-19 17:06:53 +11:00
Alessandro Gatti
ec5f2bc686 rp2/CMakeLists.txt: Set the appropriate mpy-cross flags on all targets.
This commit lets the RP2 port build system use the appropriate flags to
pass to "mpy-cross" when building frozen MPY files as part of the build
process.

Now all possible variants (RP2040, RP2350/Arm, and RP2350/RV32) have
their right flags assigned, falling back the flags set of the RP2040 if
a new variant is introduced.  Before these changes all variants would
use the RP2040 set of flags which may be a bit of an issue when building
code for the RP2350 in RV32 mode.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-12-19 17:06:53 +11:00
Alessandro Gatti
08096392b5 rp2/mpconfigport: Enable Zcmp opcodes for RP2350 in RV32 mode.
This commit enables support for Zcmp opcodes when the firmware is built
for the RP2350 in RV32 mode.

The RP2350 explicitly supports the Zcmp extension for reducing the
amount of code needed for function prologues and epilogues (see section
3.8.1.20 of the datasheet).

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-12-19 17:06:53 +11:00
Alessandro Gatti
7a69b2d786 py/asmrv32: Use Zcmp opcodes for function prologues and epilogues.
This commit introduces the possibility of using Zcmp opcodes when
generating function prologues and epilogues, reducing the generated code
size.

With the addition of selected Zcmp opcodes, each generated function can
be up to 30 bytes shorter and having a faster prologue and epilogue.  If
Zcmp opcodes can be used then register saving is a matter of a simple
CM.PUSH opcode rather than a series of C.SWSP opcodes.  Conversely,
register restoring is a single CM.POPRET opcode instead of a series of
C.LWSP opcodes followed by a C.JR RA opcode.  This should also lead to
faster code given that there's only one opcode doing the registers
saving rather than a series of them.

For functions that allocate less than three locals then the generated
code will allocate up to 12 bytes of unused stack space.  Whilst this is
a relatively rare occurrence for generated native and viper code,
inline assembler blocks will probably incur into this penalty.  Still,
considering that at the moment the only targets that support Zcmp
opcodes are relatively high-end MCUs (the RP2350 in RV32 mode and the
ESP32P4), this is probably not much of an issue.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-12-19 17:06:53 +11:00
Alessandro Gatti
1df86516e0 py/asmrv32: Reserve a flag for the Zcmp RV32 CPU extension.
This commit performs the necessary changes to handle an additional RV32
CPU extension flag, for the Zcmp extension in this case.

The changes are not limited to RV32-only code, as other parts of the
tooling need to be modified for this: the testing framework has to be
made aware that an extra bit can be set in sys.implementation._mpy and
needs to know how it is called, and "mpy-cross" must be able to actually
set that flag bit in the first place via the appropriate command line
argument.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-12-19 17:06:53 +11:00
Alessandro Gatti
d938d5af4e qemu/Makefile: Allow usage of a custom QEMU binary to run code.
This commit introduces a new optional makefile variable to let the build
system know that, when running code, a custom QEMU binary must be used
instead of the one provided by the system's PATH.

Given that the CI machine won't keep up with QEMU updates unless its
base image tracks a new version of QEMU itself, sometimes it is needed
to use a custom QEMU build to be able to test new code in an emulated
context rather than having to perform on-device testing during
development.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-12-19 17:06:53 +11:00
Alessandro Gatti
cb9d8fcc31 tests/run-tests.py: Discover RV32 extension inlineasm tests.
This commit extends the test runner to automatically discover inline
assembler tests for known RV32 extensions, and checks whether to add the
discovered tests to the enabled tests list.

Automatic discovery requires that inline assembler tests for RV32
extensions follow a specific pattern both for filenames and for the
tests' output in case of success.  A valid RV32 extension test must
have:

  * A code fragment that checks for support of the extension on the
    running target in "/tests/feature_check", called
    "inlineasm_rv32_<extensionname>.py" that should print the string
    "rv32_<extensionname>" if the extension is supported
  * A matching expected result file in "/tests/feature_check" called
    "inlineasm_rv32_<extensionname>.py.exp" that must contain the string
    "rv32_<extensionname>" (without quotes)
  * A regular MicroPython test file in "/tests/inlineasm/rv32" called
    "asm_ext_<extensionname>.py"

For example, to test the Zba extension, there must be a file called
"/tests/feature_check/inlineasm_rv32_zba.py" that should print the
string "rv32_zba" if the extension is supported, together with a file
called "/test/feature_check/inlineasm_rv32_zba.py.exp" that contains the
string "rv32_zba" in it, and finally there must be a regular MicroPython
test file called "/tests/inlineasm/rv32/asm_ext_zba.py".

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-12-19 17:06:53 +11:00
Alessandro Gatti
f0895f0ea0 py/emitnative: Optimise register clearing.
This commit introduces a new generic ASM API function to clear a
register (i.e. clearing all the registers' bits).

The native emitter used to perform a XOR operation to clear a given
register, but different platform have more optimised method to achieve
the same result taking up less space - either for the generated code or
for the code generator itself.

Arm, RV32, X86, and X64 already had an already optimised generator and
generated optimised code.  The code generator when build for Thumb takes
less space generating a constant immediate move rather than a XOR
operation, even though both operations would distill down to a single
narrow opcode.  On Xtensa the situation is almost the same as Thumb,
with the exception that a constant immediate move would take one byte
less than a XOR operation.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-12-19 14:26:01 +11:00
jetpax
e67d4a2a77 esp32/machine_sdcard: Fix SDMMC slot assignment for non-default slots.
Some checks failed
zephyr port / build (push) Has been cancelled
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
alif port / build_alif (alif_ae3_build) (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp32 port / build_idf (esp32_build_c2_c5_c6) (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_p4) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (bigendian) (push) Has been cancelled
qemu port / build_and_test_arm (sabrelite) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_hardfp) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_softfp) (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
qemu port / build_and_test_rv64 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / longlong (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / gil_enabled (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / repr_b (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_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, true, x86, 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, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 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, 2022, [17, 18)) (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, 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
Python code lint and formatting with ruff / ruff (push) Has been cancelled
The SDMMC_HOST_DEFAULT() macro sets slot to SDMMC_HOST_SLOT_1, but this
was not being overridden when the user specified a different slot number.
This caused SDMMC initialization to fail on chips like ESP32-P4 when
trying to use slot 0.

This commit ensures the slot number passed to the SDCard constructor is
properly assigned to the host configuration structure.

Tested on ESP32-P4 with SD card on slot 0.

Signed-off-by: jetpax <jep@alphabetiq.com>
2025-12-18 11:49:19 +11:00
Thomas Kiss
50a5fe0020 docs/library/network.WLAN: Fix typo for ESP32 protocol constants.
Signed-off-by: Thomas Kiss <thokis@googlemail.com>
2025-12-18 11:37:40 +11:00
Jeff Epler
8b8cd82560 py/misc: Remove unused mp_check function.
This is unused since 007f127a61 "all:
Simplify mp_int_t/mp_uint_t definition".

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-12-18 11:35:38 +11:00
Alessandro Gatti
9c9b99686e tests/target_wiring: Provide an ESP8266 target wiring module.
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
alif port / build_alif (alif_ae3_build) (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp32 port / build_idf (esp32_build_c2_c5_c6) (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_p4) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (bigendian) (push) Has been cancelled
qemu port / build_and_test_arm (sabrelite) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_hardfp) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_softfp) (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
qemu port / build_and_test_rv64 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / longlong (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / gil_enabled (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / repr_b (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_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, true, x86, 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, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 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, 2022, [17, 18)) (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, 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 commit introduces ESP8266 support for target wiring tests, fixing
execution of relevant tests that once failed on that platform.

ESP8266 boards need to have GPIO4 and GPIO5 connected together to
provide a UART loopback, in order to test whether UART data effectively
flows through.

The wiring-enabled UART transmission timing test was also updated with
measurements compatible with a few ESP8266 test boards.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-12-17 16:05:49 +11:00
Alessandro Gatti
dbf59db5a1 tests/extmod/vfs_blockdev_invalid.py: Handle low memory conditions.
This commit modifies the "extmod/vfs_blockdev_invalid" test to better
behave on boards with low available memory.

Before these changes the test would fail on ESP8266 (at least), due to
low memory, but in a way that could not be easily solved as the error
occurred in the middle of the test.

The test has been rewritten to delay its output until the very end, so
if a low memory condition occurs and needs to stop execution then no
real output will show up before the skip marker.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-12-17 16:05:29 +11:00
Alessandro Gatti
750a366f20 tests/run-tests.py: Skip list sort stress test for ESP8266.
This commit marks the "stress/list_sort.py" test to be skipped when
running on ESP8266.

The test just takes too long without yielding to the OS whilst doing the
sort, causing the internal software watchdog to kick in and reboot the
board.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-12-17 16:05:18 +11:00
Jeff Epler
ef567dc928 tests/basics/string_fstring.py: Test fstring nested replacement fields.
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
alif port / build_alif (alif_ae3_build) (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp32 port / build_idf (esp32_build_c2_c5_c6) (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_p4) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (bigendian) (push) Has been cancelled
qemu port / build_and_test_arm (sabrelite) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_hardfp) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_softfp) (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
qemu port / build_and_test_rv64 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / longlong (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / gil_enabled (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / repr_b (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_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, true, x86, 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, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 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, 2022, [17, 18)) (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, 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 does not actually cover any additional lines, but it does cover new
functionality not previously covered.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-12-17 00:14:59 +11:00
Damien George
b78fac161e tests/ports/esp32/check_err_str.py: Preallocate global variable.
This test fails on all esp32 boards without this fix, because the
try/except that runs with the heap locked attempts to increase the size of
the globals dict when assigning to the exception variable `e`.

Fix that by preallocating the global variable `e`.

Signed-off-by: Damien George <damien@micropython.org>
2025-12-16 23:37:59 +11:00
Damien George
53052857e2 esp8266/boards/ESP8266_GENERIC: Remove OTA board variant.
The OTA variant of the ESP8266_GENERIC board was never fully completed in
its functionality.  It relies on the https://github.com/pfalcon/yaota8266
component which was also never fully finished and has been unmaintained for
many years.

This commit removes this variant and it's associated build support.  It
makes it an "old_variant" so the existing historical firmware is still
listed on the download page.

Signed-off-by: Damien George <damien@micropython.org>
2025-12-16 16:30:04 +11:00
Damien George
9274f80130 esp32/boards/ESP32_GENERIC_S3: Reinstate old FLASH_4M variant.
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
alif port / build_alif (alif_ae3_build) (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp32 port / build_idf (esp32_build_c2_c5_c6) (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_p4) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (bigendian) (push) Has been cancelled
qemu port / build_and_test_arm (sabrelite) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_hardfp) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_softfp) (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
qemu port / build_and_test_rv64 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / longlong (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / gil_enabled (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / repr_b (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_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, true, x86, 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, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 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, 2022, [17, 18)) (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, 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
Commit 6201e77999 removed the
ESP32_GENERIC_S3 FLASH_4M variant from `board.json`.  But the firmware
still exists on the download server, and it makes sense to still keep those
old versions available for download, just like all other older versions are
still available.

This commit introduce a new scheme for `board.json` whereby old variants
that are no longer built can be moved to the "old_variants" section.  This
keeps them available on the download page, allowing a way to deprecate
individual board variants without removing them entirely.

An optional string can be added to the old variant to describe why it's
obsolete and what to use instead.

Signed-off-by: Damien George <damien@micropython.org>
2025-12-16 16:22:03 +11:00
Damien George
099cc9f507 all: Bump version to 1.28.0-preview.
Some checks failed
esp32 port / build_idf (esp32_build_c2_c5_c6) (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_p4) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
zephyr port / build (push) Has been cancelled
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
alif port / build_alif (alif_ae3_build) (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (bigendian) (push) Has been cancelled
qemu port / build_and_test_arm (sabrelite) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_hardfp) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_softfp) (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
qemu port / build_and_test_rv64 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / longlong (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / gil_enabled (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / repr_b (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_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, true, x86, 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, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 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, 2022, [17, 18)) (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, 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
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Signed-off-by: Damien George <damien@micropython.org>
2025-12-15 10:15:42 +11:00
37 changed files with 270 additions and 137 deletions

View File

@@ -41,7 +41,7 @@ jobs:
- name: Cached ESP-IDF install
id: cache_esp_idf
uses: actions/cache@v5
uses: actions/cache@v4
with:
path: |
./esp-idf/

View File

@@ -43,7 +43,7 @@ jobs:
run: source tools/ci.sh && echo "ZEPHYR=$ZEPHYR_VERSION" | tee "$GITHUB_OUTPUT"
- name: Cached Zephyr Workspace
id: cache_workspace
uses: actions/cache@v5
uses: actions/cache@v4
with:
# note that the Zephyr CI docker image is 15GB. At time of writing
# GitHub caches are limited to 10GB total for a project. So we only

View File

@@ -145,7 +145,7 @@ Methods
reconnects Number of reconnect attempts to make (integer, 0=none, -1=unlimited)
txpower Maximum transmit power in dBm (integer or float)
pm WiFi Power Management setting (see below for allowed values)
protocol (ESP32 Only.) WiFi Low level 802.11 protocol. See `WLAN.PROTOCOL_DEFAULTS`.
protocol (ESP32 Only.) WiFi Low level 802.11 protocol. See `WLAN.PROTOCOL_DEFAULT`.
============= ===========
Constants
@@ -170,7 +170,7 @@ ESP32 Protocol Constants
The following ESP32-only constants relate to the ``WLAN.config(protocol=...)``
network interface parameter:
.. data:: WLAN.PROTOCOL_DEFAULTS
.. data:: WLAN.PROTOCOL_DEFAULT
A bitmap representing all of the default 802.11 Wi-Fi modes supported by
the chip. Consult `ESP-IDF Wi-Fi Protocols`_ documentation for details.
@@ -184,7 +184,7 @@ network interface parameter:
<espnow-long-range>`.
This mode can be bitwise ORed with some standard 802.11 protocol bits
(including `WLAN.PROTOCOL_DEFAULTS`) in order to support a mix of standard
(including `WLAN.PROTOCOL_DEFAULT`) in order to support a mix of standard
Wi-Fi modes as well as LR mode, consult the `Espressif long-range
documentation`_ for more details.

View File

@@ -145,8 +145,8 @@ static int usage(char **argv) {
"-march=<arch> : set architecture for native emitter;\n"
" x86, x64, armv6, armv6m, armv7m, armv7em, armv7emsp,\n"
" armv7emdp, xtensa, xtensawin, rv32imc, rv64imc, host, debug\n"
"-march-flags=<flags> : set architecture-specific flags (can be either a dec/hex/bin value or a string)\n"
" supported flags for rv32imc: zba\n"
"-march-flags=<flags> : set architecture-specific flags (can be either a dec/hex/bin value or a comma-separated flags string)\n"
" supported flags for rv32imc: zba, zcmp\n"
"\n"
"Implementation specific options:\n", argv[0]
);
@@ -259,6 +259,34 @@ static bool parse_integer(const char *value, mp_uint_t *integer) {
return valid;
}
#if MICROPY_EMIT_NATIVE && MICROPY_EMIT_RV32
static bool parse_rv32_flags_string(const char *source, mp_uint_t *flags) {
assert(source && "Flag arguments string is NULL.");
assert(flags && "Collected flags pointer is NULL.");
const char *current = source;
const char *end = source + strlen(source);
mp_uint_t collected_flags = 0;
while (current < end) {
const char *separator = strchr(current, ',');
if (separator == NULL) {
separator = end;
}
ptrdiff_t length = separator - current;
if (length == (sizeof("zba") - 1) && memcmp(current, "zba", length) == 0) {
collected_flags |= RV32_EXT_ZBA;
} else if (length == (sizeof("zcmp") - 1) && memcmp(current, "zcmp", length) == 0) {
collected_flags |= RV32_EXT_ZCMP;
} else {
return false;
}
current = separator + 1;
}
*flags = collected_flags;
return collected_flags != 0;
}
#endif
MP_NOINLINE int main_(int argc, char **argv) {
pre_process_options(argc, argv);
@@ -412,14 +440,11 @@ MP_NOINLINE int main_(int argc, char **argv) {
if (mp_dynamic_compiler.native_arch == MP_NATIVE_ARCH_RV32IMC) {
mp_dynamic_compiler.backend_options = (void *)&rv32_options;
mp_uint_t raw_flags = 0;
if (parse_integer(arch_flags, &raw_flags)) {
if (parse_integer(arch_flags, &raw_flags) || parse_rv32_flags_string(arch_flags, &raw_flags)) {
if ((raw_flags & ~((mp_uint_t)RV32_EXT_ALL)) == 0) {
rv32_options.allowed_extensions = raw_flags;
processed = true;
}
} else if (strncmp(arch_flags, "zba", sizeof("zba") - 1) == 0) {
rv32_options.allowed_extensions |= RV32_EXT_ZBA;
processed = true;
}
}
#endif

View File

@@ -22,5 +22,8 @@
"vendor": "Espressif",
"variants": {
"SPIRAM_OCT": "Support for Octal-SPIRAM"
},
"old_variants": {
"FLASH_4M": ["4MiB flash", "Use the standard variant instead."]
}
}

View File

@@ -244,7 +244,11 @@ set(MICROPY_TARGET ${COMPONENT_TARGET})
if(CONFIG_IDF_TARGET_ARCH_XTENSA)
set(MICROPY_CROSS_FLAGS -march=xtensawin)
elseif(CONFIG_IDF_TARGET_ARCH_RISCV)
set(MICROPY_CROSS_FLAGS -march=rv32imc)
if (CONFIG_IDF_TARGET_ESP32P4)
set(MICROPY_CROSS_FLAGS "-march=rv32imc -march-flags=zcmp")
else()
set(MICROPY_CROSS_FLAGS -march=rv32imc)
endif()
endif()
# Set compile options for this port.

View File

@@ -166,6 +166,8 @@ static esp_err_t sdcard_ensure_card_init(sdcard_card_obj_t *self, bool force) {
esp_err_t err = sdmmc_card_init(&(self->host), &(self->card));
if (err == ESP_OK) {
// Ensure card's host structure has the correct slot after init
self->card.host.slot = self->host.slot;
self->flags |= SDCARD_CARD_FLAGS_CARD_INIT_DONE;
} else {
self->flags &= ~SDCARD_CARD_FLAGS_CARD_INIT_DONE;
@@ -307,6 +309,7 @@ static mp_obj_t machine_sdcard_make_new(const mp_obj_type_t *type, size_t n_args
else {
sdmmc_host_t _temp_host = SDMMC_HOST_DEFAULT();
_temp_host.max_freq_khz = freq / 1000;
_temp_host.slot = slot_num;
self->host = _temp_host;
}
#endif

View File

@@ -44,6 +44,9 @@
#define MICROPY_EMIT_RV32 (0)
#else
#define MICROPY_EMIT_RV32 (1)
#if CONFIG_IDF_TARGET_ESP32P4
#define MICROPY_EMIT_RV32_ZCMP (1)
#endif
#endif
#else
#define MICROPY_EMIT_XTENSAWIN (1)

View File

@@ -208,20 +208,10 @@ erase:
reset:
echo -e "\r\nimport machine; machine.reset()\r\n" >$(PORT)
ifeq ($(BOARD_VARIANT),OTA)
$(FWBIN): $(BUILD)/firmware.elf
$(ECHO) "Create $@"
$(Q)$(ESPTOOL) elf2image $^
$(Q)$(PYTHON) makeimg.py $(BUILD)/firmware.elf-0x00000.bin $(BUILD)/firmware.elf-0x[0-5][1-f]000.bin $(BUILD)/firmware-ota.bin
$(Q)cat $(YAOTA8266)/yaota8266.bin $(BUILD)/firmware-ota.bin > $@
$(Q)$(PYTHON) $(YAOTA8266)/ota-client/ota_client.py sign $@
else
$(FWBIN): $(BUILD)/firmware.elf
$(ECHO) "Create $@"
$(Q)$(ESPTOOL) elf2image $^
$(Q)$(PYTHON) makeimg.py $(BUILD)/firmware.elf-0x00000.bin $(BUILD)/firmware.elf-0x[0-5][1-f]000.bin $@
endif
$(BUILD)/firmware.elf: $(OBJ)
$(ECHO) "LINK $@"

View File

@@ -15,10 +15,12 @@
"thumbnail": "",
"url": "https://www.espressif.com/en/products/modules",
"variants": {
"OTA": "OTA compatible",
"FLASH_1M": "1MiB flash",
"FLASH_512K": "512kiB flash",
"FLASH_2M_ROMFS": "2MiB flash with ROMFS"
},
"old_variants": {
"OTA": ["OTA compatible", "OTA firmware is no longer supported."]
},
"vendor": "Espressif"
}

View File

@@ -14,13 +14,3 @@ Note: v1.12-334 and newer (including v1.13) require an ESP8266 module with
upgrading from older firmware please backup your files first, and either
erase all flash before upgrading, or after upgrading execute
`vfs.VfsLfs2.mkfs(bdev)`.
### OTA builds
Over-The-Air (OTA) builds of the ESP8266 firmware are also provided.
The first time you use this build you need to flash one of the "initial image"
images using esptool.py as described above. After that, you can update the
firmware over the air using the "OTA update" file in conjunction with the
ota-client script from yaota8266. The "OTA update" files are digitally signed
and will only work with the provided "initial image" files, and vice versa.
(Note: this feature is work-in-progress.)

View File

@@ -1,10 +0,0 @@
LD_FILES = boards/esp8266_ota.ld
MICROPY_PY_ESPNOW ?= 1
MICROPY_PY_BTREE ?= 1
MICROPY_VFS_LFS2 ?= 1
# Note: Implicitly uses the port manifest.
# Configure mpconfigboard.h.
CFLAGS += -DMICROPY_ESP8266_1M

View File

@@ -159,10 +159,6 @@ static mp_obj_t esp_flash_size(void) {
}
static MP_DEFINE_CONST_FUN_OBJ_0(esp_flash_size_obj, esp_flash_size);
// If there's just 1 loadable segment at the start of flash,
// we assume there's a yaota8266 bootloader.
#define IS_OTA_FIRMWARE() ((*(uint32_t *)0x40200000 & 0xff00) == 0x100)
extern byte _firmware_size[];
#if MICROPY_VFS_ROM_IOCTL
extern uint8_t _micropy_hw_romfs_part0_size;
@@ -180,11 +176,6 @@ static MP_DEFINE_CONST_FUN_OBJ_0(esp_flash_user_start_obj, esp_flash_user_start)
static mp_obj_t esp_check_fw(void) {
MD5_CTX ctx;
char *fw_start = (char *)0x40200000;
if (IS_OTA_FIRMWARE()) {
// Skip yaota8266 bootloader
fw_start += 0x3c000;
}
uint32_t size = *(uint32_t *)(fw_start + 0x8ffc);
printf("size: %d\n", size);
if (size > 1024 * 1024) {

View File

@@ -153,7 +153,8 @@ endif
################################################################################
# Project specific settings and compiler/linker flags
QEMU_SYSTEM = qemu-system-$(QEMU_ARCH)
QEMU_BASE ?= qemu-system-
QEMU_SYSTEM = $(QEMU_BASE)$(QEMU_ARCH)
QEMU_ARGS += -machine $(QEMU_MACHINE) -nographic -monitor null -semihosting
QEMU_ARGS += $(QEMU_EXTRA)

View File

@@ -157,6 +157,10 @@ The following options can be specified on the `make` command line:
- `CFLAGS_EXTRA`: pass in extra flags for the compiler.
- `RUN_TESTS_EXTRA`: pass in extra flags for `run-tests.py` and `run-natmodtests.py`
when invoked via `make test` or `make test_natmod`.
- `QEMU_BASE`: pass an optional partial path of the qemu binary to run code with, eg.
`/opt/custom-directory/qemu/bin/qemu-system-`, similar to how a cross compiler name
is passed to the MicroPython makefile. By default it will use the appropriate QEMU
binary found through the system's PATH environment variable.
- `QEMU_DEBUG=1`: when running qemu (via `repl`, `run` or `test` target), qemu
will block until a debugger is connected. By default it waits for a gdb connection
on TCP port 1234.

View File

@@ -487,7 +487,16 @@ list(APPEND MICROPY_SOURCE_QSTR
)
# Define mpy-cross flags
set(MICROPY_CROSS_FLAGS -march=armv6m)
if (${PICO_PLATFORM} STREQUAL "rp2040")
set(MICROPY_CROSS_FLAGS "-march=armv6m")
elseif (${PICO_PLATFORM} STREQUAL "rp2350-arm-s")
set(MICROPY_CROSS_FLAGS "-march=armv7m")
elseif (${PICO_PLATFORM} STREQUAL "rp2350-riscv")
set(MICROPY_CROSS_FLAGS "-march=rv32imc -march-flags=zba,zcmp")
else()
message(WARNING "Unknown PICO_PLATFORM version (${PICO_PLATFORM}), falling back to rp2040")
set(MICROPY_CROSS_FLAGS "-march=armv6m")
endif()
# Set the frozen manifest file
if (MICROPY_USER_FROZEN_MANIFEST)

View File

@@ -110,6 +110,7 @@
#elif PICO_RISCV
#define MICROPY_EMIT_RV32 (1)
#define MICROPY_EMIT_RV32_ZBA (1)
#define MICROPY_EMIT_RV32_ZCMP (1)
#define MICROPY_EMIT_INLINE_RV32 (1)
#endif

View File

@@ -230,6 +230,8 @@ void asm_arm_bx_reg(asm_arm_t *as, uint reg_src);
#define ASM_STORE16_REG_REG_REG(as, reg_val, reg_base, reg_index) asm_arm_strh_reg_reg_reg((as), (reg_val), (reg_base), (reg_index))
#define ASM_STORE32_REG_REG_REG(as, reg_val, reg_base, reg_index) asm_arm_str_reg_reg_reg((as), (reg_val), (reg_base), (reg_index))
#define ASM_CLR_REG(as, reg_dest) asm_arm_eor_reg_reg_reg((as), (reg_dest), (reg_dest), (reg_dest))
#endif // GENERIC_ASM_API
#endif // MICROPY_INCLUDED_PY_ASMARM_H

View File

@@ -53,6 +53,14 @@
((((value) & ~((1U << ((bits) - 1)) - 1)) == 0) || \
(((value) & ~((1U << ((bits) - 1)) - 1)) == ~((1U << ((bits) - 1)) - 1)))
static bool asm_rv32_allow_zba_opcodes(void) {
return asm_rv32_allowed_extensions() & RV32_EXT_ZBA;
}
static bool asm_rv32_allow_zcmp_opcodes(void) {
return asm_rv32_allowed_extensions() & RV32_EXT_ZCMP;
}
///////////////////////////////////////////////////////////////////////////////
void asm_rv32_emit_word_opcode(asm_rv32_t *state, mp_uint_t word) {
@@ -214,6 +222,14 @@ static void adjust_stack(asm_rv32_t *state, mp_int_t stack_size) {
return;
}
// WARNING: If REG_TEMP0 is not set to a caller-saved register, then this
// bit has to be rewritten to avoid clobbering the temporary
// register when performing the stack adjustment.
MP_STATIC_ASSERT(((REG_TEMP0 >= ASM_RV32_REG_T0) && (REG_TEMP0 <= ASM_RV32_REG_T2)) || \
((REG_TEMP0 >= ASM_RV32_REG_A0) && (REG_TEMP0 <= ASM_RV32_REG_A7)) || \
((REG_TEMP0 >= ASM_RV32_REG_T3) && (REG_TEMP0 <= ASM_RV32_REG_T6)));
// li temporary, stack_size
// c.add sp, temporary
load_full_immediate(state, REG_TEMP0, stack_size);
@@ -245,6 +261,45 @@ static void emit_function_epilogue(asm_rv32_t *state, mp_uint_t registers) {
state->saved_registers_mask = old_saved_registers_mask;
}
static mp_uint_t compute_zcmp_sequence_length(mp_uint_t registers) {
// Can only handle RA and S0..S11 and must have at least one entry.
assert((registers != 0) && (registers & (~0x0FFC0302U)) == 0 && "Invalid Zcmp registers set.");
mp_uint_t length = 32 - mp_clz(((registers & 0x00000002) >> 1) | ((registers & 0x00000300) >> 7) | ((registers & 0x0FFC0000) >> 15));
return length == 12 ? 13 : length;
}
#define EMIT_ASSERT(state, condition, message) assert((((state)->base.pass != MP_ASM_PASS_EMIT) ? true : (condition)) && (message))
static void emit_compressed_function_prologue(asm_rv32_t *state, mp_uint_t registers_mask) {
mp_uint_t sequence_length = compute_zcmp_sequence_length(registers_mask);
mp_uint_t allocated_stack = (sequence_length + 3) & (mp_uint_t)-4;
EMIT_ASSERT(state, allocated_stack >= sequence_length, "Incorrect allocated stack calculation.");
mp_uint_t tail_slack = allocated_stack - sequence_length;
mp_uint_t locals_left = (state->locals_count < tail_slack) ? 0 : (state->locals_count - tail_slack);
mp_uint_t adjustment_chunks = MIN(3, locals_left / 4);
EMIT_ASSERT(state, (adjustment_chunks * 4) <= locals_left, "Incorrect adjustment chunks rounding.");
locals_left -= adjustment_chunks * 4;
EMIT_ASSERT(state, locals_left <= (MP_INT_MAX / sizeof(uint32_t)), "Too many locals.");
mp_int_t stack_size = (mp_int_t)(locals_left * sizeof(uint32_t));
asm_rv32_opcode_cmpush(state, MIN(3 + sequence_length, 15), adjustment_chunks);
// CM.PUSH allocates a stack block and then puts the registers *at the end*
// of the block, so for example "CM.PUSH {RA, S0-S11}, -64" will put RA at
// SP + 60, not at SP + 0.
adjust_stack(state, -stack_size);
// The stack size is expressed in bytes and as a multiple of 4, hence the
// bottom two bits are not used. Since there can be up to three adjustment
// chunks, that number can be expressed in two bits, fitting nicely in the
// existing variable.
state->stack_size = ((mp_uint_t)stack_size) | adjustment_chunks;
}
static void emit_compressed_function_epilogue(asm_rv32_t *state, mp_uint_t registers_mask) {
mp_uint_t sequence_length = compute_zcmp_sequence_length(registers_mask);
mp_uint_t stack_size = state->stack_size & (mp_uint_t)(~0x03U);
adjust_stack(state, stack_size);
asm_rv32_opcode_cmpopret(state, MIN(3 + sequence_length, 15), state->stack_size & 0x03);
}
static bool calculate_displacement_for_label(asm_rv32_t *state, mp_uint_t label, ptrdiff_t *displacement) {
assert(displacement != NULL && "Displacement pointer is NULL");
@@ -256,16 +311,24 @@ static bool calculate_displacement_for_label(asm_rv32_t *state, mp_uint_t label,
///////////////////////////////////////////////////////////////////////////////
void asm_rv32_entry(asm_rv32_t *state, mp_uint_t locals) {
state->locals_count = locals;
state->saved_registers_mask |= (1U << REG_FUN_TABLE) | (1U << REG_LOCAL_1) | \
(1U << REG_LOCAL_2) | (1U << REG_LOCAL_3);
state->locals_count = locals;
emit_function_prologue(state, state->saved_registers_mask);
if (asm_rv32_allow_zcmp_opcodes()) {
emit_compressed_function_prologue(state, state->saved_registers_mask);
} else {
emit_function_prologue(state, state->saved_registers_mask);
}
}
void asm_rv32_exit(asm_rv32_t *state) {
emit_function_epilogue(state, state->saved_registers_mask);
// c.jr ra
asm_rv32_opcode_cjr(state, ASM_RV32_REG_RA);
if (asm_rv32_allow_zcmp_opcodes()) {
emit_compressed_function_epilogue(state, state->saved_registers_mask);
} else {
emit_function_epilogue(state, state->saved_registers_mask);
// c.jr ra
asm_rv32_opcode_cjr(state, ASM_RV32_REG_RA);
}
}
void asm_rv32_end_pass(asm_rv32_t *state) {
@@ -557,10 +620,6 @@ void asm_rv32_emit_optimised_xor(asm_rv32_t *state, mp_uint_t rd, mp_uint_t rs)
asm_rv32_opcode_xor(state, rd, rd, rs);
}
static bool asm_rv32_allow_zba_opcodes(void) {
return asm_rv32_allowed_extensions() & RV32_EXT_ZBA;
}
static void asm_rv32_fix_up_scaled_reg_reg_reg(asm_rv32_t *state, mp_uint_t rs1, mp_uint_t rs2, mp_uint_t operation_size) {
assert(operation_size <= 2 && "Operation size value out of range.");

View File

@@ -125,8 +125,9 @@ typedef struct _asm_rv32_t {
enum {
RV32_EXT_NONE = 0,
RV32_EXT_ZBA = 1 << 0,
RV32_EXT_ZCMP = 1 << 1,
RV32_EXT_ALL = RV32_EXT_ZBA
RV32_EXT_ALL = RV32_EXT_ZBA | RV32_EXT_ZCMP
};
typedef struct _asm_rv32_backend_options_t {
@@ -196,6 +197,10 @@ void asm_rv32_end_pass(asm_rv32_t *state);
((rs & 0x07) << 7) | ((imm & 0x40) >> 1) | ((imm & 0x38) << 7) | \
((imm & 0x04) << 4))
#define RV32_ENCODE_TYPE_CMPP(op, ft6, ft2, rlist, imm) \
((op & 0x03) | ((ft6 & 0x3F) << 10) | ((ft2 & 0x03) << 8) | \
((rlist & 0x0F) << 4) | ((imm & 0x03) << 2))
#define RV32_ENCODE_TYPE_CR(op, ft4, rs1, rs2) \
((op & 0x03) | ((rs2 & 0x1F) << 2) | ((rs1 & 0x1F) << 7) | ((ft4 & 0x0F) << 12))
@@ -439,6 +444,18 @@ static inline void asm_rv32_opcode_cxor(asm_rv32_t *state, mp_uint_t rd, mp_uint
asm_rv32_emit_halfword_opcode(state, RV32_ENCODE_TYPE_CA(0x01, 0x23, 0x01, rd, rs));
}
// CM.POPRET {REG_LIST}, IMMEDIATE
static inline void asm_rv32_opcode_cmpopret(asm_rv32_t *state, mp_uint_t reg_list, mp_uint_t immediate) {
// CMPP: 10111110 ... .. 10
asm_rv32_emit_halfword_opcode(state, RV32_ENCODE_TYPE_CMPP(0x02, 0x2F, 0x02, reg_list, immediate));
}
// CM.PUSH {REG_LIST}, -IMMEDIATE
static inline void asm_rv32_opcode_cmpush(asm_rv32_t *state, mp_uint_t reg_list, mp_uint_t immediate) {
// CMPP: 10111000 .... .. 10
asm_rv32_emit_halfword_opcode(state, RV32_ENCODE_TYPE_CMPP(0x02, 0x2E, 0x00, reg_list, immediate));
}
// CSRRC RD, RS, IMMEDIATE
static inline void asm_rv32_opcode_csrrc(asm_rv32_t *state, mp_uint_t rd, mp_uint_t rs, mp_int_t immediate) {
// I: ............ ..... 011 ..... 1110011
@@ -710,7 +727,8 @@ static inline void asm_rv32_opcode_xori(asm_rv32_t *state, mp_uint_t rd, mp_uint
}
#define MICROPY_RV32_EXTENSIONS \
(MICROPY_EMIT_RV32_ZBA ? RV32_EXT_ZBA : 0)
((MICROPY_EMIT_RV32_ZBA ? RV32_EXT_ZBA : 0) | \
(MICROPY_EMIT_RV32_ZCMP ? RV32_EXT_ZCMP : 0))
static inline uint8_t asm_rv32_allowed_extensions(void) {
uint8_t extensions = MICROPY_RV32_EXTENSIONS;
@@ -735,8 +753,8 @@ static inline uint8_t asm_rv32_allowed_extensions(void) {
#define REG_TEMP2 ASM_RV32_REG_T3
#define REG_FUN_TABLE ASM_RV32_REG_S1
#define REG_LOCAL_1 ASM_RV32_REG_S3
#define REG_LOCAL_2 ASM_RV32_REG_S4
#define REG_LOCAL_3 ASM_RV32_REG_S5
#define REG_LOCAL_2 ASM_RV32_REG_S2
#define REG_LOCAL_3 ASM_RV32_REG_S4
#define REG_ZERO ASM_RV32_REG_ZERO
void asm_rv32_meta_comparison_eq(asm_rv32_t *state, mp_uint_t rs1, mp_uint_t rs2, mp_uint_t rd);
@@ -804,7 +822,7 @@ void asm_rv32_emit_store_reg_reg_offset(asm_rv32_t *state, mp_uint_t source, mp_
#define ASM_STORE32_REG_REG_OFFSET(state, rd, rs, offset) asm_rv32_emit_store_reg_reg_offset(state, rd, rs, offset, 2)
#define ASM_SUB_REG_REG(state, rd, rs) asm_rv32_opcode_sub(state, rd, rd, rs)
#define ASM_XOR_REG_REG(state, rd, rs) asm_rv32_emit_optimised_xor(state, rd, rs)
#define ASM_CLR_REG(state, rd)
#define ASM_CLR_REG(state, rd) asm_rv32_emit_optimised_xor(state, rd, rd)
#define ASM_LOAD8_REG_REG_REG(state, rd, rs1, rs2) asm_rv32_emit_load_reg_reg_reg(state, rd, rs1, rs2, 0)
#define ASM_LOAD16_REG_REG_REG(state, rd, rs1, rs2) asm_rv32_emit_load_reg_reg_reg(state, rd, rs1, rs2, 1)
#define ASM_LOAD32_REG_REG_REG(state, rd, rs1, rs2) asm_rv32_emit_load_reg_reg_reg(state, rd, rs1, rs2, 2)

View File

@@ -485,6 +485,8 @@ void asm_thumb_b_rel12(asm_thumb_t *as, int rel);
asm_thumb_str_rlo_rlo_rlo((as), (reg_val), (reg_base), (reg_index)); \
} while (0)
#define ASM_CLR_REG(as, reg_dest) asm_thumb_mov_rlo_i8((as), (reg_dest), 0)
#endif // GENERIC_ASM_API
#endif // MICROPY_INCLUDED_PY_ASMTHUMB_H

View File

@@ -221,6 +221,8 @@ void asm_x64_call_ind(asm_x64_t *as, size_t fun_id, int temp_r32);
#define ASM_STORE32_REG_REG(as, reg_src, reg_base) ASM_STORE32_REG_REG_OFFSET((as), (reg_src), (reg_base), 0)
#define ASM_STORE32_REG_REG_OFFSET(as, reg_src, reg_base, dword_offset) asm_x64_mov_r32_to_mem32((as), (reg_src), (reg_base), 4 * (dword_offset))
#define ASM_CLR_REG(as, reg_dest) asm_x64_xor_r64_r64((as), (reg_dest), (reg_dest))
#endif // GENERIC_ASM_API
#endif // MICROPY_INCLUDED_PY_ASMX64_H

View File

@@ -216,6 +216,8 @@ void asm_x86_call_ind(asm_x86_t *as, size_t fun_id, mp_uint_t n_args, int temp_r
#define ASM_STORE32_REG_REG(as, reg_src, reg_base) ASM_STORE32_REG_REG_OFFSET((as), (reg_src), (reg_base), 0)
#define ASM_STORE32_REG_REG_OFFSET(as, reg_src, reg_base, dword_offset) asm_x86_mov_r32_to_mem32((as), (reg_src), (reg_base), 4 * (dword_offset))
#define ASM_CLR_REG(as, reg_dest) asm_x86_xor_r32_r32((as), (reg_dest), (reg_dest))
#endif // GENERIC_ASM_API
#endif // MICROPY_INCLUDED_PY_ASMX86_H

View File

@@ -464,6 +464,8 @@ void asm_xtensa_l32r(asm_xtensa_t *as, mp_uint_t reg, mp_uint_t label);
asm_xtensa_op_s32i_n((as), (reg_val), (reg_base), 0); \
} while (0)
#define ASM_CLR_REG(as, reg_dest) asm_xtensa_op_movi_n((as), (reg_dest), 0)
#endif // GENERIC_ASM_API
#endif // MICROPY_INCLUDED_PY_ASMXTENSA_H

View File

@@ -282,17 +282,13 @@ struct _emit_t {
ASM_T *as;
};
#ifndef REG_ZERO
#define REG_ZERO REG_TEMP0
#define ASM_CLR_REG(state, rd) ASM_XOR_REG_REG(state, rd, rd)
#endif
#if N_RV32
#ifdef REG_ZERO
#define ASM_MOV_LOCAL_MP_OBJ_NULL(as, local_num, reg_temp) \
ASM_MOV_LOCAL_REG(as, local_num, REG_ZERO)
#else
#define REG_ZERO REG_TEMP0
#define ASM_MOV_LOCAL_MP_OBJ_NULL(as, local_num, reg_temp) \
ASM_MOV_REG_IMM(as, reg_temp, (mp_uint_t)MP_OBJ_NULL); \
ASM_CLR_REG(as, reg_temp); \
ASM_MOV_LOCAL_REG(as, local_num, reg_temp)
#endif
@@ -1145,7 +1141,7 @@ static void emit_native_leave_exc_stack(emit_t *emit, bool start_of_handler) {
// Optimisation: PC is already cleared by global exc handler
return;
}
ASM_XOR_REG_REG(emit->as, REG_RET, REG_RET);
ASM_CLR_REG(emit->as, REG_RET);
} else {
// Found new active handler, get its PC
ASM_MOV_REG_PCREL(emit->as, REG_RET, e->label);
@@ -1242,8 +1238,7 @@ static void emit_native_global_exc_entry(emit_t *emit) {
ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, start_label, true);
} else {
// Clear the unwind state
ASM_CLR_REG(emit->as, REG_ZERO);
ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_HANDLER_UNWIND(emit), REG_ZERO);
ASM_MOV_LOCAL_MP_OBJ_NULL(emit->as, LOCAL_IDX_EXC_HANDLER_UNWIND(emit), REG_ZERO);
// clear nlr.ret_val, because it's passed to mp_native_raise regardless
// of whether there was an exception or not
@@ -1263,8 +1258,7 @@ static void emit_native_global_exc_entry(emit_t *emit) {
ASM_JUMP_IF_REG_NONZERO(emit->as, REG_RET, global_except_label, true);
// Clear PC of current code block, and jump there to resume execution
ASM_CLR_REG(emit->as, REG_ZERO);
ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_HANDLER_PC(emit), REG_ZERO);
ASM_MOV_LOCAL_MP_OBJ_NULL(emit->as, LOCAL_IDX_EXC_HANDLER_PC(emit), REG_ZERO);
ASM_JUMP_REG(emit->as, REG_LOCAL_1);
// Global exception handler: check for valid exception handler
@@ -1945,7 +1939,7 @@ static void emit_native_delete_attr(emit_t *emit, qstr qst) {
vtype_kind_t vtype_base;
emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = base
assert(vtype_base == VTYPE_PYOBJ);
ASM_XOR_REG_REG(emit->as, REG_ARG_3, REG_ARG_3); // arg3 = value (null for delete)
ASM_CLR_REG(emit->as, REG_ARG_3); // arg3 = value (null for delete)
emit_call_with_qstr_arg(emit, MP_F_STORE_ATTR, qst, REG_ARG_2); // arg2 = attribute name
emit_post(emit);
}
@@ -2091,7 +2085,7 @@ static void emit_native_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t exc
// No finally, handle the jump ourselves
// First, restore the exception handler address for the jump
if (e < emit->exc_stack) {
ASM_XOR_REG_REG(emit->as, REG_RET, REG_RET);
ASM_CLR_REG(emit->as, REG_RET);
} else {
ASM_MOV_REG_PCREL(emit->as, REG_RET, e->label);
}

View File

@@ -271,6 +271,9 @@ static void asm_debug_setcc_reg_reg_reg(asm_debug_t *as, int op, int reg1, int r
#define ASM_STORE32_REG_REG(as, reg_src, reg_base) \
asm_debug_reg_reg(as, "store32", reg_src, reg_base)
#define ASM_CLR_REG(as, reg_dest) \
asm_debug_reg(as, "clr", reg_dest)
// Word indices of REG_LOCAL_x in nlr_buf_t
#define NLR_BUF_IDX_LOCAL_1 (5) // rbx

View File

@@ -411,11 +411,6 @@ static inline uint32_t mp_ctz(uint32_t x) {
return _BitScanForward(&tz, x) ? tz : 0;
}
// Workaround for 'warning C4127: conditional expression is constant'.
static inline bool mp_check(bool value) {
return value;
}
static inline uint32_t mp_popcount(uint32_t x) {
return __popcnt(x);
}
@@ -424,7 +419,6 @@ static inline uint32_t mp_popcount(uint32_t x) {
#define mp_clzl(x) __builtin_clzl(x)
#define mp_clzll(x) __builtin_clzll(x)
#define mp_ctz(x) __builtin_ctz(x)
#define mp_check(x) (x)
#if __has_builtin(__builtin_popcount)
#define mp_popcount(x) __builtin_popcount(x)
#else

View File

@@ -39,9 +39,9 @@
// as well as a fallback to generate MICROPY_GIT_TAG if the git repo or tags
// are unavailable.
#define MICROPY_VERSION_MAJOR 1
#define MICROPY_VERSION_MINOR 27
#define MICROPY_VERSION_MINOR 28
#define MICROPY_VERSION_MICRO 0
#define MICROPY_VERSION_PRERELEASE 0
#define MICROPY_VERSION_PRERELEASE 1
// Combined version as a 32-bit number for convenience to allow version
// comparison. Doesn't include prerelease state.
@@ -507,6 +507,11 @@ typedef uint64_t mp_uint_t;
#define MICROPY_EMIT_RV32_ZBA (0)
#endif
// Whether to emit RISC-V RV32 Zcmp opcodes in native code
#ifndef MICROPY_EMIT_RV32_ZCMP
#define MICROPY_EMIT_RV32_ZCMP (0)
#endif
// Whether to enable the RISC-V RV32 inline assembler
#ifndef MICROPY_EMIT_INLINE_RV32
#define MICROPY_EMIT_INLINE_RV32 (0)

View File

@@ -79,3 +79,14 @@ print(
# Raw f-strings.
print(rf"\r\a\w {'f'} \s\t\r\i\n\g")
print(fr"\r{x}")
# Format specifiers with nested replacement fields
space = 5
prec = 2
print(f"{3.14:{space}.{prec}}")
space_prec = "5.2"
print(f"{3.14:{space_prec}}")
radix = "x"
print(f"{314:{radix}}")

View File

@@ -19,6 +19,8 @@ if "alif" in sys.platform:
bit_margin = 1
elif "esp32" in sys.platform:
timing_margin_us = 400
elif "esp8266" in sys.platform:
timing_margin_us = 4100
elif "mimxrt" in sys.platform:
initial_delay_ms = 20 # UART sends idle frame after init, so wait for that
bit_margin = 1

View File

@@ -46,12 +46,16 @@ class RAMBlockDevice:
try:
bdev = RAMBlockDevice(50)
except MemoryError:
print("SKIP")
print("SKIP-TOO-LARGE")
raise SystemExit
def test(vfs_class):
print(vfs_class)
ERROR_EIO = (OSError, "[Errno 5] EIO")
ERROR_EINVAL = (OSError, "[Errno 22] EINVAL")
ERROR_TYPE = (TypeError, "can't convert str to int")
def test(vfs_class, test_data):
bdev.read_res = 0 # reset function results
bdev.write_res = 0
@@ -61,17 +65,15 @@ def test(vfs_class):
with fs.open("test", "w") as f:
f.write("a" * 64)
for res in (0, -5, 5, 33, "invalid"):
# -5 is a legitimate negative failure (EIO), positive integer
# is not
for res, error_open, error_read in test_data:
# This variant will fail on open
bdev.read_res = res
try:
with fs.open("test", "r") as f:
print("opened")
assert error_open is None
except Exception as e:
print(type(e), e)
assert error_open is not None
assert (type(e), str(e)) == error_open
# This variant should succeed on open, may fail on read
# unless the filesystem cached the contents already
@@ -79,11 +81,35 @@ def test(vfs_class):
try:
with fs.open("test", "r") as f:
bdev.read_res = res
print("read 1", f.read(1))
print("read rest", f.read())
assert f.read(1) == "a"
assert f.read() == "a" * 63
assert error_read is None
except Exception as e:
print(type(e), e)
assert error_read is not None
assert (type(e), str(e)) == error_read
test(vfs.VfsLfs2)
test(vfs.VfsFat)
try:
test(
vfs.VfsLfs2,
(
(0, None, None),
(-5, ERROR_EIO, None),
(5, ERROR_EINVAL, None),
(33, ERROR_EINVAL, None),
("invalid", ERROR_TYPE, None),
),
)
test(
vfs.VfsFat,
(
(0, None, None),
(-5, ERROR_EIO, ERROR_EIO),
(5, ERROR_EIO, ERROR_EIO),
(33, ERROR_EIO, ERROR_EIO),
("invalid", ERROR_TYPE, ERROR_TYPE),
),
)
print("OK")
except MemoryError:
print("SKIP-TOO-LARGE")

View File

@@ -1,28 +1 @@
<class 'VfsLfs2'>
opened
read 1 a
read rest aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<class 'OSError'> [Errno 5] EIO
read 1 a
read rest aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<class 'OSError'> [Errno 22] EINVAL
read 1 a
read rest aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<class 'OSError'> [Errno 22] EINVAL
read 1 a
read rest aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<class 'TypeError'> can't convert str to int
read 1 a
read rest aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<class 'VfsFat'>
opened
read 1 a
read rest aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<class 'OSError'> [Errno 5] EIO
<class 'OSError'> [Errno 5] EIO
<class 'OSError'> [Errno 5] EIO
<class 'OSError'> [Errno 5] EIO
<class 'OSError'> [Errno 5] EIO
<class 'OSError'> [Errno 5] EIO
<class 'TypeError'> can't convert str to int
<class 'TypeError'> can't convert str to int
OK

View File

@@ -1,3 +1,5 @@
# This tests checks the behaviour of the `check_esp_err`/`check_esp_err_` C function.
try:
from esp32 import Partition as p
import micropython
@@ -23,6 +25,7 @@ except OSError as e:
# same but with out of memory condition by locking the heap
exc = "FAILED TO RAISE"
e = None # preallocate entry in globals dict
micropython.heap_lock()
try:
fun(part)
@@ -34,6 +37,7 @@ print("exc:", exc) # exc empty due to no memory
# same again but having an emergency buffer
micropython.alloc_emergency_exception_buf(256)
exc = "FAILED TO RAISE"
e = None # preallocate entry in globals dict
micropython.heap_lock()
try:
fun(part)

View File

@@ -22,7 +22,10 @@ TEST_TIMEOUT = float(os.environ.get("MICROPY_TEST_TIMEOUT", 30))
# are guaranteed to always work, this one should though.
BASEPATH = os.path.dirname(os.path.abspath(inspect.getsourcefile(lambda: None)))
RV32_ARCH_FLAGS = {"zba": 1 << 0}
RV32_ARCH_FLAGS = {
"zba": 1 << 0,
"zcmp": 1 << 1,
}
def base_path(*p):
@@ -180,6 +183,9 @@ emitter_tests_to_skip = {
# Tests to skip on specific targets.
# These are tests that are difficult to detect that they should not be run on the given target.
platform_tests_to_skip = {
"esp8266": (
"stress/list_sort.py", # watchdog kicks in because it takes too long
),
"minimal": (
"basics/class_inplace_op.py", # all special methods not supported
"basics/subclass_native_init.py", # native subclassing corner cases not support
@@ -947,10 +953,15 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
skip_tests.add("inlineasm/thumb/asmfpsqrt.py")
if args.inlineasm_arch == "rv32":
# Check if @micropython.asm_rv32 supports Zba instructions, and skip such tests if it doesn't
output = run_feature_check(pyb, args, "inlineasm_rv32_zba.py")
if output != b"rv32_zba\n":
skip_tests.add("inlineasm/rv32/asmzba.py")
# Discover extension-specific inlineasm tests and add them to the
# list of tests to run if applicable.
for extension in RV32_ARCH_FLAGS:
try:
output = run_feature_check(pyb, args, "inlineasm_rv32_{}.py".format(extension))
if output.strip() != "rv32_{}".format(extension).encode():
skip_tests.add("inlineasm/rv32/asm_ext_{}.py".format(extension))
except FileNotFoundError:
pass
# Check if emacs repl is supported, and skip such tests if it's not
t = run_feature_check(pyb, args, "repl_emacs_check.py")

View File

@@ -0,0 +1,7 @@
# Target wiring for general esp8266 board.
#
# Connect:
# - GPIO4 to GPIO5
uart_loopback_args = (1,)
uart_loopback_kwargs = {}