summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-04-04extmod/extmod.cmake: Add micropy_lib_mbedtls component.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-04-04stm32/Makefile: Allow overriding COPT in Makefile.Andrew Leech
It can now be set in mpconfigboard.mk (as well as the make command line).
2022-04-04docs/reference/mpremote: Add details about mount usage over soft reboot.Andrew Leech
2022-04-04tools/mpremote: Improve reliability of mount after soft reboot.Andrew Leech
With the existing code problems can occur with remounting, the "if t - t_last_activity > QUIET_TIMEOUT:" check can be triggered early before the REPL string comes through, meaning that the remount doesn't happen. On certain boards the "MPY: soft reboot" line comes through immediately (getting the routine past initial timeout) but then there's a slightly longer delay while the board restarts before it prints out the startup header and the REPL prompt. This commit adds some extra pattern monitoring during the timeout loop to track the state if a soft restart is actually started.
2022-04-04drivers/codec: Add driver for the WM8960 codec.robert-hh
This codec is assembled for the MIMXRT1xxx_DEV boards and available for WM8960 breakout boards as well. The driver itself has been tested as working with the MIMXRT boards and a Sparkfun WM6890 breakout board. It implements the initialization, basic methods and some enhanced methods like 3D, ALC, soft-mute and deemphasis.
2022-04-04docs: Add quickref and docs for mimxrt, including network.LAN docs.robert-hh
2022-04-02tests/pyb: Update CAN tests to match revised CAN API.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-04-02docs/library/pyb.CAN: Update CAN docs to match revised API.iabdalkader
2022-04-02stm32/pyb_can: Replace CAN.initfilterbanks with CAN.init keyword arg.iabdalkader
The CAN.initfilterbanks() class method is removed, and its functionality is replaced with the "num_filter_banks" keyword argument to the CAN constructor and CAN.init(). This configures the filter bank split. This new approach provides more flexibility configuring the resources used by a given CAN instance, allowing other MCUs like H7 to fit the API. It also brings CAN closer to how other machine peripherals are configured, where everything is done in the constructor/init method. This is a breaking change to the CAN API.
2022-04-02stm32/pyb_can: Define the maximum bit timing parameters.iabdalkader
Define the maximum parameters for CAN/FDCAN nominal bit timing, and for FDCAN data bit timing, for bit timing calculations.
2022-04-02stm32/pyb_can: Return the filter ID and type of received messages.iabdalkader
CAN.recv() now returns a 5-tuple, with the new element in the second position being a boolean, True if the ID is extended. This is a breaking change of the API for CAN.recv().
2022-04-02stm32/pyb_can: Add support for bus with mixed Classic/FD nodes.iabdalkader
A CAN bus can have mixed classic/FD nodes. Prior to this patch the CAN API could be configured for either standard or extended ID, but not both/mixed operation. This patch allows extended IDs to be filtered and enabled on a per-message basis, in send(), setfilter() and clearfilter(). This is a breaking change to the API: init() no longer accepts the extframe keyword argument.
2022-04-02stm32/pyb_can: Add support for CAN FD extended frame ID.iabdalkader
2022-04-02stm32/pyb_can: Enable CAN FD frame support and BRS.iabdalkader
- Enable CAN FD frame support and BRS. - Optimize the message RAM usage per FDCAN instance. - Document the usage and different sections of the Message RAM.
2022-04-01py/makeqstrdefs: Cleanup and extend source file classification.Daniel Jour
- The classification of source files in makeqstrdefs.py has been moved into functions to consolidate the logic for that classification into a single place. - Classification of source files (into C or C++ or "other" files) is based on the filename extension. - For C++ there are many more common filename extensions than just ".cpp"; see "Options Controlling the Kind of Output" in man gcc for example. All common extensions for C++ source files which need preprocessing have been added.
2022-04-01tests/basics/fun_callstardblstar: Add test for large arg allocation.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-04-01py/runtime: Remove unnecessary check for kw_value == MP_OBJ_NULL.Damien George
The values are always real objects, only the key can be MP_OBJ_NULL to indicate a **kwargs entry. Signed-off-by: Damien George <damien@micropython.org>
2022-04-01py: Fix compiling and decoding of *args at large arg positions.Damien George
There were two issues with the existing code: 1. "1 << i" is computed as a 32-bit number so would overflow when executed on 64-bit machines (when mp_uint_t is 64-bit). This meant that *args beyond 32 positions would not be handled correctly. 2. star_args must fit as a positive small int so that it is encoded correctly in the emitted code. MP_SMALL_INT_BITS is too big because it overflows a small int by 1 bit. MP_SMALL_INT_BITS - 1 does not work because it produces a signed small int which is then sign extended when extracted (even by mp_obj_get_int_truncated), and this sign extension means that any position arg after *args is also treated as a star-arg. So the maximum bit position is MP_SMALL_INT_BITS - 2. This means that MP_OBJ_SMALL_INT_VALUE() can be used instead of mp_obj_get_int_truncated() to get the value of star_args. These issues are fixed by this commit, and a test added. Signed-off-by: Damien George <damien@micropython.org>
2022-03-31py/emitbc: Assert that a small int fits its encoding when emitting one.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-03-31py/runtime: Use size_t/ssize_t instead of uint/int.David Lechner
This replaces instances of uint with size_t and int with ssize_t in the mp_call_prepare_args_n_kw_var() function since all of the variables are used as array offsets. Also sort headers while we are touching this. Signed-off-by: David Lechner <david@pybricks.com>
2022-03-31tests/basics/fun_callstardblstar: Add coverage test.David Lechner
This fixes code coverage for the case where a *arg without __len__ is unpacked and uses exactly the amount of memory that was allocated for kw args. This triggers the code branch where the memory for the kw args gets reallocated since it was used already by the *arg unpacking. Signed-off-by: David Lechner <david@pybricks.com>
2022-03-31py/runtime: Drop new_alloc < 4 check.David Lechner
To reach this check, n_kw has to be >= 1 and therefore args2_alloc has to be >= 2. Therefore new_alloc will always be >= 4. So this check will never be true and can be removed. Signed-off-by: David Lechner <david@pybricks.com>
2022-03-31py/runtime: Do not overallocate when len is known.David Lechner
This fixes overallocating an extra mp_obj_t when the length of *args and **args is known. Previously we were allocating 1 mp_obj_t for each n_args and n_kw plus the length of each *arg and **arg (if they are known). Since n_args includes *args and n_kw includes **args, this was allocating an extra mp_obj_t in addition to the length of these args when unpacked. To fix this, we just subtract 1 from the length to account for the 1 already implicitly allocated by n_args and n_kw. Signed-off-by: David Lechner <david@pybricks.com>
2022-03-31py/runtime: Allow multiple *args in a function call.David Lechner
This is a partial implementation of PEP 448 to allow unpacking multiple star args in a function or method call. This is implemented by changing the emitted bytecodes so that both positional args and star args are stored as positional args. A bitmap is added to indicate if an argument at a given position is a positional argument or a star arg. In the generated code, this new bitmap takes the place of the old star arg. It is stored as a small int, so this means only the first N arguments can be star args where N is the number of bits in a small int. The runtime is modified to interpret this new bytecode format while still trying to perform as few memory reallocations as possible. Signed-off-by: David Lechner <david@pybricks.com>
2022-03-31py/runtime: Allow multiple **args in a function call.David Lechner
This is a partial implementation of PEP 448 to allow multiple ** unpackings when calling a function or method. The compiler is modified to encode the argument as a None: obj key-value pair (similar to how regular keyword arguments are encoded as str: obj pairs). The extra object that was pushed on the stack to hold a single ** unpacking object is no longer used and is removed. The runtime is modified to decode this new format. Signed-off-by: David Lechner <david@pybricks.com>
2022-03-31py/vm: Prevent array bound warning when using -MP_OBJ_ITER_BUF_NSLOTS.Damien George
This warning can happen on clang 13.0.1 building mpy-cross: ../py/vm.c:748:25: error: array index -3 refers past the last possible element for an array in 64-bit address space containing 64-bit (8-byte) elements (max possible 2305843009213693952 elements) [-Werror,-Warray-bounds] sp[-MP_OBJ_ITER_BUF_NSLOTS + 1] = MP_OBJ_NULL; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Using pointer access instead of array access works around this warning. Fixes issue #8467. Signed-off-by: Damien George <damien@micropython.org>
2022-03-30py/emitnative: Don't store prelude at end of machine code if not needed.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-03-30py/asmxtensa: Fix use of l32i/s32i when offset won't fit in encoding.Damien George
This commit adds optimised l32i/s32i functions that select the best load/ store encoding based on the size of the offset, and uses the function when necessary in code generation. Without this, ASM_LOAD_REG_REG_OFFSET() could overflow the word offset (using a narrow encoding), for example when loading the prelude from the constant table when there are many (>16) constants. Fixes issue #8458. Signed-off-by: Damien George <damien@micropython.org>
2022-03-30py/compile: Only show raw code that is bytecode.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-03-30py/bc.h: Fix C++20 compilation with "volatile".stijn
C++20 is deprecating several usages of the volatile keyword so remove this one affected case in the codebase which causes such warning.
2022-03-30extmod/uasyncio: Fix gather cancelling and handling of exceptions.Damien George
The following fixes are made: - cancelling a gather now cancels all sub-tasks of the gather (previously it would only cancel the first) - if any sub-task of a gather raises an exception then the gather finishes (previously it would only finish if the first sub-task raised) Fixes issues #5798, #7807, #7901. Signed-off-by: Damien George <damien@micropython.org>
2022-03-30extmod/uasyncio: Allow task state to be a callable.Damien George
This implements a form of CPython's "add_done_callback()", but at this stage it is a hidden feature and only intended to be used internally. Signed-off-by: Damien George <damien@micropython.org>
2022-03-30stm32/modmachine: Add deepsleep support to reset_cause() for WB55.Andrew Leech
2022-03-30stm32/sdio: Use runtime calculation for clock divider of sdio on H7.Meriç SARIIŞIK
STM32H7 family has a different calculation compared to the current one for the SDMMC clock divider configuration.
2022-03-30nrf/modules: Include uasyncio in default board manifest.Andrew Leech
2022-03-30nrf/drivers/usb: Fix MP_STREAM_POLL_RD support on USB CDC.Andrew Leech
This gets ipoll working on USB CDC stdin.
2022-03-30nrf/drivers/usb: Fix background events/scheduling while at USB REPL.Andrew Leech
2022-03-30tools/mpremote: Allow running mpremote with `python -m`.Waterlens
This is helpful because some scripts are likely to use mpremote with a specific python path.
2022-03-30tests/extmod: Update I2S rate test to work on mimxrt.Damien George
Tested on Teensy 4.0. Signed-off-by: Damien George <damien@micropython.org>
2022-03-30mixmrt/machine_i2s: Add I2S protocol support.MikeTeachman
This commit adds support for machine.I2S on the mimxrt port. The I2S API is consistent with the existing stm32, esp32, and rp2 implementations. I2S features: - controller transmit and controller receive - 16-bit and 32-bit sample sizes - mono and stereo formats - sampling frequencies from 8kHz to 48kHz - 3 modes of operation: - blocking - non-blocking with callback - uasyncio - configurable internal buffer - optional MCK Tested with the following development boards: - MIMXRT1010_EVK, MIMXRT1015_EVK, MIMXRT1020_EVK, MIMXRT1050_EVK - Teensy 4.0, Teensy 4.1 - Olimex RT1010 - Seeed ARCH MIX Tested with the following I2S hardware peripherals: - UDA1334 - GY-SPH0645LM4H - WM8960 codec on board the MIMXRT boards and separate breakout board - INMP441 - PCM5102 - SGTL5000 on the Teensy audio shield Signed-off-by: Mike Teachman <mike.teachman@gmail.com>
2022-03-29docs/library/machine.I2S: Clarify what rate refers to.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-03-29tests/extmod: Add test for machine.I2S data rate.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-03-29stm32/machine_i2s: Fix 16-bit stereo i2s_frame_map.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-03-29stm32/machine_i2s: Allow I2S.deinit to be called multiple times.Damien George
In particular, it is called by the constructor if the instance already exists. So if the previous instance was deinit'd then it will be deinit'd a second time. Signed-off-by: Damien George <damien@micropython.org>
2022-03-29stm32/machine_i2s: Set FullDuplexMode to disabled on F4.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-03-28tools/mpremote: Support any prompt string when detecting soft reset.Damien George
The prompt may be changed by sys.ps1. Signed-off-by: Damien George <damien@micropython.org>
2022-03-28py/builtinimport: Alias sys to usys if import weak links aren't enabled.Damien George
The sys module should always be available (if it's compiled in), eg to change sys.path for importing. So provide an explicit alias from "sys" to "usys" so that "import sys" can always work. Signed-off-by: Damien George <damien@micropython.org>
2022-03-28py: Change jump-if-x-or-pop opcodes to have unsigned offset argument.Damien George
These jumps are always forwards, and it's more efficient in the VM to decode an unsigned argument. These opcodes are already optimised versions of the sequence "dup-top pop-jump-if-x pop" so it doesn't hurt generality to optimise them further. Signed-off-by: Damien George <damien@micropython.org>
2022-03-28py/emitbc: Add check for bytecode jump offset overflow.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-03-28py: Change jump opcodes to emit 1-byte jump offset when possible.Damien George
This commit introduces changes: - All jump opcodes are changed to have variable length arguments, of either 1 or 2 bytes (previously they were fixed at 2 bytes). In most cases only 1 byte is needed to encode the short jump offset, saving bytecode size. - The bytecode emitter now selects 1 byte jump arguments when the jump offset is guaranteed to fit in 1 byte. This is achieved by checking if the code size changed during the last pass and, if it did (if it shrank), then requesting that the compiler make another pass to get the correct offsets of the now-smaller code. This can continue multiple times until the code stabilises. The code can only ever shrink so this iteration is guaranteed to complete. In most cases no extra passes are needed, the original 4 passes are enough to get it right by the 4th pass (because the 2nd pass computes roughly the correct labels and the 3rd pass computes the correct size for the jump argument). This change to the jump opcode encoding reduces .mpy files and RAM usage (when bytecode is in RAM) by about 2% on average. The performance of the VM is not impacted, at least within measurment of the performance benchmark suite. Code size is reduced for builds that include a decent amount of frozen bytecode. ARM Cortex-M builds without any frozen code increase by about 350 bytes. Signed-off-by: Damien George <damien@micropython.org>