summaryrefslogtreecommitdiff
path: root/tools
AgeCommit message (Collapse)Author
2025-02-10tools/mpremote: Support mip install from package.json on local fs.Glenn Moloney
Add support for `mpremote mip install package.json` where `package.json` is a json file on the local filesystem. Without this, package json files can only be loaded from http, https, github or gitlab URLs. This is useful for testing `package.json` files for pacages in development and for constructing one's own `package.json` files for Python packages which are not yet available for installation using mip. Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
2025-02-10tools/ci.sh: Build MIMXRT1060_EVK with MSC enabled as part of mimxrt CI.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-02-10mimxrt: Add support for a UF2 bootloader.robert-hh
Allowing to use e.g. the Adafruit bootloaders with MicroPython. The .uf2 file is created in addition to the .bin and .hex files allowing to use the latter ones without the bootloader for debugging and testing. Changes: - Set the location of the ISR Vector and .text segment to 0x6000C000 and 0x6000C400. - Reserve an area at the start of ITCM for a copy of the interrupt vector table and copy the table on reset to this place. - Extend `machine.bootloader()` by setting the magic number to enable the bootloader on reset. - Create a .uf2 file which skips the segments below 0x6000C000. The bootloader has to be installed as a preparation step using the board specific methods, but then the firmware's .uf2 file version can be installed using the bootloader. The bootloader can be invoked with: - double reset - calling machine.bootloader() - Using the touch1200 method Double reset is hard to achieve on MIMXRT boards, since there is no clean reset pin. Some MIMXRT boards provide it by switching the power. Some boards are excluded from the .uf2 build: - MIMXRT1050_EVK: The uf2 bootloader is built for the QSPI version of the board. MicroPython supports the Hyperflash version. - MIMXRT1176_EVK: No support for this board yet, but it should be possible. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07tools/ci.sh: Add natmod tests for QEMU/Arm.Alessandro Gatti
This commit adds the natmod tests for the MPS2_AN385 board running inside QEMU to the CI pipeline. Now natmod tests capabilities are equal between the Arm and RV32 platforms for the QEMU port. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-01-29tools/mpremote: Introduce timeout_overall for read_until().Hans Maerki
And use it in `enter_raw_repl()`. This prevents waiting forever for a serial device that does not respond to the Ctrl-C/Ctrl-D/etc commands and is constantly outputting data. Signed-off-by: Hans Maerki <buhtig.hans.maerki@ergoinfo.ch>
2025-01-27tools/mpremote: Avoid initial blocking read in read_until().Hans Maerki
If the target does not return any data then `read_until()` will block indefinitely. Fix this by making the initial read part of the general read look, which always checks `inWaiting() > 0` before reading from the serial device. Also added the UART timeout to the constructor. This is not currently used but may be used as an additional safeguard. Signed-off-by: Hans Maerki <buhtig.hans.maerki@ergoinfo.ch>
2025-01-17tools/autobuild,esp32: Template the generation of esp32 port deploy.md.Angus Gratton
Allows two source files (ports/esp32/boards/deploy.md and deploy_nativeusb.md for boards with only native USB) for all esp32 installation steps, with templated chip name and flash offset inserted via string formatting. The new files add more text to explain the esptool.py port auto-detection, remove the unnecessary -z feature (already enabled by default), and add a bit of troubleshooting and port detection info. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-01-16tools/pyboard.py: Wait a bit before accessing the PTY serial port.Alessandro Gatti
Some PTY targets, namely `NETDUINO2` and `MICROBIT` under Qemu, take a bit more time to present a REPL than usual. The pyboard tool is a bit too impatient and would bail out before any of those targets had a chance to respond to the raw REPL request. Co-authored-by: Damien George <damien@micropython.org> Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-01-15tools/autobuild: Don't allow a board to change its ID.Damien George
All board IDs are now the board directory name. Signed-off-by: Damien George <damien@micropython.org>
2025-01-06tools/ci.sh: Run test_full for qemu port CI.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-12-23tools/verifygitlog.py: Show invalid commit subjects in quotes.Alessandro Gatti
If a commit subject line has any trailing whitespace it won't match the repository validation rules, and the line will show up as part of the relevant error message. However, since there's no quotation marks around the offending text, the trailing whitespace may go unnoticed, and given that the commit message is then discarded when the commit operation is retried this can get fairly annoying. This commit simply modifies the error output for invalid subject lines to add quotation marks around the offending text, so trailing whitespace is much easier to see. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-12-23qemu: Add test_natmod target for RV32 and use as part of CI pipeline.Alessandro Gatti
This commit brings the natmod tests in the CI build process for the RV32 platform. Not all example natmods are tested at the moment, as `features` requires soft-float support, and `btree` needs thread-local storage support in `mpy_ld.py` when built with the CI's toolchain. Co-authored-by: Damien George <damien@micropython.org> Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-12-23tools/mpy_ld.py: Add native modules support for RV32 code.Alessandro Gatti
This commit adds support for RV32IMC native modules, as in embedding native code into a self-contained MPY module and and make its exported functions available to the MicroPython environment. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-12-18ci: Add caching of ccache for Zephyr.Angus Gratton
Similar to the ESP32 builds, but needs additional step to pass the ccache directory through to the Zephyr container. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-12-18ci: Pull the Zephyr CI docker image from GitHub container reg.Angus Gratton
This image is 15GB so in theory this may be faster, although in testing the improvement is either non-existent or marginal. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-12-18ci: Cache Zephyr workspace installation.Angus Gratton
Can save several minutes downloading the Zephyr docker image and/or cloning repo from GitHub. Cache keyed on the Zephyr version, which AFAIK is the only determinant for the workspace contents. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-12-17tools/boardgen.py: Provide macro defns for number of cpu/board pins.Damien George
So a port can use them if needed to exclude the Pin.cpu/Pin.board objects. Signed-off-by: Damien George <damien@micropython.org>
2024-12-16tools/ci.sh: Re-enable vfs_posix tests on unix qemu MIPS CI.Damien George
These work now that _FILE_OFFSET_BITS=64. Signed-off-by: Damien George <damien@micropython.org>
2024-11-30tools/ci.sh: Remove explicit macOS pkg-config install.Angus Gratton
Reasons to remove this: - GitHub's macOS runners install this package by default nowadays. - Brew renamed this package to 'pkgconf' so installing the old name on top of the new package name has started failing. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-13tools/mpremote: Support trailing slash on dest for non-recursive copy.Damien George
This fixes a regression in db59e55fe7a0b67d3af868990468e7b8056afe42: prior to that commit `mpremote` supported trailing slashes on the destination of a normal (non-recursive) copy. Add back support for that, with the semantics that a trailing slash requires the destination to be an existing directory. Also add a test for this. Signed-off-by: Damien George <damien@micropython.org>
2024-11-13tools/mpremote: Add test for forced copy.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-11-13tools/mpremote: Make sure stdout and stderr output appear in order.Damien George
mpremote error messages now go to stderr, so make sure stdout is flushed before printing them. Also update the test runner to capture error messages. Signed-off-by: Damien George <damien@micropython.org>
2024-11-04tests/run-tests.py: Change --target/--device options to --test-instance.Damien George
Previously to this commit, running the test suite on a bare-metal board required specifying the target (really platform) and device, eg: $ ./run-tests.py --target pyboard --device /dev/ttyACM1 That's quite a lot to type, and you also need to know what the target platform is, when a lot of the time you either don't care or it doesn't matter. This commit makes it easier to run the tests by replacing both of these options with a single `--test-instance` (`-t` for short) option. That option specifies the executable/port/device to test. Then the target platform is automatically detected. The `--test-instance` can be passed: - "unix" (the default) to use the unix version of MicroPython - "webassembly" to test the webassembly port - anything else is considered a port/device to pass to Pyboard There are also some shortcuts to specify a port/device, following `mpremote`: - a<n> is short for /dev/ttyACM<n> - u<n> is short for /dev/ttyUSB<n> - c<n> is short for COM<n> For example: $ ./run-tests.py -t a1 Note that the default test instance is "unix" and so this commit does not change the standard way to run tests on the unix port, by just doing `./run-tests.py`. As part of this change, the platform (and it's native architecture if it supports importing native .mpy files) is show at the start of the test run. Signed-off-by: Damien George <damien@micropython.org>
2024-10-31tools/ci.sh: Fix reference commit for code size comparison.Angus Gratton
Previously the code size comparison was between the merge base (i.e. where the PR branched), and the generated merge commit into master. If the PR branch was older than current master, this meant the size comparison could incorrectly include changes already merged on master but missing from the PR branch. This commit changes it to compare the generated merge commit against current master, i.e. the size impact if this PR was to be merged. This commit also disables running the code size check on "push", it now only runs on pull_request events. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-10-31tools/ci.sh: Fix commit msg checking when PR branch HEAD behind master.Angus Gratton
Fixes the problem noted at https://github.com/micropython/micropython/pull/15547#issuecomment-2434479702 which is that, because default CI HEAD for a PR is a (generated) merge commit into the master branch's current HEAD, then if the PR branch isn't fully rebased then the commit check runs against commits from master as well! Also drops running this check on push, the pull_request event is triggered by default on open and update ("synchronized" event), which probably covers the cases where this check should run. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-10-28tools/mpremote: Fix UnboundLocalError in Transport.fs_writefile().Glenn Moloney
The variable `written` was being used before it was defined in the `fs_writefile()` method of the Transport class. This was causing an `UnboundLocalError` to be raised when the `progress_callback` was not provided. Fixes issue #16084. Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
2024-10-15tools/ci.sh: Add RPI_PICO2 to CI.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-10-15tools: Only issue a single Ctrl-C when entering raw REPL.Damien George
A long time ago when there was only the `stm` port, Ctrl-C would trigger a preemptive NLR jump to break out of running code. Then in commit 124df6f8d07b53542b6960dbeea9b63bff469a67 a more general approach to asynchronous `KeyboardInterrupt` exceptions was implemented, and `stmhal` supported both approaches, with the general (soft) interrupt taking priority. Then in commit bc1488a05f509cd5be8bfab9574babfcb993806f `pyboard.py` was updated with a corresponding change to make it issue a double Ctrl-C to break out of any existing code when entering the raw REPL (two Ctrl-C characters were sent in order to more reliably trigger the preemptive NLR jump). No other port has preemptive NLR jumps and so a double Ctrl-C doesn't really behave any differently to a single Ctrl-C: with USB CDC the double Ctrl-C would most likely be in the same USB packet and so processed in the same low-level USB callback, so it's just setting the keyboard interrupt flag twice in a row. The VM/runtime then just sees one keyboard interrupt and acts as though only one Ctrl-C was sent. This commit changes the double Ctrl-C to a single Ctrl-C in `pyboard.py` and `mpremote`. That keeps things as simple as they need to be. Signed-off-by: Damien George <damien@micropython.org>
2024-10-09tools/mpremote: Add option to force copy.Damien George
This adds a -f/--force option to the "cp" command, which forces unconditional copies, in particular does not check the hash. Signed-off-by: Damien George <damien@micropython.org>
2024-10-09tools/mpremote: Add initial regression tests for mpremote.Jim Mussared
These tests are specifically for the command-line interface and cover: - resume/soft-reset/connect/disconnect - mount - fs cp,touch,mkdir,cat,sha256sum,rm,rmdir - eval/exec/run This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com> Signed-off-by: Damien George <damien@micropython.org>
2024-10-09tools/mpremote: Improve error output.Jim Mussared
Makes the filesystem command give standard error messages rather than just printing the exception from the device. Makes the distinction between CommandError and TransportError clearer. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2024-10-09tools/mpremote: Add hashing ability and use for recursive copy.Jim Mussared
Changes in this commit: - Adds transport API `fs_hashfile` to compute the hash of a file with given algorithm. - Adds commands `mpremote <...>sum file` to compute and print hashes of various algorithms. - Adds shortcut `mpremote sha256sum file`. - Uses the hash computation to improve speed of recursive file copy to avoid copying a file where the target is identical. For recursive copy, if possible it will use the board's support (e.g. built-in hashlib or hashlib from micropython-lib), but will fall back to downloading the file and using the local implementation. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com> Signed-off-by: Damien George <damien@micropython.org>
2024-10-09tools/mpremote: Make filesystem commands use transport API.Jim Mussared
This introduces a Python filesystem API on `Transport` that is implemented entirely with eval/exec provided by the underlying transport subclass. Updates existing mpremote filesystem commands (and `edit) to use this API. Also re-implements recursive `cp` to allow arbitrary source / destination. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com> Signed-off-by: Damien George <damien@micropython.org>
2024-10-09tools/mpremote: Make eval parse by default.Jim Mussared
This is a step towards making the transport expose a Python API rather than functions that mostly print to stdout. Most use cases of `transport.eval()` are to get some state back from the device, so have it return as a value directly by default. Updates uses of `transport.eval()` to remove the parse argument where it now isn't needed, make the `rtc` command use eval/exec, and update the `mip` command to use eval's parsing. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2024-10-02zephyr: Upgrade to Zephyr v3.7.0.Maureen Helm
Updates the Zephyr port build instructions and CI to use the latest Zephyr release tag. Tested on frdm_k64f. Signed-off-by: Maureen Helm <maureen.helm@analog.com>
2024-10-02tools/ci.sh: Upgrade Zephyr docker image 0.26.13 and SDK 0.16.8.Maureen Helm
Upgrades CI to use the latest versions of the Zephyr docker image and Zephyr SDK. Signed-off-by: Maureen Helm <maureen.helm@analog.com>
2024-09-23tools/ci.sh: Report code size for `VIRT_RV32` as well.Alessandro Gatti
This commit adds the `VIRT_RV32` board to the list of targets for calculating code size changes as part of the CI pipeline. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-23tools/metrics.py: Add VIRT_RV32 to the code size metrics.Alessandro Gatti
This commit adds the Qemu-based RISC-V 32 bits `VIRT_RV32` board to the list of ports/boards to be built for measuring code size changes. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-23tools/ci.sh: Let RV64 use a source-built version of libffi.Alessandro Gatti
This commit lets the RV64 port use the version of libffi that is bundled as a submodule in the MicroPython source tree, as the packaged libffi library coming from Ubuntu's RISC-V repository trashes foreign function call results on exit. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-19tools/mpy_ld.py: Support jumping more than 2k on armv6m architectures.Damien George
Native .mpy files targetting armv6m (eg RP2040) cannot currently have more than about 2kiB of native code (between the start of the file and the init function). This commit fixes that by using bigger jumps to jump to the init function. Signed-off-by: Damien George <damien@micropython.org>
2024-09-19tools/ci.sh: Clean up the Unix port's Arm target.Alessandro Gatti
The Unix port's Arm target CI steps have been updated to be more in line with the other targets (the MicroPython binary doesn't need an environment variable to be set in order to run now). Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-19tools/ci.sh: Add missing FFI helper for CI RV64 Unix builds.Alessandro Gatti
The FFI helper definition was accidentally omitted when committing the necessary shell code for building RV64 Unix builds in the CI environment. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-19tools/ci.sh: Clean up the Unix port's MIPS target.Alessandro Gatti
The Unix port's MIPS target CI steps have been updated to be more in line with the other targets (the MicroPython binary now runs as a dynamic executable), and the test exceptions for ffi have been lifted. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-19all: Remove tinytest component.Damien George
With the recent qemu (d9a0fdda9a7b0db55c1115b55bb1b83cd5ce739c and 0426934969d06aa649ba903f5408cb331b5b9c2d) and zephyr (05cad7b56f5d460db26a468a05bfdeabe4a656db) changes to how their tests are run, two things became unused: - The tinytest framework, which embedded a set of tests and their expected output within firmware, so these tests could be run stand-alone. - The `--write-exp` and `--list-tests` options to `tests/run-tests.py`, which were needed primarily to generated the expected test output for tinytest (also the associated `tests/run-tests-exp.py/.sh` scripts are now unused). This commit removes the tinytest component and all its helper code. This eliminates a maintenance burden. Signed-off-by: Damien George <damien@micropython.org>
2024-09-06tools/mpy_ld.py: Ignore R_XTENSA_ASM_EXPAND relocation entries.Alessandro Gatti
As reported in #14430 the Xtensa compiler can add R_XTENSA_ASM_EXPAND relocation relaxation entries in object files, and they were not supported by mpy_ld. This commit adds handling for that entry, doing nothing with it, as it is only of real use for an optimising linker. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-06qemu: Rename qemu-arm port to qemu.Damien George
Because this port now supports multiple architectures. Signed-off-by: Damien George <damien@micropython.org>
2024-09-04qemu-arm: Merge RISC-V 32-bit support into qemu-arm port.Damien George
Currently both the qemu-arm and qemu-riscv ports share a lot of code and functionality. This commit merges the qemu-riscv port into the qemu-arm port. The only real differences between the two are the toolchains used to build the code, and the initialisation/startup framework. Everything else is pretty much the same, so this brings the following benefits: - less code duplication - less burden on maintenance - generalised qemu port, could in the future support other architectures A new board `VIRT_RV32` has been added to the qemu-arm port which is the existing RISC-V board from the qemu-riscv port. To build it: $ make BOARD=VIRT_RV32 repl To cleanly separate the code for the different architectures, startup code has been moved to ports/qemu-arm/mcu/<arch>/. Signed-off-by: Damien George <damien@micropython.org>
2024-09-04qemu-arm: Factor board config to mk fragments.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-09-04tools/mpy-tool.py: Support freezing rv32imc native code.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-08-28qemu-arm: Rework to provide a REPL and run tests via a pty serial port.Damien George
Currently, the qemu-arm (and qemu-riscv) port has two build modes: - a simple test that executes a Python string; and - a full test that uses tinytest to embed all tests within the firmware, then executes that and captures the output. This is very different to all the other ports. A difficulty with using tinytest is that with the large number of tests the firmware overflows its virtual flash size. It's also hard to run tests via .mpy files and with the native emitter. Being different to the other ports also means an extra burden on maintenance. This commit reworks the qemu-arm port so that it has a single build target that creates a standard firmware which has a REPL. When run under qemu-system-arm, the REPL acts like any other bare-metal port, complete with soft reset (use machine.reset() to turn it off and exit qemu-system-arm). This approach gives many benefits: - allows playing with a REPL without hardware; - allows running the test suite as it would on a bare-metal board, by making qemu-system-arm redirect the UART serial of the virtual device to a /dev/pts/xx file, and then running run-tests.py against that serial device; - skipping tests is now done via the logic in `run-tests.py` and no longer needs multiple places to define which tests to skip (`tools/tinytest-codegen.py`, `ports/qemu-arm/tests_profile.txt` and also `tests/run-tests.py`); - allows testing/using mpremote with the qemu-arm port. Eventually the qemu-riscv port would have a similar change. Prior to this commit the test results were: 743 tests ok. (121 skipped) With this commit the test results are: 753 tests performed (22673 individual testcases) 753 tests passed 138 tests skipped More tests are skipped because more are included in the run. But overall more tests pass. Signed-off-by: Damien George <damien@micropython.org>