Commit Graph

16639 Commits

Author SHA1 Message Date
iabdalkader
309aa26811 rp2/mpconfigport: Switch FATFS LFN to type 2.
LFN type 2 uses the stack to allocate the internal working buffer for LFN,
which is thread-safe and saves about 512 bytes of BSS memory (at the
expense of needing that much memory on the stack).

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-12-10 11:04:49 +11:00
iabdalkader
fd01cdd203 stm32/mpconfigport: Switch FATFS LFN to type 2.
LFN type 2 uses the stack to allocate the internal working buffer for LFN,
which is thread-safe and saves about 512 bytes of BSS memory (at the
expense of needing that much memory on the stack).

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-12-10 11:02:52 +11:00
iabdalkader
89191b00ea stm32/main: Deinitialize SPI and I2C on soft-reset.
Following UART, CAN, Timer, etc.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-12-10 10:54:16 +11:00
iabdalkader
405aa69887 stm32/pyb_i2c: Add pyb_i2c_deinit_all function.
I2C objects can remain active after a soft-reboot because they are
statically allocated and lack a finalizer to collect and deinitialize them.
This commit adds a `pyb_i2c_deinit_all()` function for I2C, similar to
other peripherals such as UART, DAC, etc.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-12-10 10:53:47 +11:00
iabdalkader
d42e39d87d stm32/spi: Add spi_deinit_all function.
SPI objects can remain active after a soft-reboot because they are
statically allocated and lack a finalizer to collect and deinitialize them.
This commit adds a `spi_deinit_all()` functions for SPI, similar to other
peripherals such as UART, DAC, etc.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-12-10 10:53:24 +11:00
iabdalkader
17808e7b74 stm32/sdram: Make SDRAM refresh count configurable by a board.
Refresh count calculations were using a hard-coded SDRAM frequency and
refresh cycles, so change them to values that can be set by a board.

And set these options to their existing values on STM32F769DISC and
STM32F7DISC boards.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-12-10 10:49:50 +11:00
iabdalkader
47d9988df2 stm32/boards: Rename SDRAM frequency config option to make units clear.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-12-10 10:49:29 +11:00
iabdalkader
46ca78e23f stm32/boards: Update Arduino board configs for SPI reset and bootloader.
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
Update ARDUINO_GIGA, ARDUINO_OPTA, ARDUINO_NICLA_VISION and
ARDUINO_PORTENTA_H7 to:
- Enable SPI flash soft-reset.
- Disable enter bootloader via reset.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-12-10 10:44:33 +11:00
iabdalkader
b5e80fafb2 drivers/memory/spiflash: Add a config option to soft-reset SPI flash.
Add a compile-time config option to soft-reset SPI flash on init.  This
puts the flash in a known state on reset.  Note this option is
disabled by default.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-12-10 10:40:06 +11:00
iabdalkader
d5d366beef nrf/boards/ARDUINO_NANO_33_BLE_SENSE: Update LED and timer config.
Changes:
- Enable hardware timer.
- Define LED pins.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-12-10 10:37:02 +11:00
iabdalkader
67b4e6236b mimxrt: Switch to shared TinyUSB descriptor.
This removes duplicated TinyUSB configuration and port-specific code.

Tested on RT1062, CDC+MSC still working.  @robert-hh tested CDC with 1011,
1015, 1020 and 1176.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-12-10 10:29:21 +11:00
iabdalkader
c55202dd63 shared/tinyusb: Set MSC max endpoint size based on device speed.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-12-10 10:26:27 +11:00
iabdalkader
a118cf9ab0 extmod/extmod.mk: Fix libmetal build prefix.
libmetal source files already have the build directory prefix, because
they're auto-generated inside the build directory. When they're added
to `SRC_THIRDPARTY_C`, another build directory prefix is added resulting
in the object files being generated in a nested build directory.
This patch strips the build directory prefix before adding libmetal's
source files.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-12-10 10:25:02 +11:00
Damien George
2c80d36998 tests/extmod: Convert machine1.py test to use unittest.
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: Damien George <damien@micropython.org>
2024-12-06 13:48:23 +11:00
Damien George
c7c3ffa45f tests/net_hosted: Convert connect-nonblock-xfer test to use unittest.
This allows it to run parts of the test on esp8266 (or any target using
axTLS).

Signed-off-by: Damien George <damien@micropython.org>
2024-12-06 13:48:23 +11:00
Damien George
f62df1a2c2 tests/ports/stm32_hardware: Convert DMA test to use unittest.
Signed-off-by: Damien George <damien@micropython.org>
2024-12-06 13:48:23 +11:00
Damien George
d3d2976586 qemu/Makefile: Include unittest in firmware.
So that this port can run unittest-based tests.

Signed-off-by: Damien George <damien@micropython.org>
2024-12-06 13:48:07 +11:00
Damien George
42f37e951b esp8266/mpconfigport: Enable function attributes.
This allows `unittest` to work on esp8266 boards.

Signed-off-by: Damien George <damien@micropython.org>
2024-12-06 13:48:07 +11:00
Damien George
6dcbdec4de lib/micropython-lib: Update submodule to latest.
This brings in:
- umqtt.simple: add optional socket timeout to connect method
- aioespnow,webrepl: use recommended network.WLAN.IF_[AP|STA] constants
- unittest: allow SkipTest to work within a subTest
- unittest: always use "raise" with an argument

Signed-off-by: Damien George <damien@micropython.org>
2024-12-06 13:48:07 +11:00
Damien George
a8422439ab tests/run-tests.py: Print .out file when there is no .exp file.
So that a failing unittest-based test has its entire log printed when using
`run-tests.py --print-failures`.

Signed-off-by: Damien George <damien@micropython.org>
2024-12-06 13:47:21 +11:00
Damien George
a2554f0957 tests/run-tests.py: Add support for tests to use unittest.
All the existing tests require a .exp file (either manually specified or
generated running the test first under CPython) that is used to check the
output of running the test under MicroPython.  The test passes if the
output matches the expected output exactly.

This has worked very well for a long time now.  But some of the newer
hardware tests (eg UART, SPI, PWM) don't really fit this model, for the
following main reasons:

- Some but not all parts of the test should be skipped on certain hardware
  targets.  With the expected-output approach, skipping tests is either all
  or nothing.

- It's often useful to output diagnostics as part of the test, which should
  not affect the result of the test (eg the diagnostics change from run to
  run, like timing values, or from target to target).

- Sometimes a test will do a complex check and then print False/True if it
  passed or not, which obscures the actual test result.

To improve upon this, this commit adds support to `run-tests.py` for a test
to use `unittest`.  It detects this by looking at the end of the output
after running the test, looking for the test summary printed by `unittest`
(or an error message saying `unittest` was not found).  If the test uses
`unittest` then it should not have a .exp file, and it's not run under
CPython.  A `unittest` based test passes or fails based on the summary
printed by `unittest`.

Note that (as long as `unittest` is installed on the target) the tests are
still fully independent and you can still run them without `run-tests.py`:
you just run it as usual, eg `mpremote run <test.py>`.  This is very useful
when creating and debugging tests.

Note also that the standard test suite testing Python semantics (eg
everything in `tests/basics/`) will probably never use unittest.  Only more
advanced tests will, and ones that are not runnable under CPython.

Signed-off-by: Damien George <damien@micropython.org>
2024-12-06 13:41:52 +11:00
Amirreza Hamzavi
406bccc753 docs/library/binascii: Add docs for binascii.crc32 method.
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: Amirreza Hamzavi <amirrezahamzavi2000@gmail.com>
2024-12-03 22:22:55 +11:00
chuangjinglu
2e796d6c3e docs,ports: Fix some comments and error messages with doubled-up words.
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: chuangjinglu <chuangjinglu@outlook.com>
2024-11-30 13:08:33 +11:00
Alessandro Gatti
3de3821abf extmod/modplatform: Add Android to the recognised platforms list.
This commit adds code to distinguish between regular Linux and Android,
also adding a specific entry for the platform libc.  The reported libc
is marked as "bionic" and its version matches the Android platform API
version (there are no definitions for a specific bionic version).

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-11-30 12:42:51 +11:00
Alessandro Gatti
09cf01d7c1 extmod/modplatform: Add Clang to the known compilers list.
This commit adds support to distinguish between GCC and Clang to report
the appropriate compiler version.  Usually Clang also disguises itself
as GCC for compatibility reasons, but these changes look for
Clang-specific definitions first to avoid that problem.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-11-30 12:42:51 +11:00
Alessandro Gatti
579e840de6 extmod/modplatform: Distinguish AArch64 from AArch32.
This commit adds a new platform architecture name for Arm CPUs running
in 64 bits mode ("aarch64").  The 32 bits name is left as "arm" to
maintain compatibility with existing code.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-11-30 12:42:51 +11:00
Angus Gratton
beabef5aac esp32: Add missing network.STAT_CONNECT_FAIL constant.
The esp32 port had network.STAT_ASSOC_FAIL for the same purpose,
but this is undocumented and different to all other ports. That
constant is now deprecated.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-30 12:36:03 +11:00
dependabot[bot]
6dd976cc5c github/workflows: Bump codecov/codecov-action from 4 to 5.
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4 to 5.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-30 12:05:16 +11:00
Angus Gratton
d49c1e836c tools/ci.sh: Remove explicit macOS pkg-config install.
Reasons to remove this:

- GitHub's macOS runners install this package by default nowadays.

- Brew renamed this package to 'pkgconf' so installing the old name on top
  of the new package name has started failing.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-30 11:24:36 +11:00
Angus Gratton
eb80b04944 tests/extmod: Workaround CPython warning in asyncio_new_event_loop test.
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
This started failing in CI on the mingw build, after CPython updated to
3.12.7. The test prints two warnings during interpreter shutdown of
"Task was destroyed but it is pending!".

This didn't happen on other CPython builds, and I think that's because of
finalizer order in CPython interpreter shutdown but not certain (the loop
finalizer calls loop.close() if not already closed).

Adding explicit calls to loop.close() causes the warning to be printed on
every run with CPython 3.12.7 on Linux.

Next, added the workaround exception handler to swallow this exception
as MicroPython doesn't produce an equivalent.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-28 23:12:34 +11:00
Angus Gratton
8ec067272a github/workflows: Workaround using CPython 3.12 in MSYS2 builds.
Once MSYS2 repository updates past Python 3.12, this commit can be
reverted.

Explanation:

CPython 3.12 can't pass sys_settrace_features test (see parent commit for
explanation). MSYS2 mingw-w64-ARCH-python package is currently 3.12.7.

MSYS2 doesn't recommend installing old packages from their archive (due to
library dependencies), so switch to the GitHub CI setup-python action for
now.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-28 23:12:06 +11:00
Angus Gratton
8e11e5f1a1 tests/misc/sys_settrace_features.py: Add note about CPython 3.12 issue.
CPython 3.12 has a documented issue with settrace for opcodes, apparently
due to PEP 669.  "This behavior will be changed back in 3.13 to be
consistent with previous versions."

No easy way to make the test pass on CPython 3.12, but at least this helps
signal what the problem is to anyone who runs into a failure.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-28 23:11:36 +11:00
Angus Gratton
3b3b48892f py/objfloat: Workaround non-constant NAN definition on Windows MSVC.
Recent MSVC versions have changed the definition of NAN to a non-constant
expression!  This is a bug, C standard says it should be a constant.

Good explanation and workaround at: https://stackoverflow.com/a/79199887

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-28 23:11:24 +11:00
robert-hh
da692d01ac nrf/drivers/ticker: Reset slow ticker callback count on soft reboot.
The micro:bit board (and probably other boards using the music or display
module) locked up on soft reboot.  Reason was a buffer overflow caused by
an index counter, which was not reset on soft_reboot.

That's fixed in this commit.  Tested with a micro:bit board, performing a
series of soft reboots.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-11-28 23:02:46 +11:00
Corran Webster
e70048cf59 extmod/modframebuf: Fix 0 radius bug in FrameBuffer.ellipse.
This fixes a bug in FrameBuffer.ellipse where it goes into an infinite loop
if both radii are 0.

This fixes the bug with a simple pre-check to see if both radii are 0, and
in that case sets a single pixel at the center. This is consistent with the
behaviour of the method when called with just one of the radii set to 0,
where it will draw a horizontal or vertical line of 1 pixel width.

The pixel is set with setpixel_checked so it should handle out-of-bounds
drawing correctly.

This fix also includes three new tests: one for the default behaviour, one
for drawing out-of-bounds, and one for when the sector mask is 0.

Fixes issue #16053.

Signed-off-by: Corran Webster <cwebster@unital.dev>
2024-11-28 22:56:44 +11:00
Angus Gratton
154d141965 docs,esp32: Update machine.TouchPad docs for ESP32-S2 and ESP32-S3.
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: Angus Gratton <angus@redyak.com.au>
2024-11-28 15:45:39 +11:00
Angus Gratton
66e699e8a5 esp32: Fix machine.TouchPad startup on ESP32-S2 and S3.
Closes #13178.

TouchPad confirmed working on both chips, and fixes the the ESP32-S3
reading constant max value. Was unable to reproduce the bug on ESP32-S2 but
this may be due to my test setup, and it still works with the fix.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-28 15:45:39 +11:00
Angus Gratton
ed3c75a3af esp32: Use hardware version for touchpad macro defines.
ESP32 has hardware V1 and S2/S3 has V2, and future chips
may have different versions.

This should still compile to the same binary before and after.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-28 15:45:39 +11:00
Angus Gratton
0e383a31b9 tests: Add basic wlan test.
Includes adding some ESP8266 port output to the ignored output list for the
multitest runner.

This test passes on ESP8266 and various ESP32s (including talking to each
other). Without the fix in the parent commit, ESP32 AP will fail if the
station can report its channel (i.e. channel is wrong).

Testing with a CYW43 (RPI_PICO_W) currently fails but I have some fixes
to submit so it can pass as well.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-28 15:39:06 +11:00
Angus Gratton
951a10e707 esp32: Fix setting WLAN channel in AP mode.
- Previously the call to esp_wifi_set_channel() would be immediately
  overridden by calling esp_wifi_config(...) with the previous channel set.

- AP interface doesn't seem to need more than esp_wifi_config(...) to work.
  It will automatically configure 40MHz bandwidth and place the secondary
  channel using similar logic to what was being explicitly calculated here.

- However, calling esp_wifi_set_channel() on the STA interface is necessary
  if using this interface with ESP-NOW (without connecting to an AP). So
  the esp_wifi_set_channel() call is kept in for this purpose. Without
  this, tests/multi_espnow/70_channel.py fails.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-28 15:39:06 +11:00
Angus Gratton
7647c828de tests/multi_espnow: Add channel setting test, add some docs.
Test currently passes. It was added so it can be used to check for
regressions when fixing channel selection for AP mode in a follow-up
commit.

Also add some docs about how channel setting is observed to work for
ESP-NOW.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-28 15:39:06 +11:00
Andrew Leech
78d017fc4e py/usermod.cmake: If USER_C_MODULES is a folder add micropython.cmake.
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
This mirrors how it works when using a Makefile.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2024-11-20 17:38:39 +11:00
Andrew Leech
dccd206f4c py/usermod.cmake: Add check that any specified USER_C_MODULES exists.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2024-11-20 17:34:41 +11:00
Andrew Leech
b65e89107c py/py.mk: Add check that any specified USER_C_MODULES folder exists.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2024-11-20 17:34:41 +11:00
Angus Gratton
181800eebd extmod/network_cyw43: Allow configuring active AP interface.
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
Configuring the AP for cyw43 writes to some buffers that are only sent to
the modem when the interface is brought up. This means you can't configure
the AP after calling active(True), the new settings seem to be accepted but
the radio doesn't change.

This is different to the WLAN behaviour on other ports. The esp8266 port
requires calling active(True) on the AP before configuring, even.

Fix this by bouncing the AP interface after a config change, if it's
active. Configuring with active(False) still works the same as before.

Adds a static variable to track interface active state, rather than relying
on the LWIP interface state. This is because the interface state is updated
by a driver callback and there's a race: if code calls active(True) and
then config(a=b) then the driver doesn't know it's active yet and the
changes aren't correctly applied.

It is possible this pattern will cause the AP to come up briefly with the
default "PICOabcd" SSID before being reconfigured, however (due to the
aforementioned race condition) it seems like this may not happen at all
before the new config is applied.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-20 14:42:26 +11:00
Damien George
af743eaf59 extmod/network_cyw43: Fix uninitialised variable in status('stations').
The `num_stas` was uninitialised and if it happened to take the value 0
then no results were returned.  It now has the correct maximum value.

Signed-off-by: Damien George <damien@micropython.org>
2024-11-20 14:23:20 +11:00
Angus Gratton
f562aa1291 extmod/network_cyw43: Fix isconnected() result on AP interface.
This function is documented to return True if any stations are connected to
the AP. Without this fix it returns True whenever the driver has brought
the AP interface up.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-20 14:21:57 +11:00
Damien George
c1b8e65c8e docs: Change copyright line to mention "authors and contributors".
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
The docs have been authored by many people now.  Instead of singling out
individuals in the copyright line, prefer to mention all "MicroPython
authors and contributors".

Individual contributions can still be discovered via the git history.

Signed-off-by: Damien George <damien@micropython.org>
2024-11-19 11:39:39 +11:00
Angus Gratton
c5d74fe468 docs/library: Note link between machine.soft_reset() and sys.exit().
This is currently an implementation detail of MicroPython rather than by
design.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-19 10:58:00 +11:00
Angus Gratton
a23277e3b0 docs/esp32: Add a factory reset page.
This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-11-19 10:57:53 +11:00