summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/bdev.c47
-rw-r--r--ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/board.json13
-rw-r--r--ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/board_init.c16
-rw-r--r--ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/deploy.md19
-rw-r--r--ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/manifest.py4
-rw-r--r--ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/mpconfigboard.h171
-rw-r--r--ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/mpconfigboard.mk22
-rw-r--r--ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/pins.csv100
-rw-r--r--ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/stm32h7xx_hal_conf.h19
-rw-r--r--ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/weact_stm32h743.ld33
10 files changed, 444 insertions, 0 deletions
diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/bdev.c b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/bdev.c
new file mode 100644
index 000000000..b70142300
--- /dev/null
+++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/bdev.c
@@ -0,0 +1,47 @@
+/* This file is part of the MicroPython project, http://micropython.org/
+ * The MIT License (MIT)
+ * Copyright (c) 2019 Damien P. George
+ */
+
+#include "storage.h"
+#include "spi.h"
+#include "qspi.h"
+#include "py/mpconfig.h"
+
+static const spi_proto_cfg_t spi_bus = {
+ .spi = &spi_obj[0], // SPI1
+ .baudrate = 25000000,
+ .polarity = 0,
+ .phase = 0,
+ .bits = 8,
+ .firstbit = SPI_FIRSTBIT_MSB,
+};
+
+#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
+static mp_spiflash_cache_t spi_bdev_cache;
+#endif
+
+const mp_spiflash_config_t spiflash_config = {
+ .bus_kind = MP_SPIFLASH_BUS_SPI,
+ .bus.u_spi.cs = MICROPY_HW_SPIFLASH_CS,
+
+ .bus.u_spi.data = (void *)&spi_bus,
+ .bus.u_spi.proto = &spi_proto,
+ #if MICROPY_HW_SPIFLASH_ENABLE_CACHE
+ .cache = &spi_bdev_cache,
+ #endif
+};
+
+spi_bdev_t spi_bdev;
+
+// Second external SPI flash uses hardware QSPI interface
+const mp_spiflash_config_t spiflash2_config = {
+ .bus_kind = MP_SPIFLASH_BUS_QSPI,
+ .bus.u_qspi.data = NULL,
+ .bus.u_qspi.proto = &qspi_proto,
+ #if MICROPY_HW_SPIFLASH_ENABLE_CACHE
+ .cache = &spi_bdev_cache,
+ #endif
+};
+
+spi_bdev_t spi_bdev2;
diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/board.json b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/board.json
new file mode 100644
index 000000000..11a6e0815
--- /dev/null
+++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/board.json
@@ -0,0 +1,13 @@
+{
+ "deploy": [
+ "deploy.md"
+ ],
+ "features": ["External Flash", "DAC", "Display","microSD", "USB", "USB-C"],
+ "images": [
+ "weact_stm32h743.jpg"
+ ],
+ "mcu": "stm32h7",
+ "product": "Mini STM32H743",
+ "url": "https://github.com/WeActStudio/MiniSTM32H7xx",
+ "vendor": "WeAct Studio"
+}
diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/board_init.c b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/board_init.c
new file mode 100644
index 000000000..0adf04982
--- /dev/null
+++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/board_init.c
@@ -0,0 +1,16 @@
+/* This file is part of the MicroPython project, http://micropython.org/
+ * The MIT License (MIT)
+ * Copyright (c) 2019 Damien P. George
+ */
+
+#include "py/mphal.h"
+#include "storage.h"
+
+void WeAct_Core_early_init(void) {
+ // Turn off the USB switch.
+ mp_hal_pin_output(pyb_pin_OTG_FS_POWER);
+ mp_hal_pin_low(pyb_pin_OTG_FS_POWER);
+
+ // Explicitly init SPI2 because it's not enabled as a block device
+ spi_bdev_ioctl(&spi_bdev2, BDEV_IOCTL_INIT, (uint32_t)&spiflash2_config);
+}
diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/deploy.md b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/deploy.md
new file mode 100644
index 000000000..a4572bfe3
--- /dev/null
+++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/deploy.md
@@ -0,0 +1,19 @@
+### WeAct Studio STM32H7xx
+
+WeAct Studio make a number of STM32H7xx-based boards, they can all be updated
+using
+[DFU](https://en.wikipedia.org/wiki/USB?useskin=vector#Device_Firmware_Upgrade_mechanism).
+
+### DFU update
+
+Hold the Boot button - the middle of the cluster of three buttons - while the
+board is reset (either by connecting USB or by pressing reset). Release the Boot
+button shortly after the board has reset. The board ought to now be in DFU mode
+and detectable as such from a connected computer.
+
+Use a tool like [`dfu-util`](https://dfu-util.sourceforge.net/) to update the
+firmware:
+
+```bash
+dfu-util --alt 0 -D firmware.dfu
+```
diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/manifest.py b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/manifest.py
new file mode 100644
index 000000000..7d163e184
--- /dev/null
+++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/manifest.py
@@ -0,0 +1,4 @@
+include("$(PORT_DIR)/boards/manifest.py")
+
+# Currently this file is a placeholder.
+# It would be good to extend to add an LCD driver.
diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/mpconfigboard.h b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/mpconfigboard.h
new file mode 100644
index 000000000..ad9f3bc45
--- /dev/null
+++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/mpconfigboard.h
@@ -0,0 +1,171 @@
+#define MICROPY_HW_BOARD_NAME "WEACTSTUDIO_MINI_STM32H743"
+#define MICROPY_HW_MCU_NAME "STM32H743VIT6"
+
+#define MICROPY_FATFS_EXFAT (1)
+#define MICROPY_HW_ENABLE_RTC (1)
+#define MICROPY_HW_ENABLE_RNG (1)
+#define MICROPY_HW_ENABLE_ADC (1)
+#define MICROPY_HW_ENABLE_DAC (1)
+#define MICROPY_HW_ENABLE_USB (1)
+#define MICROPY_HW_HAS_SWITCH (1)
+#define MICROPY_HW_HAS_FLASH (1)
+#define MICROPY_HW_ENABLE_SERVO (1)
+#define MICROPY_HW_ENABLE_TIMER (1)
+#define MICROPY_HW_ENABLE_SDCARD (1)
+#define MICROPY_HW_ENABLE_MMCARD (0)
+
+// ROMFS config
+#define MICROPY_HW_ROMFS_ENABLE_EXTERNAL_QSPI (1)
+#define MICROPY_HW_ROMFS_QSPI_SPIFLASH_OBJ (&spi_bdev2.spiflash)
+#define MICROPY_HW_ROMFS_ENABLE_PART0 (1)
+
+// Flash storage config
+#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
+// Disable internal filesystem to use spiflash.
+#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
+
+// W25Q64 for storage
+#define MICROPY_HW_SPIFLASH_SIZE_BYTES (8 * 1024 * 1024)
+
+// SPI flash #1, for R/W storage
+#define MICROPY_HW_SPIFLASH_CS (pin_D6)
+#define MICROPY_HW_SPIFLASH_SCK (pin_B3)
+#define MICROPY_HW_SPIFLASH_MOSI (pin_D7)
+#define MICROPY_HW_SPIFLASH_MISO (pin_B4)
+
+// External SPI Flash configuration
+#define MICROPY_HW_SPI_IS_RESERVED(id) (id == 1)
+
+// SPI flash #1, block device config
+extern const struct _mp_spiflash_config_t spiflash_config;
+extern struct _spi_bdev_t spi_bdev;
+
+#define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev)
+#define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config)
+#define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES (MICROPY_HW_SPIFLASH_SIZE_BITS / 8)
+#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
+#define MICROPY_HW_SPIFLASH_SIZE_BITS (MICROPY_HW_SPIFLASH_SIZE_BYTES * 8)
+
+// SPI flash #2, to be memory mapped
+#define MICROPY_HW_QSPI_PRESCALER (2) // 120 MHz
+#define MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 (26)
+#define MICROPY_HW_QSPIFLASH_CS (pin_B6)
+#define MICROPY_HW_QSPIFLASH_SCK (pin_B2)
+#define MICROPY_HW_QSPIFLASH_IO0 (pin_D11)
+#define MICROPY_HW_QSPIFLASH_IO1 (pin_D12)
+#define MICROPY_HW_QSPIFLASH_IO2 (pin_E2)
+#define MICROPY_HW_QSPIFLASH_IO3 (pin_D13)
+
+// SPI flash #2, block device config
+extern const struct _mp_spiflash_config_t spiflash2_config;
+extern struct _spi_bdev_t spi_bdev2;
+
+#define MICROPY_BOARD_EARLY_INIT WeAct_Core_early_init
+
+// This board has 25MHz HSE.
+// The following gives a 480MHz CPU speed.
+#define MICROPY_HW_CLK_USE_HSE (1)
+#define MICROPY_HW_CLK_PLLM (5)
+#define MICROPY_HW_CLK_PLLN (192)
+#define MICROPY_HW_CLK_PLLP (2)
+#define MICROPY_HW_CLK_PLLQ (20)
+#define MICROPY_HW_CLK_PLLR (2)
+#define MICROPY_HW_CLK_PLLVCI (RCC_PLL1VCIRANGE_2)
+#define MICROPY_HW_CLK_PLLVCO (RCC_PLL1VCOWIDE)
+#define MICROPY_HW_CLK_PLLFRAC (0)
+
+// The USB clock is set using PLL3
+#define MICROPY_HW_CLK_PLL3M (5)
+#define MICROPY_HW_CLK_PLL3N (192)
+#define MICROPY_HW_CLK_PLL3P (2)
+#define MICROPY_HW_CLK_PLL3Q (20)
+#define MICROPY_HW_CLK_PLL3R (2)
+#define MICROPY_HW_CLK_PLL3VCI (RCC_PLL3VCIRANGE_2)
+#define MICROPY_HW_CLK_PLL3VCO (RCC_PLL3VCOWIDE)
+#define MICROPY_HW_CLK_PLL3FRAC (0)
+
+// 32kHz crystal for RTC
+#define MICROPY_HW_RTC_USE_LSE (1)
+#define MICROPY_HW_RTC_USE_US (0)
+
+// 6 wait states
+#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_6
+
+// UART
+#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_UART3_TX (pin_B10)
+#define MICROPY_HW_UART3_RX (pin_B11)
+#define MICROPY_HW_UART4_TX (pin_C11)
+#define MICROPY_HW_UART4_RX (pin_C10)
+#define MICROPY_HW_UART5_TX (pin_B12) // or SPI2
+#define MICROPY_HW_UART5_RX (pin_B13) // or SPI2
+#define MICROPY_HW_UART6_TX (pin_C6)
+#define MICROPY_HW_UART6_RX (pin_C7)
+#define MICROPY_HW_UART7_TX (pin_E8)
+#define MICROPY_HW_UART7_RX (pin_E7)
+
+// I2C buses
+#define MICROPY_HW_I2C1_SCL (pin_B8)
+#define MICROPY_HW_I2C1_SDA (pin_B9)
+
+#define MICROPY_HW_I2C2_SCL (pin_B10)
+#define MICROPY_HW_I2C2_SDA (pin_B11)
+
+// SPI buses
+// NOTE: SPI1 is used for the SPI flash.
+#define MICROPY_HW_SPI1_NSS (pin_D6)
+#define MICROPY_HW_SPI1_SCK (pin_B3)
+#define MICROPY_HW_SPI1_MISO (pin_B4)
+#define MICROPY_HW_SPI1_MOSI (pin_D7)
+
+#define MICROPY_HW_SPI2_NSS (pin_B12)
+#define MICROPY_HW_SPI2_SCK (pin_B13)
+#define MICROPY_HW_SPI2_MISO (pin_B14)
+#define MICROPY_HW_SPI2_MOSI (pin_B15)
+// NOTE: SPI3 is used for the QSPI flash.
+#define MICROPY_HW_SPI3_NSS (pin_A4)
+#define MICROPY_HW_SPI3_SCK (pin_B3)
+#define MICROPY_HW_SPI3_MISO (pin_B4)
+#define MICROPY_HW_SPI3_MOSI (pin_B5)
+// NOTE: SPI4 is used for the ST7735 LCD.
+#define MICROPY_HW_SPI4_NSS (pin_E11)
+#define MICROPY_HW_SPI4_SCK (pin_E12)
+#define MICROPY_HW_SPI4_MISO (pin_E13)
+#define MICROPY_HW_SPI4_MOSI (pin_E14)
+
+// CAN buses
+#define MICROPY_HW_CAN1_TX (pin_B9)
+#define MICROPY_HW_CAN1_RX (pin_B8)
+
+// USRSW is pulled low. Pressing the button makes the input go high.
+#define MICROPY_HW_USRSW_PIN (pin_C13) // K1 on the board.
+#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 (pin_E3) // the only controllable LED on the board.
+#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
+#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
+
+// SD Card SDMMC
+#define MICROPY_HW_SDCARD_SDMMC (1)
+#define MICROPY_HW_SDCARD_CK (pin_C12)
+#define MICROPY_HW_SDCARD_CMD (pin_D2)
+#define MICROPY_HW_SDCARD_D0 (pin_C8)
+#define MICROPY_HW_SDCARD_D1 (pin_C9)
+#define MICROPY_HW_SDCARD_D2 (pin_C10)
+#define MICROPY_HW_SDCARD_D3 (pin_C11)
+
+// SD card detect switch
+#define MICROPY_HW_SDCARD_DETECT_PIN (pin_D4)
+#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
+#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_SET)
+
+// USB config
+#define MICROPY_HW_USB_FS (1)
+
+void WeAct_Core_early_init(void);
diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/mpconfigboard.mk b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/mpconfigboard.mk
new file mode 100644
index 000000000..c13c3ddad
--- /dev/null
+++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/mpconfigboard.mk
@@ -0,0 +1,22 @@
+USE_MBOOT ?= 0
+
+# MCU settings
+MCU_SERIES = h7
+CMSIS_MCU = STM32H743xx
+MICROPY_FLOAT_IMPL = double
+AF_FILE = boards/stm32h743_af.csv
+
+ifeq ($(USE_MBOOT),1)
+# When using Mboot everything goes after the bootloader
+LD_FILES = boards/stm32h723.ld boards/common_bl.ld
+TEXT0_ADDR = 0x08020000
+else
+# When not using Mboot everything goes at the start of flash
+LD_FILES = boards/WEACTSTUDIO_MINI_STM32H743/weact_stm32h743.ld boards/common_basic.ld
+TEXT0_ADDR = 0x08000000
+endif
+
+# MicroPython settings
+MICROPY_VFS_LFS2 = 1
+
+FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest.py
diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/pins.csv b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/pins.csv
new file mode 100644
index 000000000..61b188cc6
--- /dev/null
+++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/pins.csv
@@ -0,0 +1,100 @@
+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
+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
+C0,PC0
+C1,PC1
+C2,PC2
+C3,PC3
+C4,PC4
+C5,PC5
+C6,PC6
+C7,PC7
+C8,PC8
+C9,PC9
+C10,PC10
+C11,PC11
+C12,PC12
+C13,PC13
+D0,PD0
+D1,PD1
+D2,PD2
+D3,PD3
+D4,PD4
+D5,PD5
+D6,PD6
+D7,PD7
+D8,PD8
+D9,PD9
+D10,PD10
+D11,PD11
+D12,PD12
+D13,PD13
+D14,PD14
+D15,PD15
+E0,PE0
+E1,PE1
+E2,PE2
+E3,PE3
+E4,PE4
+E5,PE5
+E6,PE6
+E7,PE7
+E8,PE8
+E9,PE9
+E10,PE10
+E11,PE11
+E11,PE11
+E12,PE12
+E13,PE13
+E14,PE14
+E15,PE15
+LED_BLUE,PE3
+KEY_1,PC13
+QSPI_CS,PB6
+QSPI_CLK,PB2
+QSPI_D0,PD11
+QSPI_D1,PD12
+QSPI_D2,PE2
+QSPI_D3,PD13
+USB_DM,PA11
+USB_DP,PA12
+OSC32_IN,PC14
+OSC32_OUT,PC15
+SDIO_D0,PC8
+SDIO_D1,PC9
+SDIO_D2,PC10
+SDIO_D3,PC11
+SDIO_CMD,PD2
+SDIO_CK,PC12
+SD_SW,PD4
+OTG_FS_POWER,PD10
+OTG_FS_OVER_CURRENT,PG7
+USB_VBUS,PA9
+USB_ID,PA10
diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/stm32h7xx_hal_conf.h b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/stm32h7xx_hal_conf.h
new file mode 100644
index 000000000..c8f60c560
--- /dev/null
+++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/stm32h7xx_hal_conf.h
@@ -0,0 +1,19 @@
+/* This file is part of the MicroPython project, http://micropython.org/
+ * The MIT License (MIT)
+ * Copyright (c) 2019 Damien P. George
+ */
+#ifndef MICROPY_INCLUDED_STM32H7XX_HAL_CONF_H
+#define MICROPY_INCLUDED_STM32H7XX_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 (5000)
+#define LSE_STARTUP_TIMEOUT (5000)
+
+#include "boards/stm32h7xx_hal_conf_base.h"
+
+#endif // MICROPY_INCLUDED_STM32H7XX_HAL_CONF_H
diff --git a/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/weact_stm32h743.ld b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/weact_stm32h743.ld
new file mode 100644
index 000000000..356d69171
--- /dev/null
+++ b/ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/weact_stm32h743.ld
@@ -0,0 +1,33 @@
+/*
+ GNU linker script for WeAct Studio STM32H743
+*/
+
+/* Specify the memory areas */
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K /* sectors (0-15) */
+ FLASH_APP (rx) : ORIGIN = 0x08020000, LENGTH = 1920K /* sectors (1-15) */
+ FLASH_ROMFS (rx): ORIGIN = 0x90000000, LENGTH = 8192K /* external QSPI */
+ DTCM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K /* Used for storage cache */
+ RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* AXI SRAM */
+ RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
+}
+
+/* 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(FLASH_ROMFS);
+_micropy_hw_romfs_part0_size = LENGTH(FLASH_ROMFS);