Skip to content

Test Update#14

Open
maxpromer wants to merge 5898 commits intomicroBlock-IDE:masterfrom
micropython:master
Open

Test Update#14
maxpromer wants to merge 5898 commits intomicroBlock-IDE:masterfrom
micropython:master

Conversation

@maxpromer
Copy link
Member

No description provided.

@iPAS
Copy link

iPAS commented Aug 22, 2024

The current version (before the incoming merge) has a bug while trying to compile ports/unix.
I guess this is because of this repo is lacking behind the original which has changed the directory name from 'lib' -> 'extmod', so that AXTLS library includes a file from the wrong path.

I have to edit the code of the AXTLS library:

-------------------------- ssl/os_port_micropython.h --------------------------
index 88697f2..7d10cd9 100644
@@ -75,7 +75,7 @@ extern int mp_stream_errno;

#define TTY_FLUSH()

-#include "../../../extmod/crypto-algorithms/sha256.h"
+#include "../../../lib/crypto-algorithms/sha256.h"

#define SHA256_CTX CRYAL_SHA256_CTX
#define SHA256_Init(a) sha256_init(a)

dpgeorge and others added 29 commits November 29, 2025 23:35
Break the FS and HS initialization routines out into separate functions,
and call them as necessary from the TinyUSB or STM USB helper functions.

Signed-off-by: Damien George <damien@micropython.org>
This commit fixes the initialization sequence for TinyUSB when enabled on
the stm32 port:

- Following other ports, `mp_usbd_init()` should be called just after
  running `boot.py`, to give the user a chance to configure USB.

- Hardware initialization (via `pyb_usbd_init()`) should only occur once,
  the first time TinyUSB is started up.  This is achieved by adding a hook
  to the shared TinyUSB bindings to call `pyb_usbd_init()`, and only do the
  hardware init if TinyUSB was not already initialized.

Also, `pyb_usbd_init()` is renamed `mp_usbd_ll_init()` to make it match
with the rest of the stared TinyUSB binding code.

Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Some boards (eg NUCLEO_G0B1RE and NUCLEO_G474RE) have USB disabled but
still configure MICROPY_HW_USB_FS/HS for the cases where USB does get
enabled.  Such a configuration should not build any of the code in
`usbd_conf.c`, nor the USB interrupt handlers.

Signed-off-by: Damien George <damien@micropython.org>
This is needed to build Cortex-M55 (STM32N6) based boards.

Signed-off-by: Damien George <damien@micropython.org>
Currently the CI for stm32 only tests building about half of the available
MCU families.  This commit adds the remaining families to the stm32 CI
jobs.

Signed-off-by: Damien George <damien@micropython.org>
As per 4c9ce82 the tests now target Python
3.8 syntax and features, so update the ruff configuration to match.

Changes in this commit:
- Update to Python 3.8 syntax.
- Ignore import not at top of module warnings.
- Exclude common SDK folders.
- Exclude cpydiff test with intentional error.

Also see: micropython/micropython-lib#1059

Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
TinyUSB defines TUD_OPT_RHPORT which is the same thing, make
shorter definition RHPORT in the two files which use it.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
(and a smaller binary size as a result)

Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit adds support for ESP32-P4 SoCs.

Signed-off-by: Vincent1-python <pywei201209@163.com>
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Signed-off-by: Damien George <damien@micropython.org>
Includes a base variant with LAN, and C5_WIFI and C6_WIFI variants with
LAN, WiFi and BLE.

And builds this board in the esp32 CI, to cover the P4 support.

Signed-off-by: Vincent1-python <pywei201209@163.com>
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Signed-off-by: Damien George <damien@micropython.org>
This was necessary to un-wedge the USJ TX path on ESP32-P4, I think because
the bootloader prints a lot on this chip. I think it might be possible to
hit it on other chips, though.

The implementation is based on the ESP-IDF driver, which will always add an
extra flush when the TXFIFO is empty in case the host is expecting a ZLP.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
Eventually this cache flushing mechanism should be generalised to work the
same way for all architectures.  But for now, this allows ESP32 RV32 SoCs
to flush the D-cache whenn needed.

Signed-off-by: Damien George <damien@micropython.org>
This is necessary to get native code running on the ESP32-P4.

Signed-off-by: Damien George <damien@micropython.org>
Add support for the upcoming Soldered NULA Mini ESP32C6 board by Soldered
Electronics.

Signed-off-by: Josip Šimun Kuči <josipsimunkuci@gmail.com>
This adds an ANSI-rendered pinout for the WeAct Studio RP2350B Core board.

Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
Add a #if MICROPY_PY_MACHINE_I2S guard around the call to
machine_i2s_init0() in ports/rp2/main.c. This matches the existing
guard around machine_i2s_deinit_all() in the same function.

Signed-off-by: David Lechner <david@pybricks.com>
A follow up to 40df953 / PR #17692, this
commit adds the HSTX alternate pin function for GPIO12-19 on the RP2350.

Signed-off-by: Dryw Wade <dryw.wade@sparkfun.com>
Clears the control registers and aborts the closed channel upon a call to
`.close()` and `.__del__()` (GC collect).

Fixes issue #18446.

Signed-off-by: Dryw Wade <dryw.wade@sparkfun.com>
On RP2350B where there are more than 32 pins, using
`pio_sm_set_pins_with_mask()` and `pio_sm_set_pindirs_with_mask()` is not
correct because their arguments are `uint32_t` and higher bits get lost
when `pio.gpio_base(16)` is used.

This commit fixes the issue by using the 64-bit API functions on RP2350B.
It also makes sure pin wrapping is supported, i.e. using [30, 31, 0, 1] or
[46, 47, 16, 17] as contiguous pin ranges for a PIO program.

Fixes issue #16199.

Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
This fixes a regression introduced by PR #17926 / commit
b5fcb33 which accidentally disabled
`hashlib.sha1` and the `cryptolib` module on rp2 boards that don't have
networking enabled, eg RPI_PICO.

`hashlib.md5` is enabled to keep the configuration the same as boards that
do have networking enabled.

Signed-off-by: Damien George <damien@micropython.org>
These recently added boards had copy-paste image names,
change them to match the images pending addition to
micropython-media.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
Add variants to the new ESP32_GENERIC_P4 board, so they appear on the
download page.

Signed-off-by: Damien George <damien@micropython.org>
- Reverts the change from ec527a1 - since later change cccac2c we
  no longer exit CMake early to get the submodule list, so it's OK
  to run component manager during this phase.

- Fixes issue where "make submodules BOARD=ESP32_GENERIC_S3" (or any other
  board that depends on USB) would fail due to missing component(s).

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
As noted in discussion on PR #18263, the id parameter is optional on ports
that support virtual timers.

Add some more general explanation of hardware vs virtual timers, and remove
redundant documentation about timer callbacks in favour of the isr_rules
page.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
The destination directory for the firmware built by `autobuild.sh` is
currently hard-coded to `/tmp/autobuild-firmware-$$`.  Now that there are
many boards built by this script, the `/tmp` partition can run out of
space.

This commit makes the destination directory configurable via the
`MICROPY_AUTOBUILD_DEST` environment variable.

Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
The existing `serial_test.py` script tests data in/out throughput and
reliability.  But it only tests data sizes that are a power of two, which
may not catch certain errors with USB transmission (because FS packet size
is 64 bytes).

This commit adds a new echo sub-test to the `serial_test.py` script.  It
sends out data to the target and gets the target to echo it back, and then
compares the result (the echo'd data should be equal to the sent data).  It
does this for data packets between 1 and 520 (inclusive) bytes, which
covers USB FS and HS packet sizes (64 and 512 respectively).

It uses random data for the test, but seeded by a constant seed so that
it's deterministic.  If there's an error then it prints out all the sent
and echo'd data to make it easier to see where it went wrong (eg if the
previous packet was repeated).

Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
tompropst and others added 30 commits February 23, 2026 13:12
- `timer.c`
  - `TIM_ENTRY(7, ...)` sets IRQ based on specific STM32G4 part
- `system_stm32.c`
  - Support parts without external clock
- `boards/NUCLEO_G474RE/mpconfigboard.h`
  - Explicitly enable `MICROPY_HW_RTC_USE_LSE`

Signed-off-by: Thomas Propst <tom.propst@gmail.com>
The webassembly port does not have anything that needs polling when waiting
for events, so it can just use the default (empty) definitions of
`MICROPY_INTERNAL_WFE` and `MICROPY_INTERNAL_EVENT_HOOK`.

Signed-off-by: Damien George <damien@micropython.org>
The `builtins.help` function is automatically included when
`MICROPY_PY_BUILTINS_HELP` is enabled, which is true for this port.

The `builtins.open` function is automatically included when
`MICROPY_PY_IO` is enabled, which is true when `MICROPY_VFS` is enabled on
this port.  If `MICROPY_MBFS` is enabled instead of the VFS then `open`
must be explicitly provided.

Tested on:
- ARDUINO_NANO_33_BLE_SENSE: now has only a single `help` and `open`
- MICROBIT: now has only a single `help` and `open`
- MICROBIT with MICROPY_MBFS enabled: `help` and `open` both still exist
  and `open` works with mbfs

Signed-off-by: Damien George <damien@micropython.org>
The function does nothing so it's better that it doesn't exist at all.

Signed-off-by: Damien George <damien@micropython.org>
The function does nothing so it's better that it doesn't exist at all.

Signed-off-by: Damien George <damien@micropython.org>
It's already provided because `MICROPY_PY_IO` is enabled.

Tested on `bbc_microbit_v2`, there is now only a single open.

Signed-off-by: Damien George <damien@micropython.org>
Fixes a build issue on newer Zephyr versions.

Signed-off-by: Antonio Galea <antonio.galea@gmail.com>
The Pololu Zumo 2040 Robot is supported in pico-sdk now so we should not
include the header file here anymore, similarly to other boards.  This is
necessary for future changes from the SDK to be reflected in MicroPython
builds.

Signed-off-by: Paul Grayson <paul@pololu.com>
Replace the custom rosc_random_u8()/rosc_random_u32() implementation with
the pico_rand API from the Pico SDK. The RP2040 datasheet notes that ROSC
"does not meet the requirements of randomness for security systems because
it can be compromised", and the current 8-bit LFSR conditioning is not a
vetted algorithm under NIST SP 800-90B.

pico_rand uses various hardware RNG sources depending on the available
platform (including the RP2350 hardware TRNG) and is officially supported
and maintained as part of the Pico SDK.

This changes os.urandom(), the mbedTLS entropy source, the PRNG seed, and
the lwIP random function to all use pico_rand, and removes the custom ROSC
random functions from main.c.

Signed-off-by: Michel Le Bihan <michel@lebihan.pl>
When the timeout parameter of `esp32.RMT.wait_done()` is set to a non-zero
value, the underlying `rmt_tx_wait_all_done` blocks (it passes the timeout
to `xQueueReceive`).  Thus we should release the GIL so that other
MicroPython threads are not blocked from running.

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
This commit lets the native emitter preserve the value of the index
register when performing register-indexed loads or stores of halfword or
word values on Thumb.

The original code was optimised too aggressively for a register-starved
architecture like Thumb, and the index value in the sequence to generate
was assumed to be allocated somewhere safe.  This is valid on other
architectures, but not on Thumb.

To solve this, load operations do clobber a temporary register that
should be safe to use, REG_TEMP2, to store the scaled register offset.
REG_TEMP2's value is only used within the scope of a single ASM API
instruction.  Save operations unfortunately use a register that is
aliased to REG_TEMP2, since they need to have three values in registers
to perform the operation.  This means the index register needs to be
pushed to the stack before performing the scale + store operation, and
then popped from the stack.  That's a 4 bytes penalty on each store and
a minor speed hit on generated code (plus a minor footprint increase of
the firmware image).

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit lets the native emitter preserve the value of the index
register when performing register-indexed loads or stores for halfword
or word values on RV32.

The original code was optimised too aggressively to reduce the generated
code's size, using compressed opcodes that alias the target register to
one of the operands.  In register-indexed load/store operations, the
index register was assumed to be allocated somewhere safe, but it was
not always the case.

To solve this, now all halfword and word register-indexed operations
will use REG_TEMP2 to store the scaled index register.  The size penalty
on generated code varies across operation sizes and enabled extensions:

- byte operations stay the same size with or without Zba
- halfword operations will be 2 bytes larger without Zba, and will stay
  the same size with Zba
- word operations will be 4 bytes larger without Zba, and 2 bytes larger
  with Zba

There is also a minor firmware footprint increase to hold the extra
logic needed for conditional register clobbering, but it shouldn't be
that large anyway.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit introduces a test that should check whether viper load or
store operations won't clobber either the buffer address or the index
value being used.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Call `mp_event_handle_nowait()` in the VFS reader buffer refill path so
that pending scheduled events (USB task, network poll, etc.) get processed
during long-running import/parse/compile operations.

Without this, importing a large Python module from the filesystem blocks
for too long causing TinyUSB event queue to overflow.  For example, on
renesas-ra, running a script that imports iperf3 via mpremote run, asserts,
most likely due to SOF interrupts not getting processing:

    queue_event at lib/tinyusb/src/device/usbd.c:382
    dcd_event_handler at lib/tinyusb/src/device/usbd.c:1318
    dcd_event_sof at lib/tinyusb/src/device/dcd.h:237
    dcd_int_handler at tinyusb/src/portable/renesas/rusb2/dcd_rusb2.c:964
    <signal handler called>
    disk_ioctl at extmod/vfs_fat_diskio.c:125
    validate at lib/oofatfs/ff.c:3359
    f_read at lib/oofatfs/ff.c:3625
    file_obj_read at extmod/vfs_fat_file.c:75
    mp_stream_rw at py/stream.c:60
    mp_reader_vfs_readbyte at extmod/vfs_reader.c:59
    next_char at py/lexer.c:174
    mp_lexer_to_next at py/lexer.c:713
    mp_parse at py/parse.c:1167

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
The aim of this commit is to clarify the command line options available.
While they are available as well as in the CLI with --help, it's useful to
document them and provide a few examples.

Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
Factor out mp_os_urandom() of each port into extmod/modos.c, which then
calls the port-specific function mp_hal_get_random().

Move mp_hal_get_random() to mphalport where suitable. At the
MIMXRT and SAMD it is left in modos.c, since there are different
implementation depending on the MCU family.

At the ALIF, ESP32, CC3200 and RP2 port the file modos.c was removed,
since it was empty after moving mp_hal_get_random().

Tested for the cc3200, esp32, esp8266, mimxrt, nrf, rp2, samd, stm32
and unix ports. Compiled for the alif and the renesas port.

Signed-off-by: robert-hh <robert@hammelrath.com>
Fixes issue #18825.

Signed-off-by: robert-hh <robert@hammelrath.com>
Signed-off-by: Damien George <damien@micropython.org>
This is a reproducer for #17117.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
This turns the reproducer into a sensible-ish crash:

    TypeError: exceptions must derive from BaseException

Closes: #17117

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
This is convenient when trying to figure out the correct values
for --include/--exclude/--test-dirs/... arguments.

Signed-off-by: stijn <stijn@ignitron.net>
Test file paths which get passed to the run_tests function can be
absolute or relative and with or without leading slash in the latter
case, depending on the arguments to run-tests.py, but the skip_tests
list with tests to skip only contains relative paths so using simple
string equality comparison easily leads to false negatives.

Compare the full absolute path instead such that it doesn't matter
anymore in which form the tests are passed. Note:
- use realpath to resolve symlinks plus make the comparison case
  insensitive on windows
- the test_file passed to run_one_test is not altered by this commit,
  such that when the user inputs relative paths the tests are also
  still displayed with relative paths
- likewise the test_file_abspath is not modified because functions
  like run_micropython rely on it having forward slashes

In practice this means that it used to be so that the only forms
of running tests for which the skip_tests lists actually worked were:

 >python ./run-tests.py
 >python ./run-tests.py -d extmod

whereas it now works consistently so also for these invocations,
which in the end all point to the exact same path:

 >python ./run-tests.py -d ./extmod
 >python ./run-tests.py -d ../tests/extmod
 >python ./run-tests.py -d /full/path/to/tests/extmod

These examples used to not skip any of the tests in the extmod/
directory thereby leading to test failures.

Signed-off-by: stijn <stijn@ignitron.net>
Scan the --test-dirs argument for the main tests directory being
passed and if so do the same thing as if running from within that
main test directory.

In practice this makes the following (which used to counterintuitively
try and fail to run the .py files in the tests/ directory itself)

 >python micropython/tests/run-tests.py -d micropython/tests

do the same thing as

 >cd micropython/tests
 >python ./run-tests.py

which is logical and convenient.

Signed-off-by: stijn <stijn@ignitron.net>
Test file paths which get passed to the run_tests function can be
absolute or relative and with or without leading slash in the latter
case, depending on the arguments to run-tests.py, but since that path
is used to:
- display which tests run
- record which tests ran in the results.json
- craft the filename for the .exp/.out file for failed tests
it is desirable to always use the same file path irregardless of
how the user passed the path.

In practice this means that all forms of running our own tests like:

 >python ./run-tests.py -i extmod
 >python ./run-tests.py -d extmod
 >python ./run-tests.py -d ./extmod
 >python ./run-tests.py -d ../tests/extmod
 >python ./run-tests.py -d /full/path/to/tests/extmod

will now consistently all display the tests like

  pass  extmod/time_time_ns.py
  FAIL  extmod/some_failing_test.py

and produce output files like

  results/extmod_some_failing_test.py.exp
  results/extmod_some_failing_test.py.out

instead of displaying/using the exact path as passed.

For external tests, meaning not in the tests/ directory, we also want
to be consistent so there the choice was made to always use absolute
paths.

Signed-off-by: stijn <stijn@ignitron.net>
Fixes fatal crash if serial port access returns an error (for example: port
is native USB-CDC and the host hard faults during the test run). Instead of
crashing, have the runner mark this as a test run error and continue.

It's not certain the next test will run successfully, but this provides the
context of output showing what was happening when the communication error
occurred. Without this change, that output is lost when the fatal exception
terminates the runner process.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
This gives a more user-friendly name when the Python object (eg Pin) is
printed.  If the nodelabel is unavailable then it uses `dev->name` as a
fallback.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.