Skip to content

Comments

Update from upstream repo micropython/micropython@master#3

Open
backstroke-bot wants to merge 9495 commits intobynds:masterfrom
micropython:master
Open

Update from upstream repo micropython/micropython@master#3
backstroke-bot wants to merge 9495 commits intobynds:masterfrom
micropython:master

Conversation

@backstroke-bot
Copy link

Hello!

The upstream repository micropython/micropython@master has some new changes that aren't in this fork. So, here they are, ready to be merged! 🎉

If this pull request can be merged without conflict, you can publish your software with these new changes. Otherwise, fix any merge conflicts by clicking the Resolve Conflicts button.


If you like Backstroke, consider donating to help us pay for infrastructure here. Backstroke is a completely open source project that's free to use, but we survive on sponsorships and donations. Thanks for your support! Help out Backstroke.


Created by Backstroke (I'm a bot!)

alectric-tr and others added 30 commits November 26, 2025 14:41
There were a few typos in the documentation for the `I2CTarget.irq` method
description where `IRQ_ADDR_MATCH_READ` was used, however
`IRQ_ADDR_MATCH_WRITE` should have been used.

Fixes issue #18470.

Signed-off-by: Alex Tran <alex.t.tran@gmail.com>
Fixes issue #7915.

Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
Allows using custom DTS things such as bindings.

Signed-off-by: Vdragon <mail@massdriver.space>
Adds the ability to use PSRAM and non-contiguous memory.

Example usage, add this to dts overlay:

    / {
            heap_psram {
                    compatible = "micropython,heap";
                    size = <DT_SIZE_M(4)>;
                    memory-region = <&psram>;
            };

            heap_sram1 {
                    compatible = "micropython,heap";
                    size = <DT_SIZE_K(140)>;
                    memory-region = <&sram1>;
            };
    };

Signed-off-by: Vdragon <mail@massdriver.space>
This commit fixes a regression introduced in
1b92bda, where a new architecture was
added to mpy-cross but it had no matching native emitter exists.

The result was that the architecture emitter entry point would be
correctly calculated according to the native architecture index, but if
the emitters entry points table was not updated to match the new number
of architectures an out of bound access may be performed.

Unfortunately adding RV64IMC shifted the debug emitter index further
down the table, and that table wasn't updated to reflect the lack of an
emitter for RV64.  Adding a NULL entry there would cause a NULL pointer
access as there was no need to perform any check about the emitter entry
point function's validity until now.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit adds a new workflow step to the CI, to test the debug
emitter provided by mpy-cross.  The checks being done are limited to
make sure that the debug emitter does not crash and emits opcodes for a
simple test file that is guaranteed to work for all configurations.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Allows using TinyUSB stack on N6.

Note there's still an issue with TinyUSB on the N6: `pyb_usbd_init()` can't
be called multiple times (on soft-reboot).

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Signed-off-by: Mike Tolkachev <contact@miketolkachev.dev>
Signed-off-by: Mike Tolkachev <contact@miketolkachev.dev>
Signed-off-by: Damien George <damien@micropython.org>
This change adds WeAct Studio Mini STM32H743 board support to the STM32
port.  Some of the work from PR #12540 is combined here.

WeAct Studio Mini STM32H43 board:
https://github.com/WeActStudio/MiniSTM32H7xx

This board uses STM32H743VI:
https://www.st.com/en/microcontrollers-microprocessors/stm32h743vi.html

Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
This allows a port to do hardware initialization just before the TinyUSB
stack is brought up.  That means the hardware is only turned on when it's
needed.

Signed-off-by: Damien George <damien@micropython.org>
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>
robert-hh and others added 30 commits February 10, 2026 15:58
If the return value is set only when certain condition are true,
the compiler sometimes raises an error.

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

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

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

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Add support for RISC-V RV32IMC native code emitter in the zephyr port.  It
will be automatically enabled by default, but can be overridden by defining
`MICROPY_EMIT_RV32` and/or `MICROPY_EMIT_INLINE_RV32`.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
The old code was only handling `\r` and ignoring `\n`, which is a problem
for systems that only send `\n` as a newline.  This commit handles it
better, supporting both characters.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Convert the stm32 port from the old `MICROPY_EVENT_POLL_HOOK` macro to use
the new `mp_event_wait_xxx()` functions in conjunction with
`MICROPY_INTERNAL_WFE`.

This change should be functionally equivalent to the existing behaivour
because `mp_event_wait_ms()` and `mp_event_wait_indefinite()` are equal to
`mp_handle_pending(true); __WFI()`, which is what `MICROPY_EVENT_POLL_HOOK`
was.

Note that the `CYW43_EVENT_POLL_HOOK` macro needed to be overridden,
otherwise it would just call `mp_event_handle_nowait()` which would create
power hungry busy loops.

Signed-off-by: Damien George <damien@micropython.org>
Adds the following UARTs: 1, 4, 5, 7, 8,
assigned to pins that were not otherwise assigned.

Signed-off-by: mdaeron <mathieu@daeron.fr>
Add USB FS configuration to enable for STM32U5.

Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
This change adds WeAct STM32U585 board support to the STM32 port.
WeAct STM32U585: https://github.com/WeActStudio/WeActStudio.STM32U585Cx_CoreBoard
This board use STM32U585CI: https://www.st.com/ja/microcontrollers-microprocessors/stm32u585ci.html

Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
Header comment said "STM32F072xZ" for the STM32L072xZ linker script.

Signed-off-by: Thomas Propst <tom.propst@gmail.com>
This commit performs a few minor changes to the structures used to store
board pin information, in order to reduce the impact on the .rodata
section of the firmware of instances of those structures.

The pin objects structure ("machine_pin_obj_t") instead has its QSTR
variable holder changed from "qstr" to "qstr_short_t", and some elements
of that structure have been rearranged to remove enough padding bytes
inside structure elements to let the linker allocate less data for
instances of that structure.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
- `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>
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.