summaryrefslogtreecommitdiffstatshomepage
Commit message (Collapse)AuthorAge
* py/makeqstrdata.py: Implement MicroPython compatibility.Volodymyr Shymanskyy2025-03-05
| | | | | | | This allows running `py/makeqstrdata.py` with MicroPython itself. Signed-off-by: Volodymyr Shymanskyy <vshymanskyi@gmail.com> Signed-off-by: Angus Gratton <angus@redyak.com.au>
* zephyr/machine_wdt: Add watchdog timer implementation.danicampora2025-03-05
| | | | | | | | Simple implementation in-line with the rest of the MicroPython ports Tested on the nRF52832 and the nRF5340. Signed-off-by: danicampora <danicampora@gmail.com>
* py/modsys: Add sys.implementation._build entry.Damien George2025-03-05
| | | | | | | | | | | | | | | | | | | For a given MicroPython firmware/executable it can be sometimes important to know how it was built, which variant/board configuration it came from. This commit adds a new field `sys.implementation._build` that can help identify the configuration that MicroPython was built with. For now it's either: * <VARIANT> for unix, webassembly and windows ports * <BOARD>-<VARIANT> for microcontroller ports (the variant is optional) In the future additional elements may be added to this string, separated by a hyphen. Resolves issue #16498. Signed-off-by: Damien George <damien@micropython.org>
* test/run-tests: Print a note if it looks like unittest.main() missing.Angus Gratton2025-03-04
| | | | | | This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
* tests/run-tests: Remove any 'expected' file from a unittest run.Angus Gratton2025-03-04
| | | | | | | | | | This won't be generated normally, but a failed run (for example, from a unittest with an error or which doesn't call unittest.main()) will generate one. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
* docs/samd: Update the SAMD documentation describing default IDs/pins.robert-hh2025-03-03
| | | | | | | | | | | | Changes are: - Add the RX/TX pins to the table. In most cases these are the D0/D1 pins. - Document the ability for the instantiation of the default devices without submitting ID or pins. - Improve the example script creating the pin list to show multiple name assigments to the same pin. - Fix errors in the pinout document. Signed-off-by: robert-hh <robert@hammelrath.com>
* samd/boards: Provide default IDs for UART, I2C and SPI.robert-hh2025-03-03
| | | | | | | In combination with the defautl Pins the default device can now be instantiated e.g. as: uart = UART(). Similar for I2C and SPI. Signed-off-by: robert-hh <robert@hammelrath.com>
* samd/boards: Add missing TX/RX, SCL/SDA and SCK/MOSI/MISO pin names.robert-hh2025-03-03
| | | | | | These were missing and are needed to support UART/I2C/SPI default pins. Signed-off-by: robert-hh <robert@hammelrath.com>
* samd/machine_uart: Support default instance and TX/RX pin values.robert-hh2025-03-03
| | | | | | | If a board configures a default UART instance and/or TX/RX pins then the user can create a default UART object using `machine.UART()`. Signed-off-by: robert-hh <robert@hammelrath.com>
* samd/machine_spi: Support default instance and SCK/MOSI/MISO pin values.robert-hh2025-03-03
| | | | | | | | | | If a board configures a default SPI instance and/or SCK/MOSI/MISO pins, then the user can create a default SPI object using `machine.SPI()`. Also, if MISO is not going to be used, then MISO can be set to `None` with `miso=None`. Signed-off-by: robert-hh <robert@hammelrath.com>
* samd/machine_i2c: Support default instance and SCL/SDA pin values.robert-hh2025-03-03
| | | | | | | | | If a board configures a default I2C instance and/or SCL/SDA pins, then these no longer need to be given in the constructor. This allows the user to easily construct the default I2C instance via `machine.I2C()` and that will work on the default pins as designated on the board silkscreen. Signed-off-by: robert-hh <robert@hammelrath.com>
* py/objstr: Support tuples and start/end args in startswith and endswith.Glenn Moloney2025-03-02
| | | | | | | | | | | | | | This change allows tuples to be passed as the prefix/suffix argument to the `str.startswith()` and `str.endswith()` methods. The methods will return `True` if the string starts/ends with any of the prefixes/suffixes in the tuple. Also adds full support for the `start` and `end` arguments to both methods for compatibility with CPython. Tests have been updated for the new behaviour. Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
* renesas-ra/modrenesas: Expose the Flash block device to Python code.robert-hh2025-02-28
| | | | | | | | | | | | A new module called renesas is added, like in other ports. The accessible block device allows to use Python methods for creating and modifying the file system. The Flash block device for the file system can be accessed with: from renesas import Flash bdev = Flash(start=0) Signed-off-by: robert-hh <robert@hammelrath.com>
* docs/library/machine.Pin: Show availability of low, high and toggle.robert-hh2025-02-28
| | | | Signed-off-by: robert-hh <robert@hammelrath.com>
* cc3200/mods/pybpin: Implement Pin.toggle() method.robert-hh2025-02-28
| | | | | | Tested with a WiPy 1 board. Signed-off-by: robert-hh <robert@hammelrath.com>
* esp8266/machine_pin: Implement Pin.toggle() method.robert-hh2025-02-28
| | | | | | | Tested with a generic ESP8266 device. The actual output value is taken from the output register, not by reading the pad level. Signed-off-by: robert-hh <robert@hammelrath.com>
* esp32/machine_pin: Implement Pin.toggle() method.robert-hh2025-02-28
| | | | | | | | | | | | | | The actual output pin value is taken from the OUT register, not from the pad. Tested with: - ESP32 low and high Pin numbers - ESP32C3 low Pin numbers - ESP32C6 low Pin numbers - ESP32S2 low and high Pin numbers - ESP32S3 low and high Pin numbers Signed-off-by: robert-hh <robert@hammelrath.com>
* esp32/esp32_common.cmake: Allow overriding linker.lf.Karl Palsson2025-02-28
| | | | | | | | | | Particularly for out of tree builds, one may need to provide alternative or extra linker fragment files, or specify an absolute path to the default `linker.lf` file. In the default case, do nothing, provide a plain `linker.lf`, as before. Signed-off-by: Karl Palsson <karl.palsson@marel.com>
* esp32/README: Make some minor improvements to the README.garywill2025-02-28
| | | | | | | | | | | | Changes: - To add user to Linux dialout group, usermod is the universal Linux way. adduser is Debian-based way. - When installing IDF, we don't have to install all toolchains for all chips. - List currently supported chip models. - Other minor typo and gramma corrections. Signed-off-by: garywill <garywill@disroot.org>
* esp32/machine_i2c: Make I2C bus ID arg optional with default.Malcolm McKellips2025-02-28
| | | | | | | Similar to the previous commit, this allows constructing an I2C instance without specifying an ID. The default ID is I2C_NUM_0. Signed-off-by: Malcolm McKellips <malcolm.mckellips@sparkfun.com>
* rp2/machine_i2c: Make I2C bus ID arg optional with default.Malcolm McKellips2025-02-28
| | | | | | | | | | | | This commit gives the option to not pass an I2C Bus ID when creating a machine I2C object. If the ID is not provided, the default bus ID (which is `PICO_DEFAULT_I2C`) is used. This allows users to simply declare an I2C object with `machine.I2C()` without passing any arguments, thus creating an object with the default I2C ID, SCL, and SDA. Signed-off-by: Malcolm McKellips <malcolm.mckellips@sparkfun.com>
* rp2/boards/SPARKFUN_XRP_CONTROLLER_BETA: Add SparkFun XRP Controller.Dryw Wade2025-02-28
| | | | Signed-off-by: Dryw Wade <dryw.wade@sparkfun.com>
* rp2/boards/MACHDYNE_WERKZEUG: Add support for Machdyne Werkzeug.machdyne2025-02-28
| | | | Signed-off-by: machdyne <philip@machdyne.com>
* lib/pico-sdk: Update to version 2.1.1.Damien George2025-02-28
| | | | | | Release notes: https://github.com/raspberrypi/pico-sdk/releases/tag/2.1.1 Signed-off-by: Damien George <damien@micropython.org>
* tools/mpremote/tests: Add test for RemoteFile.readline.Damien George2025-02-28
| | | | Signed-off-by: Damien George <damien@micropython.org>
* tools/mpremote: Optimise readline support in mount.Andrew Leech2025-02-28
| | | | | | | This significantly speeds up readline on files opened directly from an mpremote mount. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
* py/parsenum: Reduce code footprint of mp_parse_num_float.Yoctopuce dev2025-02-28
| | | | | | | | | | | | | The mantissa parsing code uses a floating point variable to accumulate digits. Using an `mp_float_uint_t` variable instead and casting to `mp_float_t` at the very end reduces code size. In some cases, it also improves the rounding behaviour as extra digits are taken into account by the int-to-float conversion code. An extra test case handles the special case where mantissa overflow occurs while processing deferred trailing zeros. Signed-off-by: Yoctopuce dev <dev@yoctopuce.com>
* py/emitinlinextensa: Simplify register name lookup.Alessandro Gatti2025-02-28
| | | | | | | | This commit changes the Xtensa inline assembly parser to use a slightly simpler (and probably a tiny bit more efficient) way to look up register names when decoding instruction parameters. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
* py/emitinlinerv32: Reduce the footprint of compiled code.Alessandro Gatti2025-02-27
| | | | | | | | | | | | | | | | | | This commit introduces a few changes aimed at reducing the amount of space taken by the inline assembler once compiled: * The register string table uses 2 bytes for each qstr rather than the usual 4 * The opcode table uses 2 bytes for each qstr rather than the usual 4 * Opcode masks are not embedded in each opcode entry but looked up via an additional smaller table, reducing the number of bytes taken by an opcode's masks from 12 to 2 (with a fixed overhead of 24 bytes for the the masks themselves stored elsewhere) * Some error messages had a trailing period, now removed * Error messages have been parameterised when possible, and the overall text length is smaller. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
* py/emitinlinerv32: Fix compilation with ESP-IDF v5.2 and later.Alessandro Gatti2025-02-27
| | | | | | | | | This commit fixes a compilation warning (turned error) about a potentially uninitialised variable being used. The warning can be ignored as the variable in question is always written to, but the code has been changed to silence that warning. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
* extmod/vfs_rom: Add bounds checking for all filesystem accesses.Damien George2025-02-26
| | | | | | | | | | | | | | | | | | | Testing with ROMFS shows that it is relatively easy to end up with a corrupt filesystem on the device -- eg due to the ROMFS deploy process stopping half way through -- which could lead to hard crashes. Notably, there can be boot loops trying to mount a corrupt filesystem, crashes when importing modules like `os` that first scan the filesystem for `os.py`, and crashing when deploying a new ROMFS in certain cases because the old one is removed while still mounted. The main problem is that `mp_decode_uint()` has an loop that keeps going as long as it reads 0xff byte values, which can happen in the case of erased and unwritten flash. This commit adds full bounds checking in the new `mp_decode_uint_checked()` function, and that makes all ROMFS filesystem accesses robust. Signed-off-by: Damien George <damien@micropython.org>
* qemu/boards/SABRELITE: Increase MicroPython heap to 160k.Damien George2025-02-26
| | | | Signed-off-by: Damien George <damien@micropython.org>
* stm32/sdcard: Drop the pyb.SDCard timeout from 60 to 30 seconds.Angus Gratton2025-02-26
| | | | | | | | | | | | 60 seconds is long enough that the USB serial connection drops out before it times out (at least on my computer). Also refactor out the timeout argument from sdcard_wait_finished, to try and save a little code size. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
* stm32/sdcard: Fix unchecked uint32_t overflow in SD card driver.Angus Gratton2025-02-26
| | | | | | | | | | | | | Manifests as `readblocks(-1, buf)` failing. The ST HAL does a bounds check, but it checks `(block_num + num_blocks)` is within bounds, so if these values overflow then it allows the read which seems to hang some SD Cards (but not all). Fix by explicitly testing for overflow in our layer of the driver. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
* tests: Four typos in tests directory.Christian Clauss2025-02-25
| | | | | | Found by codespell. Signed-off-by: Christian Clauss <cclauss@me.com>
* all: Upgrade to ruff v0.9.6.Christian Clauss2025-02-25
| | | | Signed-off-by: Christian Clauss <cclauss@me.com>
* docs: Fix double 'the' in documentation.Ronald Weber2025-02-25
| | | | Signed-off-by: Ronald Weber <ronaldxweber@gmail.com>
* all: Upgrade codespell to v2.4.1.Christian Clauss2025-02-25
| | | | | | | This commit upgrades from codespell==2.2.6 to the current codespell==2.4.1, adding emac to the ignore-words-list. Signed-off-by: Christian Clauss <cclauss@me.com>
* github/workflows: Include the Python version in the ESP-IDF cache key.Angus Gratton2025-02-25
| | | | | | | Changing runner OS can change Python version, and ESP-IDF installs are keyed on ESP-IDF and Python version together. Signed-off-by: Angus Gratton <angus@redyak.com.au>
* github/workflows: Stop using ubuntu-20.04.Damien George2025-02-25
| | | | | | | | | | For GitHub Actions, ubuntu-20.04 is deprecated and will be removed by 1st April 2025. See announcement at https://github.com/actions/runner-images/issues/11101 This commit changes actions that use ubuntu-20.04 to a newer image. Signed-off-by: Damien George <damien@micropython.org>
* tools/mpremote: Add support for relative urls in package.json files.Glenn Moloney2025-02-24
| | | | | | | | | | | | | | | | | | | | | URLs in `package.json` may now be specified relative to the base URL of the `package.json` file. Relative URLs wil work for `package.json` files installed from the web as well as local file paths. Docs: update `docs/reference/packages.rst` to add documentation for: - Installing packages from local filesystems (PR #12476); and - Using relative URLs in the `package.json` file (PR #12477); - Update the packaging example to encourage relative URLs as the default in `package.json`. Add `tools/mpremote/tests/test_mip_local_install.sh` to test the installation of a package from local files using relative URLs in the `package.json`. Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
* mimxrt/hal/flexspi_nor_flash: Fix typo in comment about frequency.robert-hh2025-02-23
| | | | Signed-off-by: robert-hh <robert@hammelrath.com>
* mimxrt/boards/ADAFRUIT_METRO_M7: Reduce flash freq to 100MHz.robert-hh2025-02-23
| | | | | | | | | It was set to 133Mhz, but that is not stable. Reduce to 100MHz. The UF2 bootloader runs at 100MHz, so no need for a change of the bootloader. Signed-off-by: robert-hh <robert@hammelrath.com>
* esp32: Remove unneeded "memory.h" header file.Alessandro Gatti2025-02-23
| | | | | | | This commit removes "memory.h" from the ESP32 port tree, as it is no longer needed with recent ESP-IDF versions. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
* tools/ci.sh: Build the W5100S_EVB_PICO board with no threads.Angus Gratton2025-02-20
| | | | | | Serves as a build test for a config we don't otherwise support. Signed-off-by: Angus Gratton <angus@redyak.com.au>
* py/mkrules.cmake: Support passing CFLAGS_EXTRA in environment variable.Angus Gratton2025-02-18
| | | | | | | | | | | | | | This works similarly to the existing support in "bare metal" make ports, with the caveat that CMake will only set this value on a clean build and will reuse the previous value otherwise. This is slightly different to the CMake built-in support for CFLAGS, as this variable is used when evaluating source files for qstr generation, etc. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
* rp2: Fix build failure if threads are disabled.Angus Gratton2025-02-18
| | | | | | | | | | | | | Regression in 3af006ef meant that pendsv.c no longer compiled if threads were disabled in the build config. Add an implementation based on the earlier one (simple counter) for the non-threads case. It seems like with the current usage patterns there's no need for the counter to be incremented/decremented atomically on a single core config. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
* tests/multi_net: Add test for DTLS server and client.Damien George2025-02-14
| | | | | | | | | | | | | This adds a multi-test for DTLS server and client behaviour. It works on all ports that enable this feature (eg unix, esp32, rp2, stm32), but bare-metal ports that use lwIP are not reliable as the DTLS server because the lwIP bindings only support queuing one UDP packet at a time (that needs to be fixed). Also, to properly implement a DTLS server sockets need to support `socket.recvfrom(n, MSG_PEEK)`. That can be implemented in the future. Signed-off-by: Damien George <damien@micropython.org>
* extmod/modtls_mbedtls: Wire in support for DTLS.Keenan Johnson2025-02-14
| | | | | | | | | | | | | | | | | | | | | | | | | This commit enables support for DTLS, i.e. TLS over datagram transport protocols like UDP. While support for DTLS is absent in CPython, it is worth supporting it in MicroPython because it is the basis of the ubiquitous CoAP protocol, used in many IoT projects. To select DTLS, a new set of "protocols" are added to SSLContext: - ssl.PROTOCOL_DTLS_CLIENT - ssl.PROTOCOL_DTLS_SERVER If one of these is set, the library assumes that the underlying socket is a datagram-like socket (i.e. UDP or similar). Our own timer callbacks are implemented because the out of the box implementation relies on `gettimeofday()`. This new DTLS feature is enabled on all ports that use mbedTLS. This commit is an update to a previous PR #10062. Addresses issue #5270 which requested DTLS support. Signed-off-by: Keenan Johnson <keenan.johnson@gmail.com>
* extmod/lwip-include: Increase number of lwIP timers when mDNS enabled.Thomas Watson2025-02-14
| | | | | | | | | | | | | | | | | | | | | | | | | | Despite the code comments claiming one is sufficient, the mDNS application is capable of using up to twelve timers. Three per IP protocol are started at once in `mdns_start_multicast_timeouts_ipvX`, then another two per protocol can be started in `mdns_handle_question`. Further timers can be started for two additional callbacks. Having certain timers, such as `MDNS_MULTICAST_TIMEOUT`, fail to start due to none being free will break mDNS forever as the app will never realize it's safe to transmit a packet. Therefore, this commit goes somewhat overkill and allocates the maximal amount of timers; it's uncertain if all can run simultaneously, or how many callback timers are needed. Each timer struct is 16 bytes on standard 32 bit builds. Plus, say, 8 bytes of allocater overhead, that's 288 more bytes of RAM used which shouldn't be too horrible. Users who don't need mDNS can manually disable it to recover the RAM if necessary. This fixes mDNS on W5500_EVB_PICO (among other boards). Before, mDNS would work for a bit after connection until the host's cache expired a minute or two later. Then the board would never respond to further queries. With this patch, all works well. Signed-off-by: Thomas Watson <twatson52@icloud.com>