summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-08-28examples/network: Support full URLs in HTTP(S) client examples.Damien George
Not just the domain name. This gives better HTTP 1.0 examples if someone wants to copy them. Signed-off-by: Damien George <damien@micropython.org>
2024-08-28examples/network: Use SSLContext instead of old ssl.wrap_socket.Damien George
`ssl.wrap_socket()` is deprecated in CPython, so use `SSLContext` instead, so the example is a good example to copy. Signed-off-by: Damien George <damien@micropython.org>
2024-08-28examples/network: Support IPv4 and IPv6 in HTTP client examples.Damien George
The main changes here are to pass the address family and socket type to `getaddrinfo()`, and then use the result of the address lookup when creating the socket, so it has the correct address family. This allows both IPv4 and IPv6 to work, because the socket is created with the correct AF_INETx type for the address. Also add some more comments to the examples to explain what's going on. Fixes issue #15580. 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>
2024-08-28qemu-arm/uart: Implement uart_rx_chr.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-08-28qemu-arm/Makefile: Make the build directory reflect the board.Damien George
So multiple boards can be built at once. Signed-off-by: Damien George <damien@micropython.org>
2024-08-28shared/runtime/semihosting_arm: Add mp_semihosting_exit.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-08-28shared/runtime/semihosting_arm: Add mp_semihosting_rx_chars.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-08-28shared/runtime/semihosting_arm: Support semihosting on non-Thumb ARM.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-08-28github/workflows: Add CI to run tests against zephyr with qemu.Damien George
With this change, the zephyr port is tested against the standard test suite via the following scheme: - the zephyr port is built with the `qemu_cortex_m3` board and the `prj_minimal.conf` configuration - `qemu-system-arm` runs `zephyr.elf` - the zephyr console is redirected to a pts/pty - `tests/run-tests.py` is run in bare-metal mode against the pts/pty device This allows testing the zephyr port as though it were a physical board attached over a serial port. Signed-off-by: Damien George <damien@micropython.org>
2024-08-28zephyr: Increase CONFIG_CONSOLE_GETCHAR_BUFSIZE to 258.Damien George
It needs to be at least this big for `tools/pyboard.py` to work, which is used (among other things) by `tests/run-tests.py`. Signed-off-by: Damien George <damien@micropython.org>
2024-08-28zephyr: Remove obsolete tinytest test framework.Damien George
Commit f573e73baeddfb8fde59413e8053b538cf908f9b rewored the zephyr port to build MicroPython as a cmake target, and since that commit the `make-bin-testsuite` helper script no longer works (it requires a Makefile) and hence the tinytest test framework can no longer be run. Instead of fixing this, remove the option to use tinytest. Boards running zephyr can use the standard `tests/run-tests.py` script to run tests in the usual way. Signed-off-by: Damien George <damien@micropython.org>
2024-08-28tests/run-tests.py: Skip additional tests when slice unavailable.Damien George
Both of these tests require slice to be enabled. Signed-off-by: Damien George <damien@micropython.org>
2024-08-28tools/pyboard.py: Capture stdout for pts line.Damien George
The pts line printed by qemu-system-arm goes to stdout, not stderr. Redirect stderr to stdout in case other tools do print to stderr. Signed-off-by: Damien George <damien@micropython.org>
2024-08-26unix/coveragecpp: Include all API headers in the C++ code.stijn
Make the CI builds compile the public API as C++ to catch accidental introductions of incompatible code. Signed-off-by: stijn <stijn@ignitron.net>
2024-08-26extmod/network_wiznet5k: Add support for IPv6.Jared Hancock
This adds support for the WIZNET5K nic to use IPv6 with the LWIP stack. Additionally, if LWIP_IPV6 is disabled, the device is configured to drop all IPv6 packets to reduce load on the MCU. Signed-off-by: Jared Hancock <jared@greezybacon.me>
2024-08-26extmod/modtls_mbedtls: Optimise the DER certificate parsing fix.Angus Gratton
Small code size and binary size optimisation for the fix merged in 4d6d84983f370e48e81fb05fe31802e0a13fb369. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-08-26shared/tinyusb: Allow ports to define CDC TX/RX buffer sizes.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-08-26samd/mcu/samd21: Allow user to enable additional options.Rick Sorensen
Currently for samd21 some features are disable because of limited memory. With the ability to trade firmware and filesystem space, a user may wish to selectively enable some of these features. This change allows them to be enabled in board `mpconfigboard.h` or on the build command line for example. The selectively enable functions are: MICROPY_PY_FRAMEBUF, MICROPY_PY_SELECT, MICROPY_PY_ONEWIRE and MICROPY_PY_ASYNCIO. Signed-off-by: Rick Sorensen <rick.sorensen@gmail.com>
2024-08-26py/mkrules.mk: Fix 'make submodules' when building out-of-tree.Christian Walther
When MicroPython is used as a submodule and built from the containing project, e.g. for the embed port, `make submodules` fails because it goes looking for the sub-sub-module paths in the outer repository instead of in the micropython repository. Fix this by invoking git inside the micropython submodule. Signed-off-by: Christian Walther <cwalther@gmx.ch>
2024-08-22stm32/boards/STM32H7B3I_DK: Fix octo-spi pin configuration.nspsck
The original OSPIFLASH settings in the `mpconfigboard.h` contained some mistakes that prevented the firmware from compiling. These are now corrected and the firmware can be built with support for OSPI flash. Note: external storage in OSPI flash is not yet configured on this board. Signed-off-by: nspsck <teng.jiang94@gmail.com>
2024-08-22stm32/system_stm32: Allow selection of OSPI clock source.nspsck
Added a #if-block to `system_stm32.c` to check whether `MICROPY_HW_RCC_OSPI_CLKSOURCE` is defined. If that is the case, the clock source for the OSPI will be changed to the specified source. Signed-off-by: nspsck <teng.jiang94@gmail.com>
2024-08-22stm32/octospi: Add OSPI support for STM32H7 MCUs.nspsck
Added a if-statement to `octospi.c` to detect if the targeted MCU is one of the STM32H7 series. If that is the case, another set of variables are used for the `mp_hal_pin_config_alt_static_speed()` function, as well as for register `OCTOSPI1->CR`. This allows the STM32H723 and STM32H7B3 series MCU to use octo-spi flash like the STM32H573 series MCU. Signed-off-by: nspsck <teng.jiang94@gmail.com>
2024-08-22stm32/rfcore: Allow HSE to be a wakeup source for BLE for the WB55.Matt Trentini
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2024-08-20stm32/stm32_it: Enable PVD_PVM_IRQHandler for WB and WL MCUs.Andrew Leech
There is a gap in support for the PVD interrupt on STM32WBxx and STM32WLxx. This has been tested on NUCLEO_WB55 with the example code: from pyb import Pin, ExtInt def callback(line): print(line) PVD = 16 exti = ExtInt(PVD, ExtInt.IRQ_RISING_FALLING, Pin.PULL_DOWN, callback) exti.swint() Before this commit the CPU locks up as soon as the final line is run. After this commit it prints "16". Fixes issue #15548. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2024-08-20stm32/boards: Add missing images and update product URLs.Matt Trentini
There are some missing images at MicroPython Downloads. This commit attempts to resolve all the current issues, and add product URLs where missing. Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
2024-08-20esp32/boards: Remove all IDF3 variants.Matt Trentini
IDF 3 builds are very old now (it seems like the last successful builds are from 2021), and the current IDF 5 is stable. So remove IDF 3 variants. Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
2024-08-20samd/boards/ADAFRUIT_METRO_M4_EXPRESS: Remove wlan variant.Matt Trentini
There is no such variant. Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
2024-08-20rp2/modmachine: Set the peripheral frequency with machine.freq().robert-hh
By default, the peripheral clock for UART and SPI is set to 48 MHz and will not be affected by the MCU clock change. This can be changed by a second argument to `machine.freq(freq, peripheral_freq)`. The second argument must be either 48 MHz or identical with the first argument. Note that UART and SPI baud rates may have to be re-configured after changing the MCU clock. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-08-20rp2/main: Set the default clock frequency at boot.robert-hh
As a side effect, the peripheral clock will be set to 48Mhz and both UART and I2C will not be affected by CPu speed changed using `machine.freq()`. With the change the UART baud rate range is 50 to 3_000_000. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-08-20rp2/mphalport: Skip core1_entry if thread disabled.Phil Howard
If `MICROPY_PY_THREAD` is set to 0 (ie: a user C module wishes to use core1 exclusively) then the test of `core1_entry` would fail to compile with an "undeclared identifier" error. Fix it by wrapping in `MICROPY_PY_THREAD`. Signed-off-by: Phil Howard <phil@gadgetoid.com>
2024-08-20docs/mimxrt/quickref: Add a note about machine.RTC() subseconds.robert-hh
Telling that subseconds is not supported and returns always 0. This was changed in 913f9ad5ad9bb446c6e4310b6b5eda310098a1cf. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-08-20mimxrt/machine_pin: Clear IRQ flag when enabling or disabling IRQ.robert-hh
Preventing already pending IRQs to fire when not expected. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-08-20mimxrt/mimxrt_sdram: Fix pin config and comments.robert-hh
Signed-off-by: robert-hh <robert@hammelrath.com>
2024-08-19py/asmrv32: Use REG_TEMP2 whenever possible.Alessandro Gatti
The RV32 emitter used an additional temporary register, as certain code sequences required extra storage. This commit removes its usage in all but one case, using REG_TEMP2 instead. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-08-19py/asmrv32: Emit C.LW opcodes only when necessary.Alessandro Gatti
The RV32 emitter sometimes generated short load opcodes even when it was not supposed to. This commit fixes an off-by-one error in its offset eligibility range calculation and corrects one case of offset calculation, operating on the raw label index number rather than its effective offset in the stack (C.LW assumes all loads are word-aligned). Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-08-19py/asmrv32: Fix short/long jumps scheduling.Alessandro Gatti
The RV32 emitter always scheduled short jumps even outside the emit compiler pass. Running the full test suite through the native emitter instead of just the tests that depend on the emitter at runtime (as in, `micropython/native_*` and `micropython/viper_* tests`) uncovered more places where the invalid behaviour was still present. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-08-19py/objstr: Skip whitespace in bytes.fromhex().Glenn Moloney
Skip whitespace characters between pairs of hex numbers. This makes `bytes.fromhex()` compatible with cpython. Includes simple test in `tests/basic/builtin_str_hex.py`. Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
2024-08-16esp32/boards/LILYGO_TTGO_LORA32: Add OLED rst seq for board v1.0.Elvis Pfützenreuter
Signed-off-by: Elvis Pfützenreuter <epxx@epxx.co>
2024-08-16esp32/boards/M5STACK_ATOMS3_LITE: Add M5Stack AtomS3 Lite board.Matt Trentini
Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
2024-08-16esp32: Remove the increased stack limit margin for ESP32-C3.Angus Gratton
The extra limit for C3 dates from 6823514 which added C3 support. Measuring the minimum stack margins that can pass the stress tests I measured 768 bytes for ESP32-S3 and 512 bytes for ESP32-C3 on ESP-IDF V5.2.2 and similar on V5.0.4. i.e. The ESP32-C3 actually needs less stack margin not more! I think the extra margin for ESP32-C3 probably arose from: 1. Some toolchain inefficiency in the IDF V4.x RISC-V compiler codegen, that has since been improved. OR 2. The race condition that was fixed in e3955f42 where sometimes the limit wasn't set correctly at all. This seems to trigger more on C3, presumably some timing artifact, and I'd believe that some binaries might be more susceptible than others due to random factors. OR 3. Commit 6007f3e2062cc65fc8416f241c682e37eb956c11 which enabled custom NLR handling for ESP32-C3. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-08-16esp32: Fix Python cstack size for bluetooth irq callbacks.Angus Gratton
This value should have been adjusted when the new cstack API was adopted in e3955f421d1, as otherwise the stack limit is too small especially on ESP32-C3 where the stack limit was 6144 - 2048 - 2048. Some extra margin is needed for bluetooth irq because invoke_irq_handler() isn't a top-level task function, NimBLE calls through multiple layers first. Measuring this overhead on IDF V5.2.2 (by putting an abort() in invoke_irq_handler() and then measuring the stack size) yielded 672 bytes on ESP32-S3 and 612 bytes on ESP32-C3, similar to the size reported in cd66aa05cf. Sticking with 1024 bytes for added safety margin. This means on Xtensa the total margin for the BLE task stays the same (2048 bytes) as before switching to cstack. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-08-16esp32/mphalport: Print debug strings even before the GIL is ready.Alessandro Gatti
If verbose debugging is enabled there is some stdout output happening before the GIL is ready (for example, GC initialisation), and the code assumed that no string printing occurred before the interpreter was fully initialised. Printing long strings would operate without holding the GIL, which would crash if string output would happen too early in the startup process. This commit addresses that issue, making sure verbose debugging output will work even before the interpreter is fully initialised (as if it is not yet ready there's no GIL to take care of). Also, the threshold that would indicate whether a string is "long" (and thus requiring a GIL release/lock operation) or not was hardcoded to 20 bytes. This commit makes that configurable, maintaining 20 bytes as a default. Fixes issue #15408. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-08-16esp32/boards: Remove BLE from list of features for ESP32-S2.Matt Trentini
Fixes issue #15618. Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
2024-08-16esp32: Restore ESP32-C3 brownout detector settings to IDF defaults.Angus Gratton
Commit a66bd7a48925d318e1dd6ada756df947ffacdc12 added the ESP32_GENERIC_C3_USB board (now merged with ESP32_GENERIC_C3) and changed the brownout detector from the default level 7 (~2.51V) to level 4 (~2.92V). Raising the level again seems to fix random BOD resets on some of the cheaper ESP32-C3 dev boards (that likely skimp on power supply capacitance). Specifically, this change prevents random resets running multi_bluetooth tests on ESP32-C3 "SuperMini" board. Also removed from the LOLIN_C3_MINI board as it seems this config is a copy of the generic one. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-08-14esp32: Use the ESP-IDF default esp_console config for ESP32-C3.Angus Gratton
The ESP-IDF default on C3 is primary UART0, secondary USB serial/jtag. Previously MicroPython configured the primary as USB Serial/JTAG and manually worked with the UART0 console. However UART0 console stopped working this way in v5.2.2. The big change is that CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is no longer set, as primary console is UART0. However CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG is set and IDF provides a macro CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED which is set if either primary or secondary esp_console is USB serial/jtag. So need to use that macro instead. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-08-14esp32: Add support for ESP-IDF v5.2.2.Angus Gratton
Keeping older versions, however if the update goes well then these may be dropped in the future. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-08-14esp32/tools: Add metrics_esp32 size comparison script.Angus Gratton
Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-08-14esp32/boards: Build using newlib nano formatting functions.Angus Gratton
Saves code size, MicroPython doesn't appear to rely on any of the missing formatters (64-bit integers, c99-style named arguments). Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-08-14esp32/adc: Use new ADC calibration API in all cases.Angus Gratton
Replaces the deprecated ESP32 calibration API with the "line" method instead. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>