diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/board.json b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/board.json new file mode 100644 index 0000000000..df92725e61 --- /dev/null +++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/board.json @@ -0,0 +1,15 @@ +{ + "deploy": [ + "../PYBV10/deploy.md" + ], + "docs": "", + "features": [], + "images": [ + "weact_u585ci.jpg" + ], + "mcu": "stm32u5", + "product": "Mini STM32U585", + "thumbnail": "", + "url": "https://github.com/WeActStudio/WeActStudio.STM32U585Cx_CoreBoard", + "vendor": "WeAct Studio" +} diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/mpconfigboard.h b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/mpconfigboard.h new file mode 100644 index 0000000000..0223cbf4a4 --- /dev/null +++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/mpconfigboard.h @@ -0,0 +1,76 @@ +#define MICROPY_HW_BOARD_NAME "WEACTSTUDIO_MINI_STM32U585" +#define MICROPY_HW_MCU_NAME "STM32U585CI" + +#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1) +#define MICROPY_HW_ENABLE_ADC (1) +#define MICROPY_HW_ENABLE_DAC (1) +#define MICROPY_HW_ENABLE_USB (1) +#define MICROPY_HW_ENABLE_RNG (0) +#define MICROPY_HW_ENABLE_RTC (1) +#define MICROPY_HW_HAS_FLASH (1) +#define MICROPY_HW_HAS_SWITCH (1) + +// The board has a 25MHz oscillator, the following gives 150MHz CPU speed +#define MICROPY_HW_CLK_PLLM (4) +#define MICROPY_HW_CLK_PLLN (48) +#define MICROPY_HW_CLK_PLLP (2) +#define MICROPY_HW_CLK_PLLQ (2) +#define MICROPY_HW_CLK_PLLR (2) +#define MICROPY_HW_CLK_PLLVCI (RCC_PLLVCIRANGE_0) +#define MICROPY_HW_CLK_PLLFRAC (0) + +// 5 wait states, according to Table 37, Reference Manual (RM0481 Rev 1) +#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_4 + +// There is an external 32kHz oscillator +#define MICROPY_HW_RTC_USE_LSE (1) +#define MICROPY_HW_RCC_RTC_CLKSOURCE (RCC_RTCCLKSOURCE_LSE) + +// HSI48 +#define MICROPY_HW_RCC_HSI48_STATE (RCC_HSI48_ON) + +// UART config +#define MICROPY_HW_UART1_TX (pin_A9) +#define MICROPY_HW_UART1_RX (pin_A10) +#define MICROPY_HW_UART2_TX (pin_A2) +#define MICROPY_HW_UART2_RX (pin_A3) +#define MICROPY_HW_UART2_RTS (pin_A1) +#define MICROPY_HW_UART2_CTS (pin_A0) + +// Connect REPL to UART1 which is provided on ST-Link USB interface +#define MICROPY_HW_UART_REPL PYB_UART_1 +#define MICROPY_HW_UART_REPL_BAUD 115200 + +// I2C buses +#define MICROPY_HW_I2C1_SCL (pin_B6) +#define MICROPY_HW_I2C1_SDA (pin_B7) +#define MICROPY_HW_I2C2_SCL (pin_B10) +#define MICROPY_HW_I2C2_SDA (pin_B14) + +// SPI buses +#define MICROPY_HW_SPI1_NSS (pin_A4) +#define MICROPY_HW_SPI1_SCK (pin_A5) +#define MICROPY_HW_SPI1_MISO (pin_A6) +#define MICROPY_HW_SPI1_MOSI (pin_A7) +#define MICROPY_HW_SPI2_NSS (pin_B12) +#define MICROPY_HW_SPI2_SCK (pin_B10) +#define MICROPY_HW_SPI2_MISO (pin_B14) +#define MICROPY_HW_SPI2_MOSI (pin_B15) +#define MICROPY_HW_SPI3_NSS (pin_A15) +#define MICROPY_HW_SPI3_SCK (pin_B3) +#define MICROPY_HW_SPI3_MISO (pin_B4) +#define MICROPY_HW_SPI3_MOSI (pin_B5) + +// USRSW is pulled low. Pressing the button makes the input go high. +#define MICROPY_HW_USRSW_PIN (pin_A0) +#define MICROPY_HW_USRSW_PULL (GPIO_PULLUP) +#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING) +#define MICROPY_HW_USRSW_PRESSED (0) + +// LEDs +#define MICROPY_HW_LED1 (pin_C13) // Blue +#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin)) +#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin)) + +// USB Configuration +#define MICROPY_HW_USB_FS (MICROPY_HW_ENABLE_USB) diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/mpconfigboard.mk b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/mpconfigboard.mk new file mode 100644 index 0000000000..b5826ea35f --- /dev/null +++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/mpconfigboard.mk @@ -0,0 +1,21 @@ +USE_MBOOT ?= 0 + +# MCU settings +MCU_SERIES = u5 +CMSIS_MCU = STM32U585xx +MICROPY_FLOAT_IMPL = single +AF_FILE = boards/stm32u5a5_af.csv + +ifeq ($(USE_MBOOT),1) +# When using Mboot everything goes after the bootloader +# TODO: not tested +LD_FILES = boards/stm32h573xi.ld boards/common_bl.ld +TEXT0_ADDR = 0x08008000 +else +# When not using Mboot everything goes at the start of flash +LD_FILES = boards/stm32u585xi.ld boards/common_basic.ld +TEXT0_ADDR = 0x08000000 +endif + +# MicroPython settings +#MICROPY_HW_ENABLE_ISR_UART_FLASH_FUNCS_IN_RAM = 1 diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/pins.csv b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/pins.csv new file mode 100644 index 0000000000..3f2b669fdc --- /dev/null +++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/pins.csv @@ -0,0 +1,43 @@ +A0,PA0 +A1,PA1 +A2,PA2 +A3,PA3 +A4,PA4 +A5,PA5 +A6,PA6 +A7,PA7 +A8,PA8 +A9,PA9 +A10,PA10 +A11,PA11 +A12,PA12 +A13,PA13 +A14,PA14 +A15,PA15 +B0,PB0 +B1,PB1 +B2,PB2 +B3,PB3 +B4,PB4 +B5,PB5 +B6,PB6 +B7,PB7 +B8,PB8 +B9,PB9 +B10,PB10 +B11,PB11 +B12,PB12 +B13,PB13 +B14,PB14 +B15,PB15 +C13,PC13 +C14,PC14 +C15,PC15 +LED_BLUE,PC13 +SW,PA0 +-SWDIO,PA13 +-SWCLK,PA14 +-OSC32_IN,PH0 +-OSC32_OUT,PH1 +-USB_DM,PA11 +-USB_DP,PA12 diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/stm32u5xx_hal_conf.h b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/stm32u5xx_hal_conf.h new file mode 100644 index 0000000000..a1af8eae23 --- /dev/null +++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32U585/stm32u5xx_hal_conf.h @@ -0,0 +1,19 @@ +/* This file is part of the MicroPython project, http://micropython.org/ + * The MIT License (MIT) + * Copyright (c) 2023 Damien P. George + */ +#ifndef MICROPY_INCLUDED_STM32U5XX_HAL_CONF_H +#define MICROPY_INCLUDED_STM32U5XX_HAL_CONF_H + +// Oscillator values in Hz +#define HSE_VALUE (25000000) +#define LSE_VALUE (32768) +#define EXTERNAL_CLOCK_VALUE (12288000) + +// Oscillator timeouts in ms +#define HSE_STARTUP_TIMEOUT (100) +#define LSE_STARTUP_TIMEOUT (5000) + +#include "boards/stm32u5xx_hal_conf_base.h" + +#endif // MICROPY_INCLUDED_STM32U5XX_HAL_CONF_H diff --git a/ports/stm32/boards/stm32u585xi.ld b/ports/stm32/boards/stm32u585xi.ld new file mode 100644 index 0000000000..1612b0f10f --- /dev/null +++ b/ports/stm32/boards/stm32u585xi.ld @@ -0,0 +1,35 @@ +/* + GNU linker script for STM32U585xI +*/ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K + FLASH_APP (rx) : ORIGIN = 0x08008000, LENGTH = 992K /* sectors 4-127 (for common_bl.ld) */ + FLASH_FS (rx) : ORIGIN = 0x08100000, LENGTH = 1024K /* sectors 128-255 */ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 768K /* SRAM1: 768KB */ + SRAM4 (xrw) : ORIGIN = 0x28000000, LENGTH = 16K + FS_CACHE (xrw) : ORIGIN = 0x28000000, LENGTH = 8K +} + +/* 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; + +/* Filesystem cache in RAM, and storage in flash */ +_micropy_hw_internal_flash_storage_ram_cache_start = ORIGIN(FS_CACHE); +_micropy_hw_internal_flash_storage_ram_cache_end = ORIGIN(FS_CACHE) + LENGTH(FS_CACHE); +_micropy_hw_internal_flash_storage_start = ORIGIN(FLASH_FS); +_micropy_hw_internal_flash_storage_end = ORIGIN(FLASH_FS) + LENGTH(FLASH_FS);