summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2025-02-23mimxrt/boards/ADAFRUIT_METRO_M7: Reduce flash freq to 100MHz.robert-hh
It was set to 133Mhz, but that is not stable. Reduce to 100MHz. The UF2 bootloader runs at 100MHz, so no need for a change of the bootloader. Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-23esp32: Remove unneeded "memory.h" header file.Alessandro Gatti
This commit removes "memory.h" from the ESP32 port tree, as it is no longer needed with recent ESP-IDF versions. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-02-20tools/ci.sh: Build the W5100S_EVB_PICO board with no threads.Angus Gratton
Serves as a build test for a config we don't otherwise support. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-18py/mkrules.cmake: Support passing CFLAGS_EXTRA in environment variable.Angus Gratton
This works similarly to the existing support in "bare metal" make ports, with the caveat that CMake will only set this value on a clean build and will reuse the previous value otherwise. This is slightly different to the CMake built-in support for CFLAGS, as this variable is used when evaluating source files for qstr generation, etc. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-18rp2: Fix build failure if threads are disabled.Angus Gratton
Regression in 3af006ef meant that pendsv.c no longer compiled if threads were disabled in the build config. Add an implementation based on the earlier one (simple counter) for the non-threads case. It seems like with the current usage patterns there's no need for the counter to be incremented/decremented atomically on a single core config. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-02-14tests/multi_net: Add test for DTLS server and client.Damien George
This adds a multi-test for DTLS server and client behaviour. It works on all ports that enable this feature (eg unix, esp32, rp2, stm32), but bare-metal ports that use lwIP are not reliable as the DTLS server because the lwIP bindings only support queuing one UDP packet at a time (that needs to be fixed). Also, to properly implement a DTLS server sockets need to support `socket.recvfrom(n, MSG_PEEK)`. That can be implemented in the future. Signed-off-by: Damien George <damien@micropython.org>
2025-02-14extmod/modtls_mbedtls: Wire in support for DTLS.Keenan Johnson
This commit enables support for DTLS, i.e. TLS over datagram transport protocols like UDP. While support for DTLS is absent in CPython, it is worth supporting it in MicroPython because it is the basis of the ubiquitous CoAP protocol, used in many IoT projects. To select DTLS, a new set of "protocols" are added to SSLContext: - ssl.PROTOCOL_DTLS_CLIENT - ssl.PROTOCOL_DTLS_SERVER If one of these is set, the library assumes that the underlying socket is a datagram-like socket (i.e. UDP or similar). Our own timer callbacks are implemented because the out of the box implementation relies on `gettimeofday()`. This new DTLS feature is enabled on all ports that use mbedTLS. This commit is an update to a previous PR #10062. Addresses issue #5270 which requested DTLS support. Signed-off-by: Keenan Johnson <keenan.johnson@gmail.com>
2025-02-14extmod/lwip-include: Increase number of lwIP timers when mDNS enabled.Thomas Watson
Despite the code comments claiming one is sufficient, the mDNS application is capable of using up to twelve timers. Three per IP protocol are started at once in `mdns_start_multicast_timeouts_ipvX`, then another two per protocol can be started in `mdns_handle_question`. Further timers can be started for two additional callbacks. Having certain timers, such as `MDNS_MULTICAST_TIMEOUT`, fail to start due to none being free will break mDNS forever as the app will never realize it's safe to transmit a packet. Therefore, this commit goes somewhat overkill and allocates the maximal amount of timers; it's uncertain if all can run simultaneously, or how many callback timers are needed. Each timer struct is 16 bytes on standard 32 bit builds. Plus, say, 8 bytes of allocater overhead, that's 288 more bytes of RAM used which shouldn't be too horrible. Users who don't need mDNS can manually disable it to recover the RAM if necessary. This fixes mDNS on W5500_EVB_PICO (among other boards). Before, mDNS would work for a bit after connection until the host's cache expired a minute or two later. Then the board would never respond to further queries. With this patch, all works well. Signed-off-by: Thomas Watson <twatson52@icloud.com>
2025-02-14renesas-ra/Makefile: Remove id_code section from binary file generation.iabdalkader
The linker scripts for most of these microcontrollers contain a non-contiguous flash section for the ID code that results in big binary files, which exceed the flash size. This commit removes the ID code section from the main firmware binary, and outputs it to a separate binary, which can be deployed manually if ID code is enabled. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-02-12esp32/machine_sdcard: Fix invalid result of SDCard.read/writeblocks.Angus Gratton
Functions would return NULL instead of `mp_const_false` if failed to init. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
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>