Wykres commitów

15855 Commity (master)

Autor SHA1 Wiadomość Data
Felix Dörre aaba1d8a6c extmod/modtls_mbedtls: Implement cert verification callback for mbedtls.
This is a useful alternative to .getpeercert() when the certificate is not
stored to reduce RAM usage.

Signed-off-by: Felix Dörre <felix@dogcraft.de>
2024-02-07 13:00:57 +11:00
Felix Dörre b802f0f8ab extmod/modtls: Move the native ssl module to tls.
The current `ssl` module has quite a few differences to the CPython
implementation.  This change moves the MicroPython variant to a new `tls`
module and provides a wrapper module for `ssl` (in micropython-lib).

Users who only rely on implemented comparible behavior can continue to use
`ssl`, while users that rely on non-compatible behavior should switch to
`tls`.  Then we can make the facade in `ssl` more strictly adhere to
CPython.

Signed-off-by: Felix Dörre <felix@dogcraft.de>
2024-02-07 12:58:52 +11:00
Felix Dörre f8f1f29ac0 extmod/modssl_axtls: Add SSLContext.load_cert_chain().
To match the mbedtls implementation.

Signed-off-by: Felix Dörre <felix@dogcraft.de>
2024-02-07 12:58:52 +11:00
Damien George c68462d996 lib/micropython-lib: Update submodule to latest.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 12:58:50 +11:00
Damien George ff73683077 github/workflows: Initialise micropython-lib submodule for windows CI.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 12:58:34 +11:00
Damien George 5a68e82d17 github/workflows: Bump setup-msbuild, setup-python, checkout versions.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 11:28:52 +11:00
David Lechner ed15b3c6c6 github/workflows: Move Windows CI from AppVeyor to GitHub Actions.
By moving to GitHub actions, all MicroPython CI builds are now on GitHub
actions.  This allows faster parallel builds and saves time by not building
when no relevant files changed.

This reveals a few failing tests, so those are temporarily disabled until
they can be fixed.

Signed-off-by: David Lechner <david@pybricks.com>
Signed-off-by: Damien George <damien@micropython.org>
2024-02-06 09:50:03 +11:00
David Lechner 23342eff90 windows/Makefile: Fix float exact int formatting on 32-bit mingw.
When compiler optimizations are enabled on the mingw version of gcc, we are
getting failing tests because of rounding issues, for example:

    print(float("1e24"))

would print

    9.999999999999999e+23

instead of

    1e+24

It turns out special compiler options are needed to get GCC to use the SSE
instruction set instead of the 387 coprocessor (which uses 80-bit precision
internall).

Signed-off-by: David Lechner <david@pybricks.com>
2024-02-05 14:04:15 +11:00
Damien George ac8e7f7b67 docs/library/ssl: Change wrap_socket args keyfile/certfile to key/cert.
So they match the code in extmod/modssl_*.c.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-05 13:05:29 +11:00
Jim Lipsey 0285cb2bf4 stm32/boards/ARDUINO_PORTENTA_H7: Add pin configuration for SPI1.
Currently, only the processor's SPI2 bus is enabled (though the related
pins are labeled SPI1 in the Portenta H7 documentation).  This commit
enables the processor's SPI1 bus, which is accessible via the board's
high-density connectors.

Signed-off-by: Jim Lipsey <github@lipsey.org>
2024-02-01 11:21:44 +11:00
Angus Gratton 457f2ccf80 examples/embedding: Add -fno-common to the sample compiler flags.
This makes no difference when files are linked directly into a target
application, but on macOS additional steps are needed to index common
symbols in static libraries. See https://stackoverflow.com/a/26581710

By not creating any common symbols, this problem is bypassed.

This will also trigger linker errors if there are cases where the same
symbol is defined in the host application.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-01-31 14:29:07 +11:00
Joey232 3e48d24576 esp32/boards/UM_FEATHERS3: Use read_uv() for accurate battery voltage.
Use read_uv() to get the battery voltage because it uses the on-chip
calibraton values.

Signed-off-by: Joey232 <Joey@jsconsulting.com>
2024-01-31 14:24:16 +11:00
Takeo Takahashi 81049edf7c renesas-ra/ra/ra_i2c: Fix 1 byte and 2 bytes read issue.
Tested on Portenta C33 with AT24256B (addrsize=16) and SSD1306.

Fixes issue #13280.

Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
2024-01-31 14:16:36 +11:00
Damien George 28b18c43fe py/compile: Fix potential Py-stack overflow in try-finally with return.
If a return is executed within the try block of a try-finally then the
return value is stored on the top of the Python stack during the execution
of the finally block.  In this case the Python stack is one larger than it
normally would be in the finally block.

Prior to this commit, the compiler was not taking this case into account
and could have a Python stack overflow if the Python stack used by the
finally block was more than that used elsewhere in the function.  In such
a scenario the last argument of the function would be clobbered by the
top-most temporary value used in the deepest Python expression/statement.

This commit fixes that case by making sure enough Python stack is allocated
to the function.

Fixes issue #13562.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-31 12:56:29 +11:00
Damien George 2d7fb9a715 tests/ports/rp2/rp2_dma.py: Tweak test to be more reliable.
The timing of the DMA transfer can vary a bit, so tweak the allowed values.
Also test the return value of `rp2.DMA.irq.flags()` to make sure the IRQ is
correctly signalled.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-30 12:50:19 +11:00
Damien George 807c25d05a rp2: Change machine.I2S and rp2.DMA to use shared DMA IRQ handlers.
These separate drivers must share the DMA resource with each other.

Fixes issue #13380.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-30 12:44:22 +11:00
Matthias Urlichs d19371cb23 py/builtinimport: Simplify calls to stat_path().
stat_path is only called with stringified vstr_t objects.

Thus, pulling the stringification into the function replaces three
function calls with one, saving a few bytes.

Signed-off-by: Matthias Urlichs <matthias@urlichs.de>
2024-01-30 11:43:41 +11:00
Carlosgg f3d1495fd3 all: Update bindings, ports and tests for mbedtls v3.5.1.
Changes include:

- Some mbedtls source files renamed or deprecated.

- Our `mbedtls_config.h` files are renamed to `mbedtls_config_port.h`, so
  they don't clash with mbedtls's new default configuration file named
  `mbedtls_config.h`.

- MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE is deprecated.

- MBEDTLS_HAVE_TIME now requires an `mbedtls_ms_time` function to be
  defined but it's only used for TLSv1.3 (currently not enabled in
  MicroPython so there is a lazy implementation, i.e. seconds * 1000).

- `tests/multi_net/ssl_data.py` is removed (due to deprecation of
  MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE), there are the existing
  `ssl_cert_rsa.py` and `sslcontext_server_client.py` tests which do very
  similar, simple SSL data transfer.

- Tests now use an EC key by default (they are smaller and faster), and the
  RSA key has been regenerated due to the old PKCS encoding used by openssl
  rsa command, see
  https://stackoverflow.com/questions/40822328/openssl-rsa-key-pem-and-der-conversion-does-not-match
  (and `tests/README.md` has been updated accordingly).

Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
2024-01-30 11:08:46 +11:00
Carlosgg 92136cbe67 lib/mbedtls_errors: Update error list for latest mbedtls.
Running `./do-mp.sh` now generates this `mp_mbedtls_errors.c` file.  The
`esp32_mbedtls_errors.c` file is already up-to-date.

Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
2024-01-30 10:56:38 +11:00
Carlosgg 3f217e413d lib/mbedtls: Update to mbedtls v3.5.1.
Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
2024-01-30 10:53:48 +11:00
Damien George d5b96813dc extmod/modssl_mbedtls: Fix cipher iteration in SSLContext.get_ciphers.
Prior to this commit it would skip every second cipher returned from
mbedtls.

The corresponding test is also updated and now passes on esp32, rp2, stm32
and unix.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-29 15:11:46 +11:00
Damien George 46e833b071 qemu-arm/mpconfigport: Use MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES.
This simplifes the port configuration.  It enables quite a few new
features, including the `math` and `cmath` modules, adding about 20k to the
firmware size.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-29 13:07:31 +11:00
Damien George 40687451bb tests/extmod/framebuf_polygon.py: Replace sys.stdout.write with print.
So the test doesn't depend on the `sys` module.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-29 13:07:25 +11:00
Damien George 7211bafb33 esp8266/boards/ESP8266_GENERIC: Disable MICROPY_DEBUG_PRINTERS.
This is not enabled on any other MCU port, and is essentially unused on
esp8266 because mp_verbose_flag is always 0.  Disabling saves ~7k of flash.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-29 12:19:06 +11:00
iabdalkader 4a2e510a87 ports: Add LED pin aliases for all Arduino boards.
The standard Arduino pinout uses LEDR/G/B and LED_BUILTIN (if available).
This patch adds aliases to match the standard pinout, while retaining
LED_RED/GREEN/BLUE for compatibility with existing scripts and examples.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-01-26 14:11:42 +11:00
iabdalkader 8d9d74b6df rp2/boards/ARDUINO_NANO_RP2040_CONNECT: Increase flash storage space.
Fixes issue #13512.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-01-26 14:05:20 +11:00
Kwabena W. Agyeman bf6214505f mimxrt/modmachine: Fix deepsleep wakeup pin ifdef.
Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com>
2024-01-26 13:59:41 +11:00
Jim Mussared d4190815a3 py/mpconfig: Disable qstr hashing at minimum feature level.
This will apply to bare-arm and minimal, as well as the minimal unix
variant.

Change the default to MICROPY_QSTR_BYTES_IN_HASH=1 for the CORE,BASIC
levels, 2 for >=EXTRA.

Removes explicit setting of MICROPY_QSTR_BYTES_IN_HASH==1 in ports that
don't set the feature level (because 1 is implied by the default level,
CORE). Applies to cc3200, pic16bt, powerpc.

Removes explicit setting for nRF (which sets feature level). Also for samd,
which sets CORE for d21 and FULL for d51. This means that d21 is unchanged
with MICROPY_QSTR_BYTES_IN_HASH==1, but d51 now moves from 1 to 2 (roughly
adds 1kiB).

The only remaining port which explicitly set bytes-in-hash is rp2 because
it's high-flash (hence CORE level) but lowish-SRAM, so it's worthwhile
saving the RAM for runtime qstrs.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2024-01-25 16:38:17 +11:00
Jim Mussared 8486e28b17 stm32: Disable qstr hashing on small boards.
Sets MICROPY_QSTR_BYTES_IN_HASH==0 on stm32x0 boards.

This saves e.g. 2kiB on NUCLEO_F091.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2024-01-25 16:38:17 +11:00
Jim Mussared 7ea503929a py/qstr: Add support for MICROPY_QSTR_BYTES_IN_HASH=0.
This disables using qstr hashes altogether, which saves RAM and flash
(two bytes per interned string on a typical build) as well as code size.
On PYBV11 this is worth over 3k flash.

qstr comparison will now be done just by length then data. This affects
qstr_find_strn although this has a negligible performance impact as, for a
given comparison, the length and first character will ~usually be
different anyway.

String hashing (e.g. builtin `hash()` and map.c) now need to compute the
hash dynamically, and for the map case this does come at a performance
cost.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2024-01-25 16:38:17 +11:00
Angus Gratton 307ecc5707 docs: Add note about position-only arguments in CPython vs MicroPython.
Required modifying the gen-cpydiff.py code to allow a "preamble" section to
be inserted at the top of any of the generated files.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-01-25 11:56:38 +11:00
Jos Verlinde c8772b7baa CODECONVENTIONS: Update docs for codespell and pre-commit hook.
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
2024-01-25 11:50:07 +11:00
Jos Verlinde a166d805f4 top: Add pre-commit hook for codespell.
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
2024-01-25 11:49:58 +11:00
Damien George 982ffdee7e stm32/mboot/Makefile: Revert change to BOARD_DIR that removed abspath.
This reverts the change from ce2058685b.

Without abspath, the build artefacts (object files) for boards with source
files are placed outside the build directory, because the BOARD_DIR
variable starts with "..".  For the list of source files added to SRC_C,
none of them can start with "..".  The usual fix for that would be to make
the files relative to the top of the MicroPython repo (because of the vpath
rule), eg ports/stm32/boards/$(BOARD).  But then the $(wildcard ...)
pattern won't find files in this directory.

So abspath is necessary, although it will prevent building when there is a
space in the path.  A better solution for spaces needs to be found.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-25 11:30:14 +11:00
Damien George 6bb446b7ff tests/extmod: Remove asyncio .exp files that match CPython output.
These were added back in commit c4935f3049
because the tests required CPython 3.8, which was quite new at the time.
But CPython 3.8 was released over 4 years ago (October 2019) and the CI
test runners, and developers, have this (or a more recent) CPython version.

Removing the .exp files also helps keep MicroPython semantics the same as
CPython.

The asyncio_fair.py test it adjusted slightly to have more deterministic
timing and output.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-24 11:20:06 +11:00
Damien George 8eb658f654 github/workflows: Run mimxrt and rp2 CI with space in repository path.
To test building with make and cmake when there is a space in the path.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-24 11:07:00 +11:00
Iksas ce2058685b ports: Fix handling of paths containing spaces in Makefiles.
Make can't handle paths with spaces, see https://savannah.gnu.org/bugs/?712

The following workarounds exist:

- When using make's built-in functions:
    - Use relative paths wherever possible to avoid spaces in the first
      place.
    - All spaces in paths can be escaped with backslashes; quotes don't
      work.
    - Some users use the shell to temporarily rename directories, or to
      create symlinks without spaces.

- When using make to pass commands to the system's shell, enclose paths in
  quotes.  While make will still interpret quoted strings with spaces as
  multiple words, the system's shell will correctly parse the resulting
  command.

This commit contains the following fixes:

- In ports/stm32/mboot/Makefile: Use relative paths to avoid spaces when
  using built-in functions.

- In all other files: Use quotes to enclose paths when make is used to call
  shell functions.

All changes have been tested with a directory containing spaces.

Signed-off-by: Iksas <iksas@mailbox.org>
2024-01-24 10:43:18 +11:00
Maarten van der Schrieck 057701a770 rp2/machine_uart: Fix potential race condition in interrupt handling.
The irq service routine cleared the RT interrupt bit on TX interrupt.  This
opens the possibility that an RT interrupt is missed.

Signed-off-by: Maarten van der Schrieck <maarten@thingsconnected.nl>
2024-01-23 13:11:53 +11:00
Damien George c3ca3612d1 tests/extmod/asyncio_wait_task.py: Add test for raise and delayed wait.
This case was fixed in 2ecbad4e91, which
stored the exception in the task object.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-23 11:13:35 +11:00
iabdalkader e111793d8d nrf: Fix _start() build issue with CMSIS 5.9.0.
The `_start` function prototype is now declared as no-return, so `main()`
can't return.

To fix this, `main()` is replaced with `_start`.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-01-22 12:40:16 +11:00
iabdalkader beb4459784 mimxrt/boards: Fix __VECTOR_TABLE link issue with CMSIS 5.9.0.
In CMSIS 5.9.0, the compiler headers define `__VECTOR_TABLE`, which will be
substituted with its corresponding value (e.g., `__Vectors` for gcc).
However, the linker script in this port can't include compiler headers when
it's processed, so `__VECTOR_TABLE` is used as the literal variable name,
which results in an undefined linker error.

To fix this, the two possible values of `__VECTOR_TABLE` are both defined
in the linker script.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-01-22 12:36:43 +11:00
iabdalkader e2fa0c6395 lib/cmsis: Update to CMSIS 5.9.0.
This update brings support for Cortex-M55 and Cortex-M85, zero and copy
tables and more.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-01-22 12:36:35 +11:00
Damien George 2ecbad4e91 extmod/asyncio: Support gather of tasks that finish early.
Adds support to asyncio.gather() for the case that one or more (or all)
sub-tasks finish and/or raise an exception before the gather starts.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-22 12:03:21 +11:00
Damien George 51fbec2780 tests/extmod/machine_i2s_rate.py: Test multiple I2S instances.
Signed-off-by: Damien George <damien@micropython.org>
2024-01-22 11:49:28 +11:00
Damien George 50b809c8e8 tests/ports/rp2: Add rp2-specific tests with a test for rp2.DMA.
Signed-off-by: Damien George <damien@micropython.org>
2024-01-22 11:49:20 +11:00
Damien George 7bbcee3cf0 tests: Move port-specific test directories into tests/ports/ directory.
To keep them all together, mirroring the top-level directory structure.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-22 11:48:27 +11:00
dependabot[bot] f93ffc2875 github/workflows: Bump actions/cache from 3 to 4.
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-22 11:37:37 +11:00
iabdalkader 4fd7e456f0 renesas-ra/boards/ARDUINO_PORTENTA_C33: Fix the RTC clock source.
Switch the RTC clock source to Sub-clock (XCIN). This board has an
accurate LSE crystal, and it should be used for the RTC clock
source.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-01-21 00:19:20 +11:00
Kwabena W. Agyeman 490e8e01d5 extmod/extmod.mk: Disable uninitialized warnings in kf_rem_pio2.c.
GCC 13.2 thinks that fq is uninitialized.

Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com>
2024-01-21 00:04:29 +11:00
Jochen Sprickerhof 16c6bc47cf tools/mpremote: Reduce dependency on importlib_metadata.
No longer require importlib_metadata on new Python versions as it is
included in the standard distribution.

Signed-off-by: Jochen Sprickerhof <git@jochen.sprickerhof.de>
2024-01-17 11:27:47 +11:00