summaryrefslogtreecommitdiff
path: root/tools
AgeCommit message (Collapse)Author
2 daysgithub/workflows: Test mpy-cross debug emitter.Alessandro Gatti
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>
3 daystools/ci.sh: Add zsh and fish shell completion support.Alessandro Gatti
This commit adds custom command completion functions for both the zsh and fish shell. The behaviour for those new completions follow the existing completion for the bash shell, including the way to generate the completion alias (with appropriately named command line switches). Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
5 daystools/mpy-tool.py: Add Compiler Explorer JSON output.Anson Mansfield
This commit adds a `--json` option to `mpy-tool.py`, in order to generate Compiler-Explorer-compatible JSON annotation information for the bytecode disassembly. Some of this information might be theoretically possible to parse out from the text itself, but not all of it is, e.g. disambiguating child references with non-unique simple names. Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
12 daystools/ci.sh: Build ESP32_GENERIC_C5 as part of esp32 CI.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-11-05tools/cc1: Fix ruff lint check with list length.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-11-05tools/cc1: Apply ruff formatting to cc1 script.Christian Clauss
Running `ruff format tools/cc1` picks up `tools/cc1` which is a Python file that does not have a .py file extension. Signed-off-by: Christian Clauss <cclauss@me.com> Signed-off-by: Damien George <damien@micropython.org>
2025-10-31stm32/usb: Add support for using TinyUSB stack.Andrew Leech
This commit adapts the stm32 port to allow switching from STM USB stack to TinyUSB stack. Using TinyUSB improves consistancy with other MicroPython ports and brings in the ability to use the runtime USB definition support recently added to other TinyUSB based ports. By default the existing STM USB stack is used. TinyUSB can be enabled in a board configuration with: #define MICROPY_HW_TINYUSB_STACK (1) Or, it can be enabled from the command line with: make -C ports/stm32 CFLAGS_EXTRA='-DMICROPY_HW_TINYUSB_STACK=1' Signed-off-by: Andrew Leech <andrew@alelec.net>
2025-10-24tools/mpy-tool.py: Add architecture flags to disassembly output.Alessandro Gatti
This commit extends "mpy-tool.py"'s disassembly output of a given MPY file (triggered via the "-d" command line option) to include newly added fields. Now the target architecture for the chosen MPY file is printed out to screen in human-readable format and, if present, architecture-specific flags. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-10-24py/persistentcode: Add architecture flags compatibility checks.Alessandro Gatti
This commit extends the MPY file format in a backwards-compatible way to store an encoded form of architecture-specific flags that have been specified in the "mpy-cross" command line, or that have been explicitly set as part of a native emitter configuration. The file format changes are as follows: * The features byte, previously containing the target native architecture and the minor file format version, now claims bit 6 as a flag indicating the presence of an encoded architecture flags integer * If architecture flags need to be stored, they are placed right after the MPY file header. This means that properly-written MPY parsers, if encountering a MPY file containing encoded architecture flags, should raise an error since no architecture identifiers have been defined that make use of bits 6 and 7 in the referenced header byte. This should give enough guarantees of backwards compatibility when this feature is used (improper parsers were subjected to breakage anyway). The encoded architecture flags could have been placed at the end, but: * Having them right after the header makes the architecture compatibility checks occur before having read the whole file in memory (which still happens on certain platforms as the reader may be backed by a memory buffer), and prevents eventual memory allocations that do not take place if the module is rejected early * Properly-written MPY file parsers should have checked the upper two bits of the flags byte to be actually zero according to the format specification available right before this change, so no assumptions should have been made on the exact order of the chunks for an unexpected format. The meaning of the architecture flags value is backend-specific, with the only common characteristic of being a variable-encoded unsigned integer for the time being. The changes made to the file format effectively limit the number of possible target architectures to 16, of which 13 are already claimed. There aren't that many new architectures planned to be supported for the lifetime of the current MPY file format, so this change still leaves space for architecture updates if needed. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-10-24tools/mpremote: Fix exception when using pts.iabdalkader
Setting RTS/DTR raises "Inappropriate ioctl for device" for pts devices. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-10-23tools/autobuild: Use same length Git hash abbreviation in file names.Daniël van de Giessen
This makes the version string consistent with the one used in code, see commit 9e89c752cb. Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2025-10-23tools/ci.sh: Use a better default reference ref in code_size_build.Jeff Epler
Now the default reference commit is the first parent of the selected commit, instead of the first parent of HEAD. Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-10-23tools/metrics.py: Tersely show the commits in the size report.Jeff Epler
This will show a line for both the reference and comparison, e.g., Reference: zephyr/boards: Add PocketBeagle 2 rev A1… [00a926e99e] Comparison: metrics: Tersely show the commi… [merge of c7ac411e22] When the comparison is a merge commit (as it is during CI) the second parent of that commit is shown instead. This will be helpful when checking which revision of the code size report comment on a PR corresponds to which revision of the code. Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-10-23tools/ci.sh: Cross build 64-bit windows on Linux.Jeff Epler
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-10-22tools/ci.sh: Init micropython-lib submodule for zephyr build.Damien George
The zephyr port doesn't have a Makefile so can't run `make submodules`. Instead they must be explicitly initialized. Signed-off-by: Damien George <damien@micropython.org>
2025-10-08tools/ci: Fix typo of pipefail.Angus Gratton
Regression from 449866cb0af3fc547df6538a6552517cc8974616. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-10-08tools/ci.sh: Re-add IGNORE_ERRORS to ci_code_size_build.Jeff Epler
It was removed (possibly inadvertently) in 4c55b0879b38b373b44e84552d6754b7842b5b72 Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-10-08tools/ci.sh: Return to old branch after code_size_build.Jeff Epler
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-10-08tools/metrics.py: Allow pre_cmd to set up environment.Jeff Epler
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>
2025-10-08tools/ci.sh: Let code_size_build be customized via environment.Jeff Epler
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>
2025-10-08tools/metrics.py: When cleaning also clean mpy-cross.Jeff Epler
Changes of interest could be in emitted mpy frozen files. Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-10-08tools/ci.sh: Exit with error if zcat fails during ci_esp8266_setup.Jeff Epler
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-10-08tools/ci.sh: Add and use new ci_code_size_report function.Jeff Epler
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-10-08tools/ci.sh: Manipulate pipefail better.Jeff Epler
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-10-08tools/metrics.py: Use all CPUs during comparison builds.Jeff Epler
Don't simply hard-code a parallelism of 3 for the build. Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-10-03docs: Label table columns as "CPython output" and "MicroPython output".Angus Gratton
Abbreviating these doesn't really save space in the docs, as the code blocks in the next row are always wider than the column headings. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-10-02tools/ci.sh: Enable the full test suite for unix minimal variant.Damien George
With all the preceeding improvements to the test suite, it's now possible to just run `make VARIANT=minimal test` -- which is equivalent to just `./run-tests.py` -- on the unix minimal variant. Signed-off-by: Damien George <damien@micropython.org>
2025-10-01tools/ci.sh: Enable all possible tests on zephyr CI.Damien George
With the recent improvements to the test suite, and fixes for `pow`, the full test suite can now be run (and appropriate tests will be automatically skipped). Signed-off-by: Damien George <damien@micropython.org>
2025-10-01tools/mpremote: Workaround ESP DTR/RTS reset quirk at disconnect time.Angus Gratton
The problem with ESP board spurious reset happens at disconnect time on Windows (clearing DTR before RTS triggers a reset). Previous workarounds tried to detect possible ESP boards and apply the correct DTR and RTS settings when opening the port. Instead, we can manually clear RTS before closing the port and thereby avoid the reset issue. Opening the port can keep the default behaviour (RTS & DTR both set). close() is called from a finally block in the mpremote main module (via do_disconnect()) - so this should always happen provided the Python process isn't terminated by the OS. One additional workaround is needed to prevent a spurious reset first time a Silicon Labs CP210x-based ESP board is opened by mpremote after enumeration. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-09-28github/workflows: Add 32-bit OBJ_REPR_B CI job.Jeff Epler
This showed up some interesting errors (hopefully all fixed now). Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-09-26tools/ci.sh: Add `--bash-completion` option.Jeff Epler
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-09-24tools/metrics.py: Compute mpy-cross size as part of size metrics.Damien George
Add support to `tools/metrics.py` to compute the size delta of mpy-cross, alongside the sizes of port firmware. This is an easy and cheap addition because mpy-cross is usually built before the ports are. Although the size of mpy-cross is not critical, it's still a nice indication of how changes affect code size, and helps to eliminate any unwanted increases in mpy-cross. Signed-off-by: Damien George <damien@micropython.org>
2025-09-22tools/ci.sh: Fix missing `set -e` when run as a script.Jeff Epler
This is needed to correctly stop after an error in a CI step when running `ci.sh` as a script. Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-09-19qemu/riscv64: Add new QEMU RV64 port.Alessandro Gatti
This adds a QEMU-based bare metal RISC-V 64 bits port. For the time being only QEMU's "virt" 64 bits board is supported, using the lp64 ABI and the RV64IMC architecture. The port's README is also updated to keep track of these changes. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-09-19mpy-cross: Add RISC-V RV64IMC support in MPY files.Alessandro Gatti
MPY files can now hold data to be run on RV64IMC. This can be accomplished by passing the `-march=rv64imc` flag to mpy-cross. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-09-18tools/ci.sh: Make this script runnable as command.Jeff Epler
This makes it easier to run a sequence of ci steps locally. A help message is also provided. Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-09-15tools: Remove unneeded future imports.Jeff Epler
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
2025-09-15all: Remove Python 2.7 support.Jeff Epler
Python 2.7 has been EOL since January 2020. Ubuntu oldoldlts (Focal Fossa, 20.04) has Python 3.8. Debian oldoldstable (Buster, from 2019) has Python 3.7. RHEL 8 (from 2019) has Python 3.6. It's easier than ever to install a modern Python using uv. Given this, it seems like a fine idea to drop Python 2.7 support. Even though the build is not tested on Python as old as 3.3, I left comments stating that "3.3+" is the baseline Python version. However, it might make sense to bump this to e.g., 3.10, the oldest Python 3 version used during CI. Or, using uv or another method actually test on the oldest Python interpreter that is desirable to support (uv goes back to Python 3.7 easily; in October 2025, the oldest supported Python interpreter version will be 3.10) Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-09-10tools/mpremote: Don't apply Espressif DTR/RTS quirk to TinyUSB CDC dev.Angus Gratton
The DTR quirk workaround from dea949e86 is needed for the Espressif Serial/JTAG device, but not for TinyUSB - in fact DTR must be set for TinyUSB to correctly determine if the serial port is open (and leads to issues with lost bytes otherwise). See discussion in PR #17999. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-09-09esp32: Add IDF Component Lockfiles to git repo.Angus Gratton
This is recommended by Espressif, and it's the only way to ensure everyone builds the same set of component versions. The awkward part is that updating the ESP-IDF version will churn a line in each of these files (and possibly other changes). Adds a build-time check for lock file changes, which is either a warning or a hard error depending on the value of MICROPY_MAINTAINER_BUILD flag (introduced in previous commit). This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-09-09tools: Add an environment variable MICROPY_MAINTAINER_BUILD.Angus Gratton
This allows us to have some things which are fatal errors in CI or nightly builds, but warnings in normal developer builds. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-08-28tools/ci.sh: Skip unreliable thread/thread_gc1.py test in Github CI.Anson Mansfield
The `thread/thread_gc1.py` test is a constant source of spurious failures in Github CI. This commit adds it to the list of tests skipped when running on Github CI using either macos, qemu_riscv64, qemu_mips, or qemu_arm, to help reduce the overall false positive rate and improve the predictive value of the test fail indication. Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
2025-08-26tools/mpy-tool.py: Allow dumping MPY segments into their own files.Alessandro Gatti
This commit lets "tools/mpy-tool.py" extract MPY segments into their own files, one file per segment. A pair of new command line arguments were added, namely "-e"/"--extract" that takes a filename prefix to use as a base for the generated files' name, and "--extract-only" that - combined with "--extract" - allows selecting which kinds of segment should be dumped to the filesystem. So, for example, assuming there's a file called "module.mpy", running "./mpy-tool.py --extract segments module.mpy" would yield a series of files with names like "segments_0_module.py_QSTR_module.py.bin", "segments_1_module.py_META__module_.bin", "segments_2_module.py_QSTR_function.bin", etc. In short the file name format is "<base>_<count>_<sourcefile>_<segmentkind>_<segmentname>.bin", with <segmentkind> being META, QSTR, OBJ, or CODE. Source file names and segment names will only contain characters in the range "a-zA-Z0-9_-." to avoid having output file names with unexpected characters. The "--extract-only" option can accept one or more kinds, separated by commas and treated as case insensitive strings. The supported kinds match what is currently handled by the "MPYSegment" class in "tools/mpy-tool.py": "META", "QSTR", "OBJ", and "CODE". The absence of this command line option implies dumping every segment found. If "--extract" is passed along with "--merge", dumping is performed after the merge process takes place, in order to dump all possible segments that match the requested segment kinds. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-08-26tools/ci.sh: Extend Arm testing to include hardfp targets.Alessandro Gatti
This commit lets CI extend the testing scope of the QEMU Arm target, by letting it perform the usual battery of tests (interpreter and natmods) also on hardfp targets. The default board for Arm testing lacks hardware floating point support, so natmods weren't tested in that specific configuration. With the introduction of the "MPS_AN500" QEMU target, now this is made possible as said board emulates a Cortex-M7 machine with a single- and double-precision floating point unit. To reduce the impact on build times, the "ci_qemu_build_arm_thumb" CI step was split in two: "ci_qemu_build_arm_thumb_softfp" and "ci_qemu_build_arm_thumb_hardfp" - so hopefully those can run in parallel whenever possible. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-08-19py/misc: Add a way to detect sanitizer builds.Angus Gratton
Clang and gcc>=14 can use __has_feature() to detect if a sanitizer is enabled, but older GCC has no mechanism - need to set a macro explicitly for this to be recognised. Necessary for increasing some resource limits in sanitizer builds. Important not to use to avoid real issues! This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-08-19tools/ci: Add UBSan to longlong CI build.Angus Gratton
Also rewrite the sanitizer argument variables to not assume a variant. longlong variant currently fails in this config, due to a bug fixed in follow-up commit. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-08-16zephyr: Upgrade to Zephyr v4.2.0.Maureen Helm
Updates the Zephyr port build instructions and CI to use the latest Zephyr release tag. Tested on max32690fthr and frdm_k64f. Signed-off-by: Maureen Helm <maureen.helm@analog.com>
2025-08-11tools/codeformat.py: Print filename + linenumber when dedenting fails.Daniël van de Giessen
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2025-08-11tools/codeformat.py: Iterate lines instead of modifying list in-place.Daniël van de Giessen
Co-authored-by: David Lechner <david@pybricks.com> Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2025-08-11tools/mpremote: Fix encoding error in PyboardCommand.Jos Verlinde
This is a fix for utf-8 decoding errors that are thrown when non-utf-8 content is received. For instance during a reboot of an ESP8266 module. The fix is to handle conversion errors by replacing illegal characters. Note that these illegal characters most often occur during an MCU reboot sequence when the MCU is using baudrates different from 115200. Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>