Update from upstream repo micropython/micropython@master#3
Open
backstroke-bot wants to merge 9464 commits intobynds:masterfrom
Open
Update from upstream repo micropython/micropython@master#3backstroke-bot wants to merge 9464 commits intobynds:masterfrom
backstroke-bot wants to merge 9464 commits intobynds:masterfrom
Conversation
This makes CONFIG_MICROPY_VFS_* actually do things. Signed-off-by: Vdragon <mail@massdriver.space>
Use new Zephyr FS, and be a demonstration of that configuration. This is still on-disk compatible with existing filesystems on the internal flash. Signed-off-by: Vdragon <mail@massdriver.space>
Signed-off-by: Vdragon <mail@massdriver.space>
The documentation used integers to specify Teensy board pins, which match the board's silkscreen. But in Python code Dxx have to be used, since integers are not accepted as a Pin identifier. This commit changes the Pinout tables accordingly, consistent with the other MIMXRT boards. Signed-off-by: robert-hh <robert@hammelrath.com>
The globals need to be forwarded from the caller's context. Signed-off-by: Damien George <damien@micropython.org>
`globals()` needs to be provided in case `__import__` is a Python function.
Currently, dict views (eg `dict.keys()`, `dict.values()`) do not implement
the `bool` or `len` unary operations. That may seem like a reasonable
omission for MicroPython to keep code size down, but it actually leads to
silently incorrect bool operations, because by default things are true.
Eg we currently have:
>>> bool(dict().keys())
True
which is wrong, it should be `False` because the dict is empty.
This commit implements `bool` and `len` unary operations on dict views by
simply delegating to the existing dict unary op function.
Fixes issue #12385.
Signed-off-by: Damien George <damien@micropython.org>
The currently documentation for ilistdir tuples says that the size element is included based on the platform. However, this is not the case as it is included based on the filesystem type. This commit makes the according adjustment. Fixes issue #17516. Signed-off-by: Alex Tran <alex.t.tran@gmail.com>
RP2350 builds were using the incomplete `rp2_af.csv` alt function table
(originally made for RP2040) which broke pins > 31 in RP2350B (48-pin
QFN-80) builds:
>>> machine.Pin(31)
Pin(GPIO31, mode=IN, pull=PULL_DOWN)
>>> machine.Pin(32)
Pin(GPIO32, mode=ALT, pull=PULL_DOWN, alt=31)
To fix this, separate alt-functions tables for RP2350 and RP2350B are added
in this commit.
UART_AUX (alt function 11) was also missing, along with XIP_CS1 and
CORESIGHT_TRACE, and they are now added as well.
Signed-off-by: Phil Howard <github@gadgetoid.com>
Signed-off-by: Damien George <damien@micropython.org>
This improves REPL usage consistency across ports, by utilizing the pyexec code for the unix REPL. Only enabled when MICROPY_USE_READLINE == 1 (the default). Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
When `MICROPY_MODULE___FILE__` is enabled and parsing file input, set the global `__file__` variable to the source filename. This matches the behavior of the unix port and provides the current filename to the executing script. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
When `MICROPY_PYEXEC_COMPILE_ONLY` is enabled and the global `mp_compile_only` is True, code is compiled but not executed. Also add comprehensive tests for compile-only functionality covering both successful compilation and syntax error detection. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Provides support for command line `-X compile-only` option on unix port. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Add a general normalize_newlines() function that handles newline variations (\\r\\r\\n, \\r\\n) to \\n while preserving literal \\r characters that are part of test content. This provides a robust solution for cross-platform test compatibility, particularly addressing PTY double-newline issues that can occur with some terminal implementations. The function is applied to all test output before comparison, eliminating platform-specific newline issues. Includes a unit test to verify the normalization behavior. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Consolidates file and string execution to use the standard pyexec interface for consistency with other ports. Simplify execute_from_lexer for remaining usage: Remove unused LEX_SRC_VSTR and LEX_SRC_FILENAME cases, keeping only LEX_SRC_STR for REPL and LEX_SRC_STDIN for stdin execution. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
This ensures that ctrl-C works on the unix port when executing code at the REPL. Signed-off-by: Damien George <damien@micropython.org>
Enable `MICROPY_PYEXEC_ENABLE_EXIT_CODE_HANDLING` to propagate `sys.exit()` exit codes properly. Update `convert_pyexec_result()` to handle return values where pyexec returns the exit code with `PYEXEC_FORCED_EXIT` flag set for `SystemExit`. Extract the exit code from the lower 8 bits when the flag is set, otherwise return as-is (0 for success, 1 for exception). Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
When `MICROPY_PYEXEC_ENABLE_EXIT_CODE_HANDLING` is enabled, `SystemExit` now sets the `PYEXEC_FORCED_EXIT` flag in addition to the exit code. This allows the REPL to properly detect and exit when SystemExit is raised, while still preserving the exit code in the lower bits. Fixes `repl_lock.py` test which expects REPL to exit on `SystemExit`. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Add wrapper macros that by default expand to the callback name. Users can define this macro to add a prefix (e.g., mp_) to callback implementations, to redirect or completely override MicroPython's TinyUSB callbacks. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit adds a `--json` option to `mpy-tool.py`, in order to generate Compiler-Explorer-compatible JSON annotation information for the bytecode disassembly. Some of this information might be theoretically possible to parse out from the text itself, but not all of it is, e.g. disambiguating child references with non-unique simple names. Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Signed-off-by: Damien George <damien@micropython.org>
This is 0.19.0 plus the following changes: - remove obsolete dcd_esp32sx - fix for HID stylus descriptor and HID example - typos, docs and generator scripts - MTP fix - DWC2 enumeration when EP0 size=8 - DWC2 fix for EP0 IN - stm32 FSDEV IRQ remapping fix - DWC2 ZLP fix The reason we need the extra 24 commits is due to a bug with TinyUSB's handling of zero-length-packets in the DWC2 (Synopsis) backend, which affects the stm32 port. That's fixed by hathach/tinyusb#3293 Signed-off-by: Damien George <damien@micropython.org>
It's now available in the version of TinyUSB used by this repository. Also, update to the newer `tud_cdc_configure_t` struct name and newer `tud_cdc_configure()` function name. Signed-off-by: Damien George <damien@micropython.org>
Noted while adding C2 support that some of these comments are a bit out of date. Spun out to its own commit, and also mention C5 as well. This change also adds some recommendation on which ESP32 board to pick, as we occasionally see issues or questions that would be non-issues on a board with more RAM (and for small production or personal projects the savings of picking a cheaper ESP32 chip are basically neglible). This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Only set the rate on interfaces that are active. It seems ESP-IDF 5.4.x or so added checks that the interface is enabled, whereas previous versions silently did nothing. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Changes are: - Add constants for some of the supported ESP-NOW data rates. - Add constants for switching an ESP32 WLAN radio in/out of Long Range mode. - Document the new constants and their usage. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Uses constants added in previous commit. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v5...v6) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Add the IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP to modsocket in the Unix port so that the directives take on the values defined in the system headers. This is needed because the values of these directives are different for MacOS vs other Unix systems. Fixes issue #8456. Signed-off-by: Alex Tran <alex.t.tran@gmail.com>
This commit adds custom command completion functions for both the zsh and fish shell. The behaviour for those new completions follow the existing completion for the bash shell, including the way to generate the completion alias (with appropriately named command line switches). Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This is functionally a no-op, although will change compiled code due to the numerical values of the enums changing. This is needed for a follow-up commit, to remove the static-inline `mp_handle_pending(bool)` helper function. Signed-off-by: Damien George <damien@micropython.org>
This commit removes the static-inline `mp_handle_pending()` wrapper function, which was originally added for backwards compatibility. It replaces it with `mp_handle_pending_internal()` which is renamed to `mp_handle_pending()`, which has the same arguments. Signed-off-by: Damien George <damien@micropython.org>
This should be a no-op because the enum and bool have the same numeric value. Signed-off-by: Damien George <damien@micropython.org>
These macros were added in e11b17c for use with `sys.path` and building import path names, as well as being used by the unix port in 625d08a. But the macro usage for importing was promptly replaced with vstrs in e09ffa1, and eventually for the unix port in 520f356, over 9.5 years ago. So, remove these unused macros. Signed-off-by: Damien George <damien@micropython.org>
This inline helper function has two specific uses so doesn't need to be generally available in `py/obj.h`. Signed-off-by: Damien George <damien@micropython.org>
This is an internal helper function that assumes the argument is of type `mp_obj_fun_bc_t`, so has a better home in `py/objfun.h`. Signed-off-by: Damien George <damien@micropython.org>
And change the argument to `const mp_obj_fun_bc_t *`. This makes it clear that it requires that specific type, rather than a general `mp_obj_t`. Signed-off-by: Damien George <damien@micropython.org>
These helper functions assume their argument is of type `mp_obj_list_t` so they have a better home in `py/objlist.h`. Signed-off-by: Damien George <damien@micropython.org>
This can be done now these functions are declared in `py/objlist.h`, where the `mp_obj_list_t` struct is defined. This changes code size by -24 bytes on bare-arm, and by -56 bytes on stm32. Signed-off-by: Damien George <damien@micropython.org>
These helper functions assume their argument is of type `mp_obj_tuple_t` so they have a better home in `py/objtuple.h`. Also remove `mp_obj_tuple_hash()` because it doesn't have a corresponding function defined anywhere (nor is it ever used). Signed-off-by: Damien George <damien@micropython.org>
This can be done now that it's declared in `py/objtuple.h`, where the `mp_obj_tuple` struct is defined. This allows much better code generation for users of `mp_obj_tuple_get()` where the caller uses len/items immediately (which is most uses), because the compiler no longer needs to allocate the return values on the stack. Changes code size by -36 bytes on bare-arm and -56 bytes on stm32. Signed-off-by: Damien George <damien@micropython.org>
This commit refactors handling of opcodes whose composition can be easily defined as an entry in a table, so there's only one bit of code handling those opcodes rather than several small bits with overlapping functionalities. Two opcodes, RER and WER have been added to that table for completeness, although they're gated behind the uncommon opcodes configuration define. Still, despite two new opcodes, the final binary is smaller by about 160 bytes. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
As per the implementation of m_malloc0, if MICROPY_GC_CONSERVATIVE_CLEAR is set then all RAM is guaranteed to be zero-init by gc_alloc. py/objarray.c: Guard the explicit zero init in bytearray_make_new against being run, initialising the RAM to zero a second time, if this flag is set. Note that MICROPY_GC_CONSERVATIVE_CLEAR is default enabled by MICROPY_ENABLE_GC, and no ports currently override this value. Co-authored-by: Mike Bell <mdb036@gmail.com> Signed-off-by: Phil Howard <github@gadgetoid.com>
As per the implementation of m_malloc0, if MICROPY_GC_CONSERVATIVE_CLEAR is set then all RAM is guaranteed to be zero-init by gc_alloc. py/objstr.c: Guard the explicit zero init in bytes_make_new against being run, initialising the RAM to zero a second time, if this flag is set. Signed-off-by: Phil Howard <github@gadgetoid.com>
This is a follow up to 6436f8b that catches more cases of a failed raw REPL. If the target device is broken in a certain way then it can have a serial write error instead of just not returning any data. In that case the error raised by `pyboard.py` is "could not enter raw repl: Write timeout", which is slightly different to "could not enter raw repl" (the latter is raised when a serial read fails to return the correct data). The patch here accounts for all cases of a failed raw REPL by using `str.startswith()` instead of a string equality. This can be tested on RPI_PICO_W and RPI_PICO2_W which currently crash in the specific way needed to trigger the write timeout when running the `tests/extmod/socket_badconstructor.py` test. In particular adding the following code to the end of a test (eg `tests/extmod/random_extra.py`) will trigger the issue: import socket try: s = socket.socket(socket.AF_INET, socket.SOCK_RAW, None) except TypeError: pass With the fix here, the `run-tests.py` and `run-natmodtests.py` will abort early if that code is added (prior to the fix they would continue to run all tests and take a long time). Signed-off-by: Damien George <damien@micropython.org>
This commit adds support for the LDO driver for ESP32-P4 SOCs. Signed-off-by: Artem Makarov <gh@artemy.nl>
The esp32 port (and esp8266) doesn't read from dupterm in `mp_hal_stdin_rx_chr()` is because it uses `os.dupterm_notify()` instead, which forces a read of the dupterm sources from Python. That function should be called when it's known that there is input to read. Nevertheless, this commit adds code to explicitly poll dupterm in `mp_hal_stdin_rx_chr()`, following other ports like rp2. Signed-off-by: Matthias Urlichs <matthias@urlichs.de>
ESP-IDF v5.5.x requires min 3.16 This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
As we add the object files to the linker command line directly, they go after the other library dependencies and therefore don't resolve their dependencies. Turns out the only dependent symbol of the btree library is abort_, so explicitly include it in the link. The old way of linking the entire library is cleaner, but stopped working with ESP-IDF V5.5... This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
This argument isn't expected to be passed from Python code, but - as pointed out - it doesn't make sense how the irq() mechanism works otherwise. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
An ioctl should not have any side effects if the request is unknown. Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
Both mbedTLS and axTLS have support for producing more detailed error strings. However, these are not used if the error is raised in stream protocol functions (read/write/ioctl). This commit adds support for more detailed error messages from streams. Under the hood it's using a new MP_STREAM_RAISE_ERROR ioctl request to pass the error code back to the stream implementation which can raise a more detailed error. If the ioctl is not implemented, we fall back to the old behaviour and raise an OSError with the error code. Currently the detailed messages are only implemented for TLS sockets since those already had helper functions for raising detailed exceptions, but can be easily implemented in any other stream. Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
This is the only location in the code base that uses `mp_obj_tuple_del()`, so we can reduce code size by reworking the iter code not to use that function. The zip iter implementation should now have slightly better GC behaviour: it only allocates the return tuple if needed, instead of allocating it and then freeing it when the zip iterator is exhausted. Signed-off-by: Damien George <damien@micropython.org>
Since the parent commit, this is now unused. Signed-off-by: Damien George <damien@micropython.org>
This provides the DEBUG_printf definition which is needed when defining MICROPY_DEBUG_VERBOSE, and is consistent with all other ports. Signed-off-by: stijn <stijn@ignitron.net>
Otherwise only those in gc_mark_subtree get logged, which is incomplete and hence not very useful. Signed-off-by: stijn <stijn@ignitron.net>
This is more informative when debugging possible gc issues. Signed-off-by: stijn <stijn@ignitron.net>
Explicitly specify the wanted cast otherwise this results in
warning C4244: '=': conversion from 'unichar' to 'char',
possible loss of data
when building with msvc with most warnings enabled.
Signed-off-by: stijn <stijn@ignitron.net>
This commit introduces support for writing inline assembler code snippets when targeting Xtensa cores that use register windows (eg. the whole ESP32 family). Opcodes support is still limited to what the ESP8266 supports (as in, LX3 cores opcodes), however each LX core version is guaranteed to support all previous versions' opcodes as well. The ESP32 does not have the inline assembler enabled by default, following the existing expectations when it comes to firmware footprint. Since now emitted functions may have one of two possible exit sequences, the L32I test had to be fixed. It would return the word containing the L32I opcode itself, but the upper 8 bits of the word came from the following opcode - which can change depending on the exit code sequence. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello!
The upstream repository
micropython/micropython@masterhas some new changes that aren't in this fork. So, here they are, ready to be merged! 🎉If this pull request can be merged without conflict, you can publish your software with these new changes. Otherwise, fix any merge conflicts by clicking the
Resolve Conflictsbutton.If you like Backstroke, consider donating to help us pay for infrastructure here. Backstroke is a completely open source project that's free to use, but we survive on sponsorships and donations. Thanks for your support! Help out Backstroke.
Created by Backstroke (I'm a bot!)