Wykres commitów

15821 Commity (master)

Autor SHA1 Wiadomość Data
Damien George 628a37e6cf docs/reference/mpyfiles: Document change in .mpy sub-version.
Signed-off-by: Damien George <damien@micropython.org>
2024-03-28 16:21:35 +11:00
Damien George bdbc869f9e py/persistentcode: Bump .mpy sub-version to 6.3.
This is required because the .mpy native ABI was changed by the
introduction of `mp_proto_fun_t`, see commits:
- 416465d81e
- 5e3006f117
- e2ff00e811

And three `mp_binary` functions were added to `mp_fun_table` in
commit d2276f0d41.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-28 16:18:26 +11:00
Damien George 8b0efde927 examples/natmod/framebuf: Enable FrameBuffer.poly method.
Signed-off-by: Damien George <damien@micropython.org>
2024-03-28 16:18:09 +11:00
Damien George d2276f0d41 py/dynruntime: Add mp_binary_get_size/get_val_array/set_val_array.
These are needed to read/write array.array objects, which is useful in
native code to provide fast extensions that work with big arrays of data.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-28 16:18:09 +11:00
robert-hh 4662a71f44 drivers/memory: Add IS25LPWP064D chip to list of external flash devices.
Confirguration provided by by @ironss-iotec.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-28 15:52:40 +11:00
robert-hh d9b9e88899 samd/samd_qspiflash: Avoid reading status byte 2 when not available.
Change provided by @ironss-iotec.

Tested with Adafruit, SEEED and MiniFig boards for non-interference.

Fixes issue #14190.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-28 15:52:40 +11:00
robert-hh 3980b36173 samd/samd_spiflash: Allow configuring the flash SPI baudrate.
Using a define for MICROPY_HW_SPIFLASH_BAUDRATE in mpconfigboard.h.  If not
defined the default is 24MHz.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-28 15:52:28 +11:00
robert-hh e8e9a39a6d samd/mcu: Update clock config after changes to USB.
For all MCUs: run the test for USB clock recovery mode fallback after USB
has been started.

For samd21: change DFLL48 config from the open loop mode variant to sync
with the XOSC32KULP.  Matches better the 48MHz value.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-28 15:49:41 +11:00
robert-hh b41360d119 samd/boards: Enable MICROPY_HW_DFLL_USB_SYNC on appropriate boards.
For the boards ADAFRUIT_TRINKET_M0 and MINISAM_M4.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-28 15:37:01 +11:00
robert-hh 328b6df058 samd/README: Fix incorrect port directory name.
At a single place, STM32 was used instead of SAMD.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-28 15:36:26 +11:00
iabdalkader e8dd519e2d esp32/network_wlan: Add interface and security WLAN constants.
Following the same change to extmod network interfaces.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-28 13:01:55 +11:00
iabdalkader 81dff08bf2 esp8266/network_wlan: Add interface and security WLAN constants.
Following the same change to extmod network interfaces.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-28 13:01:55 +11:00
iabdalkader 7753045a8f extmod: Add interface and security constants at WLAN class level.
Other constants such as `machine.Pin.OUT` are defined on the class that
uses them, rather than at the module level.  This commit makes that the
case for WLAN network interfaces, adding IF_xxx and SEC_xxx constants.

The SEC_xxx constants are named as such to match the `security` keyword
that they are used with.  And the IF_xxx constants have IF as a prefix so
they are grouped together as names.

This scheme of putting constants on the class means that only the available
features (eg security configurations) are made available as constants.  It
also means that different network interfaces (eg WLAN vs LAN) can keep
their own specific constants within their class, such as PHY_xxx for LAN.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-28 12:52:28 +11:00
iabdalkader 5a7d78c732 mimxrt,stm32: Set the security mode for the default WiFi AP.
The default CYW43 WiFi AP settings were missing the security mode, leaving
the AP in open mode by default.  That's changed by this commit to use
WPA/WPA2 by default.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-28 12:51:50 +11:00
Matt Trentini db1b5df16c stm32/README: Update list of supported STM32 series.
Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
2024-03-28 12:34:46 +11:00
Damien George 35e8d184b1 shared/tinyusb: Increase default string descr max length to 40 chars.
When defining custom USB devices, longer strings may be needed.  Eventually
the memory for string descriptors can be allocated on demand, but for now
this bigger value should be reasonable.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-27 23:57:57 +11:00
Angus Gratton 0f16ae92c0 shared/tinyusb: Update some code comments for runtime USB.
Updates a few code comments that were out of date or poorly worded. No code
changes.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-03-27 23:55:41 +11:00
Angus Gratton 935f5391b5 shared/tinyusb: Don't disconnect on soft reset unless USB was active.
Previously, constructing the singleton USBDevice object was enough to
trigger a USB disconnect on soft reset. Now it also has to be active.

The only case where this changes the behaviour is if the USBDevice object
has been constructed but never set to active (no more disconnect in this
case). Otherwise, behaviour is the same.

This change was requested by hippy on the raspberrypi forums.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-03-27 23:54:12 +11:00
Damien George 79edaddf50 rp2/CMakeLists: Apply O2 optimisation to map, mpz and vm source code.
Enabling this optimisation increases the RPI_PICO firmware by +3344 bytes.

Performace change is:

diff of scores (higher is better)
N=100 M=100             rpi-base -> rpi-opt      diff      diff% (error%)
bm_chaos.py               196.56 ->  215.26 :  +18.70 =  +9.514% (+/-0.05%)
bm_fannkuch.py             52.47 ->   54.37 :   +1.90 =  +3.621% (+/-0.05%)
bm_fft.py                1476.74 -> 1530.06 :  +53.32 =  +3.611% (+/-0.01%)
bm_float.py              2305.65 -> 2444.11 : +138.46 =  +6.005% (+/-0.08%)
bm_hexiom.py               32.83 ->   35.09 :   +2.26 =  +6.884% (+/-0.05%)
bm_nqueens.py            2335.85 -> 2259.78 :  -76.07 =  -3.257% (+/-0.06%)
bm_pidigits.py            366.23 ->  465.81 :  +99.58 = +27.191% (+/-0.04%)
bm_wordcount.py            41.20 ->   41.87 :   +0.67 =  +1.626% (+/-0.01%)
core_import_mpy_multi.py  327.44 ->  335.24 :   +7.80 =  +2.382% (+/-0.08%)
core_import_mpy_single.py  63.41 ->   64.98 :   +1.57 =  +2.476% (+/-0.21%)
core_locals.py             27.24 ->   29.19 :   +1.95 =  +7.159% (+/-0.01%)
core_qstr.py              137.31 ->  140.84 :   +3.53 =  +2.571% (+/-0.03%)
core_str.py                18.44 ->   18.10 :   -0.34 =  -1.844% (+/-0.03%)
core_yield_from.py        221.69 ->  211.72 :   -9.97 =  -4.497% (+/-0.01%)
misc_aes.py               303.38 ->  308.72 :   +5.34 =  +1.760% (+/-0.02%)
misc_mandel.py           1501.00 -> 1746.60 : +245.60 = +16.362% (+/-0.04%)
misc_pystone.py          1348.22 -> 1456.75 : +108.53 =  +8.050% (+/-0.07%)
misc_raytrace.py          223.81 ->  246.16 :  +22.35 =  +9.986% (+/-0.07%)
viper_call0.py            331.05 ->  331.10 :   +0.05 =  +0.015% (+/-0.00%)
viper_call1a.py           323.34 ->  323.39 :   +0.05 =  +0.015% (+/-0.00%)
viper_call1b.py           241.01 ->  241.04 :   +0.03 =  +0.012% (+/-0.00%)
viper_call1c.py           242.88 ->  242.92 :   +0.04 =  +0.016% (+/-0.00%)
viper_call2a.py           318.41 ->  318.46 :   +0.05 =  +0.016% (+/-0.00%)
viper_call2b.py           211.27 ->  211.30 :   +0.03 =  +0.014% (+/-0.00%)

And the test `tests/basics/builtin_pow3_intbig.py` now passes (it uses a
lot of mpz code and previously took longer than 10 seconds to run on
RPI_PICO, which would lead to a timeout in the test runner).

Signed-off-by: Damien George <damien@micropython.org>
2024-03-27 12:16:30 +11:00
Jim Mussared d694ac6e1b py/makeqstrdata.py: Ensure that scope names get low qstr values.
Originally implemented in a patch file provided by @ironss-iotec.

Fixes issue #14093.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2024-03-26 22:52:25 +11:00
Amirreza Hamzavi 57de9da352 docs/library/machine.RTC: Add docs for RTC.memory() method.
Co-Authored-By: glenn20 <glenn20@users.noreply.github.com>

Signed-off-by: Amirreza Hamzavi <amirrezahamzavi2000@gmail.com>
2024-03-26 17:59:06 +11:00
Jim Mussared a0d31e54ae esp8266/Makefile: Add support for C++ user C modules.
This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2024-03-26 17:41:34 +11:00
iabdalkader fa6ccc7e72 renesas-ra/boards/ARDUINO_PORTENTA_C33: Add Arduino's external library.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-26 17:03:56 +11:00
iabdalkader da09646eab stm32/boards/ARDUINO_PORTENTA_H7: Add Arduino's external library.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-26 17:03:56 +11:00
iabdalkader 723cd03aeb stm32/boards/ARDUINO_NICLA_VISION: Add Arduino's external library.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-26 17:03:56 +11:00
iabdalkader 27aa3c19bf stm32/boards/ARDUINO_GIGA: Add Arduino's external library.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-26 17:03:56 +11:00
iabdalkader 438e522911 lib/arduino-lib: Add Arduino's external library.
This library contains external modules for Arduino boards.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-26 17:03:56 +11:00
Andrew Leech 994021e1e0 nrf/Makefile: Clean up dangling LIBS declaration.
Signed-off-by: Andrew Leech <andrew@alelec.net>
2024-03-26 16:54:21 +11:00
Andrew Leech 34c4625dcc nrf/main: Fix build of microbit when SD is enabled.
Signed-off-by: Andrew Leech <andrew@alelec.net>
2024-03-26 16:49:40 +11:00
robert-hh 4dd288ff62 nrf/modules/machine/pwm: Tag a PWM device as used in the constructor.
When PWM constructor was created without specifying a device or setting
both freq and duty rate, it was not tagged as used, and further calls to
get a PWM object may get the same PWM device assigned.

Fixes #13494.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-26 16:41:08 +11:00
Christian Walther 5e926b2222 nrf/modules/machine: Catch exceptions from pin interrupts.
Exceptions in pin interrupt handlers would end up crashing MicroPython with
a "FATAL: uncaught exception".

In addition, MicroPython would get stuck trying to output this error
message, or generally any print output from inside a pin interrupt handler,
through the UART after the first character, so that only "F" was visible.
The reason was a matching interrupt priority between the running pin
interrupt and the UARTE interrupt signaling completion of the output
operation.  Fix that by increasing the UARTE interrupt priority.

Code taken from the stm32 port and adapted.

Signed-off-by: Christian Walther <cwalther@gmx.ch>
2024-03-26 15:21:01 +11:00
Christian Walther b10182bbcc nrf: Fix non-running LFCLK.
Under some circumstances, after a hard reset, the low-frequency clock would
not be running.  This caused time.ticks_ms() to return 0, time.sleep_ms()
to get stuck, and other misbehavior.  A soft reboot would return it to a
working state.

The cause was a race condition that was hit when the bootloader would
itself turn LFCLK on, but turn it off again shortly before launching the
main application (this apparently happens with the Adafruit bootloader
from https://github.com/fanoush/ds-d6/tree/master/micropython).  Stopping
the clock is an asynchronous operation and it continues running for a short
time after the stop command is given.  When MicroPython checked whether to
start it by looking at the LFCLKSTAT register (nrf_clock_lf_is_running)
during that time, it would mistakenly not be started again.  What
MicroPython should be looking at is not whether the clock is running at
this time, but whether a start/stop command has been given, which is
indicated by the LFCLKRUN register (nrf_clock_lf_start_task_status_get).
It is not clearly documented, but empirically LFCLKRUN is not just set when
the LFCLKSTART task is triggered, but also cleared when the LFCLKSTOP task
is triggered, which is exactly what we need.

The matter is complicated by the fact that the nRF52832 has an anomaly
(see [errata](https://infocenter.nordicsemi.com/topic/errata_nRF52832_Rev3/ERR/nRF52832/Rev3/latest/anomaly_832_132.html?cp=5_2_1_0_1_33))
where starting the LFCLK will not work between 66µs and 138µs after it last
stopped. Apply a workaround for that.  See nrfx_clock_lfclk_start() in
micropython/lib/nrfx/drivers/src/nrfx_clock.c for reference, but we are not
using that because it also does other things and makes the code larger.

Signed-off-by: Christian Walther <cwalther@gmx.ch>
2024-03-26 13:03:57 +11:00
Christian Walther be89d4376b nrf/modules/machine: Enable code formatting.
It destroys a few manual alignments, but these seem minor compared to
the benefit of automated code style consistency.

Signed-off-by: Christian Walther <cwalther@gmx.ch>
2024-03-26 12:49:09 +11:00
Christian Walther d1a3e7d292 nrf/Makefile: Allow external board definitions.
Trying to use an external board definition according to
https://github.com/micropython/micropython-example-boards on the nrf port
failed with "Invalid BOARD specified".  Replacing all ocurrences of
"boards/$(BOARD)" with "$(BOARD_DIR)" following the example of
stm32/Makefile fixes that.

Signed-off-by: Christian Walther <cwalther@gmx.ch>
2024-03-26 12:32:56 +11:00
Damien George 51d05c442a tools/manifestfile.py: Fix freeze() when script is an empty iterable.
The documentation for `freeze()` says that:
- If `script` is `None`, all files in `path` will be frozen.
- If `script` is an iterable then `freeze()` is called on all items of the
  iterable.

This commit makes sure this behaviour is followed when an empty tuple/list
is passed in for `script` (previously an empty tuple/list froze all files).

Fixes issue #14125.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-25 13:41:37 +11:00
Jared Hancock 086d4d127d extmod/network_wiznet5k: Properly enable interrupt signal on w5100s.
According to the datasheet, the IEN bit to enable the interrupt is in the
MR2 register, not the MR register.

This is just cleanup as the interrupt appears to be enabled by default
after resetting the chip.

Tested on W5100S_EVB_PICO.
2024-03-25 13:25:19 +11:00
Daniël van de Giessen fcaf109917 top: Skip codespell for IDF managed components.
During a build the ESP-IDF downloads managed components in the
ports/esp32/managed_components directory, which shouldn't be spellchecked.

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2024-03-25 12:32:29 +11:00
Daniël van de Giessen a0efe2d368 esp32/main: Check if main GC heap allocation failed.
If the heap allocation fails we will crash if we continue, so at least we
can show a clear error message so one can figure out memory allocation was
the problem (instead of just seeing some arbitrary null pointer error
later).

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2024-03-25 12:19:00 +11:00
Damien George 35f3f0a87d py/nlr: Add "memory" to asm clobbers list in nlr_jump.
Newer versions of gcc (14 and up) have more sophisticated dead-code
detection, and the asm clobbers list needs to contain "memory" to inform
the compiler that the asm code actually does something.

Tested that adding this "memory" line does not change the generated code on
ARM Thumb2, x86-64 and Xtensa targets (using gcc 13.2).

Fixes issue #14115.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-25 11:52:26 +11:00
Damien George 35b2edfc24 github/workflows: Add Biome workflow for JavaScript formatting/linting.
Enable Biome on all of webassembly port and tests.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-22 14:31:25 +11:00
Damien George badc0106bd tools/ci.sh: Update webassembly CI tests.
Signed-off-by: Damien George <damien@micropython.org>
2024-03-22 14:31:25 +11:00
Damien George c1513a078d tests/ports/webassembly: Add webassembly JS tests.
Signed-off-by: Damien George <damien@micropython.org>
2024-03-22 14:31:25 +11:00
Damien George e41b571a29 tests/run-tests.py: Support running webassembly tests via node.
This allows running tests with a .js/.mjs suffix, and also .py tests using
node and the webassembly port.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-22 14:31:25 +11:00
Damien George c2cf58befc webassembly/library: Fix formatting and style for Biome.
Signed-off-by: Damien George <damien@micropython.org>
2024-03-22 14:31:25 +11:00
Damien George 26d6969fef webassembly: Update README.md to describe latest changes.
Signed-off-by: Damien George <damien@micropython.org>
2024-03-22 14:31:25 +11:00
Damien George b9eb74e73b webassembly/variants/pyscript: Add pyscript variant.
This commit adds a pyscript variant for use in https://pyscript.net/.

The configuration is:
- No ASYNCIFY, in order to keep the WASM size down and have good
  performance.
- MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES to enable most features.
- Custom manifest that includes many of the python-stdlib libraries.
- MICROPY_GC_SPLIT_HEAP_AUTO to increase GC heap size instead of doing a
  collection when memory is exhausted.  This is needed because ASYNCIFY is
  disabled.  Instead the GC collection is run at the top-level before
  executing any Python code.
- No MICROPY_VARIANT_ENABLE_JS_HOOK because there is no asynchronous
  keyboard input to interrupt a running script.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-22 14:31:25 +11:00
Damien George 6ff3e356e2 webassembly: Implement replInit() and replProcessChar().
This is the JavaScript API for starting and running a REPL.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-22 14:31:25 +11:00
Damien George 625b17a410 webassembly: Implement runCLI() for a Node-based CLI.
This allows running MicroPython webassembly from the command line using:

    node micropython.mjs

Signed-off-by: Damien George <damien@micropython.org>
2024-03-22 14:31:25 +11:00
Damien George 9b090603a0 webassembly: Implement runPythonAsync() for top-level async code.
With this commit, `interpreter.runPythonAsync(code)` can now be used to run
Python code that uses `await` at the top level.  That will yield up to
JavaScript and produce a thenable, which the JavaScript runtime can then
resume.  Also implemented is the ability for Python code to await on
JavaScript promises/thenables.  For example, outer JavaScript code can
await on `runPythonAsync(code)` which then runs Python code that does
`await js.fetch(url)`.  The entire chain of calls will be suspended until
the fetch completes.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-22 13:37:47 +11:00
Damien George 39bd0b8a0a webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:

- Proxying of Python objects to JavaScript with a PyProxy type that lives
  on the JavaScript side.  PyProxy implements JavaScript Proxy traps such
  as has, get, set and ownKeys, to make Python objects have functionality
  on the JavaScript side.

- Proxying of JavaScript objects to Python with a JsProxy type that lives
  on the Python side.  JsProxy passes through calls, attributes,
  subscription and iteration from Python to JavaScript.

- A top-level API on the JavaScript side to construct a MicroPython
  interpreter instance via `loadMicroPython()`.  That function returns an
  object that can be used to execute Python code, access the Python globals
  dict, access the Emscripten filesystem, and other things.  This API is
  based on the API provided by Pyodide (https://pyodide.org/).  As part of
  this, the top-level file is changed from `micropython.js` to
  `micropython.mjs`.

- A Python `js` module which can be used to access all JavaScript-side
  symbols, for example the DOM when run within a browser.

- A Python `jsffi` module with various helper functions like
  `create_proxy()` and `to_js()`.

- A dedenting lexer which automatically dedents Python source code if every
  non-empty line in that source starts with a common whitespace prefix.
  This is very helpful when Python source code is indented within a string
  within HTML or JavaScript for formatting reasons.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-22 13:37:47 +11:00