summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-09-02 21:24:47 +1000
committerDamien George <damien@micropython.org>2025-04-09 00:22:33 +1000
commit704d2f2d57b3e30b3b0d0cf02849e9784b60ccb6 (patch)
tree82ab2b68bae7d11dfb8419fe7a834e2eaf231293
parent7c216d17b6e1d8394d05fd5eaae1c812c3846963 (diff)
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>
-rw-r--r--ports/alif/boards/OPENMV_AE3/board.c192
-rw-r--r--ports/alif/boards/OPENMV_AE3/board.ld.S14
-rw-r--r--ports/alif/boards/OPENMV_AE3/mpconfigboard.h85
-rw-r--r--ports/alif/boards/OPENMV_AE3/mpconfigboard.mk22
-rw-r--r--ports/alif/boards/OPENMV_AE3/ospi_xip_user.h6
-rw-r--r--ports/alif/boards/OPENMV_AE3/pins.csv69
6 files changed, 388 insertions, 0 deletions
diff --git a/ports/alif/boards/OPENMV_AE3/board.c b/ports/alif/boards/OPENMV_AE3/board.c
new file mode 100644
index 000000000..65da152d8
--- /dev/null
+++ b/ports/alif/boards/OPENMV_AE3/board.c
@@ -0,0 +1,192 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024 OpenMV LLC.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "py/mphal.h"
+#include "ospi_ext.h"
+#include "ospi_flash.h"
+#include "se_services.h"
+
+#define OMV_BOOT_MAGIC_ADDR (0x200FFFFCU)
+#define OMV_BOOT_MAGIC_VALUE (0xB00710ADU)
+
+#if CORE_M55_HP
+#define NPU_IRQ_NUMBER NPU_HP_IRQ_IRQn
+#define NPU_BASE_ADDRESS (void *)NPU_HP_BASE
+#else
+#define NPU_IRQ_NUMBER NPU_HE_IRQ_IRQn
+#define NPU_BASE_ADDRESS (void *)NPU_HE_BASE
+#endif
+
+typedef struct {
+ volatile uint32_t ID; // 0x0
+ volatile uint32_t STATUS; // 0x4
+ volatile uint32_t CMD; // 0x8
+ volatile uint32_t RESET; // 0xC
+} npu_regs_t;
+
+#define NPU ((npu_regs_t *)NPU_BASE_ADDRESS)
+
+const ospi_pin_settings_t ospi_pin_settings = {
+ .peripheral_number = 0,
+ .pin_reset = pin_FLASH_RESET,
+ .pin_cs = pin_FLASH_CS,
+ .pin_clk_p = pin_FLASH_SCLK_P,
+ .pin_clk_n = pin_FLASH_SCLK_N,
+ .pin_rwds = pin_FLASH_DQSM,
+ .pin_d0 = pin_FLASH_D0,
+ .pin_d1 = pin_FLASH_D1,
+ .pin_d2 = pin_FLASH_D2,
+ .pin_d3 = pin_FLASH_D3,
+ .pin_d4 = pin_FLASH_D4,
+ .pin_d5 = pin_FLASH_D5,
+ .pin_d6 = pin_FLASH_D6,
+ .pin_d7 = pin_FLASH_D7,
+};
+
+const ospi_flash_settings_t ospi_flash_settings[] = {
+ {
+ .jedec_id = 0x3980c2,
+ .freq_hz = 100000000,
+ .read_dummy_cycles = 10,
+ OSPI_FLASH_SETTINGS_MX25,
+ },
+ {
+ .jedec_id = 0x195b9d,
+ .freq_hz = 100000000,
+ .read_dummy_cycles = 9,
+ OSPI_FLASH_SETTINGS_IS25,
+ },
+ {
+ .jedec_id = 0x17bb6b,
+ .freq_hz = 100000000,
+ .read_dummy_cycles = 7,
+ OSPI_FLASH_SETTINGS_EM,
+ },
+};
+const size_t ospi_flash_settings_len = 3;
+
+void board_startup(void) {
+ // Switch the USB multiplexer to use the Alif USB port.
+ mp_hal_pin_output(pin_USB_D_SEL);
+ mp_hal_pin_high(pin_USB_D_SEL);
+}
+
+void board_enter_bootloader(void) {
+ *((uint32_t *)OMV_BOOT_MAGIC_ADDR) = OMV_BOOT_MAGIC_VALUE;
+ NVIC_SystemReset();
+}
+
+void board_early_init(void) {
+ // Set default run profile
+ run_profile_t run_profile = {
+ .dcdc_mode = DCDC_MODE_PWM,
+ .dcdc_voltage = DCDC_VOUT_0825,
+ // CLK_SRC_LFRC or CLK_SRC_LFXO
+ .aon_clk_src = CLK_SRC_LFXO,
+ // CLK_SRC_HFRC, CLK_SRC_HFXO or CLK_SRC_PLL
+ .run_clk_src = CLK_SRC_PLL,
+ #if CORE_M55_HP
+ .cpu_clk_freq = CLOCK_FREQUENCY_400MHZ,
+ #else
+ .cpu_clk_freq = CLOCK_FREQUENCY_160MHZ,
+ #endif
+ .scaled_clk_freq = SCALED_FREQ_XO_HIGH_DIV_38_4_MHZ,
+ // AON, modem aon, SSE-700 AON, modem, SYSTOP, DEBUG, SE
+ .power_domains = PD_VBAT_AON_MASK | PD_SSE700_AON_MASK | PD_SYST_MASK |
+ PD_DBSS_MASK | PD_SESS_MASK | PD_SRAMS_MASK | PD_SRAM_CTRL_AON_MASK,
+ // Add all memories
+ .memory_blocks = SERAM_MASK | SRAM0_MASK | SRAM1_MASK | MRAM_MASK | BACKUP4K_MASK |
+ SRAM6A_MASK | SRAM6B_MASK | SRAM7_1_MASK | SRAM7_2_MASK | SRAM7_3_MASK |
+ SRAM8_MASK | SRAM9_MASK | FWRAM_MASK,
+ .phy_pwr_gating = LDO_PHY_MASK | USB_PHY_MASK | MIPI_TX_DPHY_MASK | MIPI_RX_DPHY_MASK |
+ MIPI_PLL_DPHY_MASK,
+ .vdd_ioflex_3V3 = IOFLEX_LEVEL_3V3,
+ };
+
+ if (se_services_set_run_profile(&run_profile)) {
+ MICROPY_BOARD_FATAL_ERROR("se_services_set_run_profile");
+ }
+
+ // Set default off profile
+ off_profile_t off_profile = {
+ .dcdc_mode = DCDC_MODE_PWM,
+ .dcdc_voltage = DCDC_VOUT_0825,
+ // CLK_SRC_LFRC or CLK_SRC_LFXO
+ .aon_clk_src = CLK_SRC_LFXO,
+ // CLK_SRC_HFRC, CLK_SRC_HFXO or CLK_SRC_PLL
+ .stby_clk_src = CLK_SRC_HFRC,
+ .stby_clk_freq = SCALED_FREQ_RC_STDBY_76_8_MHZ,
+ // Disable all power domains.
+ .power_domains = 0,
+ // Add all memories
+ .memory_blocks = SERAM_MASK | SRAM0_MASK | SRAM1_MASK | MRAM_MASK | BACKUP4K_MASK |
+ SRAM6A_MASK | SRAM6B_MASK | SRAM7_1_MASK | SRAM7_2_MASK | SRAM7_3_MASK |
+ SRAM8_MASK | SRAM9_MASK | FWRAM_MASK,
+ .phy_pwr_gating = LDO_PHY_MASK | USB_PHY_MASK | MIPI_TX_DPHY_MASK | MIPI_RX_DPHY_MASK |
+ MIPI_PLL_DPHY_MASK,
+ .vdd_ioflex_3V3 = IOFLEX_LEVEL_3V3,
+ .vtor_address = SCB->VTOR,
+ .vtor_address_ns = SCB->VTOR,
+ .ewic_cfg = EWIC_RTC_A,
+ .wakeup_events = WE_LPRTC,
+ };
+
+ if (se_services_set_off_profile(&off_profile)) {
+ MICROPY_BOARD_FATAL_ERROR("se_services_set_off_profile");
+ }
+
+ // Select PLL for PD4 memory.
+ if (se_services_select_pll_source(PLL_SOURCE_PLL, PLL_TARGET_PD4_SRAM)) {
+ MICROPY_BOARD_FATAL_ERROR("se_services_select_pll_source");
+ }
+}
+
+MP_WEAK void board_enter_stop(void) {
+ // Disable NPU interrupt
+ NVIC_DisableIRQ(NPU_IRQ_NUMBER);
+ NVIC_ClearPendingIRQ(NPU_IRQ_NUMBER);
+
+ // Soft-reset NPU
+ NPU->RESET = 0x00000000;
+
+ // Wait until reset
+ uint32_t data = 0;
+ do {
+ // Poll channel0 status registers
+ data = NPU->STATUS;
+ } while (data);
+
+ // Set default value, enables off for clocks and power.
+ NPU->CMD = 0x0000000C;
+}
+
+MP_WEAK void board_enter_standby(void) {
+
+}
+
+MP_WEAK void board_exit_standby(void) {
+
+}
diff --git a/ports/alif/boards/OPENMV_AE3/board.ld.S b/ports/alif/boards/OPENMV_AE3/board.ld.S
new file mode 100644
index 000000000..0d09bb15f
--- /dev/null
+++ b/ports/alif/boards/OPENMV_AE3/board.ld.S
@@ -0,0 +1,14 @@
+#include "mcu/ensemble.ld.S"
+
+/* Define ROMFS partition locations. */
+#if CORE_M55_HP
+/* The HP core has access to the external OSPI flash and MRAM ROMFS partitions. */
+_micropy_hw_romfs_part0_start = 0xa1000000;
+_micropy_hw_romfs_part0_size = 16M;
+_micropy_hw_romfs_part1_start = ORIGIN(MRAM_FS);
+_micropy_hw_romfs_part1_size = LENGTH(MRAM_FS);
+#else
+/* The HP core has access to the MRAM ROMFS partition. */
+_micropy_hw_romfs_part0_start = ORIGIN(MRAM_FS);
+_micropy_hw_romfs_part0_size = LENGTH(MRAM_FS);
+#endif
diff --git a/ports/alif/boards/OPENMV_AE3/mpconfigboard.h b/ports/alif/boards/OPENMV_AE3/mpconfigboard.h
new file mode 100644
index 000000000..cbdbd063e
--- /dev/null
+++ b/ports/alif/boards/OPENMV_AE3/mpconfigboard.h
@@ -0,0 +1,85 @@
+#define MICROPY_HW_BOARD_NAME "OpenMV-AE3"
+#define MICROPY_HW_MCU_NAME "AE302F80F55D5AE"
+
+#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C)
+typedef intptr_t mp_int_t; // must be pointer size
+typedef uintptr_t mp_uint_t; // must be pointer size
+typedef intptr_t mp_off_t;
+
+#define MICROPY_HW_USB_MSC (CORE_M55_HP)
+#define MICROPY_HW_ENABLE_HW_I2C (1)
+#define MICROPY_HW_ENABLE_OSPI (CORE_M55_HP)
+
+// ROMFS partitions
+#define MICROPY_HW_ROMFS_ENABLE_PART0 (1)
+#define MICROPY_HW_ROMFS_ENABLE_PART1 (CORE_M55_HP)
+
+// I2C buses
+#define MICROPY_HW_I2C1_SCL (pin_P0_5)
+#define MICROPY_HW_I2C1_SDA (pin_P0_4)
+
+#define MICROPY_HW_I2C2_SCL (pin_P5_1)
+#define MICROPY_HW_I2C2_SDA (pin_P5_0)
+
+#define MICROPY_HW_I2C3_SCL (pin_P1_1)
+#define MICROPY_HW_I2C3_SDA (pin_P1_0)
+
+// SPI buses
+#define MICROPY_HW_SPI0_MISO (pin_P5_0)
+#define MICROPY_HW_SPI0_MOSI (pin_P5_1)
+// #define MICROPY_HW_SPI0_NSS (pin_P5_2)
+#define MICROPY_HW_SPI0_SCK (pin_P5_3)
+
+// UART buses
+#define MICROPY_HW_UART1_TX (pin_P0_5)
+#define MICROPY_HW_UART1_RX (pin_P0_4)
+#define MICROPY_HW_UART3_TX (pin_P1_3)
+#define MICROPY_HW_UART3_RX (pin_P1_2)
+#define MICROPY_HW_UART3_RTS (pin_P7_3)
+#define MICROPY_HW_UART3_CTS (pin_P7_2)
+#define MICROPY_HW_UART4_TX (pin_P5_1)
+#define MICROPY_HW_UART4_RX (pin_P5_0)
+#define MICROPY_HW_UART5_TX (pin_P5_3)
+#define MICROPY_HW_UART5_RX (pin_P5_2)
+
+#define MICROPY_HW_USB_VID 0x37C5
+#define MICROPY_HW_USB_PID 0x16E3
+
+#define MICROPY_HW_USB_MANUFACTURER_STRING "OpenMV"
+#define MICROPY_HW_USB_PRODUCT_FS_STRING "OpenMV Camera"
+#define MICROPY_HW_USB_MSC_INQUIRY_VENDOR_STRING "OpenMV"
+
+extern void board_startup(void);
+#define MICROPY_BOARD_STARTUP board_startup
+
+extern void board_early_init(void);
+#define MICROPY_BOARD_EARLY_INIT board_early_init
+
+extern void board_enter_bootloader(void);
+#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) board_enter_bootloader()
+
+extern void board_enter_stop(void);
+#define MICROPY_BOARD_ENTER_STOP board_enter_stop
+
+extern void board_enter_standby(void);
+#define MICROPY_BOARD_ENTER_STANDBY board_enter_standby
+
+extern void board_exit_standby(void);
+#define MICROPY_BOARD_EXIT_STANDBY board_exit_standby
+
+// This is used for alif.Flash() and USB MSC.
+#define MICROPY_HW_FLASH_STORAGE_BASE_ADDR (0)
+#define MICROPY_HW_FLASH_STORAGE_BYTES (32 * 1024 * 1024)
+#define MICROPY_HW_FLASH_STORAGE_FS_BYTES (16 * 1024 * 1024)
+#define MICROPY_HW_FLASH_STORAGE_ROMFS_BYTES (16 * 1024 * 1024)
+
+// Murata 1YN configuration
+#define CYW43_CHIPSET_FIRMWARE_INCLUDE_FILE "lib/cyw43-driver/firmware/w43439_sdio_1yn_7_95_59_combined.h"
+#define CYW43_WIFI_NVRAM_INCLUDE_FILE "lib/cyw43-driver/firmware/wifi_nvram_1yn.h"
+#define CYW43_BT_FIRMWARE_INCLUDE_FILE "lib/cyw43-driver/firmware/cyw43_btfw_1yn.h"
+#define CYW43_BT_UART_BAUDRATE_DOWNLOAD_FIRMWARE (2000000)
+#define CYW43_BT_UART_BAUDRATE_ACTIVE_USE (2000000)
+
+// Bluetooth config
+#define MICROPY_HW_BLE_UART_ID (0)
+#define MICROPY_HW_BLE_UART_BAUDRATE (115200)
diff --git a/ports/alif/boards/OPENMV_AE3/mpconfigboard.mk b/ports/alif/boards/OPENMV_AE3/mpconfigboard.mk
new file mode 100644
index 000000000..83cc17dd1
--- /dev/null
+++ b/ports/alif/boards/OPENMV_AE3/mpconfigboard.mk
@@ -0,0 +1,22 @@
+# TODO: alif_ensemble-cmsis-dfp only supports AE722F80F55D5XX at the moment.
+MCU_SERIES = E7
+MCU_VARIANT = AE722F80F55D5XX
+JLINK_DEV = AE302F80F55D5_HP
+LD_FILE = boards/OPENMV_AE3/board.ld.S
+PORT = /dev/ttyUSB0
+
+ALIF_TOOLKIT_CFG_PART = AE302F80F55D5AE
+ALIF_TOOLKIT_CFG_FILE = \"app-device-config-ae3.json\"
+
+CORE_M55_HP := $(if $(filter M55_HP,$(MCU_CORE)),1,0)
+
+# MicroPython settings
+MICROPY_FLOAT_IMPL = float
+MICROPY_PY_BLUETOOTH = $(CORE_M55_HP)
+MICROPY_BLUETOOTH_NIMBLE = $(CORE_M55_HP)
+MICROPY_PY_LWIP = $(CORE_M55_HP)
+MICROPY_PY_NETWORK_CYW43 = $(CORE_M55_HP)
+MICROPY_PY_SSL = $(CORE_M55_HP)
+MICROPY_SSL_MBEDTLS = $(CORE_M55_HP)
+MICROPY_PY_OPENAMP = 1
+MICROPY_PY_OPENAMP_REMOTEPROC = 1
diff --git a/ports/alif/boards/OPENMV_AE3/ospi_xip_user.h b/ports/alif/boards/OPENMV_AE3/ospi_xip_user.h
new file mode 100644
index 000000000..c0bd9afeb
--- /dev/null
+++ b/ports/alif/boards/OPENMV_AE3/ospi_xip_user.h
@@ -0,0 +1,6 @@
+// This file is needed by ospi_xip/source/ospi/ospi_drv.c.
+#define OSPI_XIP_ENABLE_AES_DECRYPTION (0)
+#define OSPI_XIP_RX_SAMPLE_DELAY (4)
+#define OSPI_XIP_DDR_DRIVE_EDGE (0)
+// floor(1/4 OSPI clock cycle + 3.6ns) * 2
+#define OSPI_XIP_RXDS_DELAY (12)
diff --git a/ports/alif/boards/OPENMV_AE3/pins.csv b/ports/alif/boards/OPENMV_AE3/pins.csv
new file mode 100644
index 000000000..ab4f1a34f
--- /dev/null
+++ b/ports/alif/boards/OPENMV_AE3/pins.csv
@@ -0,0 +1,69 @@
+# USB multiplexer
+USB_D_SEL,P15_0
+USB_D_SEL_FB,P15_1
+
+# LEDs
+LED_RED,P0_0
+LED_GREEN,P6_3
+LED_BLUE,P6_0
+
+# User switch
+USR_SW,P15_7
+
+# Flash on OSPI0
+FLASH_RESET,P3_3
+FLASH_CS,P3_2
+FLASH_SCLK_P,P3_0
+FLASH_SCLK_N,P3_1
+FLASH_DQSM,P1_6
+FLASH_D0,P2_0
+FLASH_D1,P2_1
+FLASH_D2,P2_2
+FLASH_D3,P2_3
+FLASH_D4,P2_4
+FLASH_D5,P2_5
+FLASH_D6,P2_6
+FLASH_D7,P2_7
+
+# Murata 1YN
+BT_UART_RX,P1_4
+BT_UART_TX,P1_5
+BT_UART_CTS,P6_6
+BT_UART_RTS,P6_7
+BT_REG_ON,P5_7
+BT_DEV_WAKE,P9_2
+BT_HOST_WAKE,P13_3
+WL_REG_ON,P10_4
+WL_HOST_WAKE,P11_0
+WL_I2S_SDI,P12_0
+WL_I2S_SDO,P12_1
+WL_I2S_SCLK,P12_2
+WL_I2S_WS,P12_3
+WL_IRQ,P9_6
+WL_MISO,P12_4
+WL_MOSI,P12_5
+WL_SCLK,P12_6
+WL_CS,P12_7
+
+P0,P5_1
+P1,P5_0
+P2,P5_3
+P3,P5_2
+P4,P0_5
+P5,P0_4
+P6,P7_2
+P7,P7_3
+P8,P1_2
+P9,P1_3
+
+# UART buses
+UART1_TX,P0_5
+UART1_RX,P0_4
+UART3_TX,P1_3
+UART3_RX,P1_2
+UART3_RTS,P7_3
+UART3_CTS,P7_2
+UART4_TX,P5_1
+UART4_RX,P5_0
+UART5_TX,P5_3
+UART5_RX,P5_2