summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-09-06zephyr: Enable some core features to get more thread tests passing.danicampora
All these features are enabled at the `MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES` level, and are required to get more of the thread tests passing. Signed-off-by: danicampora <danicampora@gmail.com>
2024-09-06zephyr: Re-implement the Zephyr console in non-blocking mode.danicampora
The standard Zephyr console implementation doesn't make use of `tty_set_rx_timeout()` and therefore all the functions to receive characters block indefinitely until data is received (including `console_read()`). This commit also releases the GIL where it applies, e.g. the REPL and the time sleep functions. Signed-off-by: danicampora <danicampora@gmail.com>
2024-09-06zephyr: Add threading support.danicampora
This commit implements the `_thread` module on the zephyr port. Due to the fact that we are still using a rather old version of Zephyr, `CONFIG_DYNAMIC_THREAD` is not available and therefore the stack for threads cannot be allocated dynamically, only at compile time. So for the time being and for the purpose of this commit, a maximum of 4 Zephyr threads (besides the main thread) can be created. Once we manage to update to the latest version of Zephyr this won't be a problem anymore. Configuration for the nrf52840dk is added as part of this change, because this board was used to test the threading support. The Zephyr option `CONFIG_THREAD_CUSTOM_DATA` is used to enable threading on a per board basis. The `thread.conf` file is added as a convenient way to enable threading. Signed-off-by: danicampora <danicampora@gmail.com>
2024-09-06samd/Makefile: Specify UF2 family in firmware.uf2.Alexandre Iooss
Set the UF2 firmware images family to Microchip SAMD21 or SAMD51. This helps tools such as file to identify built firmware. Signed-off-by: Alexandre Iooss <erdnaxe@crans.org>
2024-09-06tests/extmod/machine_uart_irq_txidle.py: Simplify the test script.robert-hh
Now that no minimal delay time is required for SAMD devices. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-09-06samd/mphalport: Simplify mp_hal_delay_ms().robert-hh
Do NOT use `mp_hal_delay_us()` for short delays. This was initially done to make short delays precise, but it does not allow for scheduling. Leave using `mp_hal_delay_us()` to user code if needed. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-09-06samd/mphalport: Fix an execution order bug in mp_hal_ticks_us_64().robert-hh
The upper 32 bit of the 64 bit ticks register was taken before disabling the interrupts. That may have caused a wrong return values. Besides that, the function may cause trouble when called in an IRQ context, because it unconditionally enables IRQ. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-09-06extmod/libmetal: Fix libmetal rules for mkdir dependencies.iabdalkader
Dependency on auto-generated libmetal should be an order only prerequisite. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-09-06extmod/modlwip: Fix compile error for lwIP with SLIP support.cajt
Fixes a compile error if STM32 port is compiled with: make BOARD=(..) MICROPY_PY_LWIP=1 MICROPY_PY_LWIP_SLIP=1 `sio_send()` and `sio_tryread()` now use `mp_get_stream`. Signed-off-by: Carl Treudler <cjt@users.sf.net>
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-06unix: Add a description of COPT in the README.Angus Gratton
This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-06unix: Expand the build steps in the README.Angus Gratton
- Present the default build dependencies in one place at the top, and make a separate section about building standalone. - Add steps for the "minimal" variant as well. - Document that building standalone requires autoconf and libtool. - Allow MICROPY_STANDALONE to be set as an environment variable. Fixes issue #11313. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-06shared/runtime/sys_stdio_mphal: Fix printed type for stdio streams.timdechant
The printed type for stdio streams indicates "FileIO", which is a binary IO stream. Stdio is not binary by design, and its printed type should indicate a text stream. "TextIOWrapper" suits that purpose, and is used by VfsPosix files. Signed-off-by: timdechant <timdechant.git@gmail.com>
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-06all: Remove remaining qemu-riscv references.Damien George
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/Makefile: Clean up SRC and OBJ variables.Damien George
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-09-04tests/run-tests.py: Automatically detect native arch and mpy-cross flag.Damien George
Now that some ports support multiple architectures (eg esp32 has both Xtensa and RISC-V CPUs) it's no longer possible to set mpy-cross flags based on the target, eg `./run-tests.py --target esp32`. Instead this commit makes it so the `-march=xxx` argument to mpy-cross is detected automatically via evaluation of `sys.implementation._mpy`. Signed-off-by: Damien George <damien@micropython.org>
2024-09-04tests/net_inet: Update micropython.org certificate for SSL tests.Damien George
The Let's Encrypt root certificate has changed so needs updating in this test. Signed-off-by: Damien George <damien@micropython.org>
2024-09-04esp32: Disable hardware stack protection on ESP32-C3.Angus Gratton
Workaround for what appears to be an upstream issue: https://github.com/espressif/esp-idf/issues/14456 This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-04esp32: Fix ARDUINO_NANO_ESP32 build configuration.Angus Gratton
Regression introduced by 5e692d04 now at MICROPY_HW_USB_CDC is set. The ARDUINO_NANO_ESP32 specifically builds shared/tinyusb/mp_usb_cdc.c for the 1200bps reset behaviour. However MicroPython esp32 doesn't yet use the rest of the shared/tinyusb functionality. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-03esp32: Add MICROPY_HW_USB_CDC macro for native USB-CDC serial.Angus Gratton
This fixes issue of ESP32-S3 switching its config over to USB serial/JTAG instead of native USB. The the existing logic was hard to follow, adding this config macro makes it easier to see which USB is in use and to have board definitions that enable/disable different USB levels. This commit also drops (nominal) support for manually setting CONFIG_ESP_CONSOLE_USB_CDC in sdkconfig. No included board configs use this and it didn't seem to work (if secondary console was set to the default USB Serial/JTAG then there is no serial output on any port, and if secondary console was set to None then linking fails.) Can be re-added if there's a use case for it. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-03esp32: Fix ESP32-C3 USB serial/jtag peripheral pre-IDF 5.1.Angus Gratton
Regression in 0a11832cd in IDF 5.0.x where macro CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED is not defined. With this patch, ESP32-S3 still USB Serial/JTAG incorrectly (now on all ESP-IDF versions). Closes #15701 This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-02tests/basics: Add tests for optional args to int.to_bytes/from_bytes.Amirreza Hamzavi
Signed-off-by: Amirreza Hamzavi <amirrezahamzavi2000@gmail.com>
2024-09-02py/objint: Make byteorder argument optional in int.from_bytes() method.Amirreza Hamzavi
This was made optional in CPython 3.11. Signed-off-by: Amirreza Hamzavi <amirrezahamzavi2000@gmail.com>
2024-09-02py/objint: Make length argument optional in int.to_bytes() method.Amirreza Hamzavi
This was made optional in CPython 3.11. Signed-off-by: Amirreza Hamzavi <amirrezahamzavi2000@gmail.com>
2024-09-02py/objint: Make byteorder argument optional in int.to_bytes() method.Amirreza Hamzavi
This was made optional in CPython 3.11. Signed-off-by: Amirreza Hamzavi <amirrezahamzavi2000@gmail.com>
2024-09-02stm32/boards: Enable RAM_ISR feature on boards with UART REPL.Andrew Leech
Allows mpremote file transfer to work correctly when mpremote is used over the ST-link USB/UART REPL port. Fixes issue #8386. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2024-09-02stm32: Add option to put ISR, flash and UART code in RAM.Andrew Leech
This allows UART RX to function while flash erase/writes operations are under way, preventing lost serial data so long as it fits in the UART RX buffer. This enables (among other things) mpremote to successfully copy files to boards that use a UART REPL. Enable via the following option placed in `mpconfigboard.mk`: MICROPY_HW_ENABLE_ISR_UART_FLASH_FUNCS_IN_RAM = 1 Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2024-08-29docs/library: Document the network.PPP class.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-08-29rp2: Integrate optional network.PPP.Damien George
Can be enabled by a board by enabling `MICROPY_PY_NETWORK_PPP_LWIP`. Signed-off-by: Damien George <damien@micropython.org>
2024-08-29stm32/lwip_inc: Implement LWIP_PLATFORM_DIAG macro in terms of printf.Damien George
This allows enabling lwIP debugging output. For example, to enable PPP debugging add the following to `mpconfigboard.h`: #define LWIP_DEBUG 1 #define PPP_DEBUG LWIP_DBG_ON Signed-off-by: Damien George <damien@micropython.org>
2024-08-29stm32/uart: Use timeout_char even with CTS enabled.Damien George
When timeout=0 (non-blocking mode) the UART should still wait for each character to go out. Otherwise non-blocking mode with CTS enabled is useless because it can only write one character at a time. Signed-off-by: Damien George <damien@micropython.org>
2024-08-29stm32/machine_uart: Return number of bytes written even with timeout.Damien George
The errcode should be cleared so the caller sees a successful write, even if it's a short write. Signed-off-by: Damien George <damien@micropython.org>
2024-08-29stm32/machine_uart: Allow changing only the baudrate.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-08-29stm32: Integrate optional network.PPP.Damien George
Can be enabled by a board by enabling `MICROPY_PY_NETWORK_PPP_LWIP`. Signed-off-by: Damien George <damien@micropython.org>
2024-08-29extmod/network_ppp_lwip: Add network.PPP via lwIP.Damien George
This commit adds a new `network.PPP` interface which works on any port that has bare-metal lwIP, eg rp2, stm32, mimxrt. It has been tested on stm32. A board needs to enable `MICROPY_PY_NETWORK_PPP_LWIP` and then it can use it as follows: import network ppp = network.PPP(uart) ppp.connect() while not ppp.isconnected(): pass # use `socket` module as usual, etc ppp.disconnect() Usually the application must first configure the cellular/etc UART link to get it connected and in to PPP mode first (eg ATD*99#), before handing over control to `network.PPP`. The PPP interface automatically configures the UART IRQ callback to call PPP.poll() on incoming data. Signed-off-by: Damien George <damien@micropython.org>
2024-08-29extmod: Update make and cmake scripts to work with latest lwIP.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-08-29lib/lwip: Update lwIP to STABLE-2_2_0_RELEASE.Damien George
This updates lwIP from STABLE-2_1_3_RELEASE, which was released in November 2021. The latest STABLE-2_2_0_RELEASE was released in September 2023. Signed-off-by: Damien George <damien@micropython.org>
2024-08-29tests/extmod_hardware: Add tests for machine.UART.IRQ_RX/RXIDLE/BREAK.Damien George
These all require hardware connections, so live in a different directory. Except for the IRQ_BREAK test of ESP32 devices a single UART with loopback is sufficient. General: SAMD21: Due to the limited flash size only SAMD21 devices with external flash support uart.irq(). IRQ_BREAK: ESP32 needs different UART devices for creating and sensing a break. Lacking a second UART the test is skipped for ESP32S2 and ESP32C3. RP2 does not pass the test reliable at 115200 baud, reason to be found. Thus the upper limit is set to 57600 Baud. Coverage: esp32 pass when different UART devices are used. rp2 pass up to 57600 baud IRQ_RX: SAMD21: Being a slow device it needs data to be sent byte-by-byte at 9600 baud, since the IRQ callback is scheduled delayed and then the flags do not match any more. The data matches since it is queued in the FIFO resp. ringbuffer. CC3200: The test cannot be performed since no calls are accepted in the IRQ handler like u.read(). Skipped. Coverage: cc3200 fail due to major differences in the implementation. esp32 pass nrf pass renesas-ra pass samd pass see the notes. stm32 pass IRQ_RXIDLE: STM32: With PyBoard the IRQ is called several times, but only once with the flag IRQ_RXIDLE set. Coverage: esp32 pass mimxrt pass renesas-ra pass rp2 pass samd pass for both SAMD21 and SAMD51 stm32 fail. see notes. Signed-off-by: Damien George <damien@micropython.org> Signed-off-by: robert-hh <robert@hammelrath.com>
2024-08-29tests/extmod: Add test for machine.UART.IRQ_TXIDLE.Damien George
The test checks whether the message created by the IRQ handler appears about at the end of the data sent by UART. Supported MCUs resp. boards: - RP2040 - Teensy 4.x - Adafruit ItsyBitsy M0 - Adafruit ItsyBitsy M4 - NRF52 (Arduino Nano Connect 33 BLE) Signed-off-by: Damien George <damien@micropython.org>
2024-08-29docs/library/machine.UART: Extend the documentation for UART.irq.robert-hh
For more ports and trigger options, based on the current state of the code. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-08-29docs/library/machine.UART: Fix UART.irq docs to match current code.Damien George
These docs now match the code in `extmod/machine_uart.c`. IRQ trigger support still need to be updated for each port (to be done in a follow-up commit). Signed-off-by: Damien George <damien@micropython.org>
2024-08-29esp32/machine_uart: Implement UART.RX_IDLE based on machine.Timer.robert-hh
The UART.IRQ_IDLE callback is called about two character times after the last byte, or 1 ms, whichever is larger. For the irq, timer 0 is used. machine_timer.c had to be reworked to make it's mechanisms available for machine_uart.c. The irq.flags() value is change only at a requested event. Otherwise keep the state. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-08-29renesas-ra/machine_uart: Implement UART.IRQ_RXIDLE based on softtimer.robert-hh
Allowing to define the trigger UART.IRQ_RXIDLE as well as UART.IRQ_RX. The delay for the IRQ_RXIDLE interrupt is about 3 character times or 1-2 ms, whichever is larger. The irq.flags() value is changed only with an expected event. Do not change it otherwise. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-08-29samd/machine_uart: Implement UART.IRQ_RXIDLE based on the softtimer.robert-hh
With the softtimer the minimal delay between the end of a message and the trigger is 2 ms. For baud rates <= 9600 baud it's three character times. Tested with baud rates up tp 115200 baud. The timer used for RXIDLE is running only during UART receive, saving execution cycles when the timer is not needed. The irq.flags() value is changed only with an expected event. Do not change it otherwise. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-08-29stm32/machine_uart: Add the UART.IRQ_RX event for UART.irq().robert-hh
Just adding the event symbol. No code change required, and no impact on code execution time when the event is not selected. Tested with STM32F4xx, STM32F7xx and STM32H7xx. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-08-29nrf/modules/machine/uart: Implement Python UART IRQ for nrf52840 boards.robert-hh
Supported triggers: UART.IRQ_RX and UART.IRQ_TXIDLE. It will probably work on other boards as well, but so far untested. The irq.flags() value is changed only when requested by a triggered event. Do not change it otherwise. Signed-off-by: robert-hh <robert@hammelrath.com>