summaryrefslogtreecommitdiff
path: root/ports
AgeCommit message (Collapse)Author
22 hourstests/ports/unix: Add coverage test for readinto1 stream method.HEADorigin/masterorigin/HEADmasterDamien George
And expand the test for `readinto()` to test the difference between trying to read the requested amount by doing multiple underlying IO calls, and only doing one call. Signed-off-by: Damien George <damien@micropython.org>
22 hoursshared/runtime/mpirq: Check separate hard IRQ stack correctly.Chris Webb
On the zephyr port, hard IRQ handlers run with a separate stack on a different thread, so each call to mp_irq_dispatch() and mp_irq_handler() has to be wrapped with adjustments to the stack-limit checker. Move these adjustments into the shared mp_irq_dispatch(), introducing MICROPY_STACK_SIZE_HARD_IRQ which a port can define to non-zero if it uses a separate stack for hard IRQ handlers. We only need wrap the hard dispatch case. This should reduce binary size on zephyr without affecting other ports. Signed-off-by: Chris Webb <chris@arachsys.com>
22 hoursesp32/machine_timer: Warn that hard timers are not implemented.Chris Webb
machine.Timer() has inconsistent behaviour between ports: some run callbacks in hard IRQ context whereas others schedule them like soft IRQs. Most ports now support a hard= argument to the machine.Timer constructor or initialiser to explicitly choose between these behaviours. However, esp32 does not support hardware interrupts because they are not delivered to the main thread, so the interrupt handler would need to acquire the GIL. Raise a ValueError if hard=True is requested for esp32 machine.Timer. Signed-off-by: Chris Webb <chris@arachsys.com>
22 hoursesp8266/modmachine: Support hard IRQ timer callbacks.Chris Webb
machine.Timer() has inconsistent behaviour between ports: some run callbacks in hard IRQ context whereas others schedule them like soft IRQs. As on the rp2 port, add support to the esp8266 port for a hard= argument to explicitly choose between these, setting the default to False to match the existing behaviour. Open-code this as we don't link against mpirq.c so can't use mp_irq_dispatch(). Signed-off-by: Chris Webb <chris@arachsys.com>
22 hourszephyr/machine_timer: Support hard IRQ timer callbacks.Chris Webb
machine.Timer() has inconsistent behaviour between ports: some run callbacks in hard IRQ context whereas others schedule them like soft IRQs. As on the rp2 port, add support to the zephyr port for a hard= argument to explicitly choose between these, setting the default to False to match the existing behaviour. Adjust the stack-limit check to use the ISR stack while the callback is dispatched so that hard IRQ callbacks work, as with machine_pin.c and machine_i2c_target.c IRQ callbacks. Signed-off-by: Chris Webb <chris@arachsys.com>
22 hoursstm32/timer: Support soft IRQ timer callbacks.Chris Webb
machine.Timer() has inconsistent behaviour between ports: some run callbacks in hard IRQ context whereas others schedule them like soft IRQs. As on the rp2 port, add support to the stm32 port for a hard= argument to explicitly choose between these, setting the default to True to match the existing behaviour. Signed-off-by: Chris Webb <chris@arachsys.com>
22 hoursrenesas-ra/timer: Support soft IRQ timer callbacks.Chris Webb
machine.Timer() has inconsistent behaviour between ports: some run callbacks in hard IRQ context whereas others schedule them like soft IRQs. As on the rp2 port, add support to the renesas-ra port for a hard= argument to explicitly choose between these, setting the default to True to match the existing behaviour. Signed-off-by: Chris Webb <chris@arachsys.com>
22 hoursrp2/machine_timer: Use mp_irq_dispatch() to reduce duplication.Chris Webb
Now that mp_irq_dispatch() is available to dispatch arbitary hard/soft callbacks, take advantage of this for rp2 machine.Timer. This should slightly reduce binary size. Signed-off-by: Chris Webb <chris@arachsys.com>
33 hoursstm32/adc: Get ADC working on STM32N6 MCUs.Damien George
Changes made here for N6 are: - set RIF security attributes for ADC12 - clock ADC12 at 50MHz (maximum) so it runs at spec (max 5Msamp/sec) - increase sampling time for standard channels to 46.5 cycles - calibrate ADC in `adc.c` - correctly clear ADC_CFGR1_RES bits in `machine_adc.c` - set preselection register in `machine_adc.c` Signed-off-by: Damien George <damien@micropython.org>
42 hoursesp32/machine_uart: Call uart_wait_tx_done() only with driver installed.robert-hh
Otherwise an error message will pop up at the first instatiation of the UART object. Addresses #18122 / #18123. Signed-off-by: robert-hh <robert@hammelrath.com>
3 daysstm32/rtc: Fix RTC.wakeup issue for STM32G0.Yuuki NAGAO
To clear wakeup interrupt flag, set CWUTF on RTC_SCR instead of RTC_MISR. Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
3 daysstm32/timer: Enable RTCAPB_CLK for STM32G0.Yuuki NAGAO
To get worked pyb.RTC and machine.RTC on STM32G0. Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
3 daysstm32/timer: Fix Timer(4) issue for STM32G0.Yuuki NAGAO
The definition of TIM_ENTRY of TIM4 is incorrect. Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
3 daysstm32/machine_adc: Fix machine.ADC so it works on STM32G0.Yuuki NAGAO
Fixes are: - Enable VREG before initializing ADC. - The channel value of internal sensor should convert with __LL_ADC_CHANNEL_TO_DECIMAL_NB(). Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
3 daysstm32/adc: Fix pyb.ADC issue for STM32G0.Yuuki NAGAO
Fixes are: - The internal sensors of STM32G0 are connected channel 12, 13, 14. - Update adc_refcor before reading vbat and tempsensor because reference values are at VDDA=3.0V. - The method of initialize of sampling time is different with other MCUs: STM32G0 should initialize SamplingTimeCommon1/2 first. When reading value from ADC, ADC_ChannelConfTypeDef.SamplingTime should be specified SamplingTimeCommon1 or SamplingTimeCommon2. In this patch, SamplingTimeCommon2 is used for internal sensors and SamplingTimeCommon1 is used for external ADC channels. Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
3 daysstm32/powerctrlboot: Refactor clock settings for STM32G0.Yuuki NAGAO
Clock parameter definitions should be in `mpconfigboard.h` and use them at clock initialization. Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
3 daysstm32/make-stmconst.py: Fix missing peripheral consts in stm module.Yuuki NAGAO
Lines like the following were not handled by `make-stmconst.py`: #define APBPERIPH_BASE (PERIPH_BASE) This leads to missing definitions on stm module. For example, `stm.RTC` is not defined if `RTC_BASE` is defined as #define RTC_BASE (APBPERIPH_BASE + 0x00002800UL) because `APBPERIPH_BASE` is not handled as a valid id. This patch modifies the RegExp so it can handle the above. Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
3 daysunix/main: Ensure atexit function is called with -m <module>.Mike Wang
Previously, when running `micropython -m <module>` and the module called sys.exit(), the registered atexit function was not executed. This was due to sys.exit() raising a SystemExit exception, which bypassed the atexit handler. This change fixes the issue so that the atexit function is properly invoked when exiting via sys.exit(). Additionally, following the pattern in execute_from_lexer(), mp_hal_set_interrupt_char() and mp_handle_pending() handling were added to ensure that the atexit function is also executed when the user exits via Ctrl-C. Signed-off-by: Mike Wang <mikewang000000@gmail.com>
3 daysunix/modsocket: Set file descriptor to -1 on close.Mike Wang
After s.close(), s.fileno() now returns -1, matching CPython behavior. Some code relies on this compatibility, as it allows checking whether a socket is closed by testing its fileno() value. This change ensures better interoperability with existing Python code and libraries. Signed-off-by: Mike Wang <mikewang000000@gmail.com>
7 daysrp2/mpconfigport: Enable Zba opcodes in RISC-V mode.Alessandro Gatti
This commit enables generation of Zba opcodes by the native emitter for the Pico2, as its RISC-V implementation supports both of those extensions (see section 3.8 of the RP2350 datasheet). Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
7 daysqemu: Enable Zba opcodes for the VIRT_RV32 board.Alessandro Gatti
This commit enables the usage of the Zba address generation opcodes in the QEMU port when targeting the "VIRT_RV32" board, which emulates a generic RV32 target. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
7 daysqemu/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>
8 daysstm32/main: Use defined constants to enable N6 clocks during low power.Damien George
Use constants from the HAL instead of literal numbers to select which peripheral clocks are enabled during low power mode. Signed-off-by: Damien George <damien@micropython.org>
8 daysstm32/boards: Set RCC_HSE_BYPASS for relevant NUCLEO boards.Yuuki NAGAO
For NUCLEO boards that does not have HSE crystal, HSEState should set RCC_HSE_BYPASS to use HSE clock from ST-LINK 8MHz. Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
8 daysstm32/uart: Fix LPUART init failure with low baudrate.Yuuki NAGAO
UART prescaler value should set up correctly to initialize LPUART with low baudrate for STM32G0/G4/H5. This can be implemented similarly to STM32H7/N6/WB. Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
8 daysstm32/uart: Enable UART FIFO for STM32N6.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
8 daysstm32/i2c: Add hardware I2C implementation for STM32G4.Yuuki NAGAO
For STM32G4, hardware I2C can implement same as STM32L4 for machine.I2C. This commit makes to be able to use of hardware I2C in machine.I2C. Tested on NUCLEO-G474RE. Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
8 daysstm32/boards/NUCLEO_G474RE: Change flash latency for NUCLEO-G474RE.Yuuki NAGAO
For NUCLEO-G474RE, FLASH_LATENCY_4 can be specified instead of FLASH_LATENCY_8 because it runs at 170MHz. Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
8 daysstm32/boards/NUCLEO_F401RE: Change flash latency for NUCLEO-F401RE.Yuuki NAGAO
For NUCLEO-F401RE, FLASH_LATENCY_2 can be specified for flash latency because it runs at 84MHz. Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
10 daysunix/Makefile: Add additional testing targets.Jeff Epler
These are convenience targets for running specific tests as a developer. They are more useful that invoking run-tests directly as they take account of the VARIANT= specified on the make command-line. For instance, you can run all tests matching the regular expression "int" with `make VARIANT=... test//int`. The new targets are all documented in README.md. Signed-off-by: Jeff Epler <jepler@gmail.com>
10 daysunix/modsocket: Use type-checking mp_obj_get_int.Jeff Epler
MP_OBJ_SMALL_INT_VALUE would give erroneous results, such as assertion failures in the coverage build and other oddities like: >>> s = socket.socket() >>> s.recv(3.14) MemoryError: memory allocation failed, allocating 4235896656 bytes Signed-off-by: Jeff Epler <jepler@gmail.com>
11 daysports: Remove unneeded future imports.Jeff Epler
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
11 daysall: 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-11esp8266/main: Use new cstack API and add a stack margin of 64 bytes.Damien George
The margin of 64 bytes is needed to get `micropython/extreme_exc.py` to pass when run via-mpy. Signed-off-by: Damien George <damien@micropython.org>
2025-09-11py/stream: Add a stream.readinto1() method for machine.UART.robert-hh
Avoiding the double timeout when used with the UART class. `stream.readinto1()` returns after the first timeout. Fixes issue #17611. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-09-11esp32/machine_uart: Handle properly the timeout_char argument.robert-hh
Before, it was ignored. Tested with ESP32, ESP32S3, ESP32C6. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-09-11extmod/machine_uart: Return from read()/write() at the first timeout.robert-hh
Do not try to read/write again after timeout happened once. Fixes issue #17611. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-09-10py/gc: Clean up usage of GC_ALLOC_FLAG_HAS_FINALISER flag.Anson Mansfield
The calls signature for gc_malloc was changed in 5ed578e5b48730606536ded9a711223ae9a70262, without cleaning up existing code on the rationale that the previous bool is automatically converted to an int with the same meaning. This commit goes back and cleans up existing invocations to make their behavior more readable in a modern context. Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
2025-09-10esp32/machine_uart: Convert machine.UART objects to static instances.Angus Gratton
Makes machine.UART objects static instances (similar to other ports), adds machine_uart_deinit_all() function for cleanup on soft reset. - Fixes the case where the OS-level uart_event_task is leaked (along with 2KB of heap) when a UART object is garbage collected (including after a soft reset). - Fixes hard fault if a previous UART irq() fires after the UART object is garbage collected (including after a soft reset), but before any new UART object is instantiated for the same UART number. - Constructing multiple UART objects for the same UART now returns the same instance multiple times, not different instances. - Was also able to streamline deinit/init to only install the driver once, rather than install-with-defaults/uninstall/reinstall. Alternative would be to add a finaliser, but this is more consistent with how most other UART objects are implemented. 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-09esp32: Update esp_tinyusb component to v1.7.6.Angus Gratton
Reported to fix issues reported with serial corruption when interacting with MicroPython from macOS hosts. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-09-09esp32/usb: Fix building with USB CDC disabled.Alessandro Gatti
This commit fixes the build issues in the ESP32 port that arise when explicitly disabling USB CDC support. The USB support code gated the USB serial number retrieval behind the USB CDC support definition, even though all USB devices must be able to be queried for their serial number. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-09-09samd/mphalport: Fix building with USB CDC disabled.Alessandro Gatti
This commit fixes the build issues in the SAMD port that arise when explicitly disabling USB CDC support. The console code assumed CDC support is always enabled even if it was disabled in mpconfigport.h. These changes make accessing CDC conditional to that support configuration being enabled. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-09-09mimxrt/mphalport: Fix building with USB CDC disabled.Alessandro Gatti
This commit fixes the build issues in the MIMXRT port that arise when explicitly disabling USB CDC support. The console code assumed CDC support is always enabled even if it was disabled in mpconfigport.h. These changes make accessing CDC conditional to that support configuration being enabled. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-09-09rp2/mphalport: Fix building with USB CDC disabled.Alessandro Gatti
This commit fixes the linking issues in the RP2 port that arise when explicitly disabling USB CDC support. The console input ringbuffer needs to be made available if dupterm support is enabled, and the console character input function would always attempt to read from the input ringbuffer even if CDC support is disabled and the console isn't bound to any UART. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-09-08alif/tinyusb_port: Fix setting of USB device addr for fast hosts.Damien George
A fast host (eg Mac M4) may request the status for the SET_ADDRESS before TinyUSB gets to process it. This is because TinyUSB does not handle events inside the USB ISR, rather it waits for the top-level thread to process them. Fix that by setting the USB device address as soon as TUSB_REQ_SET_ADDRESS comes in. This patch follows the corresponding upstream fix: https://github.com/alifsemi/tinyusb/commit/fc40ea7fc6e6bd49baad6b504c88bb6a37c7a191 Signed-off-by: Damien George <damien@micropython.org>
2025-09-08zephyr/CMakeLists.txt: Enable sys.implementation._build.Damien George
This is, eg, `ZEPHYR_NUCLEO_WB55RG`. Signed-off-by: Damien George <damien@micropython.org>
2025-09-02stm32/boards/ARDUINO_OPTA: Reset ETH PHY on board init.iabdalkader
As required by the datasheet. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-09-02stm32: Enable I2CTarget for STM32L4.Chris Mason
STM32L4 uses the same I2C controller as STM32WB. Change `defined(STM32WB)` to `defined(STM32L4) || defined(STM32WB) ` in relevant files. Also remove the dummy definition of I2C2_BASE for STM32L432xx. It's now provided by the dummy definition in `i2cslave.h`. Signed-off-by: Chris Mason <c.mason@inchipdesign.com.au> Signed-off-by: Damien George <damien@micropython.org>
2025-09-01unix: Unlock heap before readline.Jeff Epler
This is intended to be equivalent to the unlock in shared/runtime/pyexec.c. Signed-off-by: Jeff Epler <jepler@gmail.com>