Commit Graph

16680 Commits

Author SHA1 Message Date
Angus Gratton
12dd9cb745 docs/esp32: Add documentation for SPI Ethernet devices on esp32 port.
Also cross-link with the other WIZNET5K driver, to avoid confusion.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-11 12:56:42 +11:00
Neil Ludban
b11ba39c57 rp2/modules: Fix memory leak and logic bug in handling of _pio_funcs.
The `rp2` package use a global dict `_pio_funcs` to populate a namespace
for `@asm_pio` functions to be executed in.  That dict is not cleaned up
after use, keeping references to bound methods of a `PIOASMEmit`.  By not
setting/clearing all the functions, `asm_pio_encode` unintentionally allows
the use of the old directives (harmless) as well as `jmp` (in general,
produces the wrong output).

Fix that by making sure `_pio_funcs` is returned to its original state
after using it:

- For `@asm_pio` update the target dict from `_pio_funcs` and then set
  additional functions as needed, leaving `_pio_funcs` unchanged.

- For `asm_pio_encode`, borrow `_pio_funcs` to use as globals (avoiding a
  bunch of memory alloc/free) but delete the instruction entries after use.

Signed-off-by: Neil Ludban <neil.ludban@gmail.com>
2025-02-11 12:44:48 +11:00
Glenn Moloney
11c9656fad tools/mpremote: Support mip install from package.json on local fs.
Some checks are pending
unix port / settrace (push) Waiting to run
unix port / settrace_stackless (push) Waiting to run
unix port / macos (push) Waiting to run
unix port / qemu_mips (push) Waiting to run
unix port / qemu_arm (push) Waiting to run
unix port / qemu_riscv64 (push) Waiting to run
webassembly port / build (push) Waiting to run
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-mingw (i686, mingw32, dev) (push) Waiting to run
windows port / build-mingw (i686, mingw32, standard) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, dev) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, standard) (push) Waiting to run
windows port / cross-build-on-linux (push) Waiting to run
zephyr port / build (push) Waiting to run
Python code lint and formatting with ruff / ruff (push) Waiting to run
Add support for `mpremote mip install package.json` where `package.json` is
a json file on the local filesystem.

Without this, package json files can only be loaded from http, https,
github or gitlab URLs.

This is useful for testing `package.json` files for pacages in development
and for constructing one's own `package.json` files for Python packages
which are not yet available for installation using mip.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
2025-02-10 15:59:58 +11:00
iabdalkader
752c1672af tools/ci.sh: Build MIMXRT1060_EVK with MSC enabled as part of mimxrt CI.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-02-10 12:53:45 +11:00
iabdalkader
cb417505f3 mimxrt/boards: Reduce stack size for 1011 and 1015 MCUs.
Reduced to 16KBs to allow enabling MSC.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-02-10 12:53:32 +11:00
iabdalkader
2f646f93d3 mimxrt: Add optional MSC support.
Add MSC support using internal flash storage or SD card.

Note this is disabled by default, and can be enabled by boards if needed.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-02-10 12:52:45 +11:00
robert-hh
0a433a02e1 mimxrt/hal: Set the flexspi flash CLK frequency on boot.
The flash clock frequency may have been set to a different value by a
bootloader.  Set the frequency according to the configured value.  Use a
table of pre-calculated dividers to get the closest value for the flash
frequency, achieving for MIMXRT10xx:

  30 -> 30.85 MHz
  50 -> 49.65 MHz
  60 -> 60 MHz
  75 -> 75.13 MHz
  80 -> 80 MHz
  100 -> 99.31 Mhz
  133 -> 132.92 MHz
  166  -> 166.15 MHz

for MIMXRT1176:

  30 -> 31 MHz
  50 -> 52.8 MJz
  60 -> 58.7 MHz
  75 -> 75.4 MHz
  80 -> 75.4 MHz
  100 -> 105.6 MHz
  133 -> 132 MHz
  166 -> 176 MHz

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-10 11:32:26 +11:00
robert-hh
d40849d07d mimxrt/boards: Add flash configuration constants to mpconfigboard.mk.
And use these to initialize the LUT table properly for the various flash
types.  The different flash types differ by 3 parameters.  Thus it is
easier to just keep one copy of the qspiflash_config structure with the LUT
table and update it during flash initialisation as needed.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-10 11:31:58 +11:00
robert-hh
9eb9451d83 mimxrt/boards: Update the deploy instructions for the UF2 bootloader.
Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-10 11:31:50 +11:00
robert-hh
2a80d5c68b mimxrt/flash: Swap the order of disabling IRQ and disabling the cache.
This change stopped problems with USB IRQ happening during flash writes.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-10 11:31:28 +11:00
robert-hh
b251aec0fc mimxrt/hal: Update the LUT and re-enable PAGEPROGRAM_QUAD.
Changes:
- Change the LUT table ordering to be similar to the order of the
  UF2-Bootloader and fsl_romapi.h.
- Rewrite the LUT entry for PAGEPROGRAM_QUAD and update the LUT.  That
  enabled QUAD program again.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-10 11:30:44 +11:00
robert-hh
e574f68820 mimxrt: Add support for a UF2 bootloader.
Allowing to use e.g. the Adafruit bootloaders with MicroPython.  The .uf2
file is created in addition to the .bin and .hex files allowing to use the
latter ones without the bootloader for debugging and testing.

Changes:

- Set the location of the ISR Vector and .text segment to 0x6000C000 and
  0x6000C400.
- Reserve an area at the start of ITCM for a copy of the interrupt vector
  table and copy the table on reset to this place.
- Extend `machine.bootloader()` by setting the magic number to enable the
  bootloader on reset.
- Create a .uf2 file which skips the segments below 0x6000C000.

The bootloader has to be installed as a preparation step using the board
specific methods, but then the firmware's .uf2 file version can be
installed using the bootloader.  The bootloader can be invoked with:

- double reset
- calling machine.bootloader()
- Using the touch1200 method

Double reset is hard to achieve on MIMXRT boards, since there is no clean
reset pin.  Some MIMXRT boards provide it by switching the power.

Some boards are excluded from the .uf2 build:

- MIMXRT1050_EVK: The uf2 bootloader is built for the QSPI version of the
  board.  MicroPython supports the Hyperflash version.
- MIMXRT1176_EVK: No support for this board yet, but it should be possible.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-10 11:28:39 +11:00
Dryw Wade
b2ce9b6fb0 rp2/boards: Add SparkFun IoT Node LoRaWAN board.
Some checks failed
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
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
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (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: Dryw Wade <dryw.wade@sparkfun.com>
2025-02-08 13:26:06 +11:00
Markus Gyger
0662c55121 rp2/rp2_pio: Add side_pindir support for PIO.
Side-setting can also be used to change pin directions instead of pin
values.  This adds a parameter `side_pindir` to decorator `asm_pio()` to
configure it.

Also replaces a few close-by 0s with corresponding PIO.* constants.

Addresses issue #10027.

Signed-off-by: Markus Gyger <markus@gyger.org>
2025-02-08 12:34:26 +11:00
StrayCat
9d0a5ac7e9 esp32/boards: Enable I2S on ESP32C3 boards.
Signed-off-by: StrayCat <marcin.eu@gmail.com>
2025-02-08 12:06:33 +11:00
iabdalkader
d76733d058 mimxrt/mpconfigport: Remove hard-coded CMSIS header.
Some checks are pending
unix port / settrace (push) Waiting to run
unix port / settrace_stackless (push) Waiting to run
unix port / macos (push) Waiting to run
unix port / qemu_mips (push) Waiting to run
unix port / qemu_arm (push) Waiting to run
unix port / qemu_riscv64 (push) Waiting to run
webassembly port / build (push) Waiting to run
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-mingw (i686, mingw32, dev) (push) Waiting to run
windows port / build-mingw (i686, mingw32, standard) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, dev) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, standard) (push) Waiting to run
windows port / cross-build-on-linux (push) Waiting to run
zephyr port / build (push) Waiting to run
Python code lint and formatting with ruff / ruff (push) Waiting to run
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-02-07 22:39:45 +11:00
iabdalkader
67ebc537c3 mimxrt/machine_rtc: Fix build with new SDKs.
In more recent SDKs, this feature is actually disabled for the MIMXRT1062.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-02-07 22:39:37 +11:00
iabdalkader
e176fea95c mimxrt/irq: Add CSI IRQ.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-02-07 22:39:32 +11:00
robert-hh
e44a2c6921 docs/samd/pinout: Add pinout for the Generic SAMD board types.
The table shows the devices available at the pin and the respective package
letter.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07 18:02:52 +11:00
robert-hh
a84143d223 docs/samd/pinout: Add pinout for Adafruit NeoKey Trinkey and QT Py.
Only pins accessible at the board are shown.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07 18:02:52 +11:00
robert-hh
36a0a83997 samd/boards: Add support for the Adafruit NeoKey Trinkey board.
Tested with that board.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07 18:02:52 +11:00
robert-hh
6cbe145ca8 samd/boards: Add support for the Adafruit QT Py board.
Supporting a variant with an optional SPIFLASH device as well.  Tested both
variants with a QT Py board.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07 18:02:47 +11:00
robert-hh
ff9c6da88c samd/Makefile: Add support for board variants.
Tested with a Adafruit SAMD QT board, which may optionally be equipped with
SPIFLASH memory.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07 18:01:57 +11:00
robert-hh
6b2e359076 samd/boards: Add generic SAMD51x20 board definitions.
The definition uses the internal oscillator for clock and only internal
flash for the file system.

It works at SAMD51J20 device as well, only that fewer pins are accessible.

Tested with a SAMD51J20 board.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07 18:00:44 +11:00
robert-hh
9ced693ade samd/boards: Add generic SAMD51x19 board definitions.
The definition uses the internal oscillator for clock and only internal
flash for the file system.

It works at SAMD51G19 and SAMD51J19 devices as well, only that fewer pins
are accessible.

Tested with a SAMD51G19 and SAMD51J9 board.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07 18:00:36 +11:00
robert-hh
304467518f samd/boards: Add generic SAMD21x18 board definitions.
The definition uses the internal oscillator for clock and only internal
flash for the file system.

It works at SAMD21G18 and SAMD21E18 devices as well, only that fewer pins
are accessible.

Tested with a SAMD21E18, SAM21G18 and SAMD21J18 board.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07 17:59:35 +11:00
Alessandro Gatti
44a7731669 py/emitnative: Load and store words just once for Viper code.
This commit fixes two Xtensa sequences in order to terminate early when
loading and storing word values via an immediate index.

This was meant to be part of 55ca3fd675
but whilst it was part of the code being tested, it didn't end up in the
commit.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-02-07 17:45:10 +11:00
Alessandro Gatti
e37d498cc0 py/emitnative: Mark condition code tables as const.
This commit marks as const the condition code tables used when figuring
out which opcode sequence must be emitted depending on the requested
comparison type.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-02-07 17:44:38 +11:00
Alessandro Gatti
f594c6f66e tools/ci.sh: Add natmod tests for QEMU/Arm.
This commit adds the natmod tests for the MPS2_AN385 board running
inside QEMU to the CI pipeline.  Now natmod tests capabilities are equal
between the Arm and RV32 platforms for the QEMU port.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-02-07 17:37:04 +11:00
Alessandro Gatti
ca3090a33f qemu/Makefile: Fix shell interpolation for automated natmod tests.
This commit fixes the command used to run natmod tests, as it relied on
a string interpolation feature of the POSIX shell that was not working
as expected inside a makefile.

The interpolation was not performed from inside the makefile and the raw
command string was sent to the operating system for execution.  Now the
command is run by using a different type of string substitution, which
explicitly performs the interpolation using a POSIX shell for-loop.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-02-07 17:37:04 +11:00
Alessandro Gatti
dfd1d69a72 tests/run-natmodtests.py: Autodetect the test target architecture.
This commit lets the natmod tests runner to automatically detect the
architecture of the test target.  This allows to avoid to explicitly
pass the architecture name to the runner in test scripts.

However, the ability to manually specify a target was not removed but it
was made optional.  This way the user is able to override the
architecture name if needed (like if one wants to test an armv6 MPY on
an armv7 board).

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-02-07 17:37:04 +11:00
Andrew Leech
b603fa38b2 py/mkrules.mk: Reset USER_C_MODULES when building mpy-cross dependency.
When a port automatically compiles `mpy-cross`, if `USER_C_MODULES` is
provided by the user on the command line then it is also applied to the
`mpy-cross` build.  That can lead to build errors if the path is relative
and not found when building `mpy-cross`.

Fix that by explicitly resetting `USER_C_MODULES` when invoking the
`mpy-cross` build.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2025-02-07 17:24:43 +11:00
eggfly
71e8b27b26 esp32/README: Fix board in octal-SPIRAM example make command.
Some checks are pending
unix port / settrace (push) Waiting to run
unix port / settrace_stackless (push) Waiting to run
unix port / macos (push) Waiting to run
unix port / qemu_mips (push) Waiting to run
unix port / qemu_arm (push) Waiting to run
unix port / qemu_riscv64 (push) Waiting to run
webassembly port / build (push) Waiting to run
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-mingw (i686, mingw32, dev) (push) Waiting to run
windows port / build-mingw (i686, mingw32, standard) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, dev) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, standard) (push) Waiting to run
windows port / cross-build-on-linux (push) Waiting to run
zephyr port / build (push) Waiting to run
Python code lint and formatting with ruff / ruff (push) Waiting to run
Signed-off-by: eggfly <lihaohua90@gmail.com>
2025-02-07 13:13:26 +11:00
Angus Gratton
921f19fc9d tests/multi_wlan: Remove esp8266 port workaround.
Not needed due to parent commit.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-07 13:03:26 +11:00
Glenn Moloney
b1e6c2b655 esp8266/network_wlan: Make WLAN.config(channel=x) use wifi_set_channel.
Also permits channel option to be used for STA_IF interface.  This
provides compatibility with esp32 code, especially for espnow users.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
2025-02-07 12:21:39 +11:00
Glenn Moloney
4bed77cc23 esp8266/network_wlan: Make WLAN.config('channel') use wifi_get_channel.
Prior to this fix, `WLAN.config('channel')` would return an incorrect
channel for AP_IF if STA has connected to an external AP running on a
different channel.

The esp8266 now has the same behaviour as for esp32 per commit
98d1c50159.

Fixes issue #11463.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
2025-02-07 12:19:12 +11:00
Mike Bell
3699cf5f38 rp2/rp2_flash: Workaround multicore lockout not being reset.
With regression test.

See upstream bug https://github.com/raspberrypi/pico-sdk/issues/2201

Tested-by: Angus Gratton <angus@redyak.com.au>
Signed-off-by: Mike Bell <mdb036@gmail.com>
2025-02-07 12:13:34 +11:00
Damien George
81ab49a607 tests/ports/rp2: Add test for SLEEP_ENx registers over lightsleep.
Signed-off-by: Damien George <damien@micropython.org>
2025-02-07 11:53:16 +11:00
Carl Pottle
55ae597bb6 rp2/modmachine: Make lightsleep preserve SLEEP_EN0 and SLEEP_EN1.
The problem was introduced in d1423ef7a2,
calling `machine.lightsleep()` overwrites RP2xxx registers `SLEEP_EN0` and
`SLEEP_EN1` with their power on default values.

Prior to that commit the register values were saved on entry to lightsleep
and restored before returning.

These changes restores the earlier behavior.

Fixes issue #16502.

Signed-off-by: Carl Pottle <cpottle9@outlook.com>
2025-02-07 11:51:41 +11:00
Kwabena W. Agyeman
112f657765 stm32/eth: Make ETH DMA buffer attributes configurable.
Some checks failed
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
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
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (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: Kwabena W. Agyeman <kwagyeman@live.com>
2025-02-04 16:50:03 +11:00
Angus Gratton
990f50fbb8 py/gc: Reorder static functions for clarity.
Some checks failed
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
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
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (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
- Renamed gc_sweep to gc_sweep_free_blocks.
- Call gc_sweep_run_finalisers from top level.
- Reordered the gc static functions to be in approximate
  runtime sequence (with forward declarations) rather than
  in declaration order.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-03 15:02:02 +11:00
Angus Gratton
fd0e529a47 unix: Add recursive mutex support.
Allows refactoring the existing thread_mutex atomic section support to use
the new recursive mutex type.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-03 15:02:02 +11:00
Angus Gratton
3bfedd0f4a rp2: Migrate to the new mp_thread_recursive_mutex_t.
Necessary for GC support, also refactored pendsv usage.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-03 15:02:02 +11:00
Angus Gratton
4bcbe88e74 py: Add optional support for recursive mutexes, use for gc mutex.
Enabled by default if using threading and no GIL

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-03 15:02:02 +11:00
Angus Gratton
40e1c111e1 py/gc: Allow gc_free from inside a gc_sweep finalizer.
Do this by tracking being inside gc collection with a
separate flag, GC_COLLECT_FLAG. In gc_free(),
ignore this flag when determining if the heap is locked.

* For finalisers calling gc_free() when heap is otherwise unlocked,
  this allows memory to be immediately freed (potentially
  avoiding a MemoryError).

* Hard IRQs still can't call gc_free(), as heap will be locked via
  gc_lock().

* If finalisers are disabled then all of this code can be compiled
  out to save some code size.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-03 15:02:02 +11:00
Angus Gratton
8a2ff2ca73 py/gc: Split out running finalizers to a separate pass.
Currently a finalizer may run and access memory which has already been
freed. (This happens mostly during gc_sweep_all() but could happen during
any garbage collection pass.)

Includes some speed improvement tweaks to skip empty FTB blocks. These help
compensate for the inherent slowdown of having to walk the heap twice.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-03 15:02:02 +11:00
Angus Gratton
d642cce27a unix: Use the bare metal mbedTLS config in the coverage buiid.
This allows coverage to test MicroPython-specific features such as
the tracked alloc cleanups added in the parent commit.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-03 15:02:02 +11:00
Angus Gratton
97f444bfa0 extmod/mbedtls: Try GC before failing to setup socket on esp32, unix.
On mbedTLS ports with non-baremetal configs (mostly esp32, technically also
unix port), mbedTLS memory is allocated from the libc heap. This means an
old SSL socket may be holding large SSL buffers and preventing a new SSL
socket from being allocated.

As a workaround, trigger a GC pass and retry before failing outright.

This was originally implemented as a global mbedTLS calloc function, but
there is complexity around the possibility of C user modules calling into
mbedTLS without holding the GIL. It would be interesting to try making a
generic version for any malloc which fails, but this would require checking
for a Python thread and probably making the GIL recursive.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-03 15:02:02 +11:00
Angus Gratton
195bf05115 tests: Add a test for SSL socket memory leaks.
Test is for an issue reported on the micropython-lib Discord as
effecting the rp2 port umqtt.simple interface when reconnecting with TLS,
however it's a more generic problem.

Currently this test fails on RPI_PICO_W and ESP32_GENERIC_C3 (and no doubt
others). Fixes are in the subsequent commits.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-03 15:02:02 +11:00
Jeff Epler
bfb1bee6fe py/parsenumbase: Favor clarity of code over manual optimisation.
Some checks failed
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
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
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (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
Follow up to 13b13d1fdd, based on some
testing on godbolt, the manual code optimisation seems unnecessary for code
size, at least on gcc x86_64 and ARM, and it's definitely not good for
clarity.

Signed-off-by: Jeff Epler <jepler@gmail.com>
2025-01-29 12:39:05 +11:00