summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2025-02-12tools/pyboard.py: Make get_time use machine.RTC instead of pyb.RTC.rufusclark
The current code evaluates `pyb.RTC().datetime()` resulting in a remote side exception, as `pyb` is not defined on most ports (only stm32). The code should evaluate `machine.RTC().datetime()` and hence return the current time. Signed-off-by: rufusclark <50201718+rufusclark@users.noreply.github.com> Signed-off-by: Damien George <damien@micropython.org>
2025-02-11extmod/vfs_rom: Remove ability to create VfsRom from an address.Damien George
It's not necessary to support this, which allows an arbitrary memory address to be specified and potentially allows invalid memory accesses. Requiring an object with the buffer protocol is safer, and also means that the length of the region is always specified. Signed-off-by: Damien George <damien@micropython.org>
2025-02-11docs/library/marshal: Document the marshal module.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-02-11extmod/modmarshal: Add new marshal module.Damien George
This commit implements a small subset of the CPython `marshal` module. It implements `marshal.dumps()` and `marshal.loads()`, but only supports (un)marshalling code objects at this stage. The semantics match CPython, except that the actual marshalled bytes is not compatible with CPython's marshalled bytes. The module is enabled at the everything level (only on the unix coverage build at this stage). Signed-off-by: Damien George <damien@micropython.org>
2025-02-11py/persistentcode: Add mp_raw_code_save_fun_to_bytes.Damien George
Serialises a bytecode function/generator to a valid .mpy as bytes. Signed-off-by: Damien George <damien@micropython.org>
2025-02-11py/objfun: Implement function.__code__ and function constructor.Damien George
This allows retrieving the code object of a function using `function.__code__`, and then reconstructing a function from a code object using `FunctionType(code_object)`. This feature is controlled by `MICROPY_PY_FUNCTION_ATTRS_CODE` and is enabled at the full-features level. Signed-off-by: Damien George <damien@micropython.org>
2025-02-11py/objcode: Factor code object out into its own file.Damien George
The `mp_obj_code_t` and `mp_type_code` code object was defined internally in both `py/builtinevex.c` and `py/profile.c`, with completely different implementations (the former very minimal, the latter quite complete). This commit factors these implementations into a new, separate source file, and allows the code object to have four different modes, selected at compile-time: - MICROPY_PY_BUILTINS_CODE_NONE: code object not included in the build. - MICROPY_PY_BUILTINS_CODE_MINIMUM: very simple code object that just holds a reference to the function that it represents. This level is used when MICROPY_PY_BUILTINS_COMPILE is enabled. - MICROPY_PY_BUILTINS_CODE_BASIC: simple code object that holds a reference to the proto-function and its constants. - MICROPY_PY_BUILTINS_CODE_FULL: almost complete implementation of the code object. This level is used when MICROPY_PY_SYS_SETTRACE is enabled. Signed-off-by: Damien George <damien@micropython.org>
2025-02-11tests/run-tests.py: Give more information when CPython crashes.Damien George
To make it easier to diagnose why CPython crashed. Signed-off-by: Damien George <damien@micropython.org>
2025-02-11docs/library/espnow: Clarify usage of the "rate" configuration key.Alessandro Gatti
This commit adds a clarification for the ESPNow module's documentation regarding its "config" method. The original documentation for that method could be interpreted as having all its configuration keys being able to be queried, but the "rate" configuration key is actually write-only due to ESP-IDF's lack of a way to retrieve that bit of information from the radio's configuration. The documentation changes highlight the fact that said configuration key is actually write-only. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-02-11docs/reference: Add strings vs bytes to speed optimisation tips.Angus Gratton
Also add some additional context links, suggestions for alternative classes, etc. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-11docs: Note which ports have default or optional network.PPP support.Angus Gratton
Also add the default values of these macros to the respective `mpconfigport.h` files, to improve discoverability. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-11docs/esp32: Add documentation for SPI Ethernet devices on esp32 port.Angus Gratton
Also cross-link with the other WIZNET5K driver, to avoid confusion. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-11rp2/modules: Fix memory leak and logic bug in handling of _pio_funcs.Neil Ludban
The `rp2` package use a global dict `_pio_funcs` to populate a namespace for `@asm_pio` functions to be executed in. That dict is not cleaned up after use, keeping references to bound methods of a `PIOASMEmit`. By not setting/clearing all the functions, `asm_pio_encode` unintentionally allows the use of the old directives (harmless) as well as `jmp` (in general, produces the wrong output). Fix that by making sure `_pio_funcs` is returned to its original state after using it: - For `@asm_pio` update the target dict from `_pio_funcs` and then set additional functions as needed, leaving `_pio_funcs` unchanged. - For `asm_pio_encode`, borrow `_pio_funcs` to use as globals (avoiding a bunch of memory alloc/free) but delete the instruction entries after use. Signed-off-by: Neil Ludban <neil.ludban@gmail.com>
2025-02-10tools/mpremote: Support mip install from package.json on local fs.Glenn Moloney
Add support for `mpremote mip install package.json` where `package.json` is a json file on the local filesystem. Without this, package json files can only be loaded from http, https, github or gitlab URLs. This is useful for testing `package.json` files for pacages in development and for constructing one's own `package.json` files for Python packages which are not yet available for installation using mip. Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
2025-02-10tools/ci.sh: Build MIMXRT1060_EVK with MSC enabled as part of mimxrt CI.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-02-10mimxrt/boards: Reduce stack size for 1011 and 1015 MCUs.iabdalkader
Reduced to 16KBs to allow enabling MSC. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-02-10mimxrt: Add optional MSC support.iabdalkader
Add MSC support using internal flash storage or SD card. Note this is disabled by default, and can be enabled by boards if needed. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-02-10mimxrt/hal: Set the flexspi flash CLK frequency on boot.robert-hh
The flash clock frequency may have been set to a different value by a bootloader. Set the frequency according to the configured value. Use a table of pre-calculated dividers to get the closest value for the flash frequency, achieving for MIMXRT10xx: 30 -> 30.85 MHz 50 -> 49.65 MHz 60 -> 60 MHz 75 -> 75.13 MHz 80 -> 80 MHz 100 -> 99.31 Mhz 133 -> 132.92 MHz 166 -> 166.15 MHz for MIMXRT1176: 30 -> 31 MHz 50 -> 52.8 MJz 60 -> 58.7 MHz 75 -> 75.4 MHz 80 -> 75.4 MHz 100 -> 105.6 MHz 133 -> 132 MHz 166 -> 176 MHz Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-10mimxrt/boards: Add flash configuration constants to mpconfigboard.mk.robert-hh
And use these to initialize the LUT table properly for the various flash types. The different flash types differ by 3 parameters. Thus it is easier to just keep one copy of the qspiflash_config structure with the LUT table and update it during flash initialisation as needed. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-10mimxrt/boards: Update the deploy instructions for the UF2 bootloader.robert-hh
Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-10mimxrt/flash: Swap the order of disabling IRQ and disabling the cache.robert-hh
This change stopped problems with USB IRQ happening during flash writes. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-10mimxrt/hal: Update the LUT and re-enable PAGEPROGRAM_QUAD.robert-hh
Changes: - Change the LUT table ordering to be similar to the order of the UF2-Bootloader and fsl_romapi.h. - Rewrite the LUT entry for PAGEPROGRAM_QUAD and update the LUT. That enabled QUAD program again. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-10mimxrt: Add support for a UF2 bootloader.robert-hh
Allowing to use e.g. the Adafruit bootloaders with MicroPython. The .uf2 file is created in addition to the .bin and .hex files allowing to use the latter ones without the bootloader for debugging and testing. Changes: - Set the location of the ISR Vector and .text segment to 0x6000C000 and 0x6000C400. - Reserve an area at the start of ITCM for a copy of the interrupt vector table and copy the table on reset to this place. - Extend `machine.bootloader()` by setting the magic number to enable the bootloader on reset. - Create a .uf2 file which skips the segments below 0x6000C000. The bootloader has to be installed as a preparation step using the board specific methods, but then the firmware's .uf2 file version can be installed using the bootloader. The bootloader can be invoked with: - double reset - calling machine.bootloader() - Using the touch1200 method Double reset is hard to achieve on MIMXRT boards, since there is no clean reset pin. Some MIMXRT boards provide it by switching the power. Some boards are excluded from the .uf2 build: - MIMXRT1050_EVK: The uf2 bootloader is built for the QSPI version of the board. MicroPython supports the Hyperflash version. - MIMXRT1176_EVK: No support for this board yet, but it should be possible. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-08rp2/boards: Add SparkFun IoT Node LoRaWAN board.Dryw Wade
Signed-off-by: Dryw Wade <dryw.wade@sparkfun.com>
2025-02-08rp2/rp2_pio: Add side_pindir support for PIO.Markus Gyger
Side-setting can also be used to change pin directions instead of pin values. This adds a parameter `side_pindir` to decorator `asm_pio()` to configure it. Also replaces a few close-by 0s with corresponding PIO.* constants. Addresses issue #10027. Signed-off-by: Markus Gyger <markus@gyger.org>
2025-02-08esp32/boards: Enable I2S on ESP32C3 boards.StrayCat
Signed-off-by: StrayCat <marcin.eu@gmail.com>
2025-02-07mimxrt/mpconfigport: Remove hard-coded CMSIS header.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-02-07mimxrt/machine_rtc: Fix build with new SDKs.iabdalkader
In more recent SDKs, this feature is actually disabled for the MIMXRT1062. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-02-07mimxrt/irq: Add CSI IRQ.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-02-07docs/samd/pinout: Add pinout for the Generic SAMD board types.robert-hh
The table shows the devices available at the pin and the respective package letter. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07docs/samd/pinout: Add pinout for Adafruit NeoKey Trinkey and QT Py.robert-hh
Only pins accessible at the board are shown. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07samd/boards: Add support for the Adafruit NeoKey Trinkey board.robert-hh
Tested with that board. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07samd/boards: Add support for the Adafruit QT Py board.robert-hh
Supporting a variant with an optional SPIFLASH device as well. Tested both variants with a QT Py board. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07samd/Makefile: Add support for board variants.robert-hh
Tested with a Adafruit SAMD QT board, which may optionally be equipped with SPIFLASH memory. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07samd/boards: Add generic SAMD51x20 board definitions.robert-hh
The definition uses the internal oscillator for clock and only internal flash for the file system. It works at SAMD51J20 device as well, only that fewer pins are accessible. Tested with a SAMD51J20 board. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07samd/boards: Add generic SAMD51x19 board definitions.robert-hh
The definition uses the internal oscillator for clock and only internal flash for the file system. It works at SAMD51G19 and SAMD51J19 devices as well, only that fewer pins are accessible. Tested with a SAMD51G19 and SAMD51J9 board. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07samd/boards: Add generic SAMD21x18 board definitions.robert-hh
The definition uses the internal oscillator for clock and only internal flash for the file system. It works at SAMD21G18 and SAMD21E18 devices as well, only that fewer pins are accessible. Tested with a SAMD21E18, SAM21G18 and SAMD21J18 board. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07py/emitnative: Load and store words just once for Viper code.Alessandro Gatti
This commit fixes two Xtensa sequences in order to terminate early when loading and storing word values via an immediate index. This was meant to be part of 55ca3fd67512555707304c6b68b836eb89f09d1c but whilst it was part of the code being tested, it didn't end up in the commit. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-02-07py/emitnative: Mark condition code tables as const.Alessandro Gatti
This commit marks as const the condition code tables used when figuring out which opcode sequence must be emitted depending on the requested comparison type. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-02-07tools/ci.sh: Add natmod tests for QEMU/Arm.Alessandro Gatti
This commit adds the natmod tests for the MPS2_AN385 board running inside QEMU to the CI pipeline. Now natmod tests capabilities are equal between the Arm and RV32 platforms for the QEMU port. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-02-07qemu/Makefile: Fix shell interpolation for automated natmod tests.Alessandro Gatti
This commit fixes the command used to run natmod tests, as it relied on a string interpolation feature of the POSIX shell that was not working as expected inside a makefile. The interpolation was not performed from inside the makefile and the raw command string was sent to the operating system for execution. Now the command is run by using a different type of string substitution, which explicitly performs the interpolation using a POSIX shell for-loop. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-02-07tests/run-natmodtests.py: Autodetect the test target architecture.Alessandro Gatti
This commit lets the natmod tests runner to automatically detect the architecture of the test target. This allows to avoid to explicitly pass the architecture name to the runner in test scripts. However, the ability to manually specify a target was not removed but it was made optional. This way the user is able to override the architecture name if needed (like if one wants to test an armv6 MPY on an armv7 board). Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-02-07py/mkrules.mk: Reset USER_C_MODULES when building mpy-cross dependency.Andrew Leech
When a port automatically compiles `mpy-cross`, if `USER_C_MODULES` is provided by the user on the command line then it is also applied to the `mpy-cross` build. That can lead to build errors if the path is relative and not found when building `mpy-cross`. Fix that by explicitly resetting `USER_C_MODULES` when invoking the `mpy-cross` build. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2025-02-07esp32/README: Fix board in octal-SPIRAM example make command.eggfly
Signed-off-by: eggfly <lihaohua90@gmail.com>
2025-02-07tests/multi_wlan: Remove esp8266 port workaround.Angus Gratton
Not needed due to parent commit. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-07esp8266/network_wlan: Make WLAN.config(channel=x) use wifi_set_channel.Glenn Moloney
Also permits channel option to be used for STA_IF interface. This provides compatibility with esp32 code, especially for espnow users. Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
2025-02-07esp8266/network_wlan: Make WLAN.config('channel') use wifi_get_channel.Glenn Moloney
Prior to this fix, `WLAN.config('channel')` would return an incorrect channel for AP_IF if STA has connected to an external AP running on a different channel. The esp8266 now has the same behaviour as for esp32 per commit 98d1c50159fe9427d72ec358ba0219eaebb1d991. Fixes issue #11463. Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
2025-02-07rp2/rp2_flash: Workaround multicore lockout not being reset.Mike Bell
With regression test. See upstream bug https://github.com/raspberrypi/pico-sdk/issues/2201 Tested-by: Angus Gratton <angus@redyak.com.au> Signed-off-by: Mike Bell <mdb036@gmail.com>
2025-02-07tests/ports/rp2: Add test for SLEEP_ENx registers over lightsleep.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2025-02-07rp2/modmachine: Make lightsleep preserve SLEEP_EN0 and SLEEP_EN1.Carl Pottle
The problem was introduced in d1423ef7a23793de3777e84d985f9902241e788e, calling `machine.lightsleep()` overwrites RP2xxx registers `SLEEP_EN0` and `SLEEP_EN1` with their power on default values. Prior to that commit the register values were saved on entry to lightsleep and restored before returning. These changes restores the earlier behavior. Fixes issue #16502. Signed-off-by: Carl Pottle <cpottle9@outlook.com>