summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-06-06top: Add "mis" to list of ignore words for codespell.Yaroslav Halchenko
Observed with codespell 2.2.5.dev57+gdc7e98d9: $ codespell ./ports/rp2/machine_uart.c:163: mis ==> miss, mist ./ports/rp2/machine_uart.c:168: mis ==> miss, mist 2
2023-06-06samd/boards: Extend the code size limit for boards with external flash.robert-hh
Code size limits are charged to: - SAMD21: 184K -> 248K - SAMD51x19: 368K -> 496K - SAMD51x20: 368K -> 1008K Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-06samd: Adapt existing samd.Flash and integrate with (Q)SPI flash in boot.robert-hh
Checks are added to ensure, that only one of the flash drivers is selected. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-06samd/samd_qspiflash: Add QSPI flash driver and configure it accordingly.robert-hh
The QSPI driver provides the interface for using an on-board QSPI flash for the filesystem. It provides the same methods as the driver for the internal flash and uses the same name. Therefore, only one of the drivers for internal flash, SPI flash and QSPI flash must be enabled at a time. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-06samd/samd_spiflash: Add SPI flash driver and configure it accordingly.robert-hh
The SPI flash driver includes the block device for being used as a filesystem. It provides the same methods as the driver for the internal flash. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-06samd/boards: Rename flash pins consistently for QSPI and SPI.robert-hh
For SAMD21 devices, the board flash signals must be named in pins.csv as FLASH_MOSI, FLASH_MISO, FLASH_SCK, FLASH_CS for creating the SPI object. And rename the QSPI pins to QSPI_xxxx instead of FLASH_xxx. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-05py/builtinimport: Remove partially-loaded modules from sys.modules.David Grayson
Prior to this commit, importing a module that exists but has a syntax error or some other problem that happens at import time would result in a potentially-incomplete module object getting added to sys.modules. Subsequent imports would use that object, resulting in confusing error messages that hide the root cause of the problem. This commit fixes that issue by removing the failed module from sys.modules using the new NLR callback mechanism. Note that it is still important to add the module to sys.modules while the import is happening so that we can support circular imports just like CPython does. Fixes issue #967. Signed-off-by: David Grayson <davidegrayson@gmail.com>
2023-06-02py: Use nlr jump callbacks to optimise compile/execute functions.Damien George
The changed functions now use less stack, and don't have any issues with local variables needing to be declared volatile. Testing on a PYBv1.0, imports (of .py, .mpy and frozen code) now use 64 less bytes of C stack per import depth. Signed-off-by: Damien George <damien@micropython.org>
2023-06-02py/nlr: Implement jump callbacks.Damien George
NLR buffers are usually quite large (use lots of C stack) and expensive to push and pop. Some of the time they are only needed to perform clean up if an exception happens, and then they re-raise the exception. This commit allows optimizing that scenario by introducing a linked-list of NLR callbacks that are called automatically when an exception is raised. They are essentially a light-weight NLR handler that can implement a "finally" block, i.e. clean-up when an exception is raised, or (by passing `true` to nlr_pop_jump_callback) when execution leaves the scope. Signed-off-by: Damien George <damien@micropython.org>
2023-06-02py/nlr: Remove commented-out debugging code.Damien George
Also remove the unnecessary include of mpstate.h. Signed-off-by: Damien George <damien@micropython.org>
2023-06-02py/nlrsetjmp: Use MP_NLR_JUMP_HEAD macro to simplify code.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-06-02tools/mpremote: Fix use of stdout_write_bytes function.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-06-02LICENSE: Move wiznet5k entry from drivers to lib.Damien George
It was removed from drivers in 71dcb21e24064d1150094e66a904877402cdd157 Signed-off-by: Damien George <damien@micropython.org>
2023-06-02tools/mpremote: Detach mpremote from pyboard.py.Jim Mussared
This commit just takes the necessary parts of pyboard.py and merges them with pyboardextended.py to make a new transport_serial.py, and updates the rest of mpremote to use this instead. It is difficult to continue to add features to mpremote (which usually requires modification to pyboard.py) while also maintaining backwards compatibility for pyboard.py. The idea is that this provides a starting point for further refactoring of mpremote to allow different transports (webrepl, BLE, etc). This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-02docs/reference/mpremote.rst: Extend the mpremote guide.Jim Mussared
Changes in this commit: - Add a extra detail to each of the commands. - Add more about handling options and arguments. - Include shortcut commands that behave like real commands to the command list (e.g. bootloader, rtc). - Add extra information and reword to address common misconceptions, in particular how commands chain together. - Add additional examples showing some more interesting combinations. - Add descriptions to each of the examples. - Add pipx installation instructions. - Describe how user-configuration works. This work was sponsored by Google Season of Docs. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-02tools/mpremote: Handle `cp` without destination.Jim Mussared
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-02tools/mpremote: Add `rtc` commands to get and set the RTC.Jim Mussared
Replaces the existing functionality provided by the `setrtc` alias to use the current time, rather than a hard-coded date/time. Use `rtc` to query the current time. Use `rtc --set` to set it. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-02tools/mpremote: Allow terminator for shortcut commands.Jim Mussared
For example, the `reset` shortcut previously allowed an optional delay, but the argument handling cannot handle `reset next-command` as `next-command` will be interpreted as the delay argument. The fix in this commit allows `reset + next-command`. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-02tools/mpremote: Add `sleep` command.Jim Mussared
This allows the sequence to be paused (e.g. wait for device, etc). Also removes the t_ms arg in reset/bootloader, because these arguments don't really need to be changed, and keeping them would mean inconsistent units used for time delays. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-02stm32/help: Exclude legacy entries from help, and adjust constant names.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-06-02stm32/help: Don't include unavailable features in help().Jim Mussared
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-02ports: Standardise docs link in help text.Jim Mussared
Updates all `help()` output to use the phrase: `For online docs please visit http://docs.micropython.org/` Some ports previously used different wording, some pointed to the wrong link. Also make all ports use `help.c` for consistency. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-02docs/reference/packages: Add GitHub repo to package example dependency.Jonas Scharpf
Signed-off-by: Jonas Scharpf <jonas@brainelectronics.de>
2023-06-01docs/library/index: Update built-in extension docs.Jim Mussared
- Make the docs match the new behavior which only allows certain modules to be extended. - List the modules that currently have the u-prefix. - Add a note about the sys.path method for forcing a built-in import. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-01unix/main: Add NLR scope for checking module __path__.Jim Mussared
If the module has a user-defined getattr, this could raise. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-01tests/import/import_pkg9.py: Add test for subpackage attribute.Jim Mussared
When foo.bar is imported, bar is added as an attribute to foo. Previously this happened on every import, but should only happen on first import. This verifies the behavior for relative imports and overriding. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-01tests/import/builtin_ext.py: Add test for built-in module override.Jim Mussared
This verifies the behavior: - Exact matches of built-ins bypass filesystem. - u-prefix modules can be overridden from the filesystem. - Builtin import can be forced using either u-prefix or sys.path=[]. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-01examples/usercmodule: Add a sub-package example.Jim Mussared
This demonstrates how to add a sub-package in a user c module, as well as how to define the necessary qstrs and enable the feature in the build. This is used by the unix coverage build to test this feature. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-01py/objmodule: Don't use sys.modules to track a builtin __init__.Jim Mussared
This can lead to duplicate initialisations if a module can be imported via multiple names, so the module must track this itself anyway. This reduces code size (diff is -40 bytes), and avoids special treatment of builtin-modules-with-init with respect to sys.modules. No other builtin modules get put into sys.modules. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-01py/builtinimport: Allow builtin modules to be packages.Jim Mussared
To use this: - Create a built-in module, and add the module object as a member of the parent module's globals dict. - The submodule can set its `__name__` to either `QSTR_foo_dot_bar` or `QSTR_bar`. The former requires using qstrdefs(port).h to make the qstr. Because `bar` is a member of `foo`'s globals, it is possible to write `import foo` and then immediately use `foo.bar` without importing it explicitly. This means that if `bar` has an `__init__`, it will not be called in this situation, and for that reason, sub-modules should not have `__init__` methods. If this is required, then all initalisation for sub-modules should be done by the top-level module's (i.e. `foo`'s) `__init__` method. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-01py/builtinimport: Optimise sub-package loading.Jim Mussared
This makes it so that sub-packages are resolved relative to their parent's `__path__`, rather than re-resolving each parent's filesystem path. The previous behavior was that `import foo.bar` would first re-search `sys.path` for `foo`, then use the resulting path to find `bar`. For already-loaded and u-prefixed modules, because we no longer need to build the path from level to level, we no longer unnecessarily search the filesystem. This should improve startup time. Explicitly makes the resolving process clear: - Loaded modules are returned immediately without touching the filesystem. - Exact-match of builtins are also returned immediately. - Then the filesystem search happens. - If that fails, then the weak-link handling is applied. This maintains the existing behavior: if a user writes `import time` they will get time.py if it exits, otherwise the built-in utime. Whereas `import utime` will always return the built-in. This also fixes a regression from a7fa18c203a241f670f12ab507aa8b349fcd45a1 where we search the filesystem for built-ins. It is now only possible to override u-prefixed builtins. This will remove a lot of filesystem stats at startup, as micropython-specific modules (e.g. `pyb`) will no longer attempt to look at the filesystem. Added several improvements to the comments and some minor renaming and refactoring to make it clearer how the import mechanism works. Overall code size diff is +56 bytes on STM32. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-01py/builtinimport: Handle empty sys.path correctly.Jim Mussared
If sys.path is enabled, but empty, this will now no longer search the filesystem. Previously an empty sys.path was equivalent to having `sys.path=[""]`. This is a breaking change, but this behavior now matches CPython. This also provides an alternative mechanism to the u-prefix to force an import of a builtin module: ``` import sys _path = sys.path[:] sys.path.clear() import foo # Forces the built-in foo. sys.path.extend(_path) del _path ``` Code size diff is -32 bytes on PYBV11. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-01py/objint: Allow int() to parse anything with the buffer protocol.Damien George
This generalises and simplifies the code and follows CPython behaviour. See similar change for floats in a07fc5b6403b9a8bf7e7cb64f857272e5346d7e2. Signed-off-by: Damien George <damien@micropython.org>
2023-06-01py/obj: Accept user types in mp_obj_get_int_maybe.Damien George
This is possible now that MP_UNARY_OP_INT_MAYBE exists. As a consequence mp_obj_get_int now also supports user types, which was previously possible with MP_UNARY_OP_INT but no tests existed for it. Signed-off-by: Damien George <damien@micropython.org>
2023-06-01py: Change MP_UNARY_OP_INT to MP_UNARY_OP_INT_MAYBE.Damien George
To be consistent with MP_UNARY_OP_INT_FLOAT and MP_UNARY_OP_INT_COMPLEX, and allow int() to first check if a type supports __int__ before trying other things (as per CPython). Signed-off-by: Damien George <damien@micropython.org>
2023-06-01tests/basics: Remove __index__ and __inv__ from special methods tests.Damien George
MicroPython does not support these special methods, and they may get in the way of other tests (eg indexing with __int__). Signed-off-by: Damien George <damien@micropython.org>
2023-06-01renesas-ra/boards/make-pins.py: Fix PA/PB pins support.Takeo Takahashi
Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
2023-06-01docs/samd: Add the pin-out for the Adafruit Metro M4 Airlift board.robert-hh
Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-01docs/mimxrt: Add the pin-out for the Adafruit Metro M7 board.robert-hh
Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-01mimxrt/Makefile: Use a specific fsl_flexspi_nor_boot.c for mimxrt1062.robert-hh
This one sets the flash image length properly for the teensy loader, such that the file system is not erased. It was already set in commit 8e542251405d780f7aa0d6c9abaa30282dd360d5 but got lost when the MIMXRT1176 board was added. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-01mimxrt/machine_pwm: Fix freq change, PWM print, and error checks.robert-hh
Three bugs have been fixed in this commit: 1. When the duty was set with duty_u16(), changing the freq with pwm.freq() would not keep relative duty rate, but the absolute pulse duration. 2. Fix another inconsistency when displaying the PWM pin's properties of a QTMR channel. 3. Improve the error checks for the second channel being a PWM pin and pin pairs to be a FLEXPWM A/B pair. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-01ports: Enable os.sync() for esp32, esp8266, rp2, mimxrt, samd51.robert-hh
These have by default FAT support. The SAMD21 build does not support FAT. The nrf port also implements os.sync(), but has it's own copy of moduos.c. Code size increases seen: 40 to 56 bytes. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-01ports: Remove os.sync() implementation from stm32 and renesas-ra.robert-hh
Now that this code was moved to extmod/moduos.c. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-01extmod/moduos: Move os.sync() into extmod/moduos.c.robert-hh
Avoiding code duplication. To enable it, set MICROPY_PY_UOS_SYNC in the port's mpconfigport.h. It is operational only for FAT file system. For other filesystems it's a no-op. Signed-off-by: robert-hh <robert@hammelrath.com>
2023-05-31shared/libc/printf: Fix stdout destination for putchar and puts.Damien George
These functions should output to the same location as printf in this file. Signed-off-by: Damien George <damien@micropython.org>
2023-05-24tools/pydfu.py: Use getattr to retrieve getargspec function.Damien George
Since Python 3.11, inspect.getargspec() has been removed. Signed-off-by: Damien George <damien@micropython.org>
2023-05-24renesas-ra: Consolidate hal_entry.c code and remove hal_entry() func.Damien George
The hal_entry.c code is duplicated across all boards, so consolidate it to a common ra_hal.c file. And remove the hal_entry() function because it simply calls main(). Signed-off-by: Damien George <damien@micropython.org>
2023-05-24stm32/boards/NUCLEO_L4A6ZG: Add new board definition.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-05-24stm32/adc: Add support for STM32L4A6 MCUs.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-05-24stm32/boards/NUCLEO_G474RE: Make it easier to enable USB.Jim Mussared
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>