Wykres commitów

15852 Commity (master)

Autor SHA1 Wiadomość Data
Sebastian Romero 4dc262c8fd renesas-ra/boards: Add named pins for Arduino Portenta C33.
Signed-off-by: Sebastian Romero <s.romero@arduino.cc>
2024-03-08 13:10:55 +11:00
Sebastian Romero 5c5fe87821 nrf/boards: Add named pins for Arduino Nano 33 BLE.
Signed-off-by: Sebastian Romero <s.romero@arduino.cc>
2024-03-08 13:10:43 +11:00
Sebastian Romero 27c0992343 esp32/boards: Add missing named digital pins for Arduino Nano ESP32.
Signed-off-by: Sebastian Romero <s.romero@arduino.cc>
2024-03-08 13:10:30 +11:00
Sebastian Romero ed29a4123f rp2/boards: Add named digital pins for Arduino Nano RP2040 Connect.
Signed-off-by: Sebastian Romero <s.romero@arduino.cc>
2024-03-08 13:10:13 +11:00
Sebastian Romero 32623d3d19 stm32/boards: Add named digital and analog pins for Arduino boardrs.
Adds Dx and Ax named pins for Arduino Gigi, Arduino Nicla Vision and
Arduino Portenta H7.  The analog pins include the dual-pad _C pins.

Signed-off-by: Sebastian Romero <s.romero@arduino.cc>
2024-03-08 13:08:38 +11:00
Damien George a9efffca96 stm32: Add support for dual-analog-pad "_C" pins on H7 MCUs.
This commit adds support for the dual-analog-pads on STM32H7 parts.  These
pads/pins are called PA0_C/PA1_C/PC2_C/PC3_C in the datasheet.  They each
have an analog switch that can optionally connect them to their normal pin
(eg PA0).  When the switch is open, the normal and _C pin are independent
pins/pads.

The approach taken in this commit to make these _C pins available to Python
is:
- put them in their own, independent row in the stm32h7_af.csv definition
  file, with only the ADC column defined (they are separate machine.Pin
  entities, and doing it this way keeps make-pins.py pretty clean)
- allow a board to reference these pins in the board's pins.csv file by the
  name PA0_C etc (so a board can alias them, for example)
- these pins (when enabled in pins.csv) now become available like any other
  machine.Pin through both machine.Pin.board and machine.Pin.cpu
- BUT these _C pins have a separate pin type which doesn't have any
  methods, because they don't have any functionality
- these _C pins can be used with machine.ADC to construct the appropriate
  ADC object, either by passing the string as machine.ADC("PA0_C") or by
  passing the object as machine.ADC(machine.Pin.cpu.PA0_C)
- if a board defines both the normal and _C pin (eg both PA0 and PA0_C) in
  pins.csv then it must not define the analog switch to be closed (this is
  a sanity check for the build, because it doesn't make sense to close the
  switch and have two separate pins)

Signed-off-by: Damien George <damien@micropython.org>
2024-03-08 12:38:00 +11:00
Angus Gratton 7fd8a6d4bc stm32/dma: Add D-cache protection for DMA RX operations, including SPI.
This new DMA API corrects possible cache coherency issues on chips with
D-Cache, when working with buffers at arbitrary memory locations (i.e.
supplied by Python code).

The API is used by SPI to fix an issue with corrupt data when reading from
SPI using DMA in certain cases.  A regression test is included (it depends
on external hardware connection).

Explanation:

1) It's necessary to invalidate D-Cache after a DMA RX operation completes
   in case the CPU reads (or speculatively reads) from the DMA RX region
   during the operation.  This seems to have been the root cause of issue
   #13471 (only when src==dest for this case).

2) More generally, it is also necessary to temporarily mark the first and
   last cache lines of a DMA RX operation as "uncached", in case the DMA
   buffer shares this cache line with unrelated data.  The CPU could
   otherwise write the other data at any time during the DMA operation (for
   example from an interrupt handler), creating a dirty cache line that's
   inconsistent with the DMA result.

Fixes issue #13471.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-03-08 12:19:48 +11:00
Angus Gratton 2345c1a04e stm32/mpu: Rename MPU_CONFIG_DISABLE to MPU_CONFIG_NOACCESS.
The existing MPU_CONFIG_DISABLE macro enables the MPU region but disables
all access to it.

The rename is necessary to support an MPU_CONFIG_DISABLE macro that
actually disables the MPU region entirely.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-03-08 10:39:02 +11:00
Angus Gratton 5fe99013b6 stm32: Simplify D-cache clean and invalidate macros.
The inline functions that these are wrappers around already account for
cache line size.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-03-08 10:38:35 +11:00
robert-hh bf68bb95f9 stm32/network_lan: Add the phy_type=x keyword option to network.LAN().
With LAN8742, LAN8720, LAN83825 and DP83848 as possible options, and the
symbols PHY_LAN8720, PHY_LAN8742, PHY_DP83825 and PHY_DP8348.  The default
is PHY_LAN8742 which is the existing behaviour.

The eth_init() parameters for the Portenta H7 board are set to phy_addr=0
and phy_type=LAN8742, which matches the previous defaults and the
schematics.

Tested with LAN8720 and DP83848 breakout boards at 10M Duplex and 100M
Duplex modes.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-07 17:54:56 +11:00
robert-hh 085e3244f0 stm32/eth: Remove redundant ETH clock enable code.
The MAC clock was initialized both in eth_init() and eth_mac_init().  The
latter is not required.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-07 17:54:04 +11:00
robert-hh 185ae18360 stm32/network_lan: Allow defining phy_addr in the LAN constructor.
The default value is 0, which is compatible with the existing behaviour.
Implementing that required changes to eth.c as well.  The value of phy_addr
is added to the eth_t data type.

Tested with a STM32F767 and a STM32H750 device.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-07 17:54:02 +11:00
Damien George b3c62f3169 top: Update .git-blame-ignore-revs for latest format/spell commits.
Signed-off-by: Damien George <damien@micropython.org>
2024-03-07 16:29:46 +11:00
Phil Howard dda9b9c6da all: Prune trailing whitespace.
Prune trailing whitespace across the whole project (almost), done
automatically with:

    grep -IUrl --color "[[:blank:]]$" --exclude-dir=.git --exclude=*.exp |\
        xargs sed -i 's/[[:space:]]*$//'

Exceptions:
- Skip third-party code in lib/ and drivers/cc3100/
- Skip generated code in bluetooth_init_cc2564C_1.5.c
- Preserve command output whitespace in docs, eg:
  docs/esp8266/tutorial/repl.rst

Signed-off-by: Phil Howard <phil@gadgetoid.com>
2024-03-07 16:25:17 +11:00
Angus Gratton decf8e6a8b all: Remove the "STATIC" macro and just use "static" instead.
The STATIC macro was introduced a very long time ago in commit
d5df6cd44a.  The original reason for this was
to have the option to define it to nothing so that all static functions
become global functions and therefore visible to certain debug tools, so
one could do function size comparison and other things.

This STATIC feature is rarely (if ever) used.  And with the use of LTO and
heavy inline optimisation, analysing the size of individual functions when
they are not static is not a good representation of the size of code when
fully optimised.

So the macro does not have much use and it's simpler to just remove it.
Then you know exactly what it's doing.  For example, newcomers don't have
to learn what the STATIC macro is and why it exists.  Reading the code is
also less "loud" with a lowercase static.

One other minor point in favour of removing it, is that it stops bugs with
`STATIC inline`, which should always be `static inline`.

Methodology for this commit was:

1) git ls-files | egrep '\.[ch]$' | \
   xargs sed -Ei "s/(^| )STATIC($| )/\1static\2/"

2) Do some manual cleanup in the diff by searching for the word STATIC in
   comments and changing those back.

3) "git-grep STATIC docs/", manually fixed those cases.

4) "rg -t python STATIC", manually fixed codegen lines that used STATIC.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-03-07 14:20:42 +11:00
Damien George b3f2f18f92 renesas-ra: Fix spelling mistakes found by codespell.
And enable codespell for this port in `pyproject.toml`.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-07 14:15:49 +11:00
Damien George ab6d59d7bd lib/cyw43-driver: Update driver to latest version v1.0.3.
Includes various bug fixes.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-07 14:07:53 +11:00
Damien George 90e517862d webassembly/Makefile: Remove --memory-init-file from linker options.
It's no longer supported by Emscripten (at least at 3.1.55).  And it's not
needed when the output is WASM, which it is by default.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-04 11:33:07 +11:00
Damien George 7d5f697c38 py/emitglue: Add explicit cast of proto_fun to uint8_t pointer.
Otherwise C++ compilers may complain when this header is included in an
extern "C" block.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-04 10:27:07 +11:00
Daniël van de Giessen bc424ddc41
py/modthread: Move thread state initialisation to shared function.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2024-02-29 14:28:58 +01:00
Daniël van de Giessen 678707c8b0 docs/library/bluetooth: Add note that ESP32 supports pairing/bonding.
Pairing and bonding was fixed for the ESP32 in the two previous commits.

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2024-02-29 14:33:22 +11:00
Daniël van de Giessen d1e15b9281 extmod/nimble: Enable key distribution to support bonding.
This sets the BLE key distribution parameters at runtime. This isn't
needed in most ports since we already set the default values in
`extmod/nimble/syscfg/syscfg.h`; however in the ESP32 port that
headerfile is not used, and the default values in the ESP-IDF don't
enable key distribution nor can we change those defaults via
`sdkconfig`. Thus we're setting these values explicitly at runtime.

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2024-02-29 14:25:59 +11:00
Daniël van de Giessen 3460b48a6d extmod/nimble: Override configuration options set in nimble_port_init.
This moves the runtime initialisation of `ble_hs_cfg` to happen after
`nimble_port_init()`. That is consistent with the order used in NimBLE
examples. On the ESP32 port this is needed because the ESP-IDF sets up
the default RAM secret store callbacks in its implementation of
`nimble_port_init()` (specifically, it calls `esp_nimble_init()` which
in turn calls `ble_store_ram_init()`). We want to override those with
our own callbacks to implement the `IRQ_[GS]ET_SECRET` events in Python.

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2024-02-29 14:25:59 +11:00
Damien George 56f9dcb580 tests/multi_bluetooth: Move ble_deepsleep to stress_deepsleep_reconnect.
This test cannot run on boards that have a native USB REPL, so rename it to
indicate that its "special".  This makes it easier to run a subset of
tests, for example:

    ./run-multitests.py multi_bluetooth/ble*.py
    ./run-multitests.py multi_bluetooth/perf*.py
    ./run-multitests.py multi_bluetooth/stress*.py

Signed-off-by: Damien George <damien@micropython.org>
2024-02-29 14:16:05 +11:00
Damien George a30c29398a ports: Don't include mpthread.h in mpthreadport.h.
Because `mpthreadport.h` is included by `mpthread.h`.

Also remove unnecessary include of `mpthreadport.h` in esp32's `main.c`.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-29 13:35:36 +11:00
Damien George b91b2a7fe9 py/mpstate: Don't declare mp_thread_get_state().
It's instead declared by the include of `py/mpthread.h`.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-29 13:33:51 +11:00
Damien George 9a4be7d7b3 py/emitbc: Remove call to adjust Python stack by 0 entries.
This call used to be needed when there was an `emit_bc_pre()` function that
needed to be called at the start of each emitted bytecode.  But in
8e7745eb31 that function was removed and now
the call to `mp_emit_bc_adjust_stack_size()` does nothing when adjusting by
0 entries, so it can be removed.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-29 11:15:37 +11:00
Damien George 8692d2602a extmod/asyncio: Make current_task raise exception when there is no task.
Matches CPython behaviour.

Fixes issue #11530.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-28 15:48:51 +11:00
robert-hh 8fdcc25eb0 py/mpconfig: Change the default enable level for the vfs module.
For boards with MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES and up.
This gets samd21 boards working (which need the vfs module in _boot.py),
B_L072Z_LRWAN1, and nrf boards with smaller MCUs that use CORE or BASIC
feature levels.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-02-26 12:43:24 +11:00
Felix Dörre d2bcb8597e extmod/modlwip: Add back support for empty IP addresses.
Prior to commit 628abf8f25 which added IPv6
support, binding a socket with

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind(("", PORT))

was possible.  But, the empty string is not regarded as a valid IP address
by lwip.  This commit adds a special case for the empty IP string,
restoring the previous CPython-compatible behaviour.

Signed-off-by: Felix Dörre <felix@dogcraft.de>
2024-02-26 12:34:59 +11:00
Felix Dörre 8547a78275 extmod/modwebsocket: Fix websocket to send correct close frame.
When the websocket closes currently, it does not send a proper
"close"-frame, but rather encodes the 0x8800-sequence inside a binary
packet, which is wrong.  The close packet is a different kind of websocket
frame, according to https://www.rfc-editor.org/rfc/rfc6455.

This change resolves an error in Firefox when the websocket closes.

Signed-off-by: Felix Dörre <felix@dogcraft.de>
2024-02-26 12:20:40 +11:00
iabdalkader b5edaf68cd stm32/sdram: Support remapping FMC memory banks.
The patch enables SDRAM banks 1 and 2 to be accessible at 0xC0000000 and
0xD0000000 respectively (default mapping) or remapped to addresses
0x60000000 and 0x70000000.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-02-26 12:13:44 +11:00
Angus Gratton 4f7d0df9bc github/ISSUE_TEMPLATE: Convert issue templates to forms.
Allows giving more specific advice, provides more links to other places to
ask questions, check details, etc.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-02-24 20:02:51 +11:00
Damien George 9e5b6972c7 py/emitglue: Make mp_emit_glue_assign_native's fun_data arg a const ptr.
It will only ever be read from, and in some cases (eg on esp8266) can
actually be in ROM.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-22 11:27:33 +11:00
Damien George 01f4e85f1b extmod/modmachine: Remove MICROPY_PY_MACHINE guard from header.
So this header file can expose declarations for contents of the `machine`
module even if that module is disabled.  Other parts of the system -- or
third-party code -- may need these declarations, for example when a single
component like MICROPY_PY_MACHINE_UART is enabled with MICROPY_PY_MACHINE
disabled.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-21 12:00:41 +11:00
Damien George 31e718a6ac stm32/mpbthciport: Allow building with MICROPY_PY_MACHINE_UART disabled.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-21 11:57:17 +11:00
Damien George 27670729a5 py/compile: Remove TODO about name mangling.
This TODO is now covered by the tests/cpydiff/core_class_name_mangling.py
test.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-21 11:42:35 +11:00
Trent Warlaven 3deeabe6e8 tests/cpydiff: Add new CPy diff test for class name mangling.
Adds new tests/documentation for missing name mangling for private class
members.

Signed-off-by: Trent Warlaven <trwbox@gmail.com>
2024-02-21 11:42:35 +11:00
Andrew Leech 2962e24167 extmod/vfs_posix_file: Ensure file object has safe default fd.
With this commit, if file open fails, the object will have fd = -1 (closed)
and the finaliser will not attempt to close anything.

Fixes issue #13672.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2024-02-21 09:51:52 +11:00
Trent Piepho 31e131bd71 esp32/machine_hw_spi: Combine argument parsing for constructor and init.
This combines the argument parsing and checking for the machine.SPI.init()
and machine.SPI() interfaces.

The only real difference was unspecified arguments in init() mean to keep
the same value, while in new they get default values.

Behavior has changed for passing the "id" argument to init().  On other
ports this isn't allowed.  But on esp32 it would change the SPI controller
of the static SPI instance to the new id.  This results in multiple static
spi objects for the same controller and they would fight over which one has
inconsistent mpy vs esp-idf state.  This has been changed to not allow "id"
with init(), like other ports.

In a few causes, a loop is used over arguments that are handled the same
way instead of cut & pasting the same stanza of code for each argument.

The init_internal function had a lot of arguments, which is not efficient
to pass.  Pass the args mp_arg_val_t array instead as a single argument.
This reduced both the number of C lines and the compiled code size.

Summary of code size change:  Two argument lists of 72 bytes are replaced
by a single shared 72 byte list.  New shared argument parsing code is small
enough to be inlined, but is still efficient enough to shrink the overall
code size by 349 bytes of the three argument handlering functions.

add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-349 (-349)
Function                                     old     new   delta
machine_hw_spi_make_new                      255     203     -52
machine_hw_spi_init                          122      67     -55
machine_hw_spi_init_internal                 698     456    -242
Total: Before=1227667, After=1227318, chg -0.03%
add/remove: 2/0 grow/shrink: 0/2 up/down: 92/-144 (-52)
Data                                         old     new   delta
spi_allowed_args                               -      72     +72
defaults$0                                     -      20     +20
allowed_args$1                               240     168     -72
allowed_args$0                              1080    1008     -72
Total: Before=165430, After=165378, chg -0.03%
add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0)

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
2024-02-20 16:55:09 +11:00
IhorNehrutsa d9944983cb esp32/machine_i2c: Fix build warnings when I2C is disabled.
Signed-off-by: IhorNehrutsa <Ihor.Nehrutsa@gmail.com>
2024-02-20 16:38:49 +11:00
Damien George 802a88c3b1 stm32/mboot: Generate FLASH_LAYOUT_STR at runtime on H5 MCUs.
The size of the flash varies among MCU variants.  Instead of requiring a
build-time variable to configure this, compute it at runtime using the
special device information word accessible through the FLASH_SIZE macro.

This feature is currently only implemented for H5 MCUs, but can be extended
to others.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-20 12:32:45 +11:00
Damien George 3db29103a4 py/builtinevex: Fix setting globals for native functions in compile().
Signed-off-by: Damien George <damien@micropython.org>
2024-02-20 12:12:28 +11:00
Damien George 916ceecaef py/emitglue: Remove n_pos_args from DEBUG_printf.
This argument was renamed in 39bf055d23.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-20 11:31:34 +11:00
Damien George 717e3dca1b py/objfun: Inline mp_obj_code_get_name() into mp_obj_fun_get_name().
The former is static and does not need to be a separate function.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-20 11:29:46 +11:00
Damien George 0c7ccb8807 py/objfun: Support __name__ on native functions and generators.
This is now easy to support, since the first machine-word of a native
function tells how to find the prelude, from which the function name can be
extracted in the same way as for bytecode.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-20 10:56:24 +11:00
Damien George 6d403eb697 py/emitnative: Simplify layout and loading of native function prelude.
Now native functions and native generators have similar behaviour: the
first machine-word of their code is an index to get to the prelude.  This
simplifies the handling of these types of functions, and also reduces the
size of the emitted native machine code by no longer requiring special code
at the start of the function to load a pointer to the prelude.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-20 10:56:24 +11:00
Damien George 9400229766 py/objfun: Split viper fun type out to separate mp_type_fun_viper type.
Viper functions are quite different to native functions and benefit from
being a separate type.  For example, viper functions don't have a bytecode-
style prelude, and don't support generators or default arguments.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-20 10:56:24 +11:00
Damien George 648a7578da py/objfun: Make mp_obj_new_fun_native/mp_obj_new_fun_asm static-inline.
To reduce code size, since they are only used once by py/emitglue.c.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-20 10:50:03 +11:00
Damien George 9716171966 py/misc: Remove m_new_obj[_var]_with_finaliser macros.
They are no longer used.  The new `mp_obj_malloc_with_finaliser()` macros
should be used instead, which force the setting of the `base.type` field.
And there's always `m_malloc_with_finaliser()` if needed.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-20 10:33:09 +11:00