Commit Graph

4877 Commits

Author SHA1 Message Date
Angus Gratton
a54b5d9aed unix/variants: Add a 'longlong' variant to test 64-bit bigints in CI.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-07-18 00:11:08 +10:00
webreflection
c72a3e528d webassembly/objpyproxy: Avoid throwing on implicit symbols access.
Some checks failed
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
This commit improves get handling by guarding against implicit unknown
symbols accessed directly by specific JS native APIs.

Fixes issue #17657.

Signed-off-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
2025-07-17 14:37:53 +10:00
Damien George
0b698b8241 rp2/mpnetworkport: Deregister all sys timeouts when netif is removed.
When mDNS is active on a netif it registers a lot of timeouts, namely:

    mdns_probe_and_announce
    mdns_handle_tc_question

    mdns_multicast_probe_timeout_reset_ipv4
    mdns_multicast_timeout_25ttl_reset_ipv4
    mdns_multicast_timeout_reset_ipv4
    mdns_send_multicast_msg_delayed_ipv4
    mdns_send_unicast_msg_delayed_ipv4

    mdns_multicast_probe_timeout_reset_ipv6
    mdns_multicast_timeout_25ttl_reset_ipv6
    mdns_multicast_timeout_reset_ipv6
    mdns_send_multicast_msg_delayed_ipv6
    mdns_send_unicast_msg_delayed_ipv6

These may still be active after a netif is removed, and if they are called
they will find that the mDNS state pointer in the netif is NULL and they
will crash.

These functions could be explicitly removed using `sys_untimeout()`, but
`mdns_handle_tc_question()` is static so it's not possible to access it.
Instead use the new `sys_untimeout_all_with_arg()` helper to deregister all
timeout callbacks when a netif is removed.

Fixes issue #17621.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-17 13:39:10 +10:00
Damien George
8504391766 alif/lwip_inc: Refactor lwipopts.h to use extmod's common options.
This change is a no-op for the firmware.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-17 13:28:24 +10:00
Jeff Epler
628d53d23c unix/coverage: Expand mp_printf coverage tests.
Some checks failed
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Test 'l' and 'll' sized objects.  When the platform's `mp_int_t` is not 64
bits, dummy values are printed instead so the test result can match across
all platforms.

Ensure hex test values have a letter so 'x' vs 'X' is tested.

And test 'p' and 'P' pointer printing.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-16 11:13:08 +10:00
Yanfeng Liu
aa2362d4de unix/Makefile: Drop include path of "i686-linux-gnu".
Some checks failed
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
This drops use of non-existing path `/usr/include/i686-linux-gnu` as
default include paths shall suffice.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2025-07-15 14:03:06 +10:00
Yoctopuce dev
df05caea6c shared/timeutils: Standardize supported date range on all platforms.
Some checks failed
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
This is code makes sure that time functions work properly on a
reasonable date range, on all platforms, regardless of the epoch.
The suggested minimum range is 1970 to 2099.

In order to reduce code footprint, code to support far away dates
is only enabled specified by the port.

New types are defined to identify timestamps.

The implementation with the smallest code footprint is when
support timerange is limited to 1970-2099 and Epoch is 1970.
This makes it possible to use 32 bit unsigned integers for
all timestamps.

On ARM4F, adding support for dates up to year 3000 adds
460 bytes of code. Supporting dates back to 1600 adds
another 44 bytes of code.

Signed-off-by: Yoctopuce dev <dev@yoctopuce.com>
2025-07-09 11:54:21 +10:00
Yoctopuce dev
c4a88f2ce7 py/obj: Add functions to retrieve large integers from mp_obj_t.
This commit provides helpers to retrieve integer values from
mp_obj_t when the content does not fit in a 32 bits integer,
without risking an implicit wrap due to an int overflow.

Signed-off-by: Yoctopuce dev <dev@yoctopuce.com>
2025-07-09 11:54:21 +10:00
Jeff Epler
da3709a738 unix/coverage: Add missing MP_OBJ_FROM_PTR casts.
An attempt to build the coverage module into the nanbox binary failed, but
pointed out that these sites needed explicit conversion from pointer to
object.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-07-08 21:50:27 +10:00
Damien George
99740dbace stm32/stm32.mk: Error out if compiling for cortex-m55 on old gcc.
Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 16:28:58 +10:00
Damien George
50ea398b00 stm32/boards/NUCLEO_N657X0: Add new board definition files.
Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 16:28:58 +10:00
Damien George
3189e49d28 stm32/boards/OPENMV_N6: Add new board definition files.
Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 16:28:58 +10:00
Damien George
7016900fbe stm32/spi: Fail spi_init if pins can't be configured.
Follows the UART and I2C drivers.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 16:25:14 +10:00
Damien George
acb294f61a stm32/mboot: Add support for STM32N6xx MCUs.
Works in the usual USB DFU mode, and can program external SPI flash.  It
will enable XSPI memory-mapped mode before jumping to the application
firmware in the external SPI flash.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 16:25:14 +10:00
Damien George
96b8f3aebc stm32/boards: Add board support files for N6.
Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 16:25:14 +10:00
Damien George
959e910366 stm32/lwip_inc: Increase lwIP memory on N6.
Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 16:25:14 +10:00
iabdalkader
eaed2518fa stm32/main: Disable D-cache when debugging N6.
See ST Errata ES0620 - Rev 0.2 section 2.1.2.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-07-08 16:25:10 +10:00
Damien George
eb3ea9ee13 stm32: Add support for STM32N6xx MCUs.
This commit adds preliminary support for ST's new STM32N6xx MCUs.

Supported features of this MCU so far are:
- basic clock tree initialisation, running at 800MHz
- fully working USB
- XSPI in memory-mapped mode
- machine.Pin
- machine.UART
- RTC and deepsleep support
- SD card
- filesystem
- ROMFS
- WiFi and BLE via cyw43-driver (SDIO backend)

Note that the N6 does not have internal flash, and has some tricky boot
sequence, so using a custom bootloader (mboot) is almost a necessity.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 16:24:27 +10:00
Damien George
24fd5f7268 stm32/boards/make-pins.py: Support up to GPIO-O.
Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 16:24:27 +10:00
Yuuki NAGAO
eaffbacb10 stm32/machine_adc: Add machine.ADC implementation for STM32L1.
Some checks failed
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
2025-07-08 14:01:41 +10:00
Matt Trentini
42cfa7cdae stm32/dma: Extend STM32H5 DMA use to SPI3 and SPI4.
Attempting to configure SPI3 and SPI4 for the STM32H5 would fail with a
linker error.  This patch resolves that, ensuring that appropriate DMA
channels are assigned to those SPI resources.

Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
2025-07-08 13:57:58 +10:00
Yuuki NAGAO
f3c56c81ea stm32/irq: Change SPI IRQ priority to be higher than DMA IRQ.
On STM32H5/STM32H7, SPI flash cannot use as storage device with DMA.  SPI
interruption may not be genearated even if DMA transfer has been done.
This is due to lower priority of SPI interruption than DMA.

This commit changes SPI interrupt priority more higher than DMA's priority.

Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
2025-07-08 13:52:22 +10:00
Damien George
0975255f86 stm32/uart: Suppress additional RX idle IRQs on F4/L1.
These MCUs only clear the RX idle IRQ if the data register is read, which
won't occur if the only IRQ is the RX idle IRQ (because then reading and
discarding the DR may lead to lost data).

To work around this, explicitly suppress the RX idle IRQ so that it's only
passed through to the Python callback once.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 13:15:47 +10:00
Damien George
d5246cea61 stm32/machine_adc: Fix internal ADC channel reading on WB MCUs.
Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 13:15:39 +10:00
Damien George
c9adabc25a stm32/adc: Fix core temperature reading on WB55.
It needs a divisor of 100 because the calibration temperatures are 30 and
130 degrees, similar to the H5.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 13:15:35 +10:00
Damien George
841439d5fb stm32/adc: Simplify ADC calibration settings.
Combine the common settings for L1/L4/WB with existing G0/G4/H5 settings.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 13:14:48 +10:00
Damien George
ea2000b81d stm32/adc: Apply re-read errata for WB55.
Following 17898f8607.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 13:14:43 +10:00
Damien George
9a9e5529af zephyr/machine_pin: Retry configuring gpio with just GPIO_OUTPUT.
Some targets like frdm_k64f don't support GPIO_OUTPUT|GPIO_INPUT, so just
use GPIO_OUTPUT in those cases (it seems they still support reading the
current output state even when configured only as GPIO_OUTPUT, unlike other
targets which require both settings).

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 11:15:11 +10:00
Damien George
bf432a3e0f zephyr/machine_timer: Make machine.Timer id argument optional.
With a default of -1, for soft timer.  This matches other ports, and the
`extmod/machine_timer.c` implementation.

This change allows the `tests/extmod/machine_soft_timer.py` test to pass.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 11:15:11 +10:00
Damien George
0fd65c44cf zephyr/mpconfigport: Enable emergency exception buffer.
Needed to pass exception tests.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 11:15:11 +10:00
Damien George
6881618307 zephyr/mpconfigport: Enable sys.maxsize.
Costs +48 bytes.  Useful to introspect the target.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 11:15:11 +10:00
Damien George
ec65cac971 zephyr/boards/rpi_pico: Add board configuration for rpi_pico.
Although the rpi_pico can already build and run with the zephyr port, this
configuration improves it in a number of ways:
- Use the USB CDC ACM as the REPL, rather than just a UART.
- Enable I2C and SPI, and add I2C1.
- Enable a filesystem, which matches exactly the rp2 port's RPI_PICO
  configuration.  So switching between zephyr and rp2 is possible and will
  retain the filesystem.
- Make the MicroPython GC heap make the most use of the available RAM.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 11:15:11 +10:00
Damien George
0faddb3c8a zephyr/boards/nucleo_wb55rg: Enable BLE, I2C, SPI and add filesystem.
Bluetooth works well now on this board, so enable all supported features.

Also increase the MicroPython GC heap size to make use of the available
RAM.

Unfortunately the filesystem does not match the stm32 port's NUCLEO_WB55
configuration.  That's not possible to do because stm32 uses a 512 byte
flash erase size, while zephyr uses 4096 bytes.  But at least here in
zephyr there's now a sizable and usable filesystem.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 11:15:11 +10:00
Damien George
35880d432a zephyr/boards/frdm_k64f: Improve board configuration.
Changes:
- Enable CONFIG_PWM so that `machine.PWM()` works.
- Increase MicroPython GC heap size.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 11:15:11 +10:00
Damien George
d0ccaff5b7 zephyr/mpconfigport: Enable MICROPY_NLR_THUMB_USE_LONG_JUMP.
Needed for some ARMv6M boards, eg rpi_pico.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 11:15:11 +10:00
Damien George
07285323cf zephyr/mpconfigport: Enable import of mpy and a few related features.
Support for importing .mpy files is quite fundamental to MicroPython these
days, eg it allows installing more efficient .mpy code via "mip install"
(and installing `unittest` only works with the .mpy version because the .py
version uses f-strings, which are not enabled on the zephyr port).  So
enable it generally for use by all boards.

As part of this, also enable:
- min/max: needed by `micropython/import_mpy_invalid.py`, and widely used
- sys.modules: needed by `run-tests.py` to run .mpy tests with --via-mpy
- io module: needed to run .mpy tests, and useful for `io.IOBase`
- array slice assign: needed to run .mpy tests, and generally useful as a
  way to do a memory copy.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 11:15:11 +10:00
Damien George
16b00cd6e7 zephyr/mpconfigport: Enable machine.SoftI2C and machine.SoftSPI.
These work now that the C-level pin HAL is implemented.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 11:15:11 +10:00
Damien George
19814bf50f zephyr/mphalport: Implement C-level pin HAL.
Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 11:15:11 +10:00
Damien George
359887933c zephyr/machine_pin: Allow constructing a Pin with an existing Pin.
Following other ports.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 10:10:34 +10:00
Damien George
9b97a30943 zephyr/machine_pin: Add Pin.OPEN_DRAIN constant.
Adding this constant is all that's needed to support open-drain pins.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 10:10:33 +10:00
Damien George
6fd069e8a5 zephyr/src: Fix USB device_next driver to work with zephyr 4.0.0.
The blocklist argument is not available in zephyr 4.0.0.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 10:10:16 +10:00
Damien George
6a53319336 zephyr/src: Increase UART input buffer to 512 bytes and reduce latency.
There are two changes here:

1. Increase the UART input bufffer to 512 bytes.  That's necessary to get
   basic REPL reliability tests working, and helps improve `mpremote`
   usage, eg copying large files.

2. Remove `uart_sem` semaphore.  This is no longer needed because
   `zephyr_getchar()` should be fully non-blocking and have as low a
   latency as possible.  `mp_hal_stdin_rx_chr()` (which calls
   `zephyr_getchar`) already uses `MICROPY_EVENT_POLL_HOOK` to get
   an efficient wait, and doing an extra wait and check for the
   semaphore in `zephyr_getchar()` just introduces unnecessary latency and
   can lead to slower input, and potentially overflowing the UART input
   buffer.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 10:10:16 +10:00
Damien George
4951a06bbb zephyr: Enable sys.stdin/out/err.
This change enables `sys.stdin`, `sys.stdout` and `sys.stderr` objects.
They are useful for general IO, and also help with testing zephyr boards.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 10:10:16 +10:00
Damien George
6b82eb75be zephyr/main: Add /flash/lib or /sd/lib to sys.path on start up.
If there is a filesystem available, this change makes sure there is a "lib"
in `sys.path`, eg so that "mip install" works correctly.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 10:10:16 +10:00
Damien George
d9b4327c66 zephyr/main: Execute boot.py and main.py like other ports.
Changes here make the zephyr port act the same as other ports for the
start up and shut down sequence:
- `boot.py` is executed if it exists, and can force a soft reset
- `main.py` is only executed if in friendly REPL and if `boot.py` executed
  successfully; and it can also force a soft reset
- print "MPY: " before "soft reboot" on soft reset

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 10:10:16 +10:00
David Schneider
16d9e704ae zephyr: Update generated header path.
Support disabled LEGACY_GENERATED_INCLUDE_PATH compatibility option.
Since Zephyr 3.7 generated include files are namespaced.

See also: zephyrproject-rtos/zephyr@bbe5e1e6eb

Signed-off-by: David Schneider <schneidav81@gmail.com>
2025-07-08 09:53:24 +10:00
Damien George
5eb94df09e zephyr/prj.conf: Use UART for console as default, not CONSOLE_SUBSYS.
Most boards enable the UART console because it's needed for USB (where USB
CDC creates a virtual UART), and for ctrl-C to work.

The `prj_minimal.conf` settings still use CONSOLE_SUBSYS.

Fixes issue #17608.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 09:29:30 +10:00
Damien George
5321b666ea zephyr/README: Update URL describing QEMU network settings.
Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 09:29:30 +10:00
Damien George
9171865782 zephyr/boards: Disable WDT on qemu boards and networking for cortex_m3.
This gets qemu_x86 and qemu_cortex_m3 building with `prj.conf` settings.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 09:29:30 +10:00
Damien George
49dbe1e272 zephyr/machine_pin: Configure OUT pin also as input so it's readable.
Zephyr allows setting both GPIO_OUTPUT and GPIO_INPUT on a pin, which means
it's an output pin that can have its current value read.

Fixes issue #17596.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-08 08:57:48 +10:00