Open
Conversation
|
The current version (before the incoming merge) has a bug while trying to compile ports/unix. I have to edit the code of the AXTLS library: -------------------------- ssl/os_port_micropython.h -------------------------- #define TTY_FLUSH() -#include "../../../extmod/crypto-algorithms/sha256.h" #define SHA256_CTX CRYAL_SHA256_CTX |
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>
Fixes issue #18370. Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
There were a few typos in the documentation for the `I2CTarget.irq` method description where `IRQ_ADDR_MATCH_READ` was used, however `IRQ_ADDR_MATCH_WRITE` should have been used. Fixes issue #18470. Signed-off-by: Alex Tran <alex.t.tran@gmail.com>
Fixes issue #7915. Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
Allows using custom DTS things such as bindings. Signed-off-by: Vdragon <mail@massdriver.space>
Adds the ability to use PSRAM and non-contiguous memory.
Example usage, add this to dts overlay:
/ {
heap_psram {
compatible = "micropython,heap";
size = <DT_SIZE_M(4)>;
memory-region = <&psram>;
};
heap_sram1 {
compatible = "micropython,heap";
size = <DT_SIZE_K(140)>;
memory-region = <&sram1>;
};
};
Signed-off-by: Vdragon <mail@massdriver.space>
This commit fixes a regression introduced in 1b92bda, where a new architecture was added to mpy-cross but it had no matching native emitter exists. The result was that the architecture emitter entry point would be correctly calculated according to the native architecture index, but if the emitters entry points table was not updated to match the new number of architectures an out of bound access may be performed. Unfortunately adding RV64IMC shifted the debug emitter index further down the table, and that table wasn't updated to reflect the lack of an emitter for RV64. Adding a NULL entry there would cause a NULL pointer access as there was no need to perform any check about the emitter entry point function's validity until now. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
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 commit migrates handling of certain narrow (ie. 16-bits) opcodes from a per-opcode dedicated code snippet to the existing table-driven opcode handler. The final ESP8266 firmware binary is 64 bytes shorter, without any change in the existing behaviour and with a reduced source code lines count too. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
If the return value is set only when certain condition are true, the compiler sometimes raises an error. Signed-off-by: robert-hh <robert@hammelrath.com>
Zephyr and MicroPython both have a variant of FatFs, but having both enabled leads to build fails. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
By putting the heap in the noinit area instead of the bss area, zephyr won't memset it to zero during start. This improves startup time, in particular if the heap is very big. The system heap of zephyr is also in the same section. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Add additional sensor type constants. Commonly used by power and current measurement sensors. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Add support for RISC-V RV32IMC native code emitter in the zephyr port. It will be automatically enabled by default, but can be overridden by defining `MICROPY_EMIT_RV32` and/or `MICROPY_EMIT_INLINE_RV32`. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
The old code was only handling `\r` and ignoring `\n`, which is a problem for systems that only send `\n` as a newline. This commit handles it better, supporting both characters. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
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.
No description provided.