Commit Graph

4877 Commits

Author SHA1 Message Date
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