Commit Graph

16366 Commits

Author SHA1 Message Date
iabdalkader 51974f20e1 stm32/boards/ARDUINO_GIGA: Update board config files.
To remove duplicate HAL macros.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-09-24 12:56:59 +10:00
iabdalkader e5984fb6da stm32/boards/ARDUINO_NICLA_VISION: Update board config files.
Changes are:
- Add pre/post stop mode entry macros.
- Make SE05X pin accessible.
- Remove duplicate HAL macros.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-09-24 12:56:53 +10:00
iabdalkader a4e3830d39 stm32/boards/ARDUINO_PORTENTA_H7: Update board config files.
Changes are:
- Add pre/post stop mode entry macros.
- Make SE05X pin accessible.
- Remove duplicate HAL macros.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-09-24 12:56:42 +10:00
iabdalkader fc006a0412 stm32/boards/ARDUINO_OPTA: Add support for the Arduino Opta board.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-09-24 12:56:21 +10:00
iabdalkader 3a2252b4c2 stm32/powerctrl: Add pre/post stop mode entry macros.
These allow a board to perform actions before/after stop mode.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-09-24 12:55:54 +10:00
iabdalkader eec5eb4260 stm32/uart: Add UART RX/CTS pin pull config options.
The UART driver enables a pull-up on RX/CTS pins by default.  This can
cause UART to fail to receive in certain situations, eg with RS485
transceivers.

This commit adds compile-time configuration options to set the pull mode on
the RX and CTS pins of each UART.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-09-24 10:20:29 +10:00
Alessandro Gatti 3e085c3aa6 tools/ci.sh: Report code size for `VIRT_RV32` as well.
This commit adds the `VIRT_RV32` board to the list of targets for
calculating code size changes as part of the CI pipeline.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-23 13:03:26 +10:00
Alessandro Gatti 58e7689142 tools/metrics.py: Add VIRT_RV32 to the code size metrics.
This commit adds the Qemu-based RISC-V 32 bits `VIRT_RV32` board to the
list of ports/boards to be built for measuring code size changes.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-23 13:03:26 +10:00
Alessandro Gatti 8a9042a72b github/workflows: Update Ubuntu images for code size CI tasks.
This updates the Ubuntu OS image the code size CI tasks run on, from
20.04-LTS to 22.04-LTS.  This is needed because 20.04 didn't have
packages that are needed to build RISC-V 32 code.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-23 12:42:07 +10:00
Alessandro Gatti f1b88e0d59 gitignore: Add ffi_lib.so to the gitignore list.
When testing the Unix port with FFI tests enabled, the FFI helper
library that's built as part of the testing process is not removed after
the tests session end.

This commit adds the built library to the gitignore list, so it doesn't
mark the sourcetree as dirty if a test run for the Unix port was started
in the past.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-23 11:47:18 +10:00
Alessandro Gatti 8f465dfd10 unix/modffi: Restrict uint32_t values to 32 bits.
This commit clears the upper 32 bits of returned `uint32_t` values,
which are handled as `unsigned int`s by the MicroPython runtime and
thus could be extended to 64 bits on some platforms.

RV64 holds 32-bit values as signed integers when held in registers, but
the code handling the FFI unsigned int case did not take this into
account.  That introduced test failures when a 32-bit value had its most
significant bit set, as when performing the value extension from 32 to
64 bits, the upper half of the value would be filled with ones.

On 32 bit platforms this change should be converted to a no-op, and
on other 64 bit platforms that aren't RISC-V it shouldn't hurt as the
value being manipulated is expected to only hold valid bits in its lower
half.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-23 11:47:18 +10:00
Alessandro Gatti bb3c711c04 tools/ci.sh: Let RV64 use a source-built version of libffi.
This commit lets the RV64 port use the version of libffi that is bundled
as a submodule in the MicroPython source tree, as the packaged libffi
library coming from Ubuntu's RISC-V repository trashes foreign function
call results on exit.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-23 11:47:18 +10:00
Alessandro Gatti 9796625457 unix/modffi: Clean up FFI closures memory management.
This commit removes custom FFI closures alloc/free functions, in favour
of using the tracked allocation facility to allocate memory for FFI
callback objects.

This stems from linking issues in the Arm port when updating LibFFI to
the latest stable version, as the overridden alloc/free functions didn't
replace LibFFI's (unlike in other ports).  The original code did no
effective cleanup for allocated callback objects, so there is no real
impact when switching allocation strategy.

The tracked allocation feature used to be enabled only if the Bluetooth
stack integration was enabled.  This commit also enables tracked
allocation support if FFI support is enabled.

Co-authored-by: Damien George <damien@micropython.org>
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-23 11:47:18 +10:00
Alessandro Gatti 2b5feb9121 lib/libffi: Update libffi to 3.4.6.
Libffi is updated to the latest stable version (v3.4.6) as the version
of libffi that was linked by the repository predates the introduction of
RISC-V processors (both 32 and 64 bits).

This is necessary as the packaged version of libffi used by the CI for
RISC-V 64 turned out to simply not work correctly, whilst a source-built
version of libffi worked just fine.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-23 11:47:18 +10:00
Seon Rozenblum b08ddbba59 esp32/boards/UM_RGBTOUCH_MINI: Fix compile error with missing modules.
Signed-off-by: Seon Rozenblum <seon@unexpectedmaker.com>
2024-09-20 15:57:52 +10:00
Andrew Leech 7e14680a83 py/objringio: Add micropython.RingIO() interface for general use.
This commit adds a new `RingIO` type which exposes the internal ring-buffer
code for general use in Python programs.  It has the stream interface
making it similar to `StringIO` and `BytesIO`, except `RingIO` has a fixed
buffer size and is automatically safe when reads and writes are in
different threads or an IRQ.

This new type is enabled at the "extra features" ROM level.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2024-09-19 18:00:44 +10:00
shiggy 6c73573b34 esp32/boards/OLIMEX_ESP32_EVB: Add Olimex ESP32 EVB board definition.
This is for boards not covered by the Olimex ESP32 PoE implementation.  The
major setting is about the PHY interface configuration.

Tested with esp-idf v5.0.4 and Olimex ESP32 EVB boards.

Signed-off-by: shiggy <mail@shiggytech.de>
2024-09-19 15:56:27 +10:00
Seon Rozenblum 9b5f99eb59 esp32/boards: Add UM_OMGS3 and UM_RGBTOUCH_MINI board definitions.
This adds two new UM boards: OMGS3 and RGB Touch Mini.  Also fixed the
NanoS3 deploy info.

Signed-off-by: Seon Rozenblum <seon@unexpectedmaker.com>
2024-09-19 15:13:35 +10:00
Seon Rozenblum d775db72b9 esp32/boards/UM_FEATHERS3NEO: Add FeatherS3 Neo board definition.
Signed-off-by: Seon Rozenblum <seon@unexpectedmaker.com>
2024-09-19 15:06:04 +10:00
Michael Sawyer 230e521515 tests/ports/unix: Update and extend the modffi integer tests.
Added the "long" modffi tests. The tests could not be added to the existing
ffi_types test because two .exp files were required for the 32-bit and
64-bit results. Code common to both the ffi_types and type "long" tests was
factored into ffi_int_base. ffi_types was renamed to ffi_int_types to group
the related tests under the "ffi_int" prefix.

Signed-off-by: Michael Sawyer <mjfsawyer@gmail.com>
2024-09-19 15:00:17 +10:00
Michael Sawyer b05983ff6d unix/modffi: Fix signed integer cast in return_ffi_value.
Casting an ffi_arg to a signed int may truncate the value. E.g., when the
ffi_arg is 64-bit and the signed int is 32-bit. Also, casting an ffi_arg
to a larger signed type will not sign extend the value. E.g., when the
ffi_arg is 32-bit and the larger signed type is int64_t. If the value is
signed, it should be cast to ffi_sarg, which is the same size as ffi_arg.

Signed-off-by: Michael Sawyer <mjfsawyer@gmail.com>
2024-09-19 15:00:06 +10:00
Damien George 8b35f2c7fa tools/mpy_ld.py: Support jumping more than 2k on armv6m architectures.
Native .mpy files targetting armv6m (eg RP2040) cannot currently have more
than about 2kiB of native code (between the start of the file and the init
function).

This commit fixes that by using bigger jumps to jump to the init function.

Signed-off-by: Damien George <damien@micropython.org>
2024-09-19 14:52:58 +10:00
Alessandro Gatti 46d8db81d3 tools/ci.sh: Clean up the Unix port's Arm target.
The Unix port's Arm target CI steps have been updated to be more in
line with the other targets (the MicroPython binary doesn't need an
environment variable to be set in order to run now).

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-19 13:49:12 +10:00
Alessandro Gatti 52d5f39881 tools/ci.sh: Add missing FFI helper for CI RV64 Unix builds.
The FFI helper definition was accidentally omitted when committing the
necessary shell code for building RV64 Unix builds in the CI
environment.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-19 13:49:12 +10:00
Alessandro Gatti 7b5738ad86 tools/ci.sh: Clean up the Unix port's MIPS target.
The Unix port's MIPS target CI steps have been updated to be more in
line with the other targets (the MicroPython binary now runs as a
dynamic executable), and the test exceptions for ffi have been lifted.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2024-09-19 13:49:12 +10:00
Damien George 1be38e8077 tests/run-tests.py: Remove --write-exp and --list-tests options.
Removing the now-unused (see previous commit for details) `--write-exp` and
`--list-tests` options helps to simplify the rather complex logic in
`run-tests.py`.

Signed-off-by: Damien George <damien@micropython.org>
2024-09-19 13:36:04 +10:00
Damien George 067ef81cd0 all: Remove tinytest component.
With the recent qemu (d9a0fdda9a and
0426934969) and zephyr
(05cad7b56f) changes to how their tests are
run, two things became unused:

- The tinytest framework, which embedded a set of tests and their expected
  output within firmware, so these tests could be run stand-alone.

- The `--write-exp` and `--list-tests` options to `tests/run-tests.py`,
  which were needed primarily to generated the expected test output for
  tinytest (also the associated `tests/run-tests-exp.py/.sh` scripts are
  now unused).

This commit removes the tinytest component and all its helper code.  This
eliminates a maintenance burden.

Signed-off-by: Damien George <damien@micropython.org>
2024-09-19 13:31:36 +10:00
Angus Gratton 5d8878b582 shared/tinyusb: Only run TinyUSB on the main thread if GIL is disabled.
If GIL is disabled then there's threat of a race condition if some other
code specifically requests USB processing (i.e. to unblock stdio), while
a scheduled TinyUSB callback is already running on another thread.

Relies on the change in the parent commit, where scheduler is restricted
to main thread if GIL is disabled.

Fixes #15390 - "TinyUSB callback can't recurse" exceptions on rp2 when
using _thread module and USB serial I/O.

Adds a unit test for stdin functioning correctly in threads (fails on rp2
port without this fix).

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-19 13:17:01 +10:00
Angus Gratton 52a593cdb1 py/scheduler: Only run callbacks on the main thread if GIL is disabled.
Otherwise it's very difficult to reason about thread safety in a
scheduler callback, as it can run at any time on any thread - including
racing against any bytecode operation on any thread.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-19 13:17:01 +10:00
iabdalkader 451ba1cf38 rp2/modules: Fix FatFS boot script to detect invalid FAT filesystem.
This change helps detect if the filesystem is invalid, by also including
the first mount attempt within the try-except.  Then the FAT is reformatted
if needed.

Fixes issue #15779.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-09-19 13:04:48 +10:00
ZodiusInfuser ded8bbdd5e rp2/machine_pin_cyw43: Include check for CYW43_GPIO.
The `#if` check only checks that `MICROPY_PY_NETWORK_CYW43` and
`MICROPY_HW_PIN_EXT_COUNT` are defined.  This is a reasonable assumption
for the Pico W, but causes conflicts if someone wants to attach an external
IO expander to their Pico W and have its pins appear as Pin objects.

This commit addresses this by adding the additional checks, letting board
builds include wireless but separately choose whether the external IO pins
come from the cyw43 or not.

Signed-off-by: Christopher Parrott <chris@pimoroni.com>
2024-09-19 12:58:43 +10:00
ZodiusInfuser 79ba6d8ce7 rp2: Increase ext pins from 10 to 32.
To allow more pins when other ways are used to provide external GPIO (ie
not via cyw43).

Signed-off-by: Christopher Parrott <chris@pimoroni.com>
2024-09-19 12:54:20 +10:00
ZodiusInfuser 5dfd3ecd8b rp2: Add board-level hooks to main, and MICROPY_SOURCE_BOARD cmake var.
Signed-off-by: Christopher Parrott <chris@pimoroni.com>
2024-09-19 12:54:20 +10:00
Angus Gratton fb069f9d06 docs/library: Document machine.Pin.toggle() method.
Original commit was by @millosolomillo from 2022, but CI no longer accepts
their auto-generated GitHub commit email...

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-19 12:04:39 +10:00
Damien George 8feb714b4d docs/library: Document math.log with two arguments.
The functionality is there but was not documented.

Signed-off-by: Damien George <damien@micropython.org>
2024-09-17 11:22:26 +10:00
Damien George 3d53b39a2a docs/reference: Fix pyboard.py filesystem cp example with three files.
Fix documentation to match behaviour (directories are not preserved).

Fixes issue #11101.

Signed-off-by: Damien George <damien@micropython.org>
2024-09-17 11:20:17 +10:00
Paul Grayson 0d8388673e docs/esp32: Update pin access example with addresses for ESP32-S3.
Signed-off-by: Paul Grayson <pdg@alum.mit.edu>
Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-09-17 11:18:47 +10:00
Matt Trentini 7953089a25 examples/natmod: Fix URL links in README.md.
Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
2024-09-17 11:14:52 +10:00
Matt Trentini 976d9d148f stm32/boards/STM32F429DISC: Add DAC support to the STM32F429DISC.
The STM32F429DISC board definition did not have DAC enabled, however the
micro/board supports it so this commit enables the feature.

Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
2024-09-17 10:58:47 +10:00
Adrian Higgins 39ddfed9a0 stm32: Update STM32L452xx Multi OTG handling.
Added custom Multi OTG handling for STM32L452xx, based on STM32L432xx
handling.

Fixes issue #15795.

Signed-off-by: Adrian Higgins <adrian@higstar.com>
2024-09-17 10:56:23 +10:00
Amirreza Hamzavi f1bdac3752 unix/README: Fix typo in build dependencies.
Signed-off-by: Amirreza Hamzavi <amirrezahamzavi2000@gmail.com>
2024-09-10 11:30:22 +10:00
danicampora 3ca01eccae zephyr/mphalport: Make mp_hal_wait_sem() always call k_poll().
Also even in the case of a zero timeout given.

Signed-off-by: danicampora <danicampora@gmail.com>
2024-09-06 20:48:13 +10:00
danicampora 1c0dc2ac3e zephyr/src: Remove k_yield() at the end of console_irq_input_hook().
Some boards like the nrf52840dk crash immediatelly after boot when
k_yield() is executed in this function.  It also makes the REPL randomly
lock up on other boards like the nucleo_wb55rg.

Signed-off-by: danicampora <danicampora@gmail.com>
2024-09-06 20:48:05 +10:00
Damien George 74d6dba294 tests/run-tests.py: Add a zephyr test target.
So that certain tests can be skipped when running on this target.  These
thread tests do not pass because the zephyr port cannot create more than 4
threads at once.

Signed-off-by: Damien George <damien@micropython.org>
2024-09-06 20:47:19 +10:00
Damien George 0afec3974c zephyr/Kconfig: Increase default GC heap size to 48k.
So that more tests can run successfully, and so users by default have more
heap for applications.  Thin minimal configuration still has a 16k GC heap.

Signed-off-by: Damien George <damien@micropython.org>
2024-09-06 20:42:57 +10:00
danicampora 935fcd1329 tests/thread: Adapt stress_aes.py to run on zephyr.
Signed-off-by: danicampora <danicampora@gmail.com>
2024-09-06 20:42:57 +10:00
Damien George e7974a28f7 zephyr/mpconfigport: Enable mpz big integers.
These are needed to be on par with other ports.

Signed-off-by: Damien George <damien@micropython.org>
2024-09-06 20:42:56 +10:00
Damien George fc630e70c4 zephyr/main: Collect registers during a MicroPython GC scan.
Signed-off-by: Damien George <damien@micropython.org>
2024-09-06 20:42:56 +10:00
danicampora 7009c75f23 zephyr: Enable some core features to get more thread tests passing.
All these features are enabled at the
`MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES` level, and are required to get
more of the thread tests passing.

Signed-off-by: danicampora <danicampora@gmail.com>
2024-09-06 20:42:56 +10:00
danicampora d68d8fcf90 zephyr: Re-implement the Zephyr console in non-blocking mode.
The standard Zephyr console implementation doesn't make use of
`tty_set_rx_timeout()` and therefore all the functions to receive
characters block indefinitely until data is received (including
`console_read()`).

This commit also releases the GIL where it applies, e.g. the REPL and the
time sleep functions.

Signed-off-by: danicampora <danicampora@gmail.com>
2024-09-06 20:42:56 +10:00