summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-06-14py/parsenum: Fix typo in #endif comment.David Lechner
This fixes a `#endif` comment to exactly match the `#if`. Signed-off-by: David Lechner <david@pybricks.com>
2023-06-14esp32/esp32_ulp: Fix ULP (FSM) support for S2 and S3.Wilko Nienhaus
This change enables the ULP (FSM) for all ESP32 variants rather than requiring it to be enabled for each board specifically. It also ensures the correct header file is included for each variant. Lastly, it updates the IDF version we're builing against to v4.4.2, as that version contains important fixes to make the ULP actually work on S2/S3 chips. See: https://github.com/espressif/esp-idf/commit/a0e3d48 Signed-off-by: Wilko Nienhaus <wilko.nienhaus@gmail.com>
2023-06-13rp2/CMake: Normalize MICROPY_PORT_DIR.Brian 'redbeard' Harrington
In 5fe2a3f1 the ESP32 port underwent a change to how `MICROPY_PORT_DIR` is defined. This commit normalizes the `rp2` port to use the same underlying variable mechanism (`CMAKE_CURRENT_LIST_DIR`). Signed-off-by: Brian 'redbeard' Harrington <redbeard@dead-city.org>
2023-06-13esp32/CMake: Change PROJECT_DIR to CMAKE_CURRENT_LIST_DIR.Brian 'redbeard' Harrington
This migrates the CMake variable `MICROPY_PORT_DIR` from the ESP-IDF defined project to the component. Previously used instances of the variable within the project definition have been migrated to `CMAKE_CURRENT_LIST_DIR`. Within the component (the `main` subdirectory in the ESP32 port) we define `MICROPY_PORT_DIR` using `CMAKE_CURRENT_LIST_DIR` and subsequently use the `MICROPY_PORT_DIR` value in all locations where `PROJECT` had previously been used. Context: In commit 9b90882146, initial support was added for building with the newly introduced CMake support provided by the ESP-IDF. Specifically, the commit message states: > This commit adds support for building the esp32 port with CMake, and in particular, it builds MicroPython as a component within the ESP-IDF. Using CMake and the ESP-IDF build infrastructure makes it much easier to maintain the port, especially with the various new ESP32 MCUs and their required toolchains. `PROJECT_DIR` is a variable populated by the ESP-IDF specifically and is not stable when used with "[Pure CMake components][1]" as documented in the ESP-IDF. It is intended to be used in the scope of the parent of the current file (the "project") as opposed to the current file ("the component"). Crossing into the parent scope like this works solely when the "project" is MicroPython, but not when used as a component by other ESP-IDF projects. Analyzing this file, the intention is to reference the "Project" which in the example is the parent directory. Within the [CMake variables][2] documentation, there is one specifically defined for referencing the directory for the CMake listfile currently being processed: [`CMAKE_CURRENT_LIST_DIR`][3]. After making the change from `PROJECT_DIR` to `CMAKE_CURRENT_LIST_DIR`, the reach into the parent scope defined by the ESP-IDF and the resulting CMake interface violation is removed. Similar to the component definition, the project `CMakeLists.txt` uses the variable `CMAKE_SOURCE_DIR` which CMake defines as "The path to the top level of the source tree." This commit changes the variable to `CMAKE_CURRENT_LIST_DIR` for the reasons cited above. [1]: https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-guides/build-system.html#writing-pure-cmake-components [2]: https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html [3]: https://cmake.org/cmake/help/latest/variable/CMAKE_CURRENT_LIST_DIR.html Signed-off-by: Brian 'redbeard' Harrington <redbeard@dead-city.org>
2023-06-10esp32/modespnow: Change name of buffer size config option to "rxbuf".Glenn Moloney
Rename "buffer" option to "rxbuf" which accords with docs and esp8266. Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
2023-06-09tools/mpremote: Fix exec_ -> exec in commands.py.Jim Mussared
This was missed in the pyboard refactor and is preventing `cp -r` from working. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08py/mkrules.mk: Automatically configure frozen options when manifest set.Damien George
Following how mkrules.cmake works. This makes it easy for a port to enable frozen code, by defining FROZEN_MANIFEST in its Makefile. Signed-off-by: Damien George <damien@micropython.org>
2023-06-08stm32/boards: Use default spibdev config where appropriate.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-06-08stm32/mpconfigboard_common: Provide default spidev config.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-06-08tools/ci.sh: Add mimxrt and samd ports to code size build.Damien George
The automatic code size build and GitHub comment is a really useful feature. This commit adds a few more builds to it (mimxrt and samd). Signed-off-by: Damien George <damien@micropython.org>
2023-06-08extmod/modtimeq: Remove timeq module.Jim Mussared
This is a MicroPython-specific module that existed to support the old version of uasyncio. It's undocumented and not enabled on all ports and takes up code size unnecessarily. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08docs/library/index: Update docs after umodule rename.Jim Mussared
- Update guide for extending built-in modules. - Remove any last trace of umodule in other docs. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08all: Replace all uses of umodule in Python code.Jim Mussared
Applies to drivers/examples/extmod/port-modules/tools. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08tests/run-natmodtests.py: Don't allow imports from the cwd.Jim Mussared
Make tests run in an isolated environment (i.e. `import io` would otherwise get the `tests/io` directory). This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08tests/run-perfbench.py: Don't allow imports from the cwd.Jim Mussared
Make tests run in an isolated environment (i.e. `import io` would otherwise get the `tests/io` directory). This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08tests/run-multitests.py: Don't allow imports from the cwd.Jim Mussared
Make tests run in an isolated environment (i.e. `import io` would otherwise get the `tests/io` directory). This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08tests: Replace umodule with module everywhere.Jim Mussared
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08py/modsys: Allow sys.path to be assigned to.Jim Mussared
Previously sys.path could be modified by append/pop or slice assignment. This allows `sys.path = [...]`, which can be simpler in many cases, but also improves CPython compatibility. It also allows sys.path to be set to a tuple which means that you can clear sys.path (e.g. temporarily) with no allocations. This also makes sys.path (and sys.argv for consistency) able to be disabled via mpconfig. The unix port (and upytesthelper) require them, so they explicitly verify that they're enabled. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08py/mpconfig: Enable module delegation if sys needs it.Jim Mussared
Otherwise you can get into the confusing state where e.g. sys.ps1 is enabled in config (via `MICROPY_PY_SYS_PS1_PS2`) but still doesn't actually get enabled. Also verify that the required delegation options are enabled in modsys.c. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08py/objmodule: Workaround for MSVC with no module delegation.Jim Mussared
When compiling mpy-cross, there is no `sys` module, and so there will be no entries in the `mp_builtin_module_delegation_table`. MSVC doesn't like this, so instead pretend as if the feature isn't enabled at all. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08py/objmodule: Add a table of built-in modules with delegation.Jim Mussared
This replaces the previous QSTR_null entry in the globals dict which could leak out to Python (e.g. via iteration of mod.__dict__) and could lead to crashes. It results in smaller code size at the expense of turning a lookup into a loop, but the list it is looping over likely only contains one or two elements. To allow a module to register its custom attr function it can use the new `MP_REGISTER_MODULE_DELEGATION` macro. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08examples/natmod: Rename umodule to module.Jim Mussared
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08all: Use MP_REGISTER_EXTENSIBLE_MODULE for overrideable built-ins.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08py/makemoduledefs.py: Add a way to register extensible built-in modules.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08all: Rename *umodule*.c to remove the "u" prefix.Jim Mussared
Updates any includes, and references from Makefiles/CMake. This essentially reverts what was done long ago in commit 136b5cbd7669e8318f8455fc2706da97a5b7994c This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08all: Rename *umodule*.h to remove the "u" prefix.Jim Mussared
This work was funded through GitHub Sponsors. Also updates #includes. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08all: Rename UMODULE to MODULE in preprocessor/Makefile vars.Jim Mussared
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08all: Rename mod_umodule*, ^umodule* to remove the "u" prefix.Jim Mussared
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08all: Rename mp_umodule*, mp_module_umodule* to remove the "u" prefix.Jim Mussared
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08py/builtinimport: Remove weak links.Jim Mussared
In order to keep "import umodule" working, the existing mechanism is replaced with a simple fallback to drop the "u". This makes importing of built-ins no longer touch the filesystem, which makes a typical built-in import take ~0.15ms rather than 3-5ms. (Weak links were added in c14a81662c1df812c0c6b4299f97966302f16477) This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08all: Rename MP_QSTR_umodule to MP_QSTR_module everywhere.Jim Mussared
This renames the builtin-modules, such that help('modules') and printing the module object will show "module" rather than "umodule". This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
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>