summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-09-22extmod/modbluetooth: Do GATTC reassembly in protected uPy context.Damien George
The calls to m_new and m_del require an exclusive uPy (really a GC) context. In particular these functions cannot be called directly from a FreeRTOS task on esp32. Fixes issue #9369. Signed-off-by: Damien George <damien@micropython.org>
2022-09-22extmod/modbluetooth: Change data_len type from size_t to uint16_t.Damien George
For consistency, and to remove the need for additional conversion of types. Signed-off-by: Damien George <damien@micropython.org>
2022-09-20tests/run-multitests: Make paths more deterministic.Andrew Leech
Allows running from a different directory, etc. This work was funded by Planet Innovation.
2022-09-20tests/run-multitests: Extend usage information.Andrew Leech
2022-09-19unix/variants/coverage: Add test for manifest freeze_mpy().Jim Mussared
This uses the frozentest.mpy that is also used by ports/minimal. Also fixes two bugs that these new tests picked up: - File extension matching in manifestfile.py. - Handling of freeze_mpy results in makemanifest. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19tests/frozen: Move frozentest.mpy from ports/ to tests/.Jim Mussared
frozentest.mpy was previously duplicated in ports/minimal and ports/powerpc. This needs to be re-generated on every .mpy version increase, so might as well just have a single copy of it. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19extmod/vfs_posix_file: Implement finaliser for files.stijn
Prevent handle leaks when file objects aren't closed explicitly and fix some MICROPY_CPYTHON_COMPAT issues: this wasn't properly adhered to because #ifdef was used so it was always on, and closing files multiple times should be avoided unconditionally.
2022-09-19py: Include filename in errors from loading/saving files via "open".Damien George
This improves error messages in mpy-cross: - When loading a .py file that doesn't exist (or can't be opened) it now includes the filename in the OSError. - When saving a .mpy file that can't be opened it now raises an exception (prior, it would silently fail), and includes the filename in the OSError. Signed-off-by: Damien George <damien@micropython.org>
2022-09-19py/runtime: Add mp_raise_OSError_with_filename helper function.Damien George
Useful when more detail is needed for an OSError associated with a file. Signed-off-by: Damien George <damien@micropython.org>
2022-09-19py/objmodule: Add support for __dict__.Jim Mussared
This matches class `__dict__`, and is similarly gated on MICROPY_CPYTHON_COMPAT. Unlike class though, because modules's globals are actually dict instances, the result is a mutable dictionary. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19py/persistentcode: Introduce .mpy sub-version.Jim Mussared
The intent is to allow us to make breaking changes to the native ABI (e.g. changes to dynruntime.h) without needing the bytecode version to increment. With this commit the two bits previously used for the feature flags (but now unused as of .mpy version 6) encode a sub-version. A bytecode-only .mpy file can be loaded as long as MPY_VERSION matches, but a native .mpy (i.e. one with an arch set) must also match MPY_SUB_VERSION. This allows 3 additional updates to the native ABI per bytecode revision. The sub-version is set to 1 because the previous commits that changed the layout of mp_obj_type_t have changed the native ABI. Signed-off-by: Jim Mussared <jim.mussared@gmail.com> Signed-off-by: Damien George <damien@micropython.org>
2022-09-19py/obj: Optimise code size and performance for make_new as a slot.Jim Mussared
The check for make_new (i.e. used to determine something's type) is now more complicated due to the slot access. This commit changes the inlining of a few frequently-used helpers to overall improve code size and performance.
2022-09-19py/obj: Convert make_new into a mp_obj_type_t slot.Jim Mussared
Instead of being an explicit field, it's now a slot like all the other methods. This is a marginal code size improvement because most types have a make_new (100/138 on PYBV11), however it improves consistency in how types are declared, removing the special case for make_new. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19py/obj: Merge getiter and iternext mp_obj_type_t slots.Jim Mussared
The goal here is to remove a slot (making way to turn make_new into a slot) as well as reduce code size by the ~40 references to mp_identity_getiter and mp_stream_unbuffered_iter. This introduces two new type flags: - MP_TYPE_FLAG_ITER_IS_ITERNEXT: This means that the "iter" slot in the type is "iternext", and should use the identity getiter. - MP_TYPE_FLAG_ITER_IS_CUSTOM: This means that the "iter" slot is a pointer to a mp_getiter_iternext_custom_t instance, which then defines both getiter and iternext. And a third flag that is the OR of both, MP_TYPE_FLAG_ITER_IS_STREAM: This means that the type should use the identity getiter, and mp_stream_unbuffered_iter as iternext. Finally, MP_TYPE_FLAG_ITER_IS_GETITER is defined as a no-op flag to give the default case where "iter" is "getiter". Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19py/objnamedtuple: Optimise slot RAM usage for namedtuple.Jim Mussared
Rather than reserving a full 12-slot mp_obj_type_t, reserve enough room for seven and cast as necessary. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19py/objtype: Optimise slot RAM usage for instance types.Jim Mussared
In all cases other than where you have a native base with a protocol, it now fits into 4 GC blocks (like it did before the slots representation). Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19py/obj: Remove basic mp_obj_type_t sparse representation.Jim Mussared
This makes the slots-based representation the only option. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19py/obj: Add slot-index mp_obj_type_t representation.Jim Mussared
The existings mp_obj_type_t uses a sparse representation for slots for the capability methods of the type (eg print, make_new). This commit adds a compact slot-index representation. The basic idea is that where the mp_obj_type_t struct used to have 12 pointer fields, it now has 12 uint8_t indices, and a variable-length array of pointers. So in the best case (no fields used) it saves 12x4-12=36 bytes (on a 32-bit machine) and in the common case (three fields used) it saves 9x4-12=24 bytes. Overall with all associated changes, this slot-index representation reduces code size by 1000 to 3000 bytes on bare-metal ports. Performance is marginally better on a few tests (eg about 1% better on misc_pystone.py and misc_raytrace.py on PYBv1.1), but overall marginally worse by a percent or so. See issue #7542 for further analysis and discussion. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19py/obj: Add accessors for type slots and use everywhere.Jim Mussared
This is a no-op, but sets the stage for changing the mp_obj_type_t representation. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19py/obj: Add "full" and "empty" non-variable-length mp_obj_type_t.Jim Mussared
This will always have the maximum/minimum size of a mp_obj_type_t representation and can be used as a member in other structs. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19py/objexcept: Make MP_DEFINE_EXCEPTION use MP_DEFINE_CONST_OBJ_TYPE.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19all: Remove unnecessary locals_dict cast.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19all: Fix #if inside MP_DEFINE_CONST_OBJ_TYPE for msvc.Jim Mussared
Changes: MP_DEFINE_CONST_OBJ_TYPE( ... #if FOO ... #endif ... ); to: MP_DEFINE_CONST_OBJ_TYPE( ... FOO_TYPE_ATTR ... ); Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19all: Make all mp_obj_type_t defs use MP_DEFINE_CONST_OBJ_TYPE.Jim Mussared
In preparation for upcoming rework of mp_obj_type_t layout. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19py/obj: Add macro to declare ROM mp_obj_type_t instances.Jim Mussared
This will allow the structure of mp_obj_type_t to change while keeping the definition code the same. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19all: Standardise mp_obj_type_t initialisation.Jim Mussared
Remove setting unused slots. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19all: Simplify buffer protocol to just a "get buffer" callback.Jim Mussared
The buffer protocol type only has a single member, and this existing layout creates problems for the upcoming split/slot-index mp_obj_type_t layout optimisations. If we need to make the buffer protocol more sophisticated in the future either we can rely on the mp_obj_type_t optimisations to just add additional slots to mp_obj_type_t or re-visit the buffer protocol then. This change is a no-op in terms of generated code. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-15rp2/Makefile: Add link to build troubleshooting on failure.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-15esp32/Makefile: Add link to build troubleshooting on failure.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-15py/mkrules.mk: Add link to build troubleshooting on failure.Jim Mussared
Also update the submodules help text to match. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-14esp32/mphalport: Fix calculation of large sleep by using 64-bit arith.Damien George
Fixes issue #9304. Signed-off-by: Damien George <damien@micropython.org>
2022-09-13py/objpolyiter: Fix comment about finaliser method.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-09-13mimxrt/machine_uart: Fix a bug in UART.write().robert-hh
Causing an incomplete send if the data size was longer than the buffer size.
2022-09-13mimxrt/machine_uart: Set the UART ioctl write poll flag properly.robert-hh
It was always set to True. The change adds a check to the tx status flag which is set when all data is transferred.
2022-09-13mimxrt/machine_spi: Allow a setting of -1 for cs in the constructor.robert-hh
In that case, no Pin will be configured for the CS signal, even if it is internally still generated. That setting allows to use any pin for CS, which then must be controlled by the Python script. Also make the default cs=-1 to match other ports (software CS).
2022-09-13mimxrt: Format the firmware image to match the new teensy loader.robert-hh
The new teensy loader keeps the file system under certain conditions: - The file size is properly set in the file header. - The header version is 4.3 These changes are implemented here, requiring a backport of fsl_flexspi_nor_boot.c. There is still a problem with the command line version of the teensy loader, which fails on the first attempt. At the second attempt it works. The GUI version of the teensy loader is fine.
2022-09-13mimxrt/machine_uart: Drop a few commented lines about TX ring buffer.robert-hh
2022-09-13tests/extmod/uasyncio_heaplock.py: Force SKIP on stackless.Jim Mussared
This is a latent issue that wasn't caught by CI because there was no configuration that had both stackless+uasyncio. The previous check to skip with stackless builds only worked when the bytecode emitter was used by default. Force the check to use the bytecode emitter. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-13unix: Refactor mpconfigvariant.mk.Jim Mussared
All variants (except minimal) enable text compression and fat/lfs, so move them to the common mpconfigport.mk. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-13py/mpconfig: Add "everything" features from unix coverage.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-13unix: Refactor mpconfigport.h and mpconfigvariant.h.Jim Mussared
This is a no-op for coverage and minimal. The standard and dev variants have been merged and enable the same feature set as a typical bare-metal board. And remove the CI for the dev build. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-13unix/variants: Remove freedos and fast variants.Jim Mussared
The freedos variant is untested by CI and is difficult to maintain. The fast variant is not a good name for what it does. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-13py/mpconfig: Make feature levels available to mpconfigport.h.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-13py/mpconfig: Add LFS1/LFS2 options to match FAT/posix.Jim Mussared
Also fixes the #ifndef for FAT & posix. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-13tools/pyboard.py: Support Windows pathname separators.Wind-stormger
Addresses issue #9132.
2022-09-13samd/mpconfigport: Enable MICROPY_ENABLE_FINALISER when VFS is used.Andrew Leech
2022-09-13zephyr/mpconfigport: Enable MICROPY_ENABLE_FINALISER when VFS is used.Andrew Leech
2022-09-13unix/mpconfigport: Enable MICROPY_ENABLE_FINALISER when VFS is used.Andrew Leech
2022-09-13extmod/vfs: Add finaliser to ilistdir to close directory handle.Andrew Leech
When iterating over filesystem/folders with os.iterdir(), an open file (directory) handle is used internally. Currently this file handle is only closed once the iterator is completely drained, eg. once all entries have been looped over / converted into list etc. If a program opens an iterdir but does not loop over it, or starts to loop over the iterator but breaks out of the loop, then the handle never gets closed. In this state, when the iter object is cleaned up by the garbage collector this open handle can cause corruption of the filesystem. Fixes issues #6568 and #8506.
2022-09-13py/objpolyiter: Add a new polyiter type with finaliser support.Andrew Leech