Wykres commitów

15841 Commity (master)

Autor SHA1 Wiadomość Data
Damien George 39bf055d23 py/emitglue: Reorder and resize members of mp_raw_code_t.
The mp_raw_code_t struct has been reordered and some members resized.  The
`n_pos_args` member is renamed to `asm_n_pos_args`, and `type_sig` renamed
to `asm_type_sig` to indicate that these are used only for the inline-asm
emitters.  These two members are also grouped together in the struct.

The justifications for resizing the members are:
- `fun_data_len` can be 32-bits without issue
- `n_children` is already limited to 16-bits by
  `mp_emit_common_t::ct_cur_child`
- `scope_flags` is already limited to 16-bits by `scope_t::scope_flags`
- `prelude_offset` is already limited to 16-bits by the argument to
  `mp_emit_glue_assign_native()`
- it's reasonable to limit the maximim number of inline-asm arguments to 12
  (24 bits for `asm_type_sig` divided by 2)

This change helps to reduce frozen code size (and in some cases RAM usage)
in the following cases:
- 64-bit targets
- builds with MICROPY_PY_SYS_SETTRACE enabled
- builds with MICROPY_EMIT_MACHINE_CODE enabled but MICROPY_EMIT_INLINE_ASM
  disabled

With this change, unix 64-bit builds are -4080 bytes in size.  Bare-metal
ports like rp2 are unchanged (because mp_raw_code_t is still 32 bytes on
those 32-bit targets).

Signed-off-by: Damien George <damien@micropython.org>
2024-02-16 12:48:02 +11:00
Felix Dörre 223e0d9a5b extmod/network_wiznet5k: Adjust IP types for IPv6.
Signed-off-by: Felix Dörre <felix@dogcraft.de>
2024-02-16 11:51:12 +11:00
Felix Dörre 628abf8f25 extmod/modlwip: Support IPv6.
With these changes IPv6 works on the rp2 port (and possibly others that use
the lwIP socket implementation).

Things that have been tested and work:
- Neighbour solicitation for v6 link local address.
- Ping of v6 link-local address.
- Receiving a SLAAC address via router advertisement.
- Ping a v6 address allocated via SLAAC.
- Perform an outgoing connection to a routed v6-address (via default
  gateway).
- Create a listening IPv6 wildcard socked bound to ::, and trying to access
  it via link-local, SLAAC, and IPv4 (to ensure the dual-stack binding
  works).

Things that could be improved:
- socket.socket().getaddrinfo only returns the v4 address.  It could also
  return v6 addresses (getaddrinfo is actively programmed to only return a
  single address, and this is the v4-address by default, with fallback to
  the v6 address if both are enabled).

Signed-off-by: Felix Dörre <felix@dogcraft.de>
2024-02-16 11:46:40 +11:00
Damien George 866fc3447c tests/multi_bluetooth/ble_irq_calls.py: Enhance test to test recursion.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-16 10:20:28 +11:00
Damien George cd66aa05cf esp32: Increase NimBLE task stack size and overflow detection headroom.
The Python BLE IRQ handler will most likely run on the NimBLE task, so its
C stack must be large enough to accommodate reasonably complicated Python
code (eg a few call depths).  So increase this stack size.

Also increase the headroom from 1024 to 2048 bytes.  This is needed because
(1) the esp32 architecture uses a fair amount of stack in general; and (2)
by the time execution gets to setting the Python stack top via
`mp_stack_set_top()` in this interlock code, about 600 bytes of stack are
already used, which reduces the amount available for Python.

Fixes issue #12349.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-16 10:19:26 +11:00
YAMAMOTO Takashi 809d113dbc unix: Don't include system headers when features are disabled.
Because the target system may not have these headers at all.

Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
2024-02-15 16:54:17 +11:00
YAMAMOTO Takashi f9704ce36e unix/input: Flush the prompt after writing it to stdout.
Depending on your setup, stdout might be buffered/line-buffered.

Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
2024-02-15 16:45:00 +11:00
YAMAMOTO Takashi 06cb6b1e9f minimal: Use printf instead of echo -e.
macOS's echo doesn't have -e option.  printf is in POSIX and more widely
available these days.

Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
2024-02-15 16:36:22 +11:00
YAMAMOTO Takashi e3be70b5e8 minimal: Allow compiling on macOS.
Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
2024-02-15 16:35:10 +11:00
Damien George c27d304bed esp32/mpnimbleport: Release the GIL while doing NimBLE port deinit.
In case callbacks must run (eg a disconnect event happens during the
deinit) and the GIL must be obtained to run the callback.

Fixes part of issue #12349.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-15 16:05:41 +11:00
Trent Piepho 34097b776e esp32/network_ppp: Make PPP support optional.
PPP is not that commonly used, let it be turned off in the board config to
save space.  It is still on by default.

On an basic ESP32-S3 build, turning off PPP with LWIP still on saves ~35 kB
of codend 4 kB of data.

   text    data     bss     dec     hex filename
1321257  304296 2941433 4566986  45afca before-ppp-off.elf
1285101  299920 2810305 4395326  43113e after-ppp-off.elf
-------------------------------
-36156    -4376     -56

Note that the BSS segment size includes all NOBITS sections in ELF file.
Some of these are aligned to 64kB chunk sized dummy blocks, I think for
alignment to MMU boundaries, and these went down by 1 block each, so 128
kiB of BSS is not really part of the binary size reduction.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
2024-02-15 13:29:43 +11:00
Angus Gratton 00ba6aaae4 ports: On cold boot, enable USB after boot.py completes.
For mimxrt, nrf, renesas-ra, rp2 and samd ports, this commit implements
similar behaviour to the stm32 port, where USB is only brought up after
boot.py completes execution.

Currently this doesn't add any useful functionality (and may break
workflows that depend on USB-CDC being live in boot.py), however it's a
precondition for more usable workflows with USB devices defined in
Python (allows setting up USB interfaces in boot.py before the device
enumerates for the first time).

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-02-15 12:31:26 +11:00
Yoctopuce 5d83bbca60 shared/timeutils: Remove useless void-return.
The C99 standard states:

    6.8.6.4 The return statement Constraints

    A return statement with an expression shall not appear in a function
    whose return type is void.  A return statement without an expression
    shall only appear in a function whose return type is void.

And when `-pedantic` is enabled the compiler gives an error.

Signed-off-by: Yoctopuce <dev@yoctopuce.com>
2024-02-15 11:00:50 +11:00
Yoctopuce 587b6f2e34 extmod/modrandom: Add integer type casts where appropriate.
To prevent compiler warnings when `mp_int_t` is 64-bits.

Signed-off-by: Yoctopuce <dev@yoctopuce.com>
2024-02-15 11:00:44 +11:00
YAMAMOTO Takashi d2a3cd7ac4 embed: Improve stack top estimation.
Obtaining the stack-top via a few function calls may yield a pointer which
is too deep within the stack.  So require the user to obtain it from a
higher level (or via some other means).

Fixes issue #11781.

Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
2024-02-15 10:07:32 +11:00
iabdalkader be8d660fc2 mimxrt: Fix header include guard names.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-02-15 09:45:14 +11:00
Damien George 0432f73206 tools/mpy-tool.py: Fix static qstrs when freezing without qstr header.
It's rare to freeze .mpy files without specifying a qstr header from a
firmware build, but it can be useful for testing, eg
`mpy-tool.py -f test.mpy`.  Fix this case so static qstrs are properly
excluded from the frozen qstr list.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-12 11:56:24 +11:00
Damien George abe43fe687 extmod/btstack: Reset pending_value_handle before calling read-done cb.
Similar to the previous commit but for MP_BLUETOOTH_IRQ_GATTC_READ_DONE:
the pending_value_handle needs to be reset before calling
mp_bluetooth_gattc_on_read_write_status(), which will call the Python IRQ
handler, which may in turn call back into BTstack to perform an action like
a write.  In that case the pending_value_handle will need to be available
for the write/read/etc to proceed.

Fixes issue #13634.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-12 11:26:27 +11:00
Damien George b4f59984f7 extmod/btstack: Reset pending_value_handle before calling write-done cb.
The pending_value_handle needs to be freed and reset before calling
mp_bluetooth_gattc_on_read_write_status(), which will call the Python IRQ
handler, which may in turn call back into BTstack to perform an action like
a write.  In that case the pending_value_handle will need to be available
for the write/read/etc to proceed.

Fixes issue #13611.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-09 11:44:28 +11:00
Damien George 8cbae12d0d unix/variants: Prefer unix-ffi packages when loading the manifest.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-08 17:16:10 +11:00
Damien George 35dd959133 tools/manifestfile.py: Change library search to use a list of paths.
This commit changes how library packages are searched for when a manifest
file is loaded: there is now simply a list of library paths that is
searched in order for the given package.  This list defaults to the
main directories in micropython-lib, but can be added to -- either appended
or prepended -- by using `add_library()`.

In particular the way unix-ffi library packages are searched has changed,
because the `unix_ffi` argument to `require()` is now removed.  Instead, if
a build wants to include packages from micropython-lib/unix-ffi, then it
must explicitly add this to the list of paths to search using:

    add_library("unix-ffi", "$(MPY_LIB_DIR)/unix-ffi")

Work done in collaboration with Jim Mussared.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-08 17:16:10 +11:00
Jos Verlinde 2bdaa1bede docs/library/sys.rst: Document implementation.version.releaselevel.
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
2024-02-07 15:51:25 +11:00
Angus Gratton 781366e476 github/workflows: Standardise formatting of ruff.yml.
All the other workflow YAML files use vertical whitespace around top-level
items.

Also remove spurious comment, the features in the linked doc aren't
actually used in this workflow (any more?).

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-02-07 15:22:41 +11:00
Angus Gratton 6f0aa275f8 github/workflows: Add comments where tool versions need to be in sync.
This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-02-07 15:21:55 +11:00
Angus Gratton 84e90639fa github/workflows: Move codespell to a GitHub workflow, version it.
Similar to ruff.yaml, it's simpler to run the codespell command directly
from a workflow file.  And developers can run codespell directly from the
command line without the need for options, or just use pre-commit.

This commit also applies a specific version to codespell, same as
pre-commit (introduced in a166d805f4).

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-02-07 15:19:38 +11:00
Damien George b038d07011 stm32/Makefile: Ignore uninitialised variable warning in H5 HAL SD code.
This warning appears when using an MCU like H562 that only has one SDMMC.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 14:55:07 +11:00
Damien George 657faee7e5 stm32/main: Allow disabling MICROPY_PY_MACHINE.
Disabling this requires also disabling: MICROPY_PY_PYB and MICROPY_PY_STM.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:45:51 +11:00
Damien George 4e6436d4cf stm32/spi: Allow disabling MICROPY_PY_MACHINE_SPI.
This requires that MICROPY_PY_PYB is also disabled.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:45:51 +11:00
Damien George 2158da213e stm32/modos: Allow disabling MICROPY_PY_MACHINE_UART.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:45:51 +11:00
Damien George 1c7afa923b drivers/dht: Only build DHT driver if MICROPY_PY_MACHINE_PULSE enabled.
Because this driver calls `machine_time_pulse_us()`.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:45:51 +11:00
Damien George 4c56b39051 docs: Use vfs module instead of os.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:25:10 +11:00
Damien George 7d28789544 ports: Use vfs module instead of os.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:25:09 +11:00
Damien George b87bbaeb43 tests: Use vfs module instead of os.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:25:09 +11:00
Damien George 5804aa0204 docs/reference/micropython2_migration.rst: Add info about os and vfs.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:25:09 +11:00
Damien George 45f99cb445 docs/library: Move vfs functions and classes from os to vfs module docs.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:25:09 +11:00
Damien George e7020463f1 extmod/modvfs: Add new "vfs" module with mount/umount and Vfs classes.
They have been moved from the "os" module.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:25:08 +11:00
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