Commit graph

4931 commits

Author SHA1 Message Date
Andrew Leech
17898f8607 stm32/machine_adc: Enable ADC re-read errata handling for STM32WB55.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2025-06-04 02:11:23 +10:00
Matt Trentini
3e33d0567f ports: Update board.json files for vendor/product consistency.
The vendor and product fields in the `board.json` files were somewhat
inconsistent.  Remove any duplication of the vendor name in the product
field so that `f"{vendor} {product}"` reads well.

In addition to that, update most of the URL's for `board.json` files that
are modified here, and match case and spacing used by the manufacturers for
the vendor and product names.

Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
2025-06-04 01:47:59 +10:00
Angus Gratton
0b224048ef unix/modsocket: Expose MSG_PEEK flag for recv & recvfrom.
This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-06-03 12:52:06 +10:00
Angus Gratton
4781cde4f7 esp32/modsocket: Add optional flags argument for recv and recvfrom.
Implements MSG_PEEK and MSG_DONTWAIT (both passed through to LWIP
sockets API).

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-06-03 12:52:06 +10:00
robert-hh
bbdc832ca9 samd/boards: Add two SparkFun SAMD21 boards.
Add support for the boards:
- SparkFun SAMD21 Dev Breakout
- SparkFun RedBoard Turbo

Both boards are SAMD21 based and actively sold by SparkFun.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-28 12:04:42 +10:00
Dryw Wade
6bfb83e30a rp2: Make FLASH LENGTH match PICO_FLASH_SIZE_BYTES in .ld files.
With a fallback to default sizes if `PICO_FLASH_SIZE_BYTES` is not defined.

Signed-off-by: Dryw Wade <dryw.wade@sparkfun.com>
2025-05-28 11:02:45 +10:00
Herwin Grobben
2dada065ac stm32: Allow QSPI to work on STM32G4.
Adding a QSPI memory chip on a STM32G4 does not work due to some small
issues, which are fixed in this commit:

- Rename QUADSPI1_xxx alt-func names to QUADSPI_xxx, to match the static
  names used in `qspi.c`.

- Enable `mpu.h` macros on G4.

- Don't include I- and D-cache invalidation on G4.

Signed-off-by: Damien George <damien@micropython.org>
2025-05-26 12:40:27 +10:00
Ayush Singh
670b7c9350 zephyr/boards: Add support for BeaglePlay CC1352p7.
- Enable support for FLASH and IEEE802154 subg radio
- Requires Zephyr v3.8.0

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-05-26 12:13:04 +10:00
Angus Gratton
b36111b12c nrf: Revert "nrf/Makefile: Enable LTO by default only on newer gcc.".
This reverts commit 62e0fa04a7.

Reverting as the only linker wrap needed for nrf port was removed
in the parent commit.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-05-26 11:15:33 +10:00
Angus Gratton
22f1d76633 shared/tinyusb: Use device event hook to schedule USB task.
Previously MicroPython ports would linker-wrap dcd_event_handler
in order to schedule the USB task callback to run when needed.

TinyUSB 0.16 added proper support for an event hook to do the
same thing without the hacky linker wrapping.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-05-26 11:15:33 +10:00
Malcolm McKellips
dc1af386a8 esp32/boards/SPARKFUN_IOT_REDBOARD_ESP32: Add SparkFun board.
Add board definition files for SparkFun IoT RedBoard ESP32.

Signed-off-by: Malcolm McKellips <malcolm.mckellips@sparkfun.com>
2025-05-22 10:37:38 +10:00
Malcolm McKellips
7f6fedef2a rp2/boards/SPARKFUN_XRP_CONTROLLER_BETA: Fix default I2C to use I2C1.
Signed-off-by: Damien George <damien@micropython.org>
2025-05-22 00:24:02 +10:00
Phil Howard
45cb9b4444 rp2/machine_pin: Fix simulated open drain with more than 32 GPIOs.
Changes are:
- Refactor the open-drain macros, add GPIO_ENABLE/DISABLE_OPEN_DRAIN, and
  move them to `mphalport.h`.
- Only use `uint64_t` for the open-drain mask if there are more than 32
  GPIOs (saves code size).
- Ensure we're shifting a `uint64_t` by using 1ULL constants.

Signed-off-by: Phil Howard <github@gadgetoid.com>
2025-05-22 00:08:27 +10:00
Phil Howard
28c8fff6d8 rp2/machine_pin: Replace macros with Pico SDK functions.
Replace custom macros with Pico SDK functions, enabling support for RP2350B
variant chips with > 32 GPIOs.

Fixes issue #17241.

Signed-off-by: Phil Howard <github@gadgetoid.com>
2025-05-22 00:03:20 +10:00
Angus Gratton
4545eb844d rp2: Disable the LWIP tick timer when not needed.
Prevents lightsleep being woken up every 64ms to service LWIP timers, when:

1. No netif is up, and
2. No TCP sockets are active

The TCP socket check may not be strictly necessary, but without ticking the
tcp timer they won't ever time out by themselves.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-05-21 13:47:45 +10:00
Damien George
a1ee42cd3e nrf: Use common implementation of machine disable/enable IRQ.
This is a breaking change due to the signature change of `enable_irq()`.
Previously the signature was:

    machine.enable_irq()

Now the signature matches other ports, and the docs, and is:

    machine.enable_irq(state)

Where `state` is the return value from `machine.disable_irq()`.

Signed-off-by: Damien George <damien@micropython.org>
2025-05-21 13:30:40 +10:00
Damien George
cc7eb1a535 nrf/boards: Use 64 byte raw-paste buffer on PCA10028 and PCA10040.
To workaround issues with JLink CDC.

Signed-off-by: Damien George <damien@micropython.org>
2025-05-21 13:14:42 +10:00
Damien George
e676b58d9f nrf: Fix UART write on parts that can't write more than 255 bytes.
Some MCUs cannot write more than 255 bytes to the UART at once.  Eg writing
256 bytes gets truncated to 0, writing 257 gets truncated to 1, etc.

Signed-off-by: Damien George <damien@micropython.org>
2025-05-21 13:14:26 +10:00
Damien George
32c65ad455 nrf: Only process interrupt chars on UARTs used for REPL.
This commit adds an `attached_to_repl` property to each UART, and makes
sure that property is correctly set/unset when the UART is attached to or
detached from the REPL.

That property is then used to make sure incoming characters on the UART are
only checked for the interrupt character if the UART is attached to the
REPL.  Otherwise a board without REPL on UART can have its code interrupted
if ctrl-C is received on the UART.

Also, put incoming UART characters on to `stdin_ringbuf` instead of the
UARTs ring buffer (the former is much larger than the latter).

Signed-off-by: Damien George <damien@micropython.org>
2025-05-21 13:10:01 +10:00
Damien George
d5db8f0461 nrf: Use correct IRAM address for native code execution on nRF52.
On nRF52, the physical SRAM is mapped to 0x20000000 for data access and
0x00800000 for instruction access.  So, while native code is allocated and
written using addresses in the 0x20000000 range, it must execute from the
0x00800000 range.

This commit makes this work correctly on nRF52 MCUs by adjusting the
address.

Signed-off-by: Damien George <damien@micropython.org>
2025-05-21 12:53:25 +10:00
Elvis Pfutzenreuter
ecbbc512b2 esp32/network_lan: Add PHY_GENERIC device type.
Support the new PHY_GENERIC device type, added in ESP-IDF v5.4.0 [1].

This PHY driver was added to ESP-IDF to support "generic"/oddball PHY
LAN chips like the JL1101, which offer no features beyond the bare
802.3 PHY standard and don't actually need a chip-specific driver (see
discussion at [2]).

[1] 0738314308
[2] https://github.com/espressif/esp-eth-drivers/pull/28

Signed-off-by: Elvis Pfutzenreuter <epxx@epxx.co>
2025-05-16 15:34:20 -03:00
Rick Sorensen
90aeac800a esp32/machine_i2c: Fix default I2C pins for C3, S3.
The default I2C init does not require setting SCL or SDA but the default
I2C0 pins for C3, S3 conflict with the espressif GPIO usage.

For the C3, pins 18/19 are for USB/JTAG.  If used for I2C() they will cause
the REPL to hang on initialization of the I2C.

For the S3 pin 19 is allocated for USB/JTAG also but the defaults do not
seem to affect the REPL.

See related #16956.

Fixes issue #17103.

Signed-off-by: Rick Sorensen <rick.sorensen@gmail.com>
Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-05-16 17:39:10 +10:00
Daniël van de Giessen
06d8c084b9 esp32/modesp32: Implement esp32.idf_task_info().
This adds a new function, `esp32.idf_task_info()`, that can be used to
retrieve task statistics which is useful for diagnosing issues where some
tasks are using up a lot of CPU time.

It's best used in conjunction with the `utop` module from micropython-lib.

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2025-05-16 16:49:59 +10:00
Angus Gratton
10f6c0699e esp32/network_lan: Add support for LAN8670 PHY.
This adds support for LAN8670 to the esp32 port.  Enabled conditionally for
the esp32 target, if ESP-IDF version is new enough (v5.3 or newer).

Fixes issue #15731.

Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-05-16 15:16:06 +10:00
IhorNehrutsa
f48b981567 esp32: Update to use ESP-IDF v5.4.1.
This version of the IDF uses about 1KB more IRAM and 1KB more DRAM on most
boards, but 6.5KB more DRAM usage on the S3.  It seems that's due to a lot
of small increases in many components.

Signed-off-by: Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com>
2025-05-16 14:02:39 +10:00
Damien George
e1ab04e820 esp32/mpthreadport: Fix double delete of tasks on soft reset.
Python threads (created via the `_thread` module) are backed by a FreeRTOS
task.  Managing the deletion of the task can be tricky, and there are
currently some bugs with this in the esp32 port.

The actual crash seen was in FreeRTOS' `uxListRemove()`, and that's because
of two calls to `vTaskDelete()` for the same task: one in
`freertos_entry()` when the task ran to completion, and the other in
`mp_thread_deinit()`.  The latter tried to delete the task a second time
because it was still in the linked list, because `vTaskPreDeletionHook()`
had not yet been called.  And the reason `vTaskPreDeletionHook()` was yet
to be called is because the FreeRTOS idle task was starved.

This commit fixes that.

There are three things done by this commit:
- remove the `vTaskPreDeletionHook`, it's not needed anymore because task
  stack memory is allocated by the IDF, not on the MicroPython heap
- when a task finishes it now removes itself from the linked list, just
  before it deletes itself
- on soft reset, all tasks are deleted and removed from the linked list in
  one swoop (while the mutex is held)

Signed-off-by: Damien George <damien@micropython.org>
2025-05-16 13:31:34 +10:00
IhorNehrutsa
a724545193 esp32/mpconfigport: Document how to get more debug info.
Signed-off-by: Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com>
2025-05-16 12:37:14 +10:00
IhorNehrutsa
150a5aa3a1 esp32/machine_pwm: Improve PWM and make its API match other ports.
This reduce inconsistencies between esp32 PWM and other ports:
1. duty_u16() high value is 2**16-1 == 65535
2. Invert PWM wave with invert=1 parameter
3. Enable PWM in light sleep mode
4. Allow PWM output and read pulse input simultaneously on the same Pin()
5. Code refactoring

Co-Authored-By: Angus Gratton <angus@redyak.com.au>
Co-Authored-By: robert-hh <robert@hammelrath.com>
Co-Authored-By: Andrew Leech <andrew.leech@planetinnovation.com.au>
Co-Authored-By: Yoann Darche <yoannd@hotmail.com>

Signed-off-by: Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com>
2025-05-16 12:35:58 +10:00
Daniël van de Giessen
3b1e22c669 esp32/network_ppp: Restructure to match extmod/network_ppp_lwip.
The ESP32 PPP implementation predates the generic
implementation in extmod. The new extmod
implementation has a few advantages such as a
better deinitialisation procedure (the ESP32
implemementation would not clean up properly and
cause crashes if recreated) and using the UART IRQ
functionality instead of running a task to read
data from the UART.

This change restructures the ESP implementation to
be much closer to the new extmod version, while
also bringing a few tiny improvements from the
ESP32 version to the extmod version. The diff
between extmod/network_ppp_lwip.c and
ports/esp32/network_ppp.c is now a small set of
easy to review ESP32 port-specific changes.

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2025-05-15 11:56:14 +10:00
Alessandro Gatti
2406582479 esp32/network_common: Raise a memory error on ESP_ERR_NO_MEM.
This commit changes the error handler for WiFi operations to recognise
out of memory conditions reported by ESP-IDF functions, and report them
as more descriptive exceptions rather than a generic "error 0x101".

The error handler only provided a human-readable error description for
WiFi-specific error codes (codes in the ESP_ERR_WIFI_BASE range), but
WiFi functions are known to return other codes.  Now ESP_ERR_NO_MEM is
covered with a specific error message, making it easier to debug issues
related to running out of ESP-IDF heap.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-05-15 11:29:41 +10:00
Daniël van de Giessen
155fa94fbf
esp32/machine_uart: Correctly manage UART queue and event task.
If the driver was reinitialised while there was
already an event task running the queue that task
is trying to receive from would be deleted,
causing it to try to take a lock that no longer
existed and deadlocking the CPU.

This change ensures the task is always shut down
before recreating the queue and recreates the task
afterwards.

It also allows setting an IRQ handler before the
UART is initialized (like other ports allow),
removes the task when the UART is deinitialized
(which was previously missing), adds a check that
no event task can be started when no queue exists,
and adds a check to prevent reinitialising the
UART driver unnecessarily.

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2025-05-14 15:55:31 +02:00
Alessandro Gatti
883dc41d46 esp32/main: Make the entry point function name configurable.
This commit introduces a new port configuration entry allowing the entry
point function name to be changed, from "app_main" to a custom name.

This is needed when MicroPython is embedded as an ESP-IDF component,
since the "app_main" symbol is already provided elsewhere, making
compilation not possible.  Marking MicroPython's symbol as weak would
make it compile and make it possible to create and start the MicroPython
task anyway with the right FreeRTOS task creation incantation, but it is
probably easier to just rename the initialisation function into
something else that can be accessed from outside.

When MicroPython is embedded as an ESP-IDF component, the
MICROPY_ESP_IDF_ENTRY definition can be set to indicate the new entry
point function name.  The new function name prototype should still be
defined in external code to let linking succeed.

Also, the NLR failure callback is marked as weak to give the chance of
handling such error in a more controlled fashion rather than trigger an
unconditional board restart.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-05-14 06:26:31 +02:00
Alessandro Gatti
116d0d4945 esp32/esp32_common.cmake: Allow adding defines and compiler flags.
This commit introduces two extra CMake variables, MICROPY_DEF_COMPONENT
and MICROPY_COMPILE_COMPONENT, that make it easier to integrate
MicroPython as a custom ESP-IDF component.

Whilst there is no official MicroPython component available for ESP-IDF,
integration can be achieved with some minor CMake scripting outside the
MicroPython tree - except for customisation of compilation defines and
build flags, which is what this commit tries to provide.

Compilation defines customisation is especially important for
MicroPython configuration, as it is not possible to inject a value for
MP_CONFIGFILE otherwise.  This means that unless MicroPython itself is
forked first to edit ports/esp32/mpconfigport.h, it is not possible to
perform any meaningful configuration of the interpreter/runtime when
included as a component.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-05-14 06:25:59 +02:00
robert-hh
1d4bf8ac40 esp32/machine_timer: Fix timer.value() for an uninitialized timer.
Raises a value error in that case, which happens after a timer was created
but not initialized, or after calling `timer.deinit()`.

Fixes issue #17033.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-14 11:58:36 +10:00
Alessandro Gatti
d7371124d2 esp32/esp32_common.cmake: Use the tinyusb source files from ESP-IDF.
This commit removes the explicit dependency on the vendored tinyusb
version for the ESP32S2 and ESP32S3 boards.

Tinyusb is still available to MicroPython through a dependency on the
`espressif/esp_tinyusb` ESP-IDF component, which in turn depends on
the `espressif/tinyusb` component itself.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-05-14 11:02:31 +10:00
Alessandro Gatti
f47e214cdc all: Rename the "NORETURN" macro to "MP_NORETURN".
This commit renames the NORETURN macro, indicating to the compiler
that a function does not return, into MP_NORETURN to maintain the same
naming convention of other similar macros.

To maintain compaitiblity with existing code NORETURN is aliased to
MP_NORETURN, but it is also deprecated for MicroPython v2.

This changeset was created using a similar process to
decf8e6a8b ("all: Remove the "STATIC"
macro and just use "static" instead."), with no documentation or python
scripts to change to reflect the new macro name.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-05-13 10:36:47 +10:00
Angus Gratton
69993daa5c rp2/modmachine: Add mutual exclusion for machine.lightsleep().
There's no specified behaviour for what should happen if both CPUs call
`lightsleep()` together, but the latest changes could cause a permanent
hang due to a race in the timer cleanup code.  Add a flag to prevent hangs
if two threads accidentally lightsleep, at least.

This allows the new lightsleep test to pass on RPI_PICO and RPI_PICO2, and
even have much tighter time deltas.  However, the test still fails on
wireless boards where the lwIP tick wakes them up too frequently.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-05-12 16:30:46 +10:00
Peter Harper
2a4f1c9f0f rp2/modmachine: Add debug code for mp_machine_lightsleep.
Add some debug code that can be enabled to determine why lightsleep is
returning early.

Signed-off-by: Peter Harper <peter.harper@raspberrypi.com>
2025-05-12 16:29:37 +10:00
Peter Harper
ee2c78cd97 rp2: Use pico-sdk alarm pool instead of soft timer for sleep.
Stop using soft timer for `mp_wfe_or_timeout`.  Now uses the alarm pool
again as issues with this code have been fixed.  This resolves the "sev"
issue that stops the RP2350 going idle.

Also, change the lightsleep code to use the hardware timer library and
alarm 1, as alarm 2 is used by and soft timers and alarm 3 is used by the
alarm pool.

Signed-off-by: Peter Harper <peter.harper@raspberrypi.com>
2025-05-12 16:24:51 +10:00
Angus Gratton
3fa77bdc7d rp2: Add temporary workaround for GCC 15.1 build failure.
This is a workaround for this upstream issue:
https://github.com/raspberrypi/pico-sdk/issues/2448

Can be removed after the next pico-sdk update.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-05-09 18:31:25 +10:00
Damien George
9c8c219f8a rp2/rp2_dma: Fix default value used in pack_ctrl on RP2350.
The bit position of CHAIN_TO is not the same as on RP2040.

Signed-off-by: Damien George <damien@micropython.org>
2025-05-09 12:05:04 +10:00
Damien George
928466d74c rp2/Makefile: Add deploy target that uses picotool load.
This is a convenient way to deploy firmware to an RP2xxx-based board.

Signed-off-by: Damien George <damien@micropython.org>
2025-05-09 12:01:50 +10:00
Angus Gratton
d00eab4a30 rp2,extmod/cyw43: Move the LWIP responder fix into common CYW43 config.
This means the fix from dd1465e7 will also apply to stm32 and mimxrt ports
that use CYW43.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-05-08 15:32:05 +10:00
Angus Gratton
b2cda6c604 extmod,alif,mimxrt,rp2,stm32: Create common cyw43 driver config header.
This is only a surface level refactor, some deeper refactoring would be
possible with (for example) the SDIO interface in mimxrt and stm32, or the
BTHCI interface which is is similar on supported ports. But sticking to
cases where the macros are the same across all ports.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-05-08 15:32:05 +10:00
Anton Blanchard
45e4deb96d zephyr/mpconfigport: Fix mp_int_t and mp_uint_t to work on 64-bit archs.
These both need to fit a pointer, so make them `intptr_t` and `uintptr_t`,
similar to other ports.

Signed-off-by: Anton Blanchard <antonb@tenstorrent.com>
2025-05-07 21:36:54 +10:00
danicampora
fe28cd78fe zephyr/modbluetooth_zephyr: Allow BLE to create services at runtime.
This commit adds the required functionality for a peripheral to create
services at runtime, using `BLE.register_services()`.

The feature is enabled on the nrf52840dk_nrf52840 board.

Note that the `CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION=n` option must be used
so that BLE notifications/indications can be sent even if not subscribed.

Signed-off-by: danicampora <danicampora@gmail.com>
2025-05-07 21:25:53 +10:00
robert-hh
80d03b7780 samd/samd_qspiflash: Remove the attempt to handle a unknown device.
Since all QSPI flash device used by this port are defined, this code was
only used unintentionally.  Besides that it was incomplete, so better drop
it.

Note: The flash type for Mini-SAM had to be changed too.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-07 16:20:19 +10:00
robert-hh
2e6df08e05 samd/samd_spiflash: Improve the flash type detection.
Changes in this commit:
- Check for the proper SFDP header.
- Use the flash size information from SFDP, if present.
- Add two more special flash chips <= 1 MByte without SFDP.  JEDEC-ID table
  for special flash types instead of a series of conditional statements.
- Add a compile flag `MICROPY_HW_SPIFLASH_SIZE` to set the size in
  `mpconfigboard.h`, which replaces getting the size from the JEDEC ID or
  the SFDP record.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-07 16:19:48 +10:00
robert-hh
c22c2c8066 samd/boards/SAMD_GENERIC_D51xxx: Fix VFS settings for internal flash.
Fixes in this commit:
- The wrong loader script was assigned for SAMD_GENERIC_D51X20, causing the
  VFS block count to be wrong.
- Change the VFS block size from 1536 to 2048.  With the setting of 1536,
  writing more that 1536 bytes at once failed.  This applies to
  SAMD_GENERIC_D51X19 and SAMD_GENERIC_D51X20.  No other SAMD51 board uses
  the internal flash for the file system.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-07 16:18:07 +10:00
robert-hh
ff9e01782b samd/modtime: Change time.time_ns() to follow the RTC time.
That is done by adding the offset to epoch, following the scheme from the
RP2 port.  RTC and `ticks_us()` are not precisely in sync, and so the
difference between `time.time_ns()/1e9` and `time.time()` will increase by
more than 9 seconds/24h.  So applications should avoid using `time.time()`
and `time.time_ns()` in the same context.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-07 16:17:07 +10:00
robert-hh
2fda4bbe05 samd/machine_i2c: Add the timeout keyword argument to the constructor.
To make it compliant with the documentation.  The default value is 50000us.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-07 16:16:45 +10:00
robert-hh
8e328da9bf samd/boards/SAMD_GENERIC_Dxxx: Add Microchip URL to board.json.
To the Microchip Web site.  Thanks to Matt Trentini for suggesting this
site.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-07 16:16:11 +10:00
Malcolm McKellips
288dce26bd docs,ports: Fix SparkFun capitalization.
This is a follow-up to 1e92bdd206 correcting
more of the instances where "Sparkfun" should be "SparkFun".

Signed-off-by: Damien George <damien@micropython.org>
2025-05-07 15:16:55 +10:00
Ayush Singh
bee1fd5e78 zephyr/boards: Enable ADC on beagleconnect_freedom.
Enable Analog inputs.  Requires Zephyr >= v3.8.0.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-05-02 12:39:16 +10:00
Vdragon
8728db3e41 zephyr: Introduce auto-listing of FlashArea Partitions.
This enables listing all flash area partitions automagically instead of
just sotrage_partitions.  It uses the label, and the ID when not present.

Signed-off-by: Vdragon <mail@massdriver.space>
2025-05-02 12:37:20 +10:00
Vdragon
6601d4d7eb zephyr: Create ability to use device_next with CDC ACM as REPL.
This enables using the newer USB stack and its CDC ACM for the REPL.

To switch to it, board file must contain `CONFIG_USB_DEVICE_STACK_NEXT=y`
and `CONFIG_USBD_CDC_ACM_CLASS=y`.  In the case of a board that is a
platform that supports the older device stack, `CONFIG_USB_DEVICE_STACK=n`
may be necessary.

Signed-off-by: Vdragon <mail@massdriver.space>
2025-05-02 12:27:14 +10:00
Patrick Joy
62479f2cb6 zephyr/boards: Add nrf9151dk board configuration.
Add support for the nrf9151dk.  This DK has a GD25WB256 32mb external QSPI
flash chip.

Signed-off-by: Patrick Joy <patrick@thinktransit.com.au>
2025-04-30 12:44:12 +10:00
Patrick Joy
e3d9d8ef51 zephyr/boards: Add nrf5340dk board configuration.
Add support for the nrf5340dk.  This DK has a MX25R64 8mb external QSPI
flash chip.

Compile using:

    $ west build -b nrf5340dk/nrf5340/cpuapp

Signed-off-by: Patrick Joy <patrick@thinktransit.com.au>
2025-04-30 12:29:11 +10:00
Vdragon
d939511dae zephyr: Create options to enable frozen modules.
Enables the ability to use frozen modules in the zephyr port.

Enabled by adding `CONFIG_MICROPY_FROZEN_MODULES` to the board
configuration file.  Manually set manifest path with
`CONFIG_MICROPY_FROZEN_MANIFEST`.

Signed-off-by: Vdragon <mail@massdriver.space>
2025-04-30 11:59:17 +10:00
Ayush Singh
f9a755c91c zephyr/boards: Enable PWM on beagleconnect_freedom.
Enable PWM config for bcf.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-04-30 00:30:27 +10:00
Ayush Singh
f4a7e713ea zephyr/machine_pwm: Implement PWM support.
Implement PWM support using standard zephyr APIs, exposed as the standard
MicroPython `machine.PWM` class.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-04-30 00:28:45 +10:00
Maureen Helm
3c8d1b13f5 zephyr: Upgrade to Zephyr v4.0.0.
Updates the Zephyr port build instructions. The CI is updated to use
Zephyr docker image 0.27.4, SDK 0.17.0 and the latest Zephyr release
tag.

Tested on max32690fthr and frdm_k64f.

Signed-off-by: Maureen Helm <maureen.helm@analog.com>
Signed-off-by: Detlev Zundel <dzu@member.fsf.org>
2025-04-29 23:00:37 +10:00
Detlev Zundel
b83606fe33 zephyr: Remove reference to CONFIG_MMC_VOLUME_NAME for v4.0.
Commit 07a8e3253a2d8a2076c9c83c4ed4158fa3fbb2a2 removes
CONFIG_MMC_VOLUME_NAME from the Kconfig space. Instead we need to use
the device tree to find the "disk-name" property of "zephyr,mmc-disk"
devices.

Signed-off-by: Detlev Zundel <dzu@member.fsf.org>
2025-04-29 23:00:37 +10:00
Detlev Zundel
cd3eaad05c zephyr: Fix call to thread_analyzer_print for v4.0.
Commit 1b6e0f64796dfd6f86a8679ea6d24e1fca1e63a8 for Zephyr v4.0.0
changed the function "thread_analyzer_print" to require a cpu argument
and allow thread analysis on each cpu separately. The argument is
ignored when THREAD_ANALYZER_AUTO_SEPARATE_CORES=n which is the
default on single core machines.

Promote this change to the MicroPython zephyr module.

Signed-off-by: Detlev Zundel <dzu@member.fsf.org>
Signed-off-by: Maureen Helm <maureen.helm@analog.com>
2025-04-29 23:00:37 +10:00
Detlev Zundel
cd71db0172 zephyr: Fix prj.conf for v4.1-rc1.
The (deprecated) kconfig option NET_SOCKETS_POSIX_NAMES was removed in
commit abad505bdeed6102061767f45acd63323973f564 so remove it from our
configuration.

As the option has been deprecated longer, this also works for v3.7 and
v4.0 the other still supported versions.

Signed-off-by: Detlev Zundel <dzu@member.fsf.org>
2025-04-29 23:00:37 +10:00
stijn
9a377801dc unix/coveragecpp: Verify struct-initializing macros' C++-compatibility.
Add code using all relevant macros to make sure they initialize
structs correctly.

Signed-off-by: stijn <stijn@ignitron.net>
2025-04-24 15:55:06 +02:00
Angus Gratton
584fa8800b esp32/tools: Update metrics_esp32 script for ESP-IDF >=v5.4.x.
The output of 'idf.py size' has changed, plus some other cleanups around
build dir name, etc.  Can now run on v5.2.2 and v5.4.1, probably other
versions.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-04-24 22:16:32 +10:00
iabdalkader
0f360880aa stm32/cyw43_configport: Update cyw43 config to use new BTHCI UART.
Update the cyw43 configuration to use the new BTHCI UART backend provided
by cyw43-driver.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-22 12:50:22 +10:00
iabdalkader
3bbed952fd mimxrt/cyw43_configport: Update cyw43 config to use new BTHCI UART.
Update the cyw43 configuration to use the new BTHCI UART backend provided
by cyw43-driver.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-22 12:49:14 +10:00
iabdalkader
399c10dc28 mimxrt/machine_uart: Enable CTS SION so it can be read.
The new CYW43 BTHCI UART backend requires CTS pin to be defined and
readable.  This patch enables the CTS pin SION bit to allow it to be read
regardless of mux mode.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-22 12:39:01 +10:00
iabdalkader
fa76d52edb drivers/ninaw10: Rename Bluetooth HCI backend driver.
Rename `bt_hci` to `bthci_uart` for consistency with the CYW43 driver and
to distinguish it from HCI backends that use a different transport.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-22 12:30:22 +10:00
Alessandro Gatti
e3c2cf7a04 esp32/esp32_common.cmake: Skip BTree module when requested.
This commit makes the BTree module truly optional, as it was
unconditionally enabled in the shared CMake script for the port.

This meant that if a board/variant did explicitly turn BTree off said
request was not honoured by the build system and the BTree module would
still be brought in.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-04-22 12:18:04 +10:00
Damien George
048ccccee0 rp2: Enable compressed error messages by default.
Reduces firmware size by about 3000 bytes.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-22 11:57:39 +10:00
Damien George
bfe16ef09b esp32: Enable compressed error messages by default.
Reduces firmware size by about 3300 bytes.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-22 11:57:26 +10:00
Andrew Leech
d6c673f28f stm32/main: Replace mp_stack_set calls with new mp_cstack_init_with_top.
Required in MICROPY_PREVIEW_VERSION_2.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2025-04-22 11:29:48 +10:00
Andrew Leech
9bde197004 rp2: Add exception text wrappers.
Required in MICROPY_PREVIEW_VERSION_2.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2025-04-22 11:29:36 +10:00
Alessandro Gatti
38a3873310 unix/mpthreadport: Work around lack of thread cancellation on Android.
This commit fixes thread-related compilation issues under Android using
Termux as its runtime environment.

On Android's libc (Bionic) thread cancellation is not implemented, but
the Unix port uses that mechanism to provide asynchronous thread
termination.  In this commit there is a workaround for that, by adding a
new signal handler to each newly created thread, whose callback simply
exits the thread.  Threads are then sent the new signal rather than
being explicitly cancelled, which in turn trigger the signal handler to
stop the thread execution at the next possible occasion.

This makes the cancellation behaviour differ slightly on Android, as
threads are probably going to linger a little bit more since the method
introduced in this commit is equivalent to setting
PTHREAD_CANCEL_DEFERRED as the thread cancellation type.  On the other
hand there are no guarantees of immediate cancellation using
PTHREAD_CANCEL_ASYNCHRONOUS either.

This fixes the pthread-related issues reported in #16259.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-04-22 10:19:20 +10:00
David Yang
6025b78d01 unix/main: Remove PATH_MAX from realpath.
POSIX.1-2008 ensures realpath() give a dynamically allocated buffer if
NULL is passed (which is also true for ports/windows/realpath.c),
avoiding an explicit call to malloc() and use of PATH_MAX, which may be
undefined on some systems.

Signed-off-by: David Yang <mmyangfl@gmail.com>
2025-04-22 00:20:47 +08:00
Yoctopuce dev
52ca826880 unix/variants: Enable os.uname() in coverage build for tests.
In order to provide test coverage for the previous commit, `os.uname()`
support is added to the unix coverage build.

Signed-off-by: Yoctopuce dev <dev@yoctopuce.com>
2025-04-21 17:38:42 +10:00
Damien George
0b3ad98ea9 mimxrt/Makefile: Fix dependencies for generation of flexram_config.s.
Prior to this fix the following would fail:

    $ make build-TEENSY40/flexram_config.s

because it didn't create the build directory before generating the file.

Also, make `hal/resethandler_MIMXRT10xx.S` have an explicit dependency on
`flexram_config.s` rather than the latter just being forced to be built
before everything else.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-10 13:56:51 +10:00
Damien George
db85427071 stm32/boards/PYBD_SF6: Support boards with larger SPI flash.
There are some newer PYBD_SF6 being produced which have a larger flash,
namely two of 8MiB (instead of the older ones with two of 2MiB).

This commit adds support for these boards.  The idea is to have the same
PYBD_SF6 firmware run on both old and new boards.  That means autodetecting
the flash at start-up and configuring all the relevant SPI/QSPI parameters,
including for ROMFS and mboot.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 22:36:55 +10:00
Damien George
ed4833d495 stm32/modmachine: Add SPI flash size to machine.info dump.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 22:36:55 +10:00
Damien George
de08190cb7 stm32/mboot: Allow USB strings to be dynamic.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 22:36:55 +10:00
Damien George
aa0945698b stm32/qspi: Allow SPI flash size to be decided at runtime.
Allows `MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2` and
`MICROPY_HW_QSPI_MPU_REGION_SIZE` to be arbitrary expressions, eg function
calls.

The `storage.h` header needs to be included in case access to `spi_bdev_t`
is needed by the macros.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 22:36:55 +10:00
Damien George
1d83c81756 stm32/vfs_rom_ioctl: Allow ROMFS configuration to be dynamic.
Options for a board to configure ROMFS are:

- Leave ROMFS disabled, do nothing.

- Enable by defining `MICROPY_HW_ROMFS_ENABLE_PARTx` to 1 and then in the
  linker script define `_micropy_hw_romfs_partX_start` and
  `_micropy_hw_romfs_partX_size`.

- Enable by defining `MICROPY_HW_ROMFS_ENABLE_PARTx` to 1 and also define
  `MICROPY_HW_ROMFS_PARTx_START` and `MICROPY_HW_ROMFS_PARTx_SIZE` which
  can be arbitrary expressions (not necessarily static)

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 22:36:55 +10:00
Damien George
2c0240e068 drivers/bus/qspi: Make num_dummy configurable for quad reads.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 22:36:55 +10:00
Damien George
704d2f2d57 alif/boards/OPENMV_AE3: Add OpenMV AE3 board definition.
Supports Murata 1YN for WiFi and BLE.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:33 +10:00
iabdalkader
7c216d17b6 alif/boards/ALIF_ENSEMBLE: Add Alif Ensemble board config.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:33 +10:00
Damien George
b79b64a726 alif/mpu: Add MPU region for OSPI1 XIP memory range.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:33 +10:00
Damien George
c395f5ebb0 alif/ospi_flash: Restore XIP settings after erase and write.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:33 +10:00
Damien George
df5e4ced76 alif/ospi_flash_settings: Use 8-bit DFS for XIP.
To match the instruction length, so the DFS is restored to the XIP value
after an erase or write (due to the final wait WIP).

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:33 +10:00
Damien George
3564ce5bd8 alif/ospi_flash: Don't invalidate cache after erasing/writing.
It's not needed, the MPU configures the XIP as non-cacheable.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:33 +10:00
Damien George
737acef5cb alif: Support more fine-grained pin alternate function selection.
Now raises an exception if the pin doesn't support the alternate function
unit number and line type, eg UART0_TX (previously it only checked the
peripheral).

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:33 +10:00
Damien George
29a873ec07 alif/machine_uart: Add machine.UART peripheral support.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
293e8db9d7 alif/mpuart: Enhance UART to support bits/parity/stop and more IRQs.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
iabdalkader
19a4689c6b alif/mcu: Pre-process Alif ToC config file.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
da46b4d708 alif/mcu: Remove json config files.
They will be generated as part of the build.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
Damien George
30dfbe5dc0 alif: Integrate cyw43 Bluetooth with NimBLE.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
d6e33423da alif: Integrate cyw43 WLAN driver.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
526c7eabce alif: Integrate lwIP and mbedTLS.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
411146b0ed alif/mpuart: Generalise UART driver to suppot all UART instances.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
4f2a8bd99f alif/mphalport: Add mp_hal_pin_config_irq_falling helper.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
d1b12cb676 alif/modules: Make HE core set /rom as current dir.
This allows HE to execute code from the ROMFS in MRAM.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
8297c95c22 alif/vfs_rom_ioctl: Add vfs_rom_ioctl with support for OSPI and MRAM.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
f83f6e7eed alif/mpu: Add function to set read-only bit on MRAM MPU region.
To allow writing to MRAM region.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
d895a62b07 alif/alif_flash: Make flash respond to the buffer protocol.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
af574a86c2 alif/alif_flash: Distinguish between total flash size and FS size.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
ca3d50a096 alif/mpuart: Use mp_hal_pin_config for TX/RX configuration.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
7e32c23218 alif/mpmetalport: Only notify after metal subsystem is init'd.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
iabdalkader
68b1dae011 alif: Link with libnosys.
This allows the correct start up functions to be called by the stdlib.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
182b5f3a12 alif/mpmetalport: Use MHU to notify remote cores.
Unlike HWSEM, the MHU IRQ can wake up cores from low-power modes, making it
better suited for notifying remote cores.  Note that no special function is
required to wake up a remote core—the act of sending a message alone will
notify it.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
b9e5f1ffba alif/se_services: Add a secondary MHU channel.
This channel can be used to communicate (pass messages) between the M55
cores in the RTSS.  Currently it's only used to notify the cores.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
facd0b7190 alif/ospi_flash: Use mp_hal_pin_config to configure OSPI pins.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
ec92bcfeff alif/machine_rtc: Add basic machine.RTC support.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
280e6e2a40 alif/machine_spi: Add machine.SPI peripheral support.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
iabdalkader
9073270c2e alif/machine_i2c: Add machine.I2C peripheral support.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
82bae652eb alif: Add support for pin alternate function selection.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
039df0c884 alif/modmachine: Implement proper low-power modes.
Lightsleep current is around 23mA.  Deepsleep current is sub 50uA.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
ff6ed730c5 alif/se_services: Use EUI extension for unique id.
The right service call to get UID is SERVICES_system_get_eui_extension
which returns an 8 bytes UID.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
92f056d58f alif/ospi_flash: Add 16-bit words swap flash setting.
The byte order (endianness) seems to be swapped when read in 8D-8D-8D in
XIP mode, for most flashes, with the exception of MX which seems to swap
half-words.

This commit adds a flash setting to allow parts to enable half-word swap
when data is written, to fix this issue.  By default, only endianness is
fixed.

Tested with both MX and ISSI parts on AE3, flash test and simple file
write/read.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
602bc86b6d alif/ospi_flash: Use OSPI in XIP mode only.
The OSPI controller supports concurrent direct/XIP accesses, there's no
need to disable XIP on direct access.  In addition to improving the
performance, this change lays the groundwork for supporting access by
the HP and HE cores simultaneously.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
df06bf91a5 alif/ospi_ext: Optimize XIP speed.
This change increases XIP read speed to ~30Mbytes/s at 50MHz DDR:
- Enable continuous mode.
- Remove hard-coded settings.
- Set XIP continuous mode timeout.

The prefetch remains disabled.  Although enabling the prefetch gives the
best performance for the CPU in XIP mode, it must be disabled when the NPU
accesses the OSPI flash.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
0709936653 alif/ospi_flash: Enable pull-up IO2/WP.
Leaving this pin low in combination with the default EM settings enables
flash protection for the EM flash.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
872f3d70d3 alif/ospi_flash: Add negative clock pin.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
8807f8d01b alif/ospi_flash: Configure dummy cycles.
The default dummy cycles may not match the actual flash frequency supported
by a certain board.  For example, the MX chip uses 20 dummy cycles by
default which supports up to 200MHz DDR, but the maximum frequency
supported by the AE3 board is 50MHz DDR.  So the dummy cycles for this
board can be as low as 6.  It's important to set the correct dummy cycles,
as it results in doubling the XIP read speed, in the case of the AE3 board.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
aec030004f alif/ospi_flash: Support flash device auto-detection in runtime.
This commit enables detecting the flash device in runtime, and uses the
settings of the detected device instead of board-defined flash settings.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
1585080ff0 alif/ospi_flash: Fix XIP for 8-bit instructions (ISSI).
Disable XIP instruction DDR for 8-bit instructions.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
5152a1f04d alif/mpmetalport: Add Open-AMP MPU region.
Define an MPU region for Open-AMP and remove hard-coded attribute.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
3d17f63478 alif/mpu: Define constants for MPU regions.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
Damien George
41e16886b1 alif/ospi_flash: Enter XIP mode when flash is idle.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
84effb386a alif/ospi_flash: Generalise flash driver to support MX chips.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
4c4b4844df alif/mpu: Add custom MPU_Load_Regions function.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
58d6fe236b alif/mpconfigport: Select SysTick on HE core.
UTIMER is used by the HP.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
c6ebecc4c3 alif/system_tick: Implement optional ARM SysTick support for systick.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
bbb8fd77fd alif/system_tick: Implement optional LPTIMER support for systick.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
iabdalkader
cee8e111cb alif/irq: Define more IRQ priorities.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
iabdalkader
4f6f283abb alif: Implement Open-AMP port backend.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
6b4d46569b alif: Support running the port on the HE core.
The same MicroPython firmware is built for the HE but with slightly
different options, for example no USB.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
8f82089bd0 alif: Support building the port for HE or HP or both cores.
With this new Makefile you can build the following:

    make BOARD=MY_BOARD MCU_CORE=M55_HP # build HP firmware/ToC.

    make BOARD=MY_BOARD MCU_CORE=M55_HE # build HE firmware/ToC.

    make BOARD=MY_BOARD MCU_CORE=M55_DUAL # build HE+HP firmware + ToC.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
iabdalkader
b7df5aa86a alif/mcu: Add ToC config for dual images.
Note that 128K at the beginning of MRAM is reserved for future bootloaders.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
Damien George
62beb541e7 alif/machine_adc: Add basic ADC support.
ADC12 information has been added to pin struct.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
31d18c5885 alif/usbd: Implement proper USB serial number.
Using SE services to get the SoC unique id.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
2f85a19d7d alif/modmachine: Implement machine.unique_id(), fix machine.reset().
They both use SE services.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
2a580b05ad alif/modalif: Add alif.info() function.
Calls the SE services to print information about the SoC.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
64af93e74e alif/mpconfigport: Enable MICROPY_PY_RANDOM_SEED_INIT_FUNC.
Uses the SE services to provide a random seed.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
c6cb082ed1 alif/mpconfigport: Enable os.urandom().
Uses the SE services to provide random numbers.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
4e62ade442 alif/se_services: Add SE services interface.
Includes services to get random numbers, reset SoC, get unique-id, dump SoC
info, and CPU control services.

Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
Damien George
53b7c14836 alif/modmachine: Enable machine.Timer.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
ada0939c5f alif/system_tick: Integrate soft timer.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
975f84f2ad alif/mphalport: Enable efficient events and implement quiet timing.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
40ff0c2f27 alif/system_tick: Use a UTIMER for system ticks and timing.
Includes an implementation of `system_tick_wfe_with_timeout_us()`.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-09 00:22:32 +10:00
Damien George
ccc5935234 alif: Add initial port to Alif Ensemble MCUs.
This commit adds the beginning of a new alif port with support for Alif
Ensemble MCUs.  See https://alifsemi.com/

Supported features of this port added by this commit:
- UART REPL.
- TinyUSB support, for REPL and MSC.
- Octal SPI flash support, for filesystem.
- machine.Pin support.

General notes about the port:
- It uses make, similar to other bare-metal ports here.
- The toolchain is the standard arm-none-eabi- toolchain.
- Flashing a board can be done using either the built-in serial bootloader,
  or JLink (both supported here).
- There are two required submodules (one for drivers/SDK, one for security
  tools), both of which are open source and on GitHub.
- No special hardware or software is needed for development, just a board
  connected over USB.

OpenMV have generously sponsored the development of this port.

Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-09 00:22:32 +10:00
Damien George
b8a9cdf067 alif/tinyusb_port: Implement SOF event.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-08 23:53:30 +10:00
iabdalkader
ebecd6d101 alif/tinyusb_port: Disable USB IRQ on deinit.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-08 23:53:20 +10:00
Damien George
092d85557c alif/tinyusb_port: Add Alif TinyUSB DCD driver.
From https://github.com/alifsemi/alif_vscode-tinyusb.git,
commit c79f39361d334ee44f44fed30c56e70dbb368649

Signed-off-by: Damien George <damien.p.george@gmail.com>
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-08 23:53:07 +10:00
Damien George
a9384c71c5 extmod/extmod.mk: Switch from drivers/cyw43/cywbt to lib/cyw43-drivers.
The cyw43-driver now provides the Bluetooth initialisation code, making
`drivers/cyw43/cywbt.c` obsolete.  To use the new code a port must enable
the `CYW43_ENABLE_BLUETOOTH_OVER_UART` option.

Some ports have yet to migrate to the new code, so in the meantime they can
explicitly add the old source to their source list and continue to use it
without change.

Signed-off-by: Damien George <damien@micropython.org>
2025-04-08 23:52:16 +10:00
Mike Bell
91cff8e4f1 rp2/rp2_flash: Configure optimal flash timings.
Configure flash timings dynamically to match the system clock.  Reconfigure
timings after flash writes.

Changes are:
- ports/rp2/main.c: Set default flash timings.
- ports/rp2/modmachine.c: Configure optimal flash timings on freq change.
- ports/rp2/rp2_flash.c: Reconfigure flash when leaving critical section.

Signed-off-by: Phil Howard <github@gadgetoid.com>
2025-04-08 11:01:14 +10:00
Mike Bell
89eea0f5e8 rp2/rp2_flash: Support flash writes from PSRAM.
Add a 256 byte (FLASH_PAGE_SIZE) SRAM copy buffer to allow copies from
PSRAM to flash.  This would otherwise hardfault since PSRAM is disabled
when doing a write to flash.

Changes are:
- ports/rp2/rp2_flash.c: Add 256 byte (flash page size) SRAM copy buffer
                         for PSRAM to flash copies.
- ports/rp2/rp2_flash.c: Invalidate the XIP cache to purge any PSRAM
                         data before critical flash operations.

Co-authored-by: Phil Howard <github@gadgetoid.com>
Co-authored-by: Angus Gratton <angus@redyak.com.au>
Signed-off-by: Phil Howard <github@gadgetoid.com>
2025-04-08 11:00:14 +10:00
Phil Howard
b7d5caf2a3 rp2/mpconfigport: Configure heap for PSRAM.
PSRAM will be used exclusively if MICROPY_GC_SPLIT_HEAP == 0, it will be
added to RAM if MICROPY_GC_SPLIT_HEAP == 1, and the system will fall back
to RAM only if it's not detected.

Due to the size of PSRAM, GC stack was overflowing and causing the GC to
scan through the entire memory pool.  This caused noticable slowdowns
during GC.  Increase the stack from 256 to 4096 bytes to avoid overflow and
increase the stack entry type size to accomodate 8MB+ PSRAM.

Changes are:
- ports/rp2/mpconfigport.h: Make split-heap optional and enable by default.
- ports/rp2/mpconfigport.h: Increase GC stack entry type to uint32_t.
- ports/rp2/mpconfigport.h: Raise GC stack size.

Co-authored-by: Kirk Benell <kirk.benell@sparkfun.com>
Signed-off-by: Phil Howard <github@gadgetoid.com>
2025-04-08 10:59:00 +10:00
Phil Howard
11f057dd9a rp2: Add support for PSRAM with auto-detection.
Performs a best-effort attempt to detect attached PSRAM, configure it and
*add* it to the MicroPython heap.  If PSRAM is not present, should fall
back to use internal RAM.

Introduce two new port/board defines:
- MICROPY_HW_ENABLE_PSRAM to enable PSRAM.
- MICROPY_HW_PSRAM_CS_PIN to define the chip-select pin (required).

Changes are:
- ports/rp2/rp2_psram.[ch]: Add new PSRAM module.
- ports/rp2/main.c: Add optional PSRAM support.
- ports/rp2/CMakeLists.txt: Include rp2_psram.c.
- ports/rp2/mpconfigport.h: Add MICROPY_HW_ENABLE_PSRAM.
- ports/rp2/modmachine.c: Reconfigure PSRAM on freq change.

Co-authored-by: Kirk Benell <kirk.benell@sparkfun.com>
Co-authored-by: Mike Bell <mike@mercuna.com>
Signed-off-by: Phil Howard <phil@gadgetoid.com>
2025-04-08 10:56:59 +10:00
Alessandro Gatti
6bb586619d esp32/esp32_common.cmake: Remove obsolete definition.
This commit removes a definition used back when ESP-IDF v4 was supported
by MicroPython.  Those times are now long gone, and so is the need for
that particular definition to be set in the first place.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-04-03 16:26:47 +11:00
Alessandro Gatti
fda9bf4917 esp32/esp32_common.cmake: Clean up RISC-V directives.
This commit cleans up a couple of RISC-V specific directives in the
build script.  Namely, removes the forced inclusion of the "riscv"
component and introduces proper mpy-cross flags.

The "riscv" component is already included by the ESP-IDF build
framework, as certain low-level components would not build otherwise, so
there is no need to add it to the required components list.

The architecture flag for mpy-cross is now set for RISC-V targets, as it
was previously set only for Xtensa targets (and it relied on a string
comparison rather than using the appropriate configuration variable).

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-04-03 16:26:47 +11:00
Alessandro Gatti
9ab6906f50 esp32/esp32_common.cmake: Use native gchelper for RISC-V.
This commit changes the gchelper implementation in use for RV32-based
targets (ESP32C3, ESP32C6) from the generic one written in C to the one
written in assembler that is specific to the CPU in question.

The native implementation is already exercised on most CI builds as it
is used by the QEMU port to compile and test the RV32 target.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-04-03 16:26:47 +11:00
Damien George
1660faacf6 stm32/boards/PYBD_SF2: Restart qspi memory-mapped mode during startup.
The PYBD boards use an F7xx which has an errata 2.4.3:

    Memory-mapped read operations may fail when timeout counter is enabled

This is unfortunate because it means that once QSPI memory-mapped flash is
accessed the QSPI peripheral will leave the CS pin active (low) forever,
which increases power consumption of the SPI flash chip (because it's
active and waiting for commands).  The exact amount of power increase
depends on the flash, but the PYBD_SFx increase by about 2.5mA.

Previously this increase in power only happened when QSPI flash was needed,
eg on PYBD_SF2 when mbedtls or nimble libraries were used.  On PYBD_SF6
it's actually never used.

But with the introduction of ROMFS which lives in the QSPI flash, the
memory is always access on start up to see if the ROMFS contains a valid
image (it must read the memory to find out).  That means these boards
always consume about 2.5mA more after starting up (compared to when ROMFS
is disabled).

The fix in this commit is to explicitly restart the QSPI memory mapped mode
during the start up process.  More precisely, the restart is done after
querying the ROMFS and just before trying to execute `boot.py`.  That's the
right location to keep power consumption permanently down if the QSPI is
never used (eg ROMFS image doesn't exist).

Signed-off-by: Damien George <damien@micropython.org>
2025-04-03 16:15:35 +11:00
Damien George
ac1cbef366 stm32/qspi: Add qspi_memory_map_exit and restart.
Signed-off-by: Damien George <damien@micropython.org>
2025-04-03 16:15:35 +11:00
Matt Trentini
c18e925431 stm32/timer: Add support for STM32H5 Timer 1.
Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
2025-04-03 16:13:28 +11:00
Herwin Grobben
91386b3d56 stm32/timer: Use APB2 to calculate timer 20 source frequency.
Signed-off-by: Herwin Grobben <h.grobben@aemics.nl>
2025-04-03 16:10:06 +11:00
Herwin Grobben
3b948893d8 stm32/stm32_it: Add handler for timer 20 interrupt.
Signed-off-by: Herwin Grobben <h.grobben@aemics.nl>
2025-04-03 16:09:43 +11:00
iabdalkader
1a47379dd6 stm32/boards: Add F427 AF CSV file.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-04-03 16:05:12 +11:00
Andrew Leech
b33b9f8121 stm32/main: Catch and report corrupted lfs filesystem at startup.
On stm32, the startup code attempts to mount the configured filesystem.  If
there is an existing littlefs filesystem that's suitable corrupted it's
possible for the reported blocksize to be incorrect here:

     uint32_t block_size = lfs2_fromle32(superblock->block_size);

This `block_size` (which is read from the filesystem iteself) is used to
create the len argument passed to `pyb_flash_make_new()`.  In that function
the len arg is validated to be a mutliple of the underlying hardware block
size, as well as not bigger than the physical flash.  Any failure is raised
as a ValueError.  This exception is not caught currently in main, it flows
up to the high level assert / startup failure.

As this occurs before `boot.py` is run, the users (potentially frozen)
application code doesn't have any opportunity to detect and handle the
issue.

This commit adds a helper function which attempts to create a block device,
and on error returns `None` instead of raising an exception.  Using this in
main means that a potentially corrupt filesystem will simply remain
unmounted, and the application can handle the issue safely.

The fix here also handles the case where the littlefs filesystem is valid
but the autodetection code (which detects the filesystem size) does not
work correctly.  In that case it will retry mounting the filesystem using
the whole size of the block device.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2025-04-03 15:08:58 +11:00
Mark Seminatore
f96417dbf2 rp2/cyw43_configport: Fix cyw43 mDNS by properly starting mDNS on netif.
The rp2 port has an incomplete mDNS implementation.  The code in `main.c`
calls `mdns_resp_init()` which opens the UDP socket for mDNS.  However, no
code in the cyw43 driver makes the proper calls to `mdns_resp_add_netif()`
and `mdns_resp_remove_netif()` to send the announce packets.  The wiznet5k
driver does make these calls and was used as a model for these changes.

This commit attempts to address this by very small changes to the
`ports/rp2/cyw43_configport.h` file.  The change uses new cyw43 driver
hooks to map the driver macros `CYW43_CB_TCPIP_INIT_EXTRA` and
`CYW43_CB_TCPIP_DEINIT_EXTRA` to the appropriate lwIP mDNS calls.

Fixes issue #15297.

Signed-off-by: Mark Seminatore <nebula_peeps4t@icloud.com>
2025-04-03 13:17:14 +11:00
Damien George
5eee5a67dc rp2/Makefile: Use $(Q) prefix on all commands.
This prevents printing the lengthy command and makes the build output a
little cleaner.

Signed-off-by: Damien George <damien@micropython.org>
2025-03-28 11:47:55 +11:00
Damien George
a828b99cff esp32/Makefile: Use $(Q) prefix on all commands.
This prevents printing the lengthy command and makes the build output a
little cleaner.

Signed-off-by: Damien George <damien@micropython.org>
2025-03-28 11:46:39 +11:00
Angus Gratton
50da085d93 rp2: Print an error message if pico-sdk submodule is missing.
This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-03-27 17:51:12 +11:00
Angus Gratton
cccac2cc01 rp2,esp32,extmod: Implement UPDATE_SUBMODULES in CMake.
Rather than having Make calling CMake to generate a list of submodules and
then run a Make target (which is complex and prone to masking other
errors), implement the submodule update logic in CMake itself.

Internal CMake-side changes are that GIT_SUBMODULES is now a CMake list,
and the trigger variable name is changed from ECHO_SUBMODULES to
UPDATE_SUBMODULES.

The run is otherwise 100% a normal CMake run now, so most of the other
special casing can be removed.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-03-27 17:51:12 +11:00
robert-hh
4dfee50a0b samd/machine_uart: Fix lock-up in loopback mode if read buffer is full.
Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-27 11:39:02 +11:00
robert-hh
6db7b47ab9 samd/machine_uart: Fix unintended UART buffer allocation on init().
The buffer was be reset on every call to uart.init().  If no sizes were
given, the buffer was set to the default size 256.  That made problems
e.g. with PPP.

This commit fixes it, keeping the buffer size if not deliberately changed
and allocating new buffers only if the size was changed.  Cater for changes
of the bits value, which requires a change to the buffer size.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-27 11:38:31 +11:00
robert-hh
2b2a431878 rp2/machine_uart: Fix unintended UART buffer allocation on init().
The buffer was be reset on every call to uart.init().  If no sizes were
given, the buffer was set to the default size 256.  That made problems e.g.
with PPP.

This commit fixes it, keeping the buffer size if not deliberately changed
and allocating new buffers only if the size was changed.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-27 11:37:57 +11:00
Angus Gratton
35d4d2d06b rp2/pendsv: Account for PendSV running on both cores, and without CYW43.
Changes:
- Move setting of PendSV priority to pendsv_init().
- Call pendsv_init() from CPU1 as well, to ensure priority is the same.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-03-27 00:07:50 +11:00
Angus Gratton
23fb171b80 rp2/mpnetworkport: Refactor out cyw43_has_pending global variable.
A better indication of whether a cyw43 event is pending is the actual flag
in the PendSV handler table. (If this fails, could also use the GPIO
interrupt enabled register bit).

This commit was needed of a previous version of the fix in the parent
commit, but it turned out not strictly necessary for the current version.
However, it's still a good clean up.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-03-27 00:05:24 +11:00
Angus Gratton
6fa498cba1 rp2/mpnetworkport: Fix lost CYW43 WiFi events when using both cores.
There's a very odd but predictable sequence of events that breaks Wi-Fi
when using both cores:

1) CPU1 calls pendsv_suspend() - for example sleep() causes
   a softtimer node to be inserted, which calls pendsv_suspend().
2) CYW43 sends wakeup IRQ. CPU0 GPIO IRQ handler schedules PendSV
   and disables the GPIO IRQ on CPU0, to re-enable after
   cyw43_poll() runs and completes.
3) CPU0 PendSV_Handler runs, sees pendsv is suspended, exits.
4) CPU1 calls pendsv_resume() and pendsv_resume() sees PendSV
   is pending and triggers it on CPU1.
5) CPU1 runs PendSV_Handler, runs cyw43_poll(), and at the end
   it re-enables the IRQ *but now on CPU1*.

However CPU1 has GPIO IRQs disabled, so the CYW43 interrupt never runs
again...

The fix in this commit is to always enable/disable the interrupt on CPU0.
This isn't supported by the pico-sdk, but it is supported by the hardware.

Fixes issue #16779.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-03-27 00:02:13 +11:00
Phil Howard
dd7a950bbc rp2/machine_spi: Allow MISO to be unspecified.
It's common with write-only SPI displays for MISO to be repurposed as a
register select or data/command pin.

While that was possible by setting up the pin after a call to
`machine.SPI()` this change makes `machine.SPI(miso=None)` explicit.

Signed-off-by: Phil Howard <github@gadgetoid.com>
2025-03-26 17:08:08 +11:00
Phil Howard
a86122396d rp2/machine_spi: Make SPI ID optional.
If the "spi_id" arg is not supplied and then the board default specified by
PICO_DEFAULT_SPI will be used.

Signed-off-by: Phil Howard <github@gadgetoid.com>
2025-03-26 17:07:51 +11:00
Phil Howard
f315a376b6 rp2/machine_i2c: Require an I2C bus ID when no default is available.
When PICO_DEFAULT_I2C is not set require an I2C bus ID instead of
using -1 as a default, which would fail with a cryptic:

    "I2C(-1) doesn't exist"

Signed-off-by: Phil Howard <github@gadgetoid.com>
2025-03-25 23:52:49 +11:00
Malcolm McKellips
93a8c53d64 rp2/boards/SPARKFUN_IOTNODE_LORAWAN_RP2350: Add SD card support.
The IOTNODE_LORAWAN_RP2350 has an SD card and we want users to be able to
`import sdcard` without copying `sdcard.py` over to their board.

Signed-off-by: Malcolm McKellips <malcolm.mckellips@sparkfun.com>
2025-03-25 23:19:29 +11:00
Malcolm McKellips
1e92bdd206 rp2/boards: Fix SparkFun vendor name.
The preferred/correct spelling is "SparkFun" so this commit updates all of
the existing SparkFun board definitions with that spelling.
2025-03-25 23:11:59 +11:00
Damien George
396ab268df stm32/qspi: Implement MP_QSPI_IOCTL_MEMORY_MODIFIED ioctl.
stm32's QSPI driver supports memory-mapped mode.  The memory-mapped flash
can also be erased/written to.  To support both these modes, it switches in
and out of memory-mapped mode during an erase/write.

If the flash is erased/written and then switched back to memory mapped
mode, the cache related to the memory-mapped region that changed must be
invalidated.  Otherwise subsequent code may end up reading old data.

That cache invalidation is currently not being done, and this commit fixes
that.

This bug has been around ever since QSPI memory-mapped mode existed, but
it's never really been observed because it's not common to use flash in
memory-mapped mode and also erase/write it.  Eg PYBD_SF2 uses the
memory-mapped flash in read-only mode to store additional firmware.

But since the introduction of ROMFS, things changed.  The `vfs.rom_ioctl()`
command can erase/write memory-mapped flash.

Signed-off-by: Damien George <damien@micropython.org>
2025-03-25 12:59:04 +11:00
Damien George
c61e859108 drivers: Add MP_QSPI_IOCTL_MEMORY_MODIFIED to indicate flash changed.
Signed-off-by: Damien George <damien@micropython.org>
2025-03-25 12:58:43 +11:00
robert-hh
274c8c419c mimxrt/boards: Update deploy instructions.
Make the final step of the deploy more detailed.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-25 12:45:17 +11:00
robert-hh
cdcc70d4f8 mimxrt: Enable default devices for I2C, SPI and UART.
Since all boards are configured to have a I2C(0), SPI(0) and UART(1), these
can be set as default devices, allowing the instantiation of I2C(), SPI(),
UART() without an id argument.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-25 12:44:20 +11:00
robert-hh
1e7328ca28 mimxrt/machine_i2c: Support the timeout keyword argument.
Set the default timeout to 50000 us.  The default used to be 0, causing the
NXP I2C driver to silently stop working in case of a non-responding device.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-25 12:42:26 +11:00
robert-hh
b85ad4bd41 mimxrt/machine_uart: Fix rx/tx buffer allocation bug.
The buffer would be reset on every call to `uart.init()`.  If no sizes were
given, the buffer would be set to the default size 256.  That made problems
e.g. with PPP.  Also, the RX buffer was not stored at the UART object and
not visible to GC as being in use.  Then a `gc.collect()` would eventually
free the buffer.

This commit fixes those issues, keeping the buffer size if not deliberately
changed and allocating new buffers only if the size was changed.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-25 12:41:21 +11:00
robert-hh
1398e7fd20 mimxrt/hal/qspi_nor_flash_config: Use a safe common CS timing.
The flash devices used by the MIMXRT board are specified either with 3ns or
5 ns CS setup and hold time.  Since a single configuration file is used for
all boards, use 5ns instead of 3ns to be safe, even if there were no
problems so far.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-25 12:40:41 +11:00
robert-hh
2d20dbce2c mimxrt/machine_uart: Remove duplicate init and make IRQ optional.
Changes:
- The duplicate LPUART_Init call was not needed, just an edit fail.
- Allow a port to disable UART.irq().  Some code for configuration stays,
  but the respective UART IRQ is not enabled.  Calling uart.irq() will
  cause an exception by extmod/machine_uart.c.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-25 12:40:02 +11:00
robert-hh
2a5b97beae mimxrt/mpconfigport: Enable PPP for boards with lwIP.
PPP is now enabled on all boards with Ethernet support.  PPP could be
enabled for other boards without Ethernet like the Teensy 4.0 as well in a
second step.  Enabling for MIMXRT101x boards is hardly possible due to the
large RAM demand of lwIP.

Tested with a Teensy 4.1 board and a SimCom A7608 GPRS/LTE modem.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-25 12:38:56 +11:00
robert-hh
d8edae040f mimxrt/mpconfigport: Enable support for exFAT.
There is plenty of room in the MIMXRT board flash, so it can be enabled.

Tested with:
- MIMXRT1176_EVK
- MIMXRT1061 (Teensy 4.1)
- MIMXRT1010 (Olimex RT1010)

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-25 12:38:42 +11:00
robert-hh
58f1ade318 mimxrt/machine_adc: Add ADC.read_uv() method.
Matching the generic documentation.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-25 12:38:00 +11:00
robert-hh
f1018ee5c2 mimxrt/boards/MAKERDIARY_RT1011_NANO_KIT: Add new Makerdiary board.
This is a board based on the i.MX RT1011 in breadboard-friendly shape.  A
good basic board with 16M flash and regular pinout, providing access to
many GPIO_nn and GPIO_AD_nn Pins.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-17 13:59:32 +11:00
Angus Gratton
9db2398009 stm32/can: Refactor can.h API to not depend on pyboard can types.
This is necessary for the machine.CAN implementation to use the same
low-level functions.

Includes some refactoring around FIFO selection as there was a footgun
where CAN_FIFO0/1 are 0/1 but FDCAN_RX_FIFO0/1 are not. Added an explicit
type for non-hardware-specific FIFO numbering.

Also moved responsibility for re-enabling CAN receive interrupts into the
higher layer (pyb_can.c layer) after calling can_receive().

Also includes this behaviour change for FDCAN boards:

- Fix for boards with FDCAN not updating error status
  counters (num_error_warning, num_error_passive, num_bus_off). These are
  now updated the same as on boards with CAN Classic controllers, as
  documented.

- Previously FDCAN boards would trigger the RX callback function on error
  events instead (passing undocumented irq numbers 3, 4, 5).
  This behaviour has been removed in favour of the documented behaviour of
  updating the status counters.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-03-14 14:52:09 +11:00
iabdalkader
96ce08e498 stm32/boards/ARDUINO_PORTENTA_H7: Enable 4MiB ROMFS part in ext flash.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-03-13 21:44:26 +11:00