Skip to content

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)

jepler and others added 29 commits October 5, 2025 15:43
.. at least on x86_64 (unix standard build).  Size was unchanged on
RPI_PICO_W.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
This allows out-of-tree tests like:

    $ make -C ports/unix/ BUILD=/tmp MICROPY_MPYCROSS=~/bin/mpy-cross test

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
After locally building zephyr e.g., with

    $ tools/ci.sh zephyr_setup zephyr_run_tests

these directories are created by the build system.  However, they should
never be tracked by git.  Similarly with the esp8266 ci.sh functions.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
These changes correspond to the following TinyUSB commits:

- d997f0071ea5d2d07e340d183fffb97e09526773
  change dcd_init() to take rhport struct

- 1f18be93db39dbc57bbf34f982dbe07e209a2ae3
  change the tusb_rhport_init_t struct, exclude the rhport to make API more
  consistent

- e83e08343afca86b2bacf26822ef9032571e6f56
  change dcd_init() return from void to bool

Signed-off-by: Damien George <damien@micropython.org>
When calling from Python into JavaScript and passing along keyword
arguments, the FFI bindings currently only support at most 1 positional
argument. For example:

    import js
    js.func(1, b=2, c=3)

This commit fixes that by supporting arbitrary number of positional
arguments, in combination with keyword arguments.  So now the following
works:

    import js
    js.func(1, 2, c=3, d=4)

Tests are added for these new, supported cases.

Signed-off-by: Damien George <damien@micropython.org>
Correctly format integers when there are leading zeros with a grouping
character, such as "{:04,d}".format(0x100) -> "0,256".

The new padding patterns for commas-and-zeroes and underscores-and-zeroes
are smooshed together into the existing pad_zeroes to save space.

Only the two combinations of (decimal + commas) and (other bases +
underscores) are properly supported.

Also add a test for it.

Fixes issue #18082.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
The esp32 I2C driver sets a global timeout during init.  The functionality
for this is currently only correct for original esp32 and esp32-s2, newer
parts have a slightly different argument which is log-base-2 of the
timeout.

Note that `i2c_set_timeout()` is a thin layer around `i2c_ll_set_tout()`
with the latter writing directly to the hardware register.  So the timeout
argument passed to `i2c_set_timeout()` needs to be in units calculated by
`i2c_ll_calculate_timeout_us_to_reg_val()`.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Don't simply hard-code a parallelism of 3 for the build.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Changes of interest could be in emitted mpy frozen files.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
For instance, to compare HEAD to origin/master on only the minimal x86
build, use

    PORTS_TO_CHECK=m REFERENCE=origin/master tools/ci.sh code_size_build

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
This is a necessary step to allow cleanly building the xtensa port during
CI, as it's undesirable to apply the esp-idf environment settings while
building other ports.

PRE_CMD_<letter> can be used to override the command, or add a command if
not otherwise specified.  Note that <letter> is case sensitive.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
It was removed (possibly inadvertently)
in 4c55b08

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Regression from 449866c.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
This was missed in d441788.

Signed-off-by: Damien George <damien@micropython.org>
dpgeorge and others added 30 commits December 7, 2025 15:49
Signed-off-by: Damien George <damien@micropython.org>
Add a cast to fix build error of mpy-cross on Windows CI.

Prior to this fix the failure was:

    D:\a\micropython\micropython\py\asmbase.c(105,56): warning C4319: '~':
      zero extending 'unsigned int' to 'size_t' of greater size
      [D:\a\micropython\micropython\mpy-cross\mpy-cross.vcxproj]

Signed-off-by: Damien George <damien@micropython.org>
Prior to this change mpy-cross would fail to build under Windows with:

    D:\a\micropython\micropython\py\emitinlinerv32.c(398,40): warning
      C4319: '~': zero extending 'unsigned int' to 'mp_uint_t' of greater
      size [D:\a\micropython\micropython\mpy-cross\mpy-cross.vcxproj]

Signed-off-by: Damien George <damien@micropython.org>
This fixes the test used by the help function to iterate over its
argument's attribute to use the proper `mp_map_slot_is_filled` function
to check if a slot in the map is filled; the previous test only checked
for `MP_OBJ_NULL` keys and would attempt to print the null value
whenever a `MP_OBJ_SENTINEL` key marking a deleted entry was present.

Fixes: #18061
Fixes: #18481

Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
This test reproduces the bug that gave rise to the esp32 segfaults in
issues #18061 and #18481 on all platforms.

Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Add peripheral clock selection for ADC345 to use analog port under ADC3.

Fixes #18527.

Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
Among other things, the framebuf module is missing on NUCEO_G474RE. This
board seems to disable a lot of modules, while other *E boards with the
same flash configuration (eg NUCLEO_F411RE) don't seem to disable any
modules in this way.

So, remove all of the lines disabling modules to make it consistent with
other boards.

Signed-off-by: Steve Sanbeg <steve.sanbeg@gmail.com>
The ESP32-P4 currently comes in three revisions (0.0, 0.1 and 1.0) and all
of them are out in the wild.  Even though the IDF defaults to a minimum of
0.1 we would like to support as many as possible, so configure MicroPython
to work down to revision 0.0.

The firmware only grows by 32 bytes when enabling this option.

Signed-off-by: Damien George <damien@micropython.org>
This updates the esp_hosted component for ESP32-P4 boards to use the latest
version 2.7.0.  Testing on a P4 board with C6 WiFi shows there are no
regressions for WiFi or BLE.

Also rename the `CONFIG_ESP_ENABLE_BT` option to the new
`CONFIG_ESP_HOSTED_ENABLE_BT_NIMBLE` option used by the component.

This change is made partly to work around a current issue with the IDF
component manager, that esp_hosted versions after 2.0.17 and prior to
2.7.0 have all disappeared.

Signed-off-by: Damien George <damien@micropython.org>
This brings in:
- usb-device: raise RuntimeError when DCD error occurs
- usb-device-hid: return True after submit_xfer
- inspect: implement a very basic signature function
- datetime: apply localtz patch to include naive date/time support
- datetime: optimize for code size
- sdcard: updating sector calculation for SDXC
- mip: optimize _CHUNK_SIZE const for code size
- aioble/examples: change variable name to _ADV_INTERVAL_US
- aioble: fix typo in README in aioble.ADDR_PUBLIC
- copy: fix typo in _deepcopy_dispatch
- requests: update example for fetching using requests
- all: fix formatting errors in docstrings
- CONTRIBUTING: add guidelines for module documentation and versioning
- cbor2: silence missing `__eq__` warning
- pyproject.toml: reorganize ruff lint settings for newer ruff
- all: correct various typos in comments and docs
- lora: fix import error detection for missing drivers
- inspect: support closures/generators/async-funcs in inspect.signature
- usb-device-hid: fix descriptor protocol config and set correct default
- usb-device-hid: use report protocol after report descriptor requested
- umqtt.simple: add unsubscribe method
- aiohttp: correctly handle WebSocket message fragmentation
- iperf3: fix use as a CLI on the unix port of MicroPython
- iperf3: factor out data transfer logic to separate function
- iperf3: fix server UDP mode
- unix-ffi/socket: remove ip add/drop membership from socket
- tarfile: add basic unittest for tarfile.TarFile
- tarfile: fix FileSection.skip to not rely on extended readinto args
- argparse: Add support for custom argument types
- pyproject.toml: add codespell configuration, CI and precommit
- all: fix spelling and typos in comments and docstring
- aioble/examples: change variable name to _ADV_INTERVAL_US

Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Commit 6201e77 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>
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>
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>
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>
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>
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>
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>
This is unused since 007f127 "all:
Simplify mp_int_t/mp_uint_t definition".

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
Signed-off-by: Thomas Kiss <thokis@googlemail.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.