Wykres commitów

15138 Commity (b0e03b3e07f4077d1686da0a2dcee3686e4a5f9e)

Autor SHA1 Wiadomość Data
Jim Mussared b5836e7252 esp32: Use uppercase variant names.
This is to support a future change to add the variant name to the build
directory and therefore should be the same style as the board name.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-23 13:54:37 +10:00
Jim Mussared f007d0aa3d nrf/boards: Rename all nRF boards to use uppercase.
This is to match all the other ports.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-23 13:54:37 +10:00
Angus Gratton 2919a9fbf3 stm32/modstm: Add MICROPY_PY_STM_CONST flag, clear it for STM32WL5.
MICROPY_PY_STM_CONST defaults to 1 if MICROPY_PY_STM is set.  Overriding to
0 disables the named register peripheral constants being including in the
stm32 module.

This saves about 7.5KB of code size for the STM32WL55, which is significant
as this SoC doesn't have a lot of flash.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-23 11:58:11 +10:00
Angus Gratton 02620c2236 stm32/subghz: Add STM32WL55 subghz radio interface to stm module.
This is the minimum C interface to allow a modem driver to be built in
Python.  Interface is simple, with the intention that the micropython-lib
driver is the main (only) consumer of it.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-23 11:58:11 +10:00
Angus Gratton 9e0f934cdf stm32/dma: Fix DMA completion on WL55 boards.
No IRQHandlers were compiled in for this board.

Includes small consolidation of the same DMAMUX_ENABLE line for STM32G4,
STM32WB, STM32WL.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-23 11:58:11 +10:00
Angus Gratton 2c62adb42c stm32/powerctrlboot: Support STM32WL system clock from HSE+PLL.
Switches default on the NUCLEO_WL55 board to use the HSE oscillator powered
from PB0_VDDTCXO pin.

Build-time configuration can select from MSI internal oscillator (previous
default), HSE via crystal, or HSE bypass with TCXO powered from PB0_VDDTCXO
pin (new default)

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-23 11:58:11 +10:00
Angus Gratton e6cfb77342 stm32/spi: Add STM32WL5 SUBGHZ SPI peripheral.
This is a "normal" SPI peripheral with no external pins, to avoid having to
grow spi_obj[] for just this one board map it as SPI ID 3 (board has SPI
IDs 1,2 already).

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-23 11:58:08 +10:00
robert-hh a18d62e067
mimxrt: Fix UART RTS/CTS assignments for the OLIMEX and Adafruit boards.
At the Adafruit Metro M7 the pin GPIO_AD_13 is used for JTAG. Therefore
it is not configured for RTS at UART 2 and 3.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-08-16 10:06:59 +02:00
Angus Gratton 40fcbe1246 top: Enable ruff linter check for F821 undefined-name.
Very helpful for catching typos or missing imports when writing code!

Description can be found at
https://beta.ruff.rs/docs/rules/undefined-name/

Parent commits contain various small fixes and inline ignores for this
check.  The only blanket exception is manifest files, which are numerous
and evaluated with some global names pre-defined - these can be globally
ignored.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-16 16:16:44 +10:00
Angus Gratton 1a5c9b9da4 tools/mpy-tool.py: Ignore linter failure in Python 2 compatibility code.
Found by Ruff checking F821.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-16 16:16:44 +10:00
Angus Gratton b8189d039d tools/mpy_ld.py: Pre-declare some local variables to appease linter.
Spurious fix as the logic is structured such that these variables will be
set before dereferenced, but this keeps Ruff happy (no more F821
undefined-name).

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-16 16:16:44 +10:00
Angus Gratton 974f99482c renesas-ra/boards: Remove unreachable code in make-pins.py.
Looks like copy-paste from the stm32 make-pins.py, references a function
that is not present in the renesas-ra version.

Found by Ruff checking F821.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-16 16:16:40 +10:00
Angus Gratton 29c022e0f1 examples/hwapi: Add missing import for 96Boards Carbon example.
Found by Ruff checking F821.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-16 16:13:41 +10:00
Angus Gratton 801910fc83 all: Add missing imports for micropython.const.
Found by Ruff checking F821.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-16 16:13:27 +10:00
Angus Gratton ef864a4aa4 cc3200/tools: Fix exception raised on process failure.
subprocess.CalledProcessError() constructor arguments aren't documented,
but these are them.  Even if they change, it's an improvement over a
non-existent exception name!

Found by Ruff checking F821.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-16 16:13:11 +10:00
Angus Gratton cec3ff5526 mpy-cross: Fix source file name in file-not-found error.
Found by Ruff with F821.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-16 16:13:01 +10:00
Angus Gratton 861fbf6ab5 examples: Mark asm, pio, etc. as noqa: F821 (undefined-name).
These files all use decorators (@asm_thumb, @asm_pio) that add names to the
function scope, that the linter cannot see.

It's useful to clear them in the file not in pyproject.toml as example code
will be copied and adapted elsewhere, and those developers may also use
Ruff (we hope!)

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-16 16:12:33 +10:00
Kwabena W. Agyeman 00855eeb36 mimxrt/hal: Make flash clock frequency configurable.
Signed-off-by: "Kwabena W. Agyeman" <kwagyeman@live.com>
2023-08-15 23:45:22 +10:00
Kwabena W. Agyeman cb7e133dbe mimxrt/boards: Add support for GPIO control of SNVS pins.
Signed-off-by: "Kwabena W. Agyeman" <kwagyeman@live.com>
2023-08-15 23:35:33 +10:00
Kwabena W. Agyeman afe2ca1a0a mimxrt/machine_uart: Add support for UART hardware flow control.
Signed-off-by: "Kwabena W. Agyeman" <kwagyeman@live.com>
2023-08-15 23:21:33 +10:00
robert-hh e43c669b4a mimxrt/machine_uart: Add uart.deinit method and machine_uart_deinit_all.
The call to machine_uart_deinit_all() is needed to avoid a crash after soft
reset, if a UART had been used and data arrives before it is instantiated
again.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-08-15 23:08:30 +10:00
robert-hh a9a219d8bf mimxrt/hal/pwm_backport: Fix 0 and 65536 edge cases of PWM's duty_u16.
It should be that:
- duty_u16=0: output low, no pulse
- duty_u16=65536: output high, no pulse

That previously did not apply to all of the three PWM mechanisms of this
port.  This commit fixes it.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-08-15 23:06:12 +10:00
robert-hh a9821c0185 mimxrt/machine_pin: Fix bug when Pin.irq is called without a handler.
When called without a handler, the IRQ data was not cleared.  That caused a
crash at the second soft reset in a row.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-08-15 23:03:37 +10:00
Jim Mussared 91674c41b8 tools/autobuild: Automatically build all variants for each board.
Removes the special-case for stm32.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-15 17:38:02 +10:00
Jim Mussared 96258d3716 esp32/partitions.csv: Rename to partitions-4MiB.csv.
To be consistent with the other partitions files (which have the "-
{2,8,16,32}MiB" suffix). Also renames partitions-ota.csv.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-15 17:38:02 +10:00
Jim Mussared afd407af8f esp32/boards/GENERIC_S3: Merge with GENERIC_S3_{SPIRAM,SPIRAM_OCT}.
These are now variants of the GENERIC_S3 board.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-15 17:38:02 +10:00
Jim Mussared b25a67590d esp32/boards/GENERIC_S2: Merge with ESP32_S2_WROVER.
Unsure of the history of the ESP32_S2_WROVER board (and why it wasn't
named GENERIC_S2_...) but now it's a variant of the generic S2 board.

Also removes the non-existent CONFIG_USB_AND_UART from all S2 boards.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-15 17:38:02 +10:00
Jim Mussared 4815af75bc esp32/boards/GENERIC_C3: Merge with GENERIC_C3_USB.
As the IDF no longer supports earlier revisions of the C3 by default, we
now just explicitly support rev 3+ and enable USB (which wasn't supported
in earlier revisions).

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-15 17:37:44 +10:00
Jim Mussared 2fbf42d3ad esp32/boards/GENERIC: Merge with GENERIC_{SPIRAM,OTA,D2WD,UNICORE}.
These are now variants of the GENERIC board.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-15 17:37:44 +10:00
Jim Mussared 9573d31071 all: Remove query-variants make target.
This is difficult to implement on cmake-based ports, and having the list
of variants in mpconfigboard.{cmake,mk} duplicates information that's
already in board.json.

This removes the existing query-variants make target from stm32 & rp2
and the definition of BOARD_VARIANTS from the various board files.

Also renames the cmake variable to MICROPY_BOARD_VARIANT to match other
variables such as MICROPY_BOARD. The make variable stays as
BOARD_VARIANT.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-15 17:37:44 +10:00
Jim Mussared ad123ed013 esp32/Makefile: Implement `make submodules` to match other ports.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-15 17:37:44 +10:00
Damien George fa1ea21f75 esp32/gccollect: Make level arg volatile to force recursive function.
Otherwise the compiler may inline the gc_collect_inner() function and/or
remove the recursion, which is necessary to spill all the windowed
registers to the C stack.

Signed-off-by: Damien George <damien@micropython.org>
2023-08-15 16:12:54 +10:00
Angus Gratton 05dcb8be99 esp32: Enable automatic Python heap growth.
Via MICROPY_GC_SPLIT_HEAP_AUTO feature flag added in previous commit.

Tested on ESP32 GENERIC_SPIRAM and GENERIC_S3 configurations, with some
worst-case allocation patterns and the standard test suite.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-15 10:50:46 +10:00
Angus Gratton 98fd78437c esp32: Allow malloc() to allocate from SPIRAM.
Also shrinks the "prefer internal" threshold to 8KB, any allocation larger
than this will try PSRAM first.

Change the mbedTLS config to use regular malloc() as well, instead of
internal only.  The default is set to internal-only due to to potential
physical security issue of readout via PSRAM on the original ESP32.
However, as MicroPython runs from plaintext flash and all other context is
in the MP heap of PSRAM then it's hard to see how worsens physical security
for MP.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-15 10:49:33 +10:00
Angus Gratton 519c24dd48 py/gc: Add new MICROPY_GC_SPLIT_HEAP_AUTO "auto grow heap" mode.
When set, the split heap is automatically extended with new areas on
demand, and shrunk if a heap area becomes empty during a GC pass or soft
reset.

To save code size the size allocation for a new heap block (including
metadata) is estimated at 103% of the failed allocation, rather than
working from the more complex algorithm in gc_try_add_heap(). This appears
to work well except in the extreme limit case when almost all RAM is
exhausted (~last few hundred bytes). However in this case some allocation
is likely to fail soon anyhow.

Currently there is no API to manually add a block of a given size to the
heap, although that could easily be added if necessary.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-15 10:48:02 +10:00
Angus Gratton d325ee4509 py/gc: Apply some code formatting cleanup.
This commit:
- Breaks up some long lines for readability.
- Fixes a potential macro argument expansion issue.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-15 10:41:02 +10:00
Damien George 88518009ce tests/extmod/select_poll_eintr.py: Improve robustness of test.
Increase allowed range of dt_ms, and print it in case of failure.

Signed-off-by: Damien George <damien@micropython.org>
2023-08-15 00:08:51 +10:00
Damien George f6af48416d extmod/modselect: Properly track number of poll objects that are fd's.
Signed-off-by: Damien George <damien@micropython.org>
2023-08-14 18:48:47 +10:00
Jim Mussared 24a6e951ec ports: Simplify board feature tags in board.json.
This commit:
- Finds a common set of board feature tags and maps existing features to
  that reduced set.
- Removes some less-useful board feature tags.
- Ensures all MCUs are specified correctly.
- Ensures all boards have a vendor (and fixes some vendor names).

This is to make the downloads page show a less intimidating set of filters.

Work done in conjunction with Matt Trentini <matt.trentini@gmail.com>.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-10 14:54:03 +10:00
Jim Mussared 4bbe879c26 tools/mpremote: Make soft-reset count as an action.
Otherwise `mpremote soft-reset` will implicitly run the repl command.

Fixes issue #10871.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-10 14:11:53 +10:00
Jos Verlinde 232c29c2ed tools/codeformat.py: Use pyproject.toml for black config.
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
2023-08-10 11:54:36 +10:00
Daniël van de Giessen 8dbb29da3f tools/codeformat.py: Skip formatting ESP-IDF managed components.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2023-08-10 11:36:24 +10:00
Angus Gratton 597fcb4751 tools/mpy-tool.py: Use isinstance() for type checking.
Ruff version 283 expanded E721 to fail when making direct comparison
against a built-in type.  Change the code to use isinstance() as
suggested, these usages appear to have equivalent functionality.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-09 17:41:54 +10:00
Damien George d529c20674 extmod/modssl_mbedtls: Fix ioctl of a socket in closed/error state.
Signed-off-by: Damien George <damien@micropython.org>
2023-08-09 13:22:57 +10:00
Damien George 20d3a6b196 extmod/modssl_mbedtls: Reject ioctls that are not supported.
An SSL stream can only handle CLOSE and POLL ioctls.  Other ones do not
make sense, or at least it doesn't make sense to pass the ioctl request
directly down to the underlying stream.

In particular MP_STREAM_GET_FILENO should not be passed to the underlying
stream because the SSL stream is not directly related to a file descriptor,
and the SSL stream must handle the polling itself.

Signed-off-by: Damien George <damien@micropython.org>
2023-08-09 13:22:32 +10:00
Damien George 218242d1de tests/extmod: Skip select/socket tests if they can't create UDP socket.
Some targets (eg PYBV10) have the socket module but are unable to create
UDP sockets without a registered NIC.  So skip UDP tests on these targets.

Signed-off-by: Damien George <damien@micropython.org>
2023-08-07 12:39:29 +10:00
Damien George 6b78a1bf00 tests/extmod: Add coverage tests for select module.
Signed-off-by: Damien George <damien@micropython.org>
2023-08-07 12:37:48 +10:00
Damien George 3f417e8943 extmod/modselect: Remove undocumented support for flags arg to poll.
The signature of this method was poller.poll(timeout=-1, flags=0, /) but
the flags argument was not documented and is not CPython compatible.  So
it's removed in this commit.

(The optional flags remains for the ipoll() method, which is documented.)

Signed-off-by: Damien George <damien@micropython.org>
2023-08-07 12:37:47 +10:00
Damien George ef71028f77 extmod/modselect: Add optimisation to use system poll when possible.
A previous commit removed the unix-specific select module implementation
and made unix use the common one.

This commit adds an optimisation so that the system poll function is used
when polling objects that have a file descriptor.  With this optimisation
enabled, if code registers both file-descriptor-based objects, and non-
file-descriptor-based objects with select.poll() then the following occurs:

- the system poll is called for all file-descriptor-based objects with a
  timeout of 1ms

- then the bare-metal polling implementation is used for remaining objects,
  which calls into their ioctl method (which can be in C or Python)

In the case where all objects have file descriptors, the system poll is
called with the full timeout requested by the caller.  That makes it as
efficient as possible in the case everything has a file descriptor.

Benefits of this approach:

- all ports use the same select module implementation

- the unix port now supports polling of all objects and matches bare metal
  implementations

- it's still efficient for existing cases where only files and sockets are
  polled (on unix)

- the bare metal implementation does not change

- polling of SSL objects will now work on unix by calling in to the ioctl
  method on SSL objects (this is required for asyncio ssl support)

Note that extmod/vfs_posix_file.c has poll disable when the optimisation is
enabled, because the code is not reachable when the optimisation is used.

Signed-off-by: Damien George <damien@micropython.org>
2023-08-07 12:11:40 +10:00
Damien George ebc6556346 extmod/modselect: Factor low-level polling code into common function.
Signed-off-by: Damien George <damien@micropython.org>
2023-08-07 12:11:40 +10:00