diff options
| author | Damien George <damien@micropython.org> | 2024-06-18 17:46:21 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-07-08 16:24:27 +1000 |
| commit | eb3ea9ee13093d81053f5d07b8c96e4fc0e1383d (patch) | |
| tree | 07f7bb3e3f9c6fb1f4204c531d3c18a29c3cb189 /ports/stm32/mpu.h | |
| parent | 24fd5f72682922664c0bcf70d6e3631a6d5b8d2b (diff) | |
stm32: Add support for STM32N6xx MCUs.
This commit adds preliminary support for ST's new STM32N6xx MCUs.
Supported features of this MCU so far are:
- basic clock tree initialisation, running at 800MHz
- fully working USB
- XSPI in memory-mapped mode
- machine.Pin
- machine.UART
- RTC and deepsleep support
- SD card
- filesystem
- ROMFS
- WiFi and BLE via cyw43-driver (SDIO backend)
Note that the N6 does not have internal flash, and has some tricky boot
sequence, so using a custom bootloader (mboot) is almost a necessity.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'ports/stm32/mpu.h')
| -rw-r--r-- | ports/stm32/mpu.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/ports/stm32/mpu.h b/ports/stm32/mpu.h index 5756cb056..8713fe837 100644 --- a/ports/stm32/mpu.h +++ b/ports/stm32/mpu.h @@ -137,18 +137,26 @@ static inline void mpu_config_end(uint32_t irq_state) { enable_irq(irq_state); } -#elif defined(STM32H5) +#elif defined(STM32H5) || defined(STM32N6) #define MPU_REGION_SIG (MPU_REGION_NUMBER0) #define MPU_REGION_ETH (MPU_REGION_NUMBER1) -#define MPU_REGION_LAST_USED (MPU_REGION_NUMBER1) +#define MPU_REGION_DMA_UNCACHED_1 (MPU_REGION_NUMBER2) +#define MPU_REGION_DMA_UNCACHED_2 (MPU_REGION_NUMBER3) +#define MPU_REGION_LAST_USED (MPU_REGION_NUMBER3) #define ST_DEVICE_SIGNATURE_BASE (0x08fff800) #define ST_DEVICE_SIGNATURE_LIMIT (0x08ffffff) // STM32H5 Cortex-M33 MPU works differently from older cores. // Macro only takes region size in bytes, Attributes are coded in mpu_config_region(). +#define MPU_CONFIG_DISABLE (0) #define MPU_CONFIG_ETH(size) (size) +#define MPU_CONFIG_UNCACHED(size) (size) + +#if defined(STM32N6) +#define MPU_REGION_SIZE_32B (32) +#endif static inline void mpu_init(void) { // Configure attribute 0, inner-outer non-cacheable (=0x44). @@ -180,8 +188,12 @@ static inline uint32_t mpu_config_start(void) { } static inline void mpu_config_region(uint32_t region, uint32_t base_addr, uint32_t size) { - if (region == MPU_REGION_ETH) { - // Configure region 1 to make DMA memory non-cacheable. + if (size == 0) { + // Disable MPU for this region. + MPU->RNR = region; + MPU->RLAR &= ~MPU_RLAR_EN_Msk; + } else if (region == MPU_REGION_ETH || region == MPU_REGION_DMA_UNCACHED_1 || region == MPU_REGION_DMA_UNCACHED_2) { + // Configure region to make DMA memory non-cacheable. __DMB(); // Configure attribute 1, inner-outer non-cacheable (=0x44). |
