summaryrefslogtreecommitdiffstatshomepage
path: root/ports/stm32/boards
diff options
context:
space:
mode:
Diffstat (limited to 'ports/stm32/boards')
-rw-r--r--ports/stm32/boards/NUCLEO_N657X0/bdev.c42
-rw-r--r--ports/stm32/boards/NUCLEO_N657X0/board.c122
-rw-r--r--ports/stm32/boards/NUCLEO_N657X0/board.md17
-rw-r--r--ports/stm32/boards/NUCLEO_N657X0/mpconfigboard.h103
-rw-r--r--ports/stm32/boards/NUCLEO_N657X0/mpconfigboard.mk26
-rw-r--r--ports/stm32/boards/NUCLEO_N657X0/partition_stm32n657xx.h5
-rw-r--r--ports/stm32/boards/NUCLEO_N657X0/pins.csv62
-rw-r--r--ports/stm32/boards/NUCLEO_N657X0/stm32n6xx_hal_conf.h18
-rw-r--r--ports/stm32/boards/OPENMV_N6/bdev.c41
-rw-r--r--ports/stm32/boards/OPENMV_N6/board.c131
-rw-r--r--ports/stm32/boards/OPENMV_N6/board.ld39
-rw-r--r--ports/stm32/boards/OPENMV_N6/manifest.py3
-rw-r--r--ports/stm32/boards/OPENMV_N6/mpconfigboard.h167
-rw-r--r--ports/stm32/boards/OPENMV_N6/mpconfigboard.mk30
-rw-r--r--ports/stm32/boards/OPENMV_N6/partition_stm32n657xx.h5
-rw-r--r--ports/stm32/boards/OPENMV_N6/pins.csv142
-rw-r--r--ports/stm32/boards/OPENMV_N6/stm32n6xx_hal_conf.h18
-rw-r--r--ports/stm32/boards/common_n6_flash.ld57
-rw-r--r--ports/stm32/boards/common_text.ld8
-rwxr-xr-xports/stm32/boards/make-pins.py2
-rw-r--r--ports/stm32/boards/pllvalues.py2
-rw-r--r--ports/stm32/boards/stm32n657_af.csv42
-rw-r--r--ports/stm32/boards/stm32n657x0.ld34
-rw-r--r--ports/stm32/boards/stm32n6xx_hal_conf_base.h215
24 files changed, 1329 insertions, 2 deletions
diff --git a/ports/stm32/boards/NUCLEO_N657X0/bdev.c b/ports/stm32/boards/NUCLEO_N657X0/bdev.c
new file mode 100644
index 0000000000..2180d46174
--- /dev/null
+++ b/ports/stm32/boards/NUCLEO_N657X0/bdev.c
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2025 Damien P. George
+ *
+ * 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/obj.h"
+#include "storage.h"
+#include "xspi.h"
+
+#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
+#error "Cannot enable MICROPY_HW_SPIFLASH_ENABLE_CACHE"
+#endif
+
+// External SPI flash uses hardware XSPI interface.
+const mp_spiflash_config_t spiflash_config = {
+ .bus_kind = MP_SPIFLASH_BUS_QSPI,
+ .bus.u_qspi.data = (void *)&xspi_flash2,
+ .bus.u_qspi.proto = &xspi_proto,
+};
+
+spi_bdev_t spi_bdev;
diff --git a/ports/stm32/boards/NUCLEO_N657X0/board.c b/ports/stm32/boards/NUCLEO_N657X0/board.c
new file mode 100644
index 0000000000..fe5f2f1cc8
--- /dev/null
+++ b/ports/stm32/boards/NUCLEO_N657X0/board.c
@@ -0,0 +1,122 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024-2025 Damien P. George
+ *
+ * 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 "boardctrl.h"
+#include "xspi.h"
+
+// Values for OTP fuses for VDDIO3, to select low voltage mode (<2.5V).
+// See RM0486, Section 5, Table 18.
+#define BSEC_HW_CONFIG_ID (124U)
+#define BSEC_HWS_HSLV_VDDIO3 (1U << 15)
+
+static void board_config_vdd(void) {
+ // TODO: move some of the below code to a common location for all N6 boards?
+
+ // Enable PWR, BSEC and SYSCFG clocks.
+ LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_PWR);
+ LL_APB4_GRP2_EnableClock(LL_APB4_GRP2_PERIPH_BSEC);
+ LL_APB4_GRP2_EnableClock(LL_APB4_GRP2_PERIPH_SYSCFG);
+
+ // Program high speed IO optimization fuses if they aren't already set.
+ uint32_t fuse;
+ BSEC_HandleTypeDef hbsec = { .Instance = BSEC };
+ const uint32_t mask = BSEC_HWS_HSLV_VDDIO3;
+ if (HAL_BSEC_OTP_Read(&hbsec, BSEC_HW_CONFIG_ID, &fuse) != HAL_OK) {
+ fuse = 0;
+ } else if ((fuse & mask) != mask) {
+ // Program the fuse, and read back the set value.
+ if (HAL_BSEC_OTP_Program(&hbsec, BSEC_HW_CONFIG_ID, fuse | mask, HAL_BSEC_NORMAL_PROG) != HAL_OK) {
+ fuse = 0;
+ } else if (HAL_BSEC_OTP_Read(&hbsec, BSEC_HW_CONFIG_ID, &fuse) != HAL_OK) {
+ fuse = 0;
+ }
+ }
+
+ // Enable Vdd ADC, needed for the ADC to work.
+ LL_PWR_EnableVddADC();
+
+ // Configure VDDIO2.
+ LL_PWR_EnableVddIO2();
+ LL_PWR_SetVddIO2VoltageRange(LL_PWR_VDDIO_VOLTAGE_RANGE_3V3);
+ SYSCFG->VDDIO2CCCR |= SYSCFG_VDDIO2CCCR_EN; // enable IO compensation
+
+ // Configure VDDIO3. Only enable 1.8V mode if the fuse is set.
+ LL_PWR_EnableVddIO3();
+ if (fuse & BSEC_HWS_HSLV_VDDIO3) {
+ LL_PWR_SetVddIO3VoltageRange(LL_PWR_VDDIO_VOLTAGE_RANGE_1V8);
+ }
+ SYSCFG->VDDIO3CCCR |= SYSCFG_VDDIO3CCCR_EN; // enable IO compensation
+
+ // Configure VDDIO4.
+ LL_PWR_EnableVddIO4();
+ LL_PWR_SetVddIO4VoltageRange(LL_PWR_VDDIO_VOLTAGE_RANGE_3V3);
+ SYSCFG->VDDIO4CCCR |= SYSCFG_VDDIO4CCCR_EN; // enable IO compensation
+
+ // Enable VDD for ADC and USB.
+ LL_PWR_EnableVddADC();
+ LL_PWR_EnableVddUSB();
+}
+
+void mboot_board_early_init(void) {
+ board_config_vdd();
+ xspi_init();
+}
+
+void board_early_init(void) {
+ #if !MICROPY_HW_RUNS_FROM_EXT_FLASH
+ // Firmware runs directly from SRAM, so configure VDD and enable XSPI flash.
+ board_config_vdd();
+ xspi_init();
+ #endif
+}
+
+void board_leave_standby(void) {
+ // TODO: move some of the below code to a common location for all N6 boards?
+
+ // Enable PWR, BSEC and SYSCFG clocks.
+ LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_PWR);
+ LL_APB4_GRP2_EnableClock(LL_APB4_GRP2_PERIPH_BSEC);
+ LL_APB4_GRP2_EnableClock(LL_APB4_GRP2_PERIPH_SYSCFG);
+
+ // Configure VDDIO2.
+ LL_PWR_EnableVddIO2();
+ LL_PWR_SetVddIO2VoltageRange(LL_PWR_VDDIO_VOLTAGE_RANGE_3V3);
+ SYSCFG->VDDIO2CCCR |= SYSCFG_VDDIO2CCCR_EN; // enable IO compensation
+
+ // Configure VDDIO3 (1.8V mode selection is retained).
+ LL_PWR_EnableVddIO3();
+ SYSCFG->VDDIO3CCCR |= SYSCFG_VDDIO3CCCR_EN; // enable IO compensation
+
+ // Configure VDDIO4.
+ LL_PWR_EnableVddIO4();
+ LL_PWR_SetVddIO4VoltageRange(LL_PWR_VDDIO_VOLTAGE_RANGE_3V3);
+ SYSCFG->VDDIO4CCCR |= SYSCFG_VDDIO4CCCR_EN; // enable IO compensation
+
+ // Enable VDD for ADC and USB.
+ LL_PWR_EnableVddADC();
+ LL_PWR_EnableVddUSB();
+}
diff --git a/ports/stm32/boards/NUCLEO_N657X0/board.md b/ports/stm32/boards/NUCLEO_N657X0/board.md
new file mode 100644
index 0000000000..3360c5db6c
--- /dev/null
+++ b/ports/stm32/boards/NUCLEO_N657X0/board.md
@@ -0,0 +1,17 @@
+The mboot bootloader must first be built and deployed to this board. Make sure that
+CN9 is in position 1-2 to select STLK as the 5V power source, that JP1 is in position
+1-2 (lower position) and JP2 is in position 2-3 (upper position). Then plug in a USB
+cable into the ST-LINK port CN10. This will allow mboot firmware to be programmed to
+the external SPI flash via ST's tools, eg:
+
+ make -C ports/stm32/mboot BOARD=NUCLEO_N657X0 deploy-trusted
+
+Once mboot is installed, change CN9 to position 3-4 to select USB as the 5V power
+source, change JP2 back to position 1-2 (lower position) and change the USB cable to
+CN8. mboot will present a USB DFU device on this USB port, and the red LED2 should be
+blinking at 1Hz to indicate that mboot is active. If it's not active then hold the
+USER button and press NRST, and wait until all three LEDs are on, then release USER.
+Now mboot will be active.
+
+Once the USB DFU port can be seen, the firmware below can be programmed as usual with
+any DFU loader.
diff --git a/ports/stm32/boards/NUCLEO_N657X0/mpconfigboard.h b/ports/stm32/boards/NUCLEO_N657X0/mpconfigboard.h
new file mode 100644
index 0000000000..ccc3fa051f
--- /dev/null
+++ b/ports/stm32/boards/NUCLEO_N657X0/mpconfigboard.h
@@ -0,0 +1,103 @@
+#define MICROPY_HW_BOARD_NAME "NUCLEO-N657X0"
+#define MICROPY_HW_MCU_NAME "STM32N657X0"
+
+#define MICROPY_GC_STACK_ENTRY_TYPE uint32_t
+#define MICROPY_ALLOC_GC_STACK_SIZE (128)
+#define MICROPY_FATFS_EXFAT (1)
+
+#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
+#define MICROPY_HW_HAS_SWITCH (1)
+#define MICROPY_HW_HAS_FLASH (1)
+#define MICROPY_HW_ENABLE_RNG (1)
+#define MICROPY_HW_ENABLE_RTC (1)
+#define MICROPY_HW_ENABLE_DAC (0)
+#define MICROPY_HW_ENABLE_USB (1)
+#define MICROPY_PY_PYB_LEGACY (0)
+
+#define MICROPY_BOARD_EARLY_INIT board_early_init
+#define MICROPY_BOARD_LEAVE_STANDBY board_leave_standby()
+
+// HSE is 48MHz, this gives a CPU frequency of 800MHz.
+#define MICROPY_HW_CLK_PLLM (6)
+#define MICROPY_HW_CLK_PLLN (100)
+#define MICROPY_HW_CLK_PLLP1 (1)
+#define MICROPY_HW_CLK_PLLP2 (1)
+#define MICROPY_HW_CLK_PLLFRAC (0)
+
+// The LSE is a 32kHz crystal.
+#define MICROPY_HW_RTC_USE_LSE (1)
+#define MICROPY_HW_RTC_USE_US (1)
+
+// External SPI flash, MX25UM51245GXDI00.
+#define MICROPY_HW_XSPIFLASH_SIZE_BITS_LOG2 (29)
+
+// SPI flash, block device config.
+#define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev)
+#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev)
+#define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config)
+#define MICROPY_HW_BDEV_SPIFLASH_OFFSET_BYTES (4 * 1024 * 1024)
+#define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES (60 * 1024 * 1024)
+
+// UART buses
+#define MICROPY_HW_UART1_TX (pyb_pin_UART1_TX)
+#define MICROPY_HW_UART1_RX (pyb_pin_UART1_RX)
+#define MICROPY_HW_UART3_TX (pyb_pin_UART3_TX)
+#define MICROPY_HW_UART3_RX (pyb_pin_UART3_RX)
+#define MICROPY_HW_UART_REPL (PYB_UART_1)
+#define MICROPY_HW_UART_REPL_BAUD (115200)
+
+// I2C buses
+#define MICROPY_HW_I2C1_SCL (pyb_pin_I2C1_SCL)
+#define MICROPY_HW_I2C1_SDA (pyb_pin_I2C1_SDA)
+
+// SPI buses
+#define MICROPY_HW_SPI5_NSS (pyb_pin_SPI5_CS)
+#define MICROPY_HW_SPI5_SCK (pyb_pin_SPI5_SCK)
+#define MICROPY_HW_SPI5_MISO (pyb_pin_SPI5_MISO)
+#define MICROPY_HW_SPI5_MOSI (pyb_pin_SPI5_MOSI)
+
+// USER2 is floating, and pressing the button makes the input go high.
+#define MICROPY_HW_USRSW_PIN (pyb_pin_BUTTON)
+#define MICROPY_HW_USRSW_PULL (GPIO_PULLDOWN)
+#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
+#define MICROPY_HW_USRSW_PRESSED (1)
+
+// LEDs
+#define MICROPY_HW_LED1 (pyb_pin_LED_RED)
+#define MICROPY_HW_LED2 (pyb_pin_LED_GREEN)
+#define MICROPY_HW_LED3 (pyb_pin_LED_BLUE)
+#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
+#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
+
+// USB config
+#define MICROPY_HW_USB_HS (1)
+#define MICROPY_HW_USB_HS_IN_FS (1)
+#define MICROPY_HW_USB_MAIN_DEV (USB_PHY_HS_ID)
+
+/******************************************************************************/
+// Bootloader configuration
+
+#define MBOOT_BOARD_EARLY_INIT(initial_r0) mboot_board_early_init()
+
+#define MBOOT_SPIFLASH_CS (pyb_pin_XSPIM_P2_CS)
+#define MBOOT_SPIFLASH_SCK (pyb_pin_XSPIM_P2_SCK)
+#define MBOOT_SPIFLASH_MOSI (pyb_pin_XSPIM_P2_IO0)
+#define MBOOT_SPIFLASH_MISO (pyb_pin_XSPIM_P2_IO1)
+#define MBOOT_SPIFLASH_ADDR (0x70000000)
+#define MBOOT_SPIFLASH_BYTE_SIZE (64 * 1024 * 1024)
+#define MBOOT_SPIFLASH_LAYOUT "/0x70000000/16384*4Kg"
+#define MBOOT_SPIFLASH_ERASE_BLOCKS_PER_PAGE (1)
+#define MBOOT_SPIFLASH_SPIFLASH (&spi_bdev.spiflash)
+#define MBOOT_SPIFLASH_CONFIG (&spiflash_config)
+
+/******************************************************************************/
+// Function and variable declarations
+
+extern const struct _mp_spiflash_config_t spiflash_config;
+extern struct _spi_bdev_t spi_bdev;
+
+void mboot_board_early_init(void);
+void mboot_board_entry_init(void);
+
+void board_early_init(void);
+void board_leave_standby(void);
diff --git a/ports/stm32/boards/NUCLEO_N657X0/mpconfigboard.mk b/ports/stm32/boards/NUCLEO_N657X0/mpconfigboard.mk
new file mode 100644
index 0000000000..fa64cb1706
--- /dev/null
+++ b/ports/stm32/boards/NUCLEO_N657X0/mpconfigboard.mk
@@ -0,0 +1,26 @@
+# Without mboot, the main firmware must fit in 512k flash, will be copied to SRAM by
+# the hardware bootloader, and will run from SRAM. With mboot, the main firmware can
+# be much larger and will run from flash via XSPI in memory-mapped mode.
+USE_MBOOT ?= 1
+
+MCU_SERIES = n6
+CMSIS_MCU = STM32N657xx
+AF_FILE = boards/stm32n657_af.csv
+ifeq ($(BUILDING_MBOOT),1)
+SYSTEM_FILE = $(STM32LIB_CMSIS_BASE)/Source/Templates/system_stm32$(MCU_SERIES)xx_fsbl.o
+else
+SYSTEM_FILE = $(STM32LIB_CMSIS_BASE)/Source/Templates/system_stm32$(MCU_SERIES)xx_s.o
+endif
+STM32_N6_HEADER_VERSION = 2.1
+DKEL = $(STM32_CUBE_PROGRAMMER)/bin/ExternalLoader/MX25UM51245G_STM32N6570-NUCLEO.stldr
+
+ifeq ($(USE_MBOOT),1)
+LD_FILES = boards/stm32n657x0.ld boards/common_n6_flash.ld
+TEXT0_ADDR = 0x70080000
+else
+LD_FILES = boards/stm32n657x0.ld boards/common_basic.ld
+TEXT0_ADDR = 0x34180400
+endif
+
+# MicroPython settings
+MICROPY_FLOAT_IMPL = double
diff --git a/ports/stm32/boards/NUCLEO_N657X0/partition_stm32n657xx.h b/ports/stm32/boards/NUCLEO_N657X0/partition_stm32n657xx.h
new file mode 100644
index 0000000000..ac38dac748
--- /dev/null
+++ b/ports/stm32/boards/NUCLEO_N657X0/partition_stm32n657xx.h
@@ -0,0 +1,5 @@
+// This board does not use any security settings, so can just stay in secure
+// mode without configuring the SAU.
+
+static inline void TZ_SAU_Setup(void) {
+}
diff --git a/ports/stm32/boards/NUCLEO_N657X0/pins.csv b/ports/stm32/boards/NUCLEO_N657X0/pins.csv
new file mode 100644
index 0000000000..033f0a552e
--- /dev/null
+++ b/ports/stm32/boards/NUCLEO_N657X0/pins.csv
@@ -0,0 +1,62 @@
+D0,PD9
+D1,PD8
+D2,PD0
+D3,PE9
+D4,PE0
+D5,PE10
+D6,PD5
+D7,PE11
+D8,PD12
+D9,PD7
+D10,PA3
+D11,PG2
+D12,PG1
+D13,PE15
+D14,PC1
+D15,PH9
+
+# Ax header pins are connected directly to the following digital IO
+A0D,PF5
+A1D,PC10
+A2D,PF6
+A3D,PA2
+A4D,PC12
+A5D,PH2
+
+# Ax header pins are connected to the following analog IO via an op-amp in voltage-follower mode running at 1.8V
+A0,PA8
+A1,PA9
+A2,PA10
+A3,PA12
+A4,PF3
+A5,PG15
+
+-UART1_TX,PE5
+-UART1_RX,PE6
+-UART3_TX,PD8
+-UART3_RX,PD9
+
+-I2C1_SCL,PH9
+-I2C1_SDA,PC1
+
+-SPI5_CS,PA3
+-SPI5_SCK,PE15
+-SPI5_MISO,PG1
+-SPI5_MOSI,PG2
+
+-BUTTON,PC13
+LED_BLUE,PG8
+LED_RED,PG10
+LED_GREEN,PG0
+
+-XSPIM_P2_DQS,PN0
+-XSPIM_P2_CS,PN1
+-XSPIM_P2_IO0,PN2
+-XSPIM_P2_IO1,PN3
+-XSPIM_P2_IO2,PN4
+-XSPIM_P2_IO3,PN5
+-XSPIM_P2_SCK,PN6
+-XSPIM_P2_IO4,PN8
+-XSPIM_P2_IO5,PN9
+-XSPIM_P2_IO6,PN10
+-XSPIM_P2_IO7,PN11
diff --git a/ports/stm32/boards/NUCLEO_N657X0/stm32n6xx_hal_conf.h b/ports/stm32/boards/NUCLEO_N657X0/stm32n6xx_hal_conf.h
new file mode 100644
index 0000000000..4012d56e5a
--- /dev/null
+++ b/ports/stm32/boards/NUCLEO_N657X0/stm32n6xx_hal_conf.h
@@ -0,0 +1,18 @@
+/* This file is part of the MicroPython project, http://micropython.org/
+ * The MIT License (MIT)
+ * Copyright (c) 2019 Damien P. George
+ */
+#ifndef MICROPY_INCLUDED_STM32N6XX_HAL_CONF_H
+#define MICROPY_INCLUDED_STM32N6XX_HAL_CONF_H
+
+// Oscillator values in Hz
+#define HSE_VALUE (48000000)
+#define LSE_VALUE (32768)
+
+// Oscillator timeouts in ms
+#define HSE_STARTUP_TIMEOUT (100)
+#define LSE_STARTUP_TIMEOUT (5000)
+
+#include "boards/stm32n6xx_hal_conf_base.h"
+
+#endif // MICROPY_INCLUDED_STM32N6XX_HAL_CONF_H
diff --git a/ports/stm32/boards/OPENMV_N6/bdev.c b/ports/stm32/boards/OPENMV_N6/bdev.c
new file mode 100644
index 0000000000..c6c918bd67
--- /dev/null
+++ b/ports/stm32/boards/OPENMV_N6/bdev.c
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2025 Damien P. George
+ *
+ * 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 "storage.h"
+#include "xspi.h"
+
+#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
+#error "Cannot enable MICROPY_HW_SPIFLASH_ENABLE_CACHE"
+#endif
+
+// External SPI flash uses hardware XSPI interface.
+const mp_spiflash_config_t spiflash_config = {
+ .bus_kind = MP_SPIFLASH_BUS_QSPI,
+ .bus.u_qspi.data = (void *)&xspi_flash2,
+ .bus.u_qspi.proto = &xspi_proto,
+};
+
+spi_bdev_t spi_bdev;
diff --git a/ports/stm32/boards/OPENMV_N6/board.c b/ports/stm32/boards/OPENMV_N6/board.c
new file mode 100644
index 0000000000..1f82d10bac
--- /dev/null
+++ b/ports/stm32/boards/OPENMV_N6/board.c
@@ -0,0 +1,131 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024-2025 Damien P. George
+ *
+ * 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 "boardctrl.h"
+#include "xspi.h"
+
+// Values for OTP fuses for VDDIO2/3, to select low voltage mode (<2.5V).
+// See RM0486, Section 5, Table 18.
+#define BSEC_HW_CONFIG_ID (124U)
+#define BSEC_HWS_HSLV_VDDIO3 (1U << 15)
+#define BSEC_HWS_HSLV_VDDIO2 (1U << 16)
+
+#define OMV_BOOT_MAGIC_ADDR (0x3401FFFCU)
+#define OMV_BOOT_MAGIC_VALUE (0xB00710ADU)
+
+void mboot_board_early_init(void) {
+ // TODO: move some of the below code to a common location for all N6 boards?
+
+ // Enable PWR, BSEC and SYSCFG clocks.
+ LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_PWR);
+ LL_APB4_GRP2_EnableClock(LL_APB4_GRP2_PERIPH_BSEC);
+ LL_APB4_GRP2_EnableClock(LL_APB4_GRP2_PERIPH_SYSCFG);
+
+ // Program high speed IO optimization fuses if they aren't already set.
+ uint32_t fuse;
+ BSEC_HandleTypeDef hbsec = { .Instance = BSEC };
+ const uint32_t mask = BSEC_HWS_HSLV_VDDIO2 | BSEC_HWS_HSLV_VDDIO3;
+ if (HAL_BSEC_OTP_Read(&hbsec, BSEC_HW_CONFIG_ID, &fuse) != HAL_OK) {
+ fuse = 0;
+ } else if ((fuse & mask) != mask) {
+ // Program the fuse, and read back the set value.
+ if (HAL_BSEC_OTP_Program(&hbsec, BSEC_HW_CONFIG_ID, fuse | mask, HAL_BSEC_NORMAL_PROG) != HAL_OK) {
+ fuse = 0;
+ } else if (HAL_BSEC_OTP_Read(&hbsec, BSEC_HW_CONFIG_ID, &fuse) != HAL_OK) {
+ fuse = 0;
+ }
+ }
+
+ // Enable Vdd ADC, needed for the ADC to work.
+ LL_PWR_EnableVddADC();
+
+ // Configure VDDIO2. Only enable 1.8V mode if the fuse is set.
+ LL_PWR_EnableVddIO2();
+ if (fuse & BSEC_HWS_HSLV_VDDIO2) {
+ LL_PWR_SetVddIO2VoltageRange(LL_PWR_VDDIO_VOLTAGE_RANGE_1V8);
+ }
+ SYSCFG->VDDIO2CCCR |= SYSCFG_VDDIO2CCCR_EN; // enable IO compensation
+
+ // Configure VDDIO3. Only enable 1.8V mode if the fuse is set.
+ LL_PWR_EnableVddIO3();
+ if (fuse & BSEC_HWS_HSLV_VDDIO3) {
+ LL_PWR_SetVddIO3VoltageRange(LL_PWR_VDDIO_VOLTAGE_RANGE_1V8);
+ }
+ SYSCFG->VDDIO3CCCR |= SYSCFG_VDDIO3CCCR_EN; // enable IO compensation
+
+ // Configure VDDIO4.
+ LL_PWR_EnableVddIO4();
+ LL_PWR_SetVddIO4VoltageRange(LL_PWR_VDDIO_VOLTAGE_RANGE_3V3);
+ SYSCFG->VDDIO4CCCR |= SYSCFG_VDDIO4CCCR_EN; // enable IO compensation
+
+ // Enable VDD for ADC and USB.
+ LL_PWR_EnableVddADC();
+ LL_PWR_EnableVddUSB();
+
+ // Enable XSPI in memory-mapped mode.
+ xspi_init();
+}
+
+void board_enter_bootloader(unsigned int n_args, const void *args) {
+ // Support both OpenMV bootloader and mboot.
+ *((uint32_t *)OMV_BOOT_MAGIC_ADDR) = OMV_BOOT_MAGIC_VALUE;
+ SCB_CleanDCache();
+ boardctrl_maybe_enter_mboot(n_args, args);
+}
+
+void board_early_init(void) {
+ // TODO: if (HAL_PWREx_ConfigSupply(PWR_EXTERNAL_SOURCE_SUPPLY ) != HAL_OK)
+
+ LL_PWR_EnableWakeUpPin(LL_PWR_WAKEUP_PIN3 | LL_PWR_WAKEUP_PIN2);
+ LL_PWR_SetWakeUpPinPolarityLow(LL_PWR_WAKEUP_PIN3 | LL_PWR_WAKEUP_PIN2);
+}
+
+void board_leave_standby(void) {
+ // TODO: move some of the below code to a common location for all N6 boards?
+
+ // Enable PWR, BSEC and SYSCFG clocks.
+ LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_PWR);
+ LL_APB4_GRP2_EnableClock(LL_APB4_GRP2_PERIPH_BSEC);
+ LL_APB4_GRP2_EnableClock(LL_APB4_GRP2_PERIPH_SYSCFG);
+
+ // Configure VDDIO2 (1.8V mode selection is retained).
+ LL_PWR_EnableVddIO2();
+ SYSCFG->VDDIO2CCCR |= SYSCFG_VDDIO2CCCR_EN; // enable IO compensation
+
+ // Configure VDDIO3 (1.8V mode selection is retained).
+ LL_PWR_EnableVddIO3();
+ SYSCFG->VDDIO3CCCR |= SYSCFG_VDDIO3CCCR_EN; // enable IO compensation
+
+ // Configure VDDIO4.
+ LL_PWR_EnableVddIO4();
+ LL_PWR_SetVddIO4VoltageRange(LL_PWR_VDDIO_VOLTAGE_RANGE_3V3);
+ SYSCFG->VDDIO4CCCR |= SYSCFG_VDDIO4CCCR_EN; // enable IO compensation
+
+ // Enable VDD for ADC and USB.
+ LL_PWR_EnableVddADC();
+ LL_PWR_EnableVddUSB();
+}
diff --git a/ports/stm32/boards/OPENMV_N6/board.ld b/ports/stm32/boards/OPENMV_N6/board.ld
new file mode 100644
index 0000000000..e9ded785f2
--- /dev/null
+++ b/ports/stm32/boards/OPENMV_N6/board.ld
@@ -0,0 +1,39 @@
+/*
+ Linker script for OPENMV_N6.
+
+ Note: upper 512k of SRAM2 is copied from external flash upon reset.
+*/
+
+/* Specify the memory areas */
+MEMORY
+{
+ FLEXRAM_S (xrw) : ORIGIN = 0x34000000, LENGTH = 80K
+ SRAM2_S_RAM (xrw) : ORIGIN = 0x34100000, LENGTH = 1024K
+ SRAM2_S_FSBL (xrw) : ORIGIN = 0x34180400, LENGTH = 511K /* mboot firmware, not needed after mboot exits */
+ EXT_FLASH (rx) : ORIGIN = 0x70080000, LENGTH = 3584K
+ EXT_FLASH_FS (rx) : ORIGIN = 0x70400000, LENGTH = 4M
+ EXT_FLASH_ROMFS (rx) : ORIGIN = 0x70800000, LENGTH = 24M
+}
+
+REGION_ALIAS("IRAM", FLEXRAM_S);
+REGION_ALIAS("RAM", SRAM2_S_RAM);
+REGION_ALIAS("FLASH_APP", EXT_FLASH);
+
+/* produce a link error if there is not this amount of RAM for these sections */
+_minimum_stack_size = 2K;
+_minimum_heap_size = 16K;
+
+/* Define the stack. The stack is full descending so begins just above last byte
+ of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
+_estack = ORIGIN(RAM) + LENGTH(RAM) - _estack_reserve;
+_sstack = _estack - 16K; /* tunable */
+
+/* RAM extents for the garbage collector */
+_ram_start = ORIGIN(RAM);
+_ram_end = ORIGIN(RAM) + LENGTH(RAM);
+_heap_start = _ebss; /* heap starts just after statically allocated memory */
+_heap_end = _sstack;
+
+/* ROMFS location */
+_micropy_hw_romfs_part0_start = ORIGIN(EXT_FLASH_ROMFS);
+_micropy_hw_romfs_part0_size = LENGTH(EXT_FLASH_ROMFS);
diff --git a/ports/stm32/boards/OPENMV_N6/manifest.py b/ports/stm32/boards/OPENMV_N6/manifest.py
new file mode 100644
index 0000000000..62990220f3
--- /dev/null
+++ b/ports/stm32/boards/OPENMV_N6/manifest.py
@@ -0,0 +1,3 @@
+include("$(PORT_DIR)/boards/manifest.py")
+require("bundle-networking")
+require("aioble")
diff --git a/ports/stm32/boards/OPENMV_N6/mpconfigboard.h b/ports/stm32/boards/OPENMV_N6/mpconfigboard.h
new file mode 100644
index 0000000000..ed7bb548a1
--- /dev/null
+++ b/ports/stm32/boards/OPENMV_N6/mpconfigboard.h
@@ -0,0 +1,167 @@
+#define MICROPY_HW_BOARD_NAME "OpenMV N6"
+#define MICROPY_HW_MCU_NAME "STM32N657X0"
+
+#define MICROPY_GC_STACK_ENTRY_TYPE uint32_t
+#define MICROPY_ALLOC_GC_STACK_SIZE (128)
+#define MICROPY_FATFS_EXFAT (1)
+
+#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
+#define MICROPY_HW_HAS_SWITCH (0)
+#define MICROPY_HW_HAS_FLASH (1)
+#define MICROPY_HW_SDCARD_MOUNT_AT_BOOT (0)
+#define MICROPY_HW_ENABLE_RNG (1)
+#define MICROPY_HW_ENABLE_RTC (1)
+#define MICROPY_HW_ENABLE_DAC (0)
+#define MICROPY_HW_ENABLE_USB (1)
+#define MICROPY_HW_ENABLE_SDCARD (1)
+#define MICROPY_PY_PYB_LEGACY (0)
+
+#define MICROPY_BOARD_ENTER_BOOTLOADER board_enter_bootloader
+#define MICROPY_BOARD_EARLY_INIT board_early_init
+#define MICROPY_BOARD_LEAVE_STANDBY board_leave_standby()
+
+// HSE is 48MHz, this gives a CPU frequency of 800MHz.
+#define MICROPY_HW_CLK_PLLM (6)
+#define MICROPY_HW_CLK_PLLN (100)
+#define MICROPY_HW_CLK_PLLP1 (1)
+#define MICROPY_HW_CLK_PLLP2 (1)
+#define MICROPY_HW_CLK_PLLFRAC (0)
+
+// The LSE is a 32kHz crystal.
+#define MICROPY_HW_RTC_USE_LSE (1)
+#define MICROPY_HW_RTC_USE_US (1)
+
+// External SPI flash.
+#define MICROPY_HW_XSPIFLASH_SIZE_BITS_LOG2 (28) // 256Mbit
+
+// ROMFS config
+#define MICROPY_HW_ROMFS_ENABLE_EXTERNAL_XSPI (1)
+#define MICROPY_HW_ROMFS_XSPI_SPIBDEV_OBJ (&spi_bdev)
+#define MICROPY_HW_ROMFS_ENABLE_PART0 (1)
+
+// SPI flash, block device config.
+#define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev)
+#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev)
+#define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config)
+#define MICROPY_HW_BDEV_SPIFLASH_OFFSET_BYTES (4 * 1024 * 1024)
+#define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES (4 * 1024 * 1024)
+
+// UART buses
+#define MICROPY_HW_UART2_TX (pyb_pin_BT_TXD)
+#define MICROPY_HW_UART2_RX (pyb_pin_BT_RXD)
+#define MICROPY_HW_UART2_RTS (pyb_pin_BT_RTS)
+#define MICROPY_HW_UART2_CTS (pyb_pin_BT_CTS)
+#define MICROPY_HW_UART3_TX (pyb_pin_UART3_TX)
+#define MICROPY_HW_UART3_RX (pyb_pin_UART3_RX)
+#define MICROPY_HW_UART4_TX (pyb_pin_UART4_TX)
+#define MICROPY_HW_UART4_RX (pyb_pin_UART4_RX)
+#define MICROPY_HW_UART7_TX (pyb_pin_UART7_TX)
+#define MICROPY_HW_UART7_RX (pyb_pin_UART7_RX)
+
+// I2C buses
+#define MICROPY_HW_I2C2_SCL (pyb_pin_I2C2_SCL)
+#define MICROPY_HW_I2C2_SDA (pyb_pin_I2C2_SDA)
+#define MICROPY_HW_I2C4_SCL (pyb_pin_I2C4_SCL)
+#define MICROPY_HW_I2C4_SDA (pyb_pin_I2C4_SDA)
+
+// SPI buses
+#define MICROPY_HW_SPI2_NSS (pyb_pin_SPI2_CS)
+#define MICROPY_HW_SPI2_SCK (pyb_pin_SPI2_SCK)
+#define MICROPY_HW_SPI2_MISO (pyb_pin_SPI2_MISO)
+#define MICROPY_HW_SPI2_MOSI (pyb_pin_SPI2_MOSI)
+#define MICROPY_HW_SPI4_NSS (pyb_pin_SPI4_CS)
+#define MICROPY_HW_SPI4_SCK (pyb_pin_SPI4_SCK)
+#define MICROPY_HW_SPI4_MISO (pyb_pin_SPI4_MISO)
+#define MICROPY_HW_SPI4_MOSI (pyb_pin_SPI4_MOSI)
+
+// USER is pulled high, and pressing the button makes the input go low.
+#define MICROPY_HW_USRSW_PIN (pyb_pin_BUTTON)
+#define MICROPY_HW_USRSW_PULL (GPIO_NOPULL)
+#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
+#define MICROPY_HW_USRSW_PRESSED (0)
+
+// LEDs
+#define MICROPY_HW_LED1 (pyb_pin_LED_RED)
+#define MICROPY_HW_LED2 (pyb_pin_LED_GREEN)
+#define MICROPY_HW_LED3 (pyb_pin_LED_BLUE)
+#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
+#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
+
+// SD Card SDMMC
+// SD_VSELECT: low(default)=3.3V IO, high=1.8V IO
+// SD_RESET: drive low to turn off SD VCC (pulled high by default)
+// SD_DETECT: pulled high in hardware, goes low when SD inserted
+#define MICROPY_HW_SDCARD_SDMMC (1)
+#define MICROPY_HW_SDCARD_CK (pyb_pin_SD_SDIO_CK)
+#define MICROPY_HW_SDCARD_CMD (pyb_pin_SD_SDIO_CMD)
+#define MICROPY_HW_SDCARD_D0 (pyb_pin_SD_SDIO_D0)
+#define MICROPY_HW_SDCARD_D1 (pyb_pin_SD_SDIO_D1)
+#define MICROPY_HW_SDCARD_D2 (pyb_pin_SD_SDIO_D2)
+#define MICROPY_HW_SDCARD_D3 (pyb_pin_SD_SDIO_D3)
+#define MICROPY_HW_SDCARD_DETECT_PIN (pyb_pin_SD_DETECT)
+#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_NOPULL)
+#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
+
+// WiFi SDMMC
+#define MICROPY_HW_SDIO_SDMMC (2)
+#define MICROPY_HW_SDIO_CK (pyb_pin_WL_SDIO_CK)
+#define MICROPY_HW_SDIO_CMD (pyb_pin_WL_SDIO_CMD)
+#define MICROPY_HW_SDIO_D0 (pyb_pin_WL_SDIO_D0)
+#define MICROPY_HW_SDIO_D1 (pyb_pin_WL_SDIO_D1)
+#define MICROPY_HW_SDIO_D2 (pyb_pin_WL_SDIO_D2)
+#define MICROPY_HW_SDIO_D3 (pyb_pin_WL_SDIO_D3)
+
+// USB config
+#define MICROPY_HW_USB_HS (1)
+#define MICROPY_HW_USB_HS_IN_FS (1)
+#define MICROPY_HW_USB_MAIN_DEV (USB_PHY_HS_ID)
+#define MICROPY_HW_USB_VID 0x37C5
+#define MICROPY_HW_USB_PID 0x1206
+#define MICROPY_HW_USB_PID_CDC (MICROPY_HW_USB_PID)
+#define MICROPY_HW_USB_PID_MSC (MICROPY_HW_USB_PID)
+#define MICROPY_HW_USB_PID_CDC_MSC (MICROPY_HW_USB_PID)
+#define MICROPY_HW_USB_PID_CDC_HID (MICROPY_HW_USB_PID)
+#define MICROPY_HW_USB_PID_CDC_MSC_HID (MICROPY_HW_USB_PID)
+
+// 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"
+
+// Bluetooth config
+#define MICROPY_HW_BLE_UART_ID (PYB_UART_2)
+#define MICROPY_HW_BLE_UART_BAUDRATE (115200)
+#define MICROPY_HW_BLE_UART_BAUDRATE_SECONDARY (3000000)
+#define MICROPY_HW_BLE_UART_BAUDRATE_DOWNLOAD_FIRMWARE (3000000)
+
+/******************************************************************************/
+// Bootloader configuration
+
+#define MBOOT_BOARD_EARLY_INIT(initial_r0) mboot_board_early_init()
+
+#define MBOOT_FSLOAD (1)
+#define MBOOT_VFS_FAT (1)
+
+#define MBOOT_SPIFLASH_CS (pyb_pin_XSPIM_P2_CS)
+#define MBOOT_SPIFLASH_SCK (pyb_pin_XSPIM_P2_SCK)
+#define MBOOT_SPIFLASH_MOSI (pyb_pin_XSPIM_P2_IO0)
+#define MBOOT_SPIFLASH_MISO (pyb_pin_XSPIM_P2_IO1)
+#define MBOOT_SPIFLASH_ADDR (0x70000000)
+#define MBOOT_SPIFLASH_BYTE_SIZE (32 * 1024 * 1024)
+#define MBOOT_SPIFLASH_LAYOUT "/0x70000000/8192*4Kg"
+#define MBOOT_SPIFLASH_ERASE_BLOCKS_PER_PAGE (1)
+#define MBOOT_SPIFLASH_SPIFLASH (&spi_bdev.spiflash)
+#define MBOOT_SPIFLASH_CONFIG (&spiflash_config)
+
+/******************************************************************************/
+// Function and variable declarations
+
+extern const struct _mp_spiflash_config_t spiflash_config;
+extern struct _spi_bdev_t spi_bdev;
+
+void mboot_board_early_init(void);
+void mboot_board_entry_init(void);
+
+void board_enter_bootloader(unsigned int n_args, const void *args);
+void board_early_init(void);
+void board_leave_standby(void);
diff --git a/ports/stm32/boards/OPENMV_N6/mpconfigboard.mk b/ports/stm32/boards/OPENMV_N6/mpconfigboard.mk
new file mode 100644
index 0000000000..0283a486c1
--- /dev/null
+++ b/ports/stm32/boards/OPENMV_N6/mpconfigboard.mk
@@ -0,0 +1,30 @@
+# This board requires a bootloader, either mboot or OpenMV's bootloader.
+USE_MBOOT = 1
+
+MCU_SERIES = n6
+CMSIS_MCU = STM32N657xx
+AF_FILE = boards/stm32n657_af.csv
+ifeq ($(BUILDING_MBOOT),1)
+SYSTEM_FILE = $(STM32LIB_CMSIS_BASE)/Source/Templates/system_stm32$(MCU_SERIES)xx_fsbl.o
+else
+SYSTEM_FILE = $(STM32LIB_CMSIS_BASE)/Source/Templates/system_stm32$(MCU_SERIES)xx_s.o
+endif
+STM32_N6_HEADER_VERSION = 2.3
+DKEL = $(STM32_CUBE_PROGRAMMER)/bin/ExternalLoader/MX25UM51245G_STM32N6570-NUCLEO.stldr
+
+LD_FILES = boards/OPENMV_N6/board.ld boards/common_n6_flash.ld
+TEXT0_ADDR = 0x70080000
+
+# MicroPython settings
+MICROPY_FLOAT_IMPL = double
+MICROPY_PY_BLUETOOTH ?= 1
+MICROPY_BLUETOOTH_NIMBLE ?= 1
+MICROPY_BLUETOOTH_BTSTACK ?= 0
+MICROPY_PY_LWIP ?= 1
+MICROPY_PY_NETWORK_CYW43 ?= 1
+MICROPY_PY_SSL ?= 1
+MICROPY_SSL_MBEDTLS ?= 1
+MICROPY_VFS_LFS2 ?= 1
+
+# Board specific frozen modules
+FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest.py
diff --git a/ports/stm32/boards/OPENMV_N6/partition_stm32n657xx.h b/ports/stm32/boards/OPENMV_N6/partition_stm32n657xx.h
new file mode 100644
index 0000000000..ac38dac748
--- /dev/null
+++ b/ports/stm32/boards/OPENMV_N6/partition_stm32n657xx.h
@@ -0,0 +1,5 @@
+// This board does not use any security settings, so can just stay in secure
+// mode without configuring the SAU.
+
+static inline void TZ_SAU_Setup(void) {
+}
diff --git a/ports/stm32/boards/OPENMV_N6/pins.csv b/ports/stm32/boards/OPENMV_N6/pins.csv
new file mode 100644
index 0000000000..b05b8b57f9
--- /dev/null
+++ b/ports/stm32/boards/OPENMV_N6/pins.csv
@@ -0,0 +1,142 @@
+,PA0
+,PA1
+,PA2
+,PA3
+,PA4
+,PA5
+,PA6
+,PA7
+,PA8
+,PA9
+,PA10
+SPI2_CS,PA11
+SPI2_SCK,PA12
+UART4_RX,PA11
+UART4_TX,PA12
+P3,PA11
+P2,PA12
+,PA13
+,PA14
+,PA15
+,PB0
+,PB1
+,PB2
+,PB3
+,PB4
+,PB5
+SPI4_MISO,PB6
+SPI4_MOSI,PB7
+,PB8
+,PB9
+I2C2_SCL,PB10
+I2C2_SDA,PB11
+UART3_TX,PB10
+UART3_RX,PB11
+P4,PB10
+P5,PB11
+,PB12
+,PB13
+,PB14
+,PB15
+,PC0
+,PC1
+,PC2
+,PC3
+,PC4
+,PC5
+,PC6
+,PC7
+,PC8
+,PC9
+,PC10
+,PC11
+,PC12
+P11,PC13
+,PC14
+,PC15
+,PD0
+,PD1
+,PD2
+,PD3
+,PD4
+,PD5
+P10,PD6
+SPI2_MOSI,PD7
+P0,PD7
+,PD8
+,PD9
+,PD10
+SPI2_MISO,PD11
+P1,PD11
+,PD12
+P8,PD13
+,PD14
+,PD15
+,PE0
+,PE1
+,PE2
+,PE3
+,PE4
+,PE5
+,PE6
+UART7_RX,PE7
+UART7_TX,PE8
+,PE9
+,PE10
+SPI4_CS,PE11
+SPI4_SCK,PE12
+I2C4_SCL,PE13
+I2C4_SDA,PE14
+,PE15
+P6,PG0
+P9,PG12
+P7,PG13
+,PG15
+
+BUTTON,PF4
+LED_RED,PG10
+LED_GREEN,PA7
+LED_BLUE,PB1
+
+-XSPIM_P2_DQS,PN0
+-XSPIM_P2_CS,PN1
+-XSPIM_P2_IO0,PN2
+-XSPIM_P2_IO1,PN3
+-XSPIM_P2_IO2,PN4
+-XSPIM_P2_IO3,PN5
+-XSPIM_P2_SCK,PN6
+-XSPIM_P2_NCLK,PN7
+-XSPIM_P2_IO4,PN8
+-XSPIM_P2_IO5,PN9
+-XSPIM_P2_IO6,PN10
+-XSPIM_P2_IO7,PN11
+-FLASH_RESET,PN12
+
+-WL_REG_ON,PB12
+-WL_HOST_WAKE,PB14
+-WL_SDIO_D0,PB8
+-WL_SDIO_D1,PG8
+-WL_SDIO_D2,PB9
+-WL_SDIO_D3,PB4
+-WL_SDIO_CMD,PA0
+-WL_SDIO_CK,PD2
+-WL_I2S_SDO,PG14
+-WL_I2S_WS,PB15
+-WL_I2S_SCLK,PB13
+-BT_RXD,PF6
+-BT_TXD,PD5
+-BT_CTS,PG5
+-BT_RTS,PF3
+-BT_REG_ON,PD10
+-BT_HOST_WAKE,PD14
+-BT_DEV_WAKE,PD15
+
+-SD_SDIO_D0,PC8
+-SD_SDIO_D1,PC9
+-SD_SDIO_D2,PC10
+-SD_SDIO_D3,PC11
+-SD_SDIO_CK,PC12
+-SD_SDIO_CMD,PH2
+-SD_RESET,PC7
+-SD_DETECT,PC6
+-SD_VSELECT,PG6
diff --git a/ports/stm32/boards/OPENMV_N6/stm32n6xx_hal_conf.h b/ports/stm32/boards/OPENMV_N6/stm32n6xx_hal_conf.h
new file mode 100644
index 0000000000..4012d56e5a
--- /dev/null
+++ b/ports/stm32/boards/OPENMV_N6/stm32n6xx_hal_conf.h
@@ -0,0 +1,18 @@
+/* This file is part of the MicroPython project, http://micropython.org/
+ * The MIT License (MIT)
+ * Copyright (c) 2019 Damien P. George
+ */
+#ifndef MICROPY_INCLUDED_STM32N6XX_HAL_CONF_H
+#define MICROPY_INCLUDED_STM32N6XX_HAL_CONF_H
+
+// Oscillator values in Hz
+#define HSE_VALUE (48000000)
+#define LSE_VALUE (32768)
+
+// Oscillator timeouts in ms
+#define HSE_STARTUP_TIMEOUT (100)
+#define LSE_STARTUP_TIMEOUT (5000)
+
+#include "boards/stm32n6xx_hal_conf_base.h"
+
+#endif // MICROPY_INCLUDED_STM32N6XX_HAL_CONF_H
diff --git a/ports/stm32/boards/common_n6_flash.ld b/ports/stm32/boards/common_n6_flash.ld
new file mode 100644
index 0000000000..a1f1fa531f
--- /dev/null
+++ b/ports/stm32/boards/common_n6_flash.ld
@@ -0,0 +1,57 @@
+/* Memory layout for N6 when the application runs from external flash in XIP mode.
+
+ FLASH_APP .isr_vector
+ FLASH_APP .text
+ FLASH_APP .data
+
+ RAM .data
+ RAM .bss
+ RAM .heap
+ RAM .stack
+*/
+
+ENTRY(Reset_Handler)
+
+REGION_ALIAS("FLASH_COMMON", FLASH_APP);
+
+/* define output sections */
+SECTIONS
+{
+ .isr_vector :
+ {
+ _siram = .;
+
+ /* This ISR is used for normal application mode. */
+ . = ALIGN(1024);
+ KEEP(*(.isr_vector));
+
+ /* This ISR is used when waking from STANDBY. */
+ . = ALIGN(1024);
+ KEEP(*(.rodata.iram_bootloader_isr_vector));
+
+ /* Need to place in RAM all the code necessary to write to
+ * flash, and to resume from STANDBY. */
+ *(.*.iram_bootloader_reset);
+ *(.*.memcpy);
+ *(.*.mp_hal_gpio_clock_enable);
+ *(.*.mp_hal_pin_config);
+ *(.*.mp_hal_pin_config_speed);
+ *drivers/memory/spiflash.o(.text.* .rodata.*)
+ *xspi.o(.text.* .rodata.*);
+ *boards*(.rodata.spiflash_config*)
+ *boards*(.*.board_leave_standby);
+ *(*.rodata.pin_N*_obj);
+ *(.text.LL_AHB4_GRP1_EnableClock);
+ *(.text.LL_APB4_GRP2_EnableClock);
+
+ . = ALIGN(4);
+ _eiram = .;
+ } >IRAM AT> FLASH_COMMON
+
+ INCLUDE common_text.ld
+ INCLUDE common_extratext_data_in_flash.ld
+ INCLUDE common_bss_heap_stack.ld
+}
+
+/* Used by the start-up code to initialise data */
+_siiram = LOADADDR(.isr_vector);
diff --git a/ports/stm32/boards/common_text.ld b/ports/stm32/boards/common_text.ld
index 16eea43bae..d95467babc 100644
--- a/ports/stm32/boards/common_text.ld
+++ b/ports/stm32/boards/common_text.ld
@@ -12,3 +12,11 @@
. = ALIGN(4);
_etext = .; /* define a global symbol at end of code */
} >FLASH_COMMON
+
+/* Secure Gateway stubs */
+.gnu.sgstubs :
+{
+ . = ALIGN(4);
+ *(.gnu.sgstubs*)
+ . = ALIGN(4);
+} >FLASH_COMMON
diff --git a/ports/stm32/boards/make-pins.py b/ports/stm32/boards/make-pins.py
index 1b89fd6415..6f8a0a659d 100755
--- a/ports/stm32/boards/make-pins.py
+++ b/ports/stm32/boards/make-pins.py
@@ -215,7 +215,7 @@ class Stm32Pin(boardgen.Pin):
def validate_cpu_pin_name(cpu_pin_name):
boardgen.Pin.validate_cpu_pin_name(cpu_pin_name)
- if not re.match("P[A-K][0-9]+(_C)?$", cpu_pin_name):
+ if not re.match("P[A-O][0-9]+(_C)?$", cpu_pin_name):
raise boardgen.PinGeneratorError("Invalid cpu pin name '{}'".format(cpu_pin_name))
diff --git a/ports/stm32/boards/pllvalues.py b/ports/stm32/boards/pllvalues.py
index d8856bfecd..ae042d999c 100644
--- a/ports/stm32/boards/pllvalues.py
+++ b/ports/stm32/boards/pllvalues.py
@@ -293,7 +293,7 @@ def main():
break
# Relax constraint on PLLQ being 48MHz on MCUs which have separate PLLs for 48MHz
- relax_pll48 = mcu_series.startswith(("stm32f413", "stm32f7", "stm32h5", "stm32h7"))
+ relax_pll48 = mcu_series.startswith(("stm32f413", "stm32f7", "stm32h5", "stm32h7", "stm32n6"))
hse_valid_plls = compute_pll_table(hse, relax_pll48)
if hsi is not None:
diff --git a/ports/stm32/boards/stm32n657_af.csv b/ports/stm32/boards/stm32n657_af.csv
new file mode 100644
index 0000000000..35e305a376
--- /dev/null
+++ b/ports/stm32/boards/stm32n657_af.csv
@@ -0,0 +1,42 @@
+Port ,Pin ,AF0 ,AF1 ,AF2 ,AF3 ,AF4 ,AF5 ,AF6 ,AF7 ,AF8 ,AF9 ,AF10 ,AF11 ,AF12 ,AF13 ,AF14 ,AF15 ,ADC
+ , ,SYS ,LPTIM1/TIM1/2/16/17,LPTIM3/PDM_SAI1/TIM3/4/5/12/15,I3C1/LPTIM2/3/LPUART1/OCTOSPI/TIM1/8,CEC/DCMI/I2C1/2/3/4/LPTIM1/2/SPI1/I2S1/TIM15/USART1,CEC/I3C1/LPTIM1/SPI1/I2S1/SPI2/I2S2/SPI3/I2S3/SPI4/5/6,I2C4/OCTOSPI/SAI1/SPI3/I2S3/SPI4/UART4/12/USART10/USB_PD,SDMMC1/SPI2/I2S2/SPI3/I2S3/SPI6/UART7/8/12/USART1/2/3/6/10/11,LPUART1/SAI2/SDMMC1/SPI6/UART4/5/8,FDCAN1/2/FMC[NAND16]/FMC[NORmux]/FMC[NOR_RAM]/OCTOSPI/SDMMC2/TIM13/14,CRS/FMC[NAND16]/OCTOSPI/SAI2/SDMMC2/TIM8/USB_,ETH[MII/RMII]/FMC[NAND16]/OCTOSPI/SDMMC2/UART7/9/USB_PD,FMC[NAND16]/FMC[NORmux]/FMC[NOR_RAM]/FMC[SDRAM_16bit]/SDMMC1,DCMI/FMC[NAND16]/FMC[NORmux]/FMC[NOR_RAM]/LPTIM5,LPTIM3/4/5/6/TIM2/UART5,SYS ,ADC
+PortA,PA0 , , , , , , , , , , , ,SDMMC2_CMD , , , , ,ADC12_INP0/ADC12_INN1
+PortA,PA3 , , , , , ,SPI5_NSS , , , , , , , , , , ,
+PortA,PA5 , , , , , , , , , , , , , , , , ,ADC2_INP18
+PortA,PA8 , , , , , , , , , , , , , , , , ,ADC12_INP5
+PortA,PA9 , , , , , , , , , , , , , , , , ,ADC12_INP10
+PortA,PA10, , , , , , , , , , , , , , , , ,ADC12_INP11/ADC12_INN10
+PortA,PA11, , , , , , , , ,UART4_RX , , , , , , , ,ADC12_INP12/ADC12_INN11
+PortA,PA12, , , , , , , , ,UART4_TX , , , , , , , ,ADC12_INP13/ADC12_INN12
+PortB,PB4 , , , , , , , , , , , ,SDMMC2_D3 , , , , ,
+PortB,PB8 , , , , , , , , , , , ,SDMMC2_D0 , , , , ,
+PortB,PB9 , , , , , , , , , , , ,SDMMC2_D2 , , , , ,
+PortB,PB10, ,TIM2_CH3 , , , , , ,USART3_TX , , , , , , , , ,
+PortB,PB11, ,TIM2_CH4 , , , , , ,USART3_RX , , , , , , , , ,
+PortC,PC8 , , , , , , , , , , ,SDMMC1_D0 , , , , , ,
+PortC,PC9 , , , , , , , , , , ,SDMMC1_D1 , , , , , ,
+PortC,PC10, , , , , , , , , , ,SDMMC1_D2 , , , , , ,
+PortC,PC11, , , , , , , , , , ,SDMMC1_D3 , , , , , ,
+PortC,PC12, , , , , , , , , , ,SDMMC1_CK , , , , , ,
+PortD,PD2 , , , , , , , , , , , ,SDMMC2_CK , , , , ,
+PortD,PD5 , , , , , , , ,USART2_TX , , , , , , , , ,
+PortD,PD6 , , , , ,TIM15_CH2 , , , , , , , , , , , ,
+PortD,PD8 , , , , , , , ,USART3_TX , , , , , , , , ,
+PortD,PD9 , , , , , , , ,USART3_RX , , , , , , , , ,
+PortD,PD13, , ,TIM4_CH2 , , , , , , , , , , , , , ,
+PortE,PE5 , , , , , , , ,USART1_TX , , , , , , , , ,
+PortE,PE6 , , , , , , , ,USART1_RX , , , , , , , , ,
+PortE,PE7 , , , , , , , , ,UART7_RX , , , , , , , ,
+PortE,PE8 , , , , , , , , ,UART7_TX , , , , , , , ,
+PortE,PE15, , , , , ,SPI5_SCK , , , , , , , , , , ,
+PortF,PF3 , , , , , , , ,USART2_RTS , , , , , , , , ,ADC1_INP16
+PortF,PF6 , , , , , , , ,USART2_RX , , , , , , , , ,
+PortG,PG0 , , ,TIM12_CH1 , , , , , , , , , , , , , ,
+PortG,PG1 , , , , , ,SPI5_MISO , , , , , , , , , , ,
+PortG,PG2 , , , , , ,SPI5_MOSI , , , , , , , , , , ,
+PortG,PG5 , , , , , , , ,USART2_CTS , , , , , , , , ,
+PortG,PG8 , , , , , , , , , , , ,SDMMC2_D1 , , , , ,
+PortG,PG12, ,TIM17_CH1 , , , , , , , , , , , , , , ,
+PortG,PG13, , ,TIM4_CH1 , , , , , , , , , , , , , ,
+PortG,PG15, , , , , , , , , , , , , , , , ,ADC12_INP7/ADC12_INN3
+PortC,PH2 , , , , , , , , , , ,SDMMC1_CMD , , , , , ,
diff --git a/ports/stm32/boards/stm32n657x0.ld b/ports/stm32/boards/stm32n657x0.ld
new file mode 100644
index 0000000000..242d113b30
--- /dev/null
+++ b/ports/stm32/boards/stm32n657x0.ld
@@ -0,0 +1,34 @@
+/*
+ GNU linker script for STM32N657x0
+
+ Note: upper 512k of SRAM2 is copied from external flash upon reset.
+*/
+
+/* Specify the memory areas */
+MEMORY
+{
+ FLEXRAM_S (xrw) : ORIGIN = 0x34000000, LENGTH = 80K
+ SRAM2_S_RAM (xrw) : ORIGIN = 0x34100000, LENGTH = 512K /* only use first half, second half may contain firmware */
+ SRAM2_S_FSBL (xrw) : ORIGIN = 0x34180400, LENGTH = 511K /* firmware loaded from SPI flash upon reset */
+ EXT_FLASH (rx) : ORIGIN = 0x70080000, LENGTH = 1536K
+}
+
+REGION_ALIAS("IRAM", FLEXRAM_S);
+REGION_ALIAS("RAM", SRAM2_S_RAM);
+REGION_ALIAS("FLASH", SRAM2_S_FSBL);
+REGION_ALIAS("FLASH_APP", EXT_FLASH);
+
+/* produce a link error if there is not this amount of RAM for these sections */
+_minimum_stack_size = 2K;
+_minimum_heap_size = 16K;
+
+/* Define the stack. The stack is full descending so begins just above last byte
+ of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
+_estack = ORIGIN(RAM) + LENGTH(RAM) - _estack_reserve;
+_sstack = _estack - 16K; /* tunable */
+
+/* RAM extents for the garbage collector */
+_ram_start = ORIGIN(RAM);
+_ram_end = ORIGIN(RAM) + LENGTH(RAM);
+_heap_start = _ebss; /* heap starts just after statically allocated memory */
+_heap_end = _sstack;
diff --git a/ports/stm32/boards/stm32n6xx_hal_conf_base.h b/ports/stm32/boards/stm32n6xx_hal_conf_base.h
new file mode 100644
index 0000000000..641a003d8b
--- /dev/null
+++ b/ports/stm32/boards/stm32n6xx_hal_conf_base.h
@@ -0,0 +1,215 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024 Damien P. George
+ *
+ * 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.
+ */
+#ifndef MICROPY_INCLUDED_STM32N6XX_HAL_CONF_BASE_H
+#define MICROPY_INCLUDED_STM32N6XX_HAL_CONF_BASE_H
+
+// Enable various HAL modules
+#define HAL_MODULE_ENABLED
+#define HAL_ADC_MODULE_ENABLED
+#define HAL_BSEC_MODULE_ENABLED
+#define HAL_CACHEAXI_MODULE_ENABLED
+#define HAL_CORTEX_MODULE_ENABLED
+#define HAL_CRC_MODULE_ENABLED
+#define HAL_CRYP_MODULE_ENABLED
+#define HAL_CSI_MODULE_ENABLED
+#define HAL_DCMI_MODULE_ENABLED
+#define HAL_DCMIPP_MODULE_ENABLED
+#define HAL_DMA_MODULE_ENABLED
+#define HAL_DMA2D_MODULE_ENABLED
+#define HAL_DTS_MODULE_ENABLED
+#define HAL_ETH_MODULE_ENABLED
+#define HAL_EXTI_MODULE_ENABLED
+#define HAL_FDCAN_MODULE_ENABLED
+#define HAL_GFXMMU_MODULE_ENABLED
+#define HAL_GFXTIM_MODULE_ENABLED
+#define HAL_GPIO_MODULE_ENABLED
+#define HAL_GPU2D_MODULE_ENABLED
+#define HAL_HASH_MODULE_ENABLED
+#define HAL_HCD_MODULE_ENABLED
+#define HAL_I2C_MODULE_ENABLED
+#define HAL_I3C_MODULE_ENABLED
+#define HAL_ICACHE_MODULE_ENABLED
+#define HAL_IRDA_MODULE_ENABLED
+#define HAL_IWDG_MODULE_ENABLED
+#define HAL_JPEG_MODULE_ENABLED
+#define HAL_LPTIM_MODULE_ENABLED
+#define HAL_LTDC_MODULE_ENABLED
+#define HAL_MCE_MODULE_ENABLED
+#define HAL_MDF_MODULE_ENABLED
+#define HAL_MDIOS_MODULE_ENABLED
+#define HAL_MMC_MODULE_ENABLED
+#define HAL_NAND_MODULE_ENABLED
+#define HAL_NOR_MODULE_ENABLED
+#define HAL_PCD_MODULE_ENABLED
+#define HAL_PKA_MODULE_ENABLED
+#define HAL_PSSI_MODULE_ENABLED
+#define HAL_PWR_MODULE_ENABLED
+#define HAL_RAMCFG_MODULE_ENABLED
+#define HAL_RCC_MODULE_ENABLED
+#define HAL_RIF_MODULE_ENABLED
+#define HAL_RNG_MODULE_ENABLED
+#define HAL_RTC_MODULE_ENABLED
+#define HAL_SAI_MODULE_ENABLED
+#define HAL_SD_MODULE_ENABLED
+#define HAL_SDRAM_MODULE_ENABLED
+#define HAL_SMARTCARD_MODULE_ENABLED
+#define HAL_SMBUS_MODULE_ENABLED
+#define HAL_SPDIFRX_MODULE_ENABLED
+#define HAL_SPI_MODULE_ENABLED
+#define HAL_SRAM_MODULE_ENABLED
+#define HAL_TIM_MODULE_ENABLED
+#define HAL_UART_MODULE_ENABLED
+#define HAL_USART_MODULE_ENABLED
+#define HAL_WWDG_MODULE_ENABLED
+#define HAL_XSPI_MODULE_ENABLED
+
+// Oscillator values in Hz
+#define HSI_VALUE (64000000UL)
+#define LSI_VALUE (32000UL)
+#define MSI_VALUE (4000000UL)
+
+// SysTick has the highest priority
+#define TICK_INT_PRIORITY (0x00)
+
+// Miscellaneous HAL settings
+#define VDD_VALUE 3300UL
+#define USE_RTOS 0
+#define USE_SD_TRANSCEIVER 0
+#define USE_SPI_CRC 1
+
+// Disable dynamic callback registration
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CACHEAXI_REGISTER_CALLBACKS 0U /* CACHEAXI register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DCMIPP_REGISTER_CALLBACKS 0U /* DCMIPP register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DTS_REGISTER_CALLBACKS 0U /* DTS register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U /* FDCAN register callback disabled */
+#define USE_HAL_GFXMMU_REGISTER_CALLBACKS 0U /* GFXMMU register callback disabled */
+#define USE_HAL_GFXTIM_REGISTER_CALLBACKS 0U /* GFXTIM register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_I3C_REGISTER_CALLBACKS 0U /* I3C register callback disabled */
+#define USE_HAL_IWDG_REGISTER_CALLBACKS 0U /* IWDG register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MCE_REGISTER_CALLBACKS 0U /* MCE register callback disabled */
+#define USE_HAL_MDF_REGISTER_CALLBACKS 0U /* MDF register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_PKA_REGISTER_CALLBACKS 0U /* PKA register callback disabled */
+#define USE_HAL_PSSI_REGISTER_CALLBACKS 0U /* PSSI register callback disabled */
+#define USE_HAL_RAMCFG_REGISTER_CALLBACKS 0U /* RAMCFG register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+#define USE_HAL_XSPI_REGISTER_CALLBACKS 0U /* XSPI register callback disabled */
+
+// Include various HAL modules for convenience
+#include "stm32n6xx_hal_rcc.h"
+#include "stm32n6xx_hal_gpio.h"
+#include "stm32n6xx_hal_rif.h"
+#include "stm32n6xx_hal_dma.h"
+#include "stm32n6xx_hal_cacheaxi.h"
+#include "stm32n6xx_hal_cortex.h"
+#include "stm32n6xx_hal_adc.h"
+#include "stm32n6xx_hal_bsec.h"
+#include "stm32n6xx_hal_crc.h"
+#include "stm32n6xx_hal_cryp.h"
+#include "stm32n6xx_hal_dcmi.h"
+#include "stm32n6xx_hal_dcmipp.h"
+#include "stm32n6xx_hal_dma2d.h"
+#include "stm32n6xx_hal_dts.h"
+#include "stm32n6xx_hal_eth.h"
+#include "stm32n6xx_hal_exti.h"
+#include "stm32n6xx_hal_fdcan.h"
+#include "stm32n6xx_hal_gfxmmu.h"
+#include "stm32n6xx_hal_gfxtim.h"
+#include "stm32n6xx_hal_gpio.h"
+#include "stm32n6xx_hal_gpu2d.h"
+#include "stm32n6xx_hal_hash.h"
+#include "stm32n6xx_hal_hcd.h"
+#include "stm32n6xx_hal_i2c.h"
+#include "stm32n6xx_hal_i3c.h"
+#include "stm32n6xx_hal_icache.h"
+#include "stm32n6xx_hal_irda.h"
+#include "stm32n6xx_hal_iwdg.h"
+#include "stm32n6xx_hal_jpeg.h"
+#include "stm32n6xx_hal_lptim.h"
+#include "stm32n6xx_hal_ltdc.h"
+#include "stm32n6xx_hal_mce.h"
+#include "stm32n6xx_hal_mdf.h"
+#include "stm32n6xx_hal_mdios.h"
+#include "stm32n6xx_hal_mmc.h"
+#include "stm32n6xx_hal_nand.h"
+#include "stm32n6xx_hal_nor.h"
+#include "stm32n6xx_hal_nand.h"
+#include "stm32n6xx_hal_pcd.h"
+#include "stm32n6xx_hal_pka.h"
+#include "stm32n6xx_hal_pssi.h"
+#include "stm32n6xx_hal_pwr.h"
+#include "stm32n6xx_hal_ramcfg.h"
+#include "stm32n6xx_hal_rng.h"
+#include "stm32n6xx_hal_rtc.h"
+#include "stm32n6xx_hal_sai.h"
+#include "stm32n6xx_hal_sd.h"
+#include "stm32n6xx_hal_sdram.h"
+#include "stm32n6xx_hal_smartcard.h"
+#include "stm32n6xx_hal_smbus.h"
+#include "stm32n6xx_hal_spdifrx.h"
+#include "stm32n6xx_hal_spi.h"
+#include "stm32n6xx_hal_sram.h"
+#include "stm32n6xx_hal_tim.h"
+#include "stm32n6xx_hal_uart.h"
+#include "stm32n6xx_hal_usart.h"
+#include "stm32n6xx_hal_wwdg.h"
+#include "stm32n6xx_hal_xspi.h"
+#include "stm32n6xx_ll_lpuart.h"
+#include "stm32n6xx_ll_pwr.h"
+#include "stm32n6xx_ll_rtc.h"
+#include "stm32n6xx_ll_usart.h"
+
+// HAL parameter assertions are disabled
+#define assert_param(expr) ((void)0)
+
+#endif // MICROPY_INCLUDED_STM32N6XX_HAL_CONF_BASE_H