summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
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
2022-09-09tools/makemanifest.py: Force the repo version of the mpy_cross package.Jim Mussared
In case the version from pypi is installed or some other version is available in sys.path, prepend `$(TOP)/mpy-cross` to sys.path instead. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-09zephyr/boards: Add config for bbc_microbit_v2.Damien George
This enables the bluetooth module. GAP scanning and advertising works. Signed-off-by: Damien George <damien@micropython.org>
2022-09-09extmod/modbluetooth: Replace def_handle with end_handle in char IRQ.Jim Mussared
This is technically a breaking change, but: a) We need the end handle to do descriptor discovery properly. b) We have no possible use for the existing definition handle in the characteristic result IRQ. None of the methods can use it, and therefore no existing code should be using it in a way that changing it to a different integer value should break. Unfortunately NimBLE doesn't make it easy to get the end handle, so also implement a mechanism to use the following characteristic to calculate the previous characteristic's end handle. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-09extmod/modbluetooth: Fix descriptor registration with empty tuple.Jim Mussared
Incorrect use of "continue" when the tuple was length zero meant it broke the rest of the argument handling. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-08stm32/boards/PYB: Fix handling of BOARD_VARIANT selection.Jim Mussared
The matches should not have been quoted. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-08tools/autobuild: Use distinct directory for building stm32 variants.Jim Mussared
Previous the build directory just used the board name, now make it use the variant name too. This shouldn't have any change because the existing directory should not exist (all builds run by these scripts remove their build directory after completion), but it makes debugging easier. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-08rp2/boards: Remove all I2C,SPI pin defs that already match pico-sdk.Jim Mussared
I.e. for whichever SPI/I2C instance is PICO_DEFAULT_I2C, there's no need to set MICROPY_HW_SPIn_SCK. The only ones remaining are for the non-default instance. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-08rp2/machine_i2c: Use pico-sdk's default pins for I2C.Jim Mussared
Inherits the default values for whichever instance is PICO_DEFAULT_I2C. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-08rp2/machine_spi: Use pico-sdk's default pins for SPI.Jim Mussared
Rather than hardcoding the defaults, use pico-sdk's board definition. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-08rp2/boards: Set PICO_BOARD correctly for each board.Jim Mussared
In most cases, it's calculated automatically from the board name, and so doesn't need to be set at all. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-08rp2/rp2_flash: Add start/len support to rp2.Flash() constructor.Phil Howard
This allows support for partitioned flash on rp2 boards. See issue #9208. Signed-off-by: Phil Howard <phil@gadgetoid.com>
2022-09-08drivers: Remove drivers that are now in micropython-lib.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-08ports: Use micropython-lib version of drivers in manifests.Jim Mussared