mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
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>
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "led.h"
|
||||
#include "storage.h"
|
||||
#include "irq.h"
|
||||
#include "xspi.h"
|
||||
|
||||
#if MICROPY_HW_ENABLE_STORAGE
|
||||
|
||||
@@ -44,13 +45,17 @@
|
||||
|
||||
static bool storage_is_initialised = false;
|
||||
|
||||
#if !defined(STM32N6)
|
||||
static void storage_systick_callback(uint32_t ticks_ms);
|
||||
#endif
|
||||
|
||||
void storage_init(void) {
|
||||
if (!storage_is_initialised) {
|
||||
storage_is_initialised = true;
|
||||
|
||||
#if !defined(STM32N6)
|
||||
systick_enable_dispatch(SYSTICK_DISPATCH_STORAGE, storage_systick_callback);
|
||||
#endif
|
||||
|
||||
MICROPY_HW_BDEV_IOCTL(BDEV_IOCTL_INIT, 0);
|
||||
|
||||
@@ -58,10 +63,12 @@ void storage_init(void) {
|
||||
MICROPY_HW_BDEV2_IOCTL(BDEV_IOCTL_INIT, 0);
|
||||
#endif
|
||||
|
||||
#if !defined(STM32N6)
|
||||
// Enable the flash IRQ, which is used to also call our storage IRQ handler
|
||||
// It must go at the same priority as USB (see comment in irq.h).
|
||||
NVIC_SetPriority(FLASH_IRQn, IRQ_PRI_FLASH);
|
||||
HAL_NVIC_EnableIRQ(FLASH_IRQn);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +84,7 @@ uint32_t storage_get_block_count(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(STM32N6)
|
||||
static void storage_systick_callback(uint32_t ticks_ms) {
|
||||
if (STORAGE_IDLE_TICK(ticks_ms)) {
|
||||
// Trigger a FLASH IRQ to execute at a lower priority
|
||||
@@ -96,6 +104,7 @@ void FLASH_IRQHandler(void) {
|
||||
#endif
|
||||
IRQ_EXIT(FLASH_IRQn);
|
||||
}
|
||||
#endif
|
||||
|
||||
void storage_flush(void) {
|
||||
MICROPY_HW_BDEV_IOCTL(BDEV_IOCTL_SYNC, 0);
|
||||
@@ -235,11 +244,11 @@ int storage_write_blocks(const uint8_t *src, uint32_t block_num, uint32_t num_bl
|
||||
// Board defined an external SPI flash for use with extended block protocol
|
||||
#define MICROPY_HW_BDEV_BLOCKSIZE_EXT (MP_SPIFLASH_ERASE_BLOCK_SIZE)
|
||||
#define MICROPY_HW_BDEV_READBLOCKS_EXT(dest, bl, off, len) \
|
||||
(spi_bdev_readblocks_raw(MICROPY_HW_BDEV_SPIFLASH_EXTENDED, (dest), (bl), (off), (len)))
|
||||
(spi_bdev_readblocks_raw(MICROPY_HW_BDEV_SPIFLASH_EXTENDED, (dest), MICROPY_HW_BDEV_SPIFLASH_OFFSET_BYTES / MP_SPIFLASH_ERASE_BLOCK_SIZE + (bl), (off), (len)))
|
||||
#define MICROPY_HW_BDEV_WRITEBLOCKS_EXT(src, bl, off, len) \
|
||||
(spi_bdev_writeblocks_raw(MICROPY_HW_BDEV_SPIFLASH_EXTENDED, (src), (bl), (off), (len)))
|
||||
(spi_bdev_writeblocks_raw(MICROPY_HW_BDEV_SPIFLASH_EXTENDED, (src), MICROPY_HW_BDEV_SPIFLASH_OFFSET_BYTES / MP_SPIFLASH_ERASE_BLOCK_SIZE + (bl), (off), (len)))
|
||||
#define MICROPY_HW_BDEV_ERASEBLOCKS_EXT(bl, len) \
|
||||
(spi_bdev_eraseblocks_raw(MICROPY_HW_BDEV_SPIFLASH_EXTENDED, (bl), (len)))
|
||||
(spi_bdev_eraseblocks_raw(MICROPY_HW_BDEV_SPIFLASH_EXTENDED, MICROPY_HW_BDEV_SPIFLASH_OFFSET_BYTES / MP_SPIFLASH_ERASE_BLOCK_SIZE + (bl), (len)))
|
||||
|
||||
#elif (MICROPY_VFS_LFS1 || MICROPY_VFS_LFS2) && MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
|
||||
// Board uses littlefs and internal flash, so enable extended block protocol on internal flash
|
||||
|
||||
Reference in New Issue
Block a user