summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-05-06webassembly/proxy_c: Only proxy across resolve/reject funs when needed.Damien George
To improve efficiency. Signed-off-by: Damien George <damien@micropython.org>
2024-05-06webassembly/proxy_c: Reject promises with a PythonError instance.Damien George
The `reason` in a rejected promise should be an instance of `Error`. That leads to better error messages on the JavaScript side. Signed-off-by: Damien George <damien@micropython.org>
2024-05-06webassembly/api: Fix importing micropython.mjs module from node REPL.Damien George
Fixes issue #14363. Signed-off-by: Damien George <damien@micropython.org>
2024-05-03stm32/i2c: Fix clock enable for I2C4 on STM32F7 MCUs.Damien George
This was broken by 5aec051f9f0e1be9750ca4f08478275f298087a3 when adding support for I2C4 on H7 MCUs. Signed-off-by: Damien George <damien@micropython.org>
2024-05-01stm32/mboot: Buffer the correct amount of bytes for a flash write.Damien George
Different MCUs have different requirements for the minimum number of bytes that can be written to internal flash. Signed-off-by: Damien George <damien@micropython.org>
2024-05-01stm32/flash: Fix writing final words to flash on H5 and H7 MCUs.Damien George
The calculations `num_word32 / 4` and `num_word32 / 8` were rounding down the number of words to program to flash, and therefore possibly truncating the data (eg mboot could miss writing the final few words of the firmware). That's fixed in this commit by adding extra logic to program any remaining words. And the logic for H5 and H7 is combined. Signed-off-by: Damien George <damien@micropython.org>
2024-05-01stm32/boards/LEGO_HUB_NO7: Add robust update logic to mboot.Damien George
Following change in 899592ac341ed9f10ee554424f964f6880fc8c48 Signed-off-by: Damien George <damien@micropython.org>
2024-05-01stm32/boards/LEGO_HUB_NO6: Write key after writing elements.Damien George
In case there is a power failure after during this operation, the key must be the last thing that is written, to indicate valid data. Signed-off-by: Damien George <damien@micropython.org>
2024-04-29docs/develop/optimizations: Fix typo identified in issue 14391.Matt Trentini
Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
2024-04-26nrf/mpconfigport: Enable MICROPY_NLR_THUMB_USE_LONG_JUMP on nRF51xx.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-04-25py/nlrthumb: Make non-Thumb2 long-jump workaround opt-in.J. Neuschäfer
Although the original motivation given for the workaround[1] is correct, nlr.o and nlrthumb.o are linked with a small enough distance that the problem does not occur, and the workaround isn't necessary. The distance between the b instruction and its target (nlr_push_tail) is just 64 bytes[2], well within the ±2046 byte range addressable by an unconditional branch instruction in Thumb mode. The workaround induces a relocation in the text section (textrel), which isn't supported everywhere, notably not on musl-libc[3], where it causes a crash on start-up. With the workaround removed, micropython works on an ARMv5T Linux system built with musl-libc. This commit changes nlrthumb.c to use a direct jump by default, but leaves the long jump workaround as an option for those cases where it's actually needed. [1]: commit dd376a239dc4f47b0ee7866810fcda151f3cf6dd Author: Damien George <damien.p.george@gmail.com> Date: Fri Sep 1 15:25:29 2017 +1000 py/nlrthumb: Get working again on standard Thumb arch (ie not Thumb2). "b" on Thumb might not be long enough for the jump to nlr_push_tail so it must be done indirectly. [2]: Excerpt from objdump -d micropython: 000095c4 <nlr_push_tail>: 95c4: b510 push {r4, lr} 95c6: 0004 movs r4, r0 95c8: f02d fd42 bl 37050 <mp_thread_get_state> 95cc: 6943 ldr r3, [r0, #20] 95ce: 6023 str r3, [r4, #0] 95d0: 6144 str r4, [r0, #20] 95d2: 2000 movs r0, #0 95d4: bd10 pop {r4, pc} 000095d6 <nlr_pop>: 95d6: b510 push {r4, lr} 95d8: f02d fd3a bl 37050 <mp_thread_get_state> 95dc: 6943 ldr r3, [r0, #20] 95de: 681b ldr r3, [r3, #0] 95e0: 6143 str r3, [r0, #20] 95e2: bd10 pop {r4, pc} 000095e4 <nlr_push>: 95e4: 60c4 str r4, [r0, #12] 95e6: 6105 str r5, [r0, #16] 95e8: 6146 str r6, [r0, #20] 95ea: 6187 str r7, [r0, #24] 95ec: 4641 mov r1, r8 95ee: 61c1 str r1, [r0, #28] 95f0: 4649 mov r1, r9 95f2: 6201 str r1, [r0, #32] 95f4: 4651 mov r1, sl 95f6: 6241 str r1, [r0, #36] @ 0x24 95f8: 4659 mov r1, fp 95fa: 6281 str r1, [r0, #40] @ 0x28 95fc: 4669 mov r1, sp 95fe: 62c1 str r1, [r0, #44] @ 0x2c 9600: 4671 mov r1, lr 9602: 6081 str r1, [r0, #8] 9604: e7de b.n 95c4 <nlr_push_tail> [3]: https://www.openwall.com/lists/musl/2020/09/25/4 Signed-off-by: J. Neuschäfer <j.ne@posteo.net>
2024-04-24webassembly/api: Inject asyncio.run if needed by the script.Damien George
This allows a simple way to run the existing asyncio tests under the webassembly port, which doesn't support `asyncio.run()`. Signed-off-by: Damien George <damien@micropython.org>
2024-04-24webassembly: Add JavaScript-based asyncio support.Damien George
This commit adds a significant portion of the existing MicroPython asyncio module to the webassembly port, using parts of the existing asyncio code and some custom JavaScript parts. The key difference to the standard asyncio is that this version uses the JavaScript runtime to do the actual scheduling and waiting on events, eg Promise fulfillment, timeouts, fetching URLs. This implementation does not include asyncio.run(). Instead one just uses asyncio.create_task(..) to start tasks and then returns to the JavaScript. Then JavaScript will run the tasks. The implementation here tries to reuse as much existing asyncio code as possible, and gets all the semantics correct for things like cancellation and asyncio.wait_for. An alternative approach would reimplement Task, Event, etc using JavaScript Promise's. That approach is very difficult to get right when trying to implement cancellation (because it's not possible to cancel a JavaScript Promise). Signed-off-by: Damien George <damien@micropython.org>
2024-04-24webassembly/modjsffi: Add jsffi.async_timeout_ms.Damien George
This function exposes `setTimeout()` as an async function. Signed-off-by: Damien George <damien@micropython.org>
2024-04-24extmod/modasyncio: Make mp_asyncio_context variable public.Damien George
So it can be accessed by a port if needed, for example to see if asyncio has been imported. Signed-off-by: Damien George <damien@micropython.org>
2024-04-24webassembly/proxy_c: Fix then-continue to convert reason to throw value.Damien George
When a Promise is rejected on the JavaScript side, the reject reason should be thrown into the encapsulating generator on the Python side. Signed-off-by: Damien George <damien@micropython.org>
2024-04-24webassembly/proxy_c: Fix proxy then reject handling.Damien George
An exception on the Python side should be passed to the Promise reject callback on the JavaScript side. Signed-off-by: Damien George <damien@micropython.org>
2024-04-24webassembly/objjsproxy: Fix handling of thrown value into JS generator.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-04-24webassembly/api: Allocate code data on C heap when running Python code.Damien George
Otherwise Emscripten allocates it on the Emscripten C stack, which will overflow for large amounts of code. Fixes issue #14307. Signed-off-by: Damien George <damien@micropython.org>
2024-04-24webassembly/api: Fix waiting for Emscripten module to be loaded.Damien George
In modularize mode, the `_createMicroPythonModule()` constructor must be await'ed on, before `Module` is ready to use. Signed-off-by: Damien George <damien@micropython.org>
2024-04-22github/workflows: Run code size workflow on shared or port code changes.Damien George
To get more insight to firmware size changes when code changes. Signed-off-by: Damien George <damien@micropython.org>
2024-04-22tests/cpydiff: Add a note about risk of resizing memoryview targets.Angus Gratton
This a stop-gap until there is a proper fix for this. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-04-22py/objarray: Fix use-after-free if extending a bytearray from itself.Angus Gratton
Two cases, one assigning to a slice. Closes https://github.com/micropython/micropython/issues/13283 Second is extending a slice from itself, similar logic. In both cases the problem occurs when m_renew causes realloc to move the buffer, leaving a dangling pointer behind. There are more complex and hard to fix cases when either argument is a memoryview into the buffer, currently resizing to a new address breaks memoryviews into that object. Reproducing this bug and confirming the fix was done by running the unix port under valgrind with GC-aware extensions. Note in default configurations with GIL this bug exists but has no impact (the free buffer won't be reused while the function is still executing, and is no longer referenced after it returns). Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-04-22py/obj: Fix initialiser order in MP_DEFINE_CONST_OBJ_TYPE_NARGS_ macros.Vonasmic
This commit swaps the order of the `flags` and `name` struct initialisers for `mp_obj_type_t`, to fix an incompatibility with C++. The original order of the initialiser didn't match the definition of the type, and although that's still legal C, it's not legal C++. Signed-off-by: Vonasmic <kasarkal123@gmail.com>
2024-04-22py/objfun: Fix C++ compatibility with casting in inline functions.stijn
Explicit casts are needed. Fixes recent changes from 648a7578da21cc7ddb4046fc59891144e797b983 and 9400229766624e80db6a6f95af287a5542dc1b43. Signed-off-by: stijn <stijn@ignitron.net>
2024-04-22rp2/README: Fix typo, improve sentence about building with other boards.Michiel W. Beijen
Signed-off-by: Michiel W. Beijen <mb@x14.nl>
2024-04-22rp2/modmachine: Prevent lock-up when lightsleep() called within thread.Simon Wood
When `lightsleep()` is called from within a thread the interrupts may not be enabled on current core, and thus the call to `lightsleep()` never completes. Fixes issue #14092. Signed-off-by: Simon Wood <simon@mungewell.org>
2024-04-20github/workflows: Update coverage workflow to codecov-action@v4.J. Neuschäfer
Fixes: https://github.com/micropython/micropython/issues/14340 Signed-off-by: J. Neuschäfer <j.ne@posteo.net>
2024-04-17shared/tinyusb: Fix dynamic USB control callbacks for wLength==0.Angus Gratton
In the case where an OUT control transfer triggers with wLength==0 (i.e. all data sent in the SETUP phase, and no additional data phase) the callbacks were previously implemented to return b"" (i.e. an empty buffer for the data phase). However this didn't actually work as intended because b"" can't provide a RW buffer (needed for OUT transfers with a data phase to write data into), so actually the endpoint would stall. The symptom was often that the device process the request (if processing it in the SETUP phase when all information was already available), but the host sees the endpoint stall and eventually returns an error. This commit changes the behaviour so returning True from the SETUP phase of a control transfer queues a zero length status response. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-04-11lib/arduino-lib: Update submodule to the latest.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-30webassembly/proxy_js: Allow a Python proxy of a function to be undone.Damien George
This optimises the case where a Python function is, for example, stored to a JavaScript attribute and then later retrieved from Python. The Python function no longer needs to be a proxy with double proxying needed for the call from Python -> JavaScript -> Python. Signed-off-by: Damien George <damien@micropython.org>
2024-03-30webassembly/proxy_js: Promote Python thenable to a Promise.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-03-30webassembly/proxy_c: Ensure return value of async fun is passed to JS.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-03-29mimxrt: Add support for OpenAMP.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-29stm32/mpremoteprocport: Use metal logging functions.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-29extmod/modopenamp: Use metal logging functions exclusively.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-29extmod/modopenamp: Set a default log handler for ports.iabdalkader
Use the existing metal log handling mechanism instead of overriding the metal_log, which causes build issues when logging is enabled. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-29samd/mcu: Guard static function with appropriate #if.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-03-29tests/net_inet: Add simpler tls sites test, and skip existing on axtls.Damien George
Ports that use axtls cannot run the `test_tls_sites.py` test because the sites it connects to use advanced ciphers. So skip this test on such ports, and add a new, simpler test that doesn't require certificate verification and works with axtls. Signed-off-by: Damien George <damien@micropython.org>
2024-03-28extmod/modtls_axtls: Add verify_mode and CERT_NONE constant.Damien George
Supporting `verify_mode` and `CERT_NONE` is required for the new `ssl.py` code, as well as `requests` to work. Signed-off-by: Damien George <damien@micropython.org>
2024-03-28docs/reference/mpyfiles: Document change in .mpy sub-version.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-03-28py/persistentcode: Bump .mpy sub-version to 6.3.Damien George
This is required because the .mpy native ABI was changed by the introduction of `mp_proto_fun_t`, see commits: - 416465d81e911b088836f4e7c37fac2bc0f67917 - 5e3006f1172d0eabbbefeb3268dfb942ec7cf9cd - e2ff00e81113d7a3f32f860652017644b5d68bf1 And three `mp_binary` functions were added to `mp_fun_table` in commit d2276f0d41c2fa66a224725fdb2411846c91cf1a. Signed-off-by: Damien George <damien@micropython.org>
2024-03-28examples/natmod/framebuf: Enable FrameBuffer.poly method.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2024-03-28py/dynruntime: Add mp_binary_get_size/get_val_array/set_val_array.Damien George
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-28drivers/memory: Add IS25LPWP064D chip to list of external flash devices.robert-hh
Confirguration provided by by @ironss-iotec. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-28samd/samd_qspiflash: Avoid reading status byte 2 when not available.robert-hh
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-28samd/samd_spiflash: Allow configuring the flash SPI baudrate.robert-hh
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-28samd/mcu: Update clock config after changes to USB.robert-hh
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-28samd/boards: Enable MICROPY_HW_DFLL_USB_SYNC on appropriate boards.robert-hh
For the boards ADAFRUIT_TRINKET_M0 and MINISAM_M4. Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-28samd/README: Fix incorrect port directory name.robert-hh
At a single place, STM32 was used instead of SAMD. Signed-off-by: robert-hh <robert@hammelrath.com>