Skip to content

Commit 9b73e34

Browse files
yn386dpgeorge
authored andcommitted
stm32/boards/WEACTSTUDIO_MINI_STM32H743: Add WeAct H743VI board support.
This change adds WeAct Studio Mini STM32H743 board support to the STM32 port. Some of the work from PR micropython#12540 is combined here. WeAct Studio Mini STM32H43 board: https://github.com/WeActStudio/MiniSTM32H7xx This board uses STM32H743VI: https://www.st.com/en/microcontrollers-microprocessors/stm32h743vi.html Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
1 parent 22cff2f commit 9b73e34

File tree

10 files changed

+444
-0
lines changed

10 files changed

+444
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* This file is part of the MicroPython project, http://micropython.org/
2+
* The MIT License (MIT)
3+
* Copyright (c) 2019 Damien P. George
4+
*/
5+
6+
#include "storage.h"
7+
#include "spi.h"
8+
#include "qspi.h"
9+
#include "py/mpconfig.h"
10+
11+
static const spi_proto_cfg_t spi_bus = {
12+
.spi = &spi_obj[0], // SPI1
13+
.baudrate = 25000000,
14+
.polarity = 0,
15+
.phase = 0,
16+
.bits = 8,
17+
.firstbit = SPI_FIRSTBIT_MSB,
18+
};
19+
20+
#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
21+
static mp_spiflash_cache_t spi_bdev_cache;
22+
#endif
23+
24+
const mp_spiflash_config_t spiflash_config = {
25+
.bus_kind = MP_SPIFLASH_BUS_SPI,
26+
.bus.u_spi.cs = MICROPY_HW_SPIFLASH_CS,
27+
28+
.bus.u_spi.data = (void *)&spi_bus,
29+
.bus.u_spi.proto = &spi_proto,
30+
#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
31+
.cache = &spi_bdev_cache,
32+
#endif
33+
};
34+
35+
spi_bdev_t spi_bdev;
36+
37+
// Second external SPI flash uses hardware QSPI interface
38+
const mp_spiflash_config_t spiflash2_config = {
39+
.bus_kind = MP_SPIFLASH_BUS_QSPI,
40+
.bus.u_qspi.data = NULL,
41+
.bus.u_qspi.proto = &qspi_proto,
42+
#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
43+
.cache = &spi_bdev_cache,
44+
#endif
45+
};
46+
47+
spi_bdev_t spi_bdev2;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"deploy": [
3+
"deploy.md"
4+
],
5+
"features": ["External Flash", "DAC", "Display","microSD", "USB", "USB-C"],
6+
"images": [
7+
"weact_stm32h743.jpg"
8+
],
9+
"mcu": "stm32h7",
10+
"product": "Mini STM32H743",
11+
"url": "https://github.com/WeActStudio/MiniSTM32H7xx",
12+
"vendor": "WeAct Studio"
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* This file is part of the MicroPython project, http://micropython.org/
2+
* The MIT License (MIT)
3+
* Copyright (c) 2019 Damien P. George
4+
*/
5+
6+
#include "py/mphal.h"
7+
#include "storage.h"
8+
9+
void WeAct_Core_early_init(void) {
10+
// Turn off the USB switch.
11+
mp_hal_pin_output(pyb_pin_OTG_FS_POWER);
12+
mp_hal_pin_low(pyb_pin_OTG_FS_POWER);
13+
14+
// Explicitly init SPI2 because it's not enabled as a block device
15+
spi_bdev_ioctl(&spi_bdev2, BDEV_IOCTL_INIT, (uint32_t)&spiflash2_config);
16+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
### WeAct Studio STM32H7xx
2+
3+
WeAct Studio make a number of STM32H7xx-based boards, they can all be updated
4+
using
5+
[DFU](https://en.wikipedia.org/wiki/USB?useskin=vector#Device_Firmware_Upgrade_mechanism).
6+
7+
### DFU update
8+
9+
Hold the Boot button - the middle of the cluster of three buttons - while the
10+
board is reset (either by connecting USB or by pressing reset). Release the Boot
11+
button shortly after the board has reset. The board ought to now be in DFU mode
12+
and detectable as such from a connected computer.
13+
14+
Use a tool like [`dfu-util`](https://dfu-util.sourceforge.net/) to update the
15+
firmware:
16+
17+
```bash
18+
dfu-util --alt 0 -D firmware.dfu
19+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include("$(PORT_DIR)/boards/manifest.py")
2+
3+
# Currently this file is a placeholder.
4+
# It would be good to extend to add an LCD driver.
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
#define MICROPY_HW_BOARD_NAME "WEACTSTUDIO_MINI_STM32H743"
2+
#define MICROPY_HW_MCU_NAME "STM32H743VIT6"
3+
4+
#define MICROPY_FATFS_EXFAT (1)
5+
#define MICROPY_HW_ENABLE_RTC (1)
6+
#define MICROPY_HW_ENABLE_RNG (1)
7+
#define MICROPY_HW_ENABLE_ADC (1)
8+
#define MICROPY_HW_ENABLE_DAC (1)
9+
#define MICROPY_HW_ENABLE_USB (1)
10+
#define MICROPY_HW_HAS_SWITCH (1)
11+
#define MICROPY_HW_HAS_FLASH (1)
12+
#define MICROPY_HW_ENABLE_SERVO (1)
13+
#define MICROPY_HW_ENABLE_TIMER (1)
14+
#define MICROPY_HW_ENABLE_SDCARD (1)
15+
#define MICROPY_HW_ENABLE_MMCARD (0)
16+
17+
// ROMFS config
18+
#define MICROPY_HW_ROMFS_ENABLE_EXTERNAL_QSPI (1)
19+
#define MICROPY_HW_ROMFS_QSPI_SPIFLASH_OBJ (&spi_bdev2.spiflash)
20+
#define MICROPY_HW_ROMFS_ENABLE_PART0 (1)
21+
22+
// Flash storage config
23+
#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
24+
// Disable internal filesystem to use spiflash.
25+
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
26+
27+
// W25Q64 for storage
28+
#define MICROPY_HW_SPIFLASH_SIZE_BYTES (8 * 1024 * 1024)
29+
30+
// SPI flash #1, for R/W storage
31+
#define MICROPY_HW_SPIFLASH_CS (pin_D6)
32+
#define MICROPY_HW_SPIFLASH_SCK (pin_B3)
33+
#define MICROPY_HW_SPIFLASH_MOSI (pin_D7)
34+
#define MICROPY_HW_SPIFLASH_MISO (pin_B4)
35+
36+
// External SPI Flash configuration
37+
#define MICROPY_HW_SPI_IS_RESERVED(id) (id == 1)
38+
39+
// SPI flash #1, block device config
40+
extern const struct _mp_spiflash_config_t spiflash_config;
41+
extern struct _spi_bdev_t spi_bdev;
42+
43+
#define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev)
44+
#define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config)
45+
#define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES (MICROPY_HW_SPIFLASH_SIZE_BITS / 8)
46+
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
47+
#define MICROPY_HW_SPIFLASH_SIZE_BITS (MICROPY_HW_SPIFLASH_SIZE_BYTES * 8)
48+
49+
// SPI flash #2, to be memory mapped
50+
#define MICROPY_HW_QSPI_PRESCALER (2) // 120 MHz
51+
#define MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 (26)
52+
#define MICROPY_HW_QSPIFLASH_CS (pin_B6)
53+
#define MICROPY_HW_QSPIFLASH_SCK (pin_B2)
54+
#define MICROPY_HW_QSPIFLASH_IO0 (pin_D11)
55+
#define MICROPY_HW_QSPIFLASH_IO1 (pin_D12)
56+
#define MICROPY_HW_QSPIFLASH_IO2 (pin_E2)
57+
#define MICROPY_HW_QSPIFLASH_IO3 (pin_D13)
58+
59+
// SPI flash #2, block device config
60+
extern const struct _mp_spiflash_config_t spiflash2_config;
61+
extern struct _spi_bdev_t spi_bdev2;
62+
63+
#define MICROPY_BOARD_EARLY_INIT WeAct_Core_early_init
64+
65+
// This board has 25MHz HSE.
66+
// The following gives a 480MHz CPU speed.
67+
#define MICROPY_HW_CLK_USE_HSE (1)
68+
#define MICROPY_HW_CLK_PLLM (5)
69+
#define MICROPY_HW_CLK_PLLN (192)
70+
#define MICROPY_HW_CLK_PLLP (2)
71+
#define MICROPY_HW_CLK_PLLQ (20)
72+
#define MICROPY_HW_CLK_PLLR (2)
73+
#define MICROPY_HW_CLK_PLLVCI (RCC_PLL1VCIRANGE_2)
74+
#define MICROPY_HW_CLK_PLLVCO (RCC_PLL1VCOWIDE)
75+
#define MICROPY_HW_CLK_PLLFRAC (0)
76+
77+
// The USB clock is set using PLL3
78+
#define MICROPY_HW_CLK_PLL3M (5)
79+
#define MICROPY_HW_CLK_PLL3N (192)
80+
#define MICROPY_HW_CLK_PLL3P (2)
81+
#define MICROPY_HW_CLK_PLL3Q (20)
82+
#define MICROPY_HW_CLK_PLL3R (2)
83+
#define MICROPY_HW_CLK_PLL3VCI (RCC_PLL3VCIRANGE_2)
84+
#define MICROPY_HW_CLK_PLL3VCO (RCC_PLL3VCOWIDE)
85+
#define MICROPY_HW_CLK_PLL3FRAC (0)
86+
87+
// 32kHz crystal for RTC
88+
#define MICROPY_HW_RTC_USE_LSE (1)
89+
#define MICROPY_HW_RTC_USE_US (0)
90+
91+
// 6 wait states
92+
#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_6
93+
94+
// UART
95+
#define MICROPY_HW_UART1_TX (pin_A9)
96+
#define MICROPY_HW_UART1_RX (pin_A10)
97+
#define MICROPY_HW_UART2_TX (pin_A2)
98+
#define MICROPY_HW_UART2_RX (pin_A3)
99+
#define MICROPY_HW_UART3_TX (pin_B10)
100+
#define MICROPY_HW_UART3_RX (pin_B11)
101+
#define MICROPY_HW_UART4_TX (pin_C11)
102+
#define MICROPY_HW_UART4_RX (pin_C10)
103+
#define MICROPY_HW_UART5_TX (pin_B12) // or SPI2
104+
#define MICROPY_HW_UART5_RX (pin_B13) // or SPI2
105+
#define MICROPY_HW_UART6_TX (pin_C6)
106+
#define MICROPY_HW_UART6_RX (pin_C7)
107+
#define MICROPY_HW_UART7_TX (pin_E8)
108+
#define MICROPY_HW_UART7_RX (pin_E7)
109+
110+
// I2C buses
111+
#define MICROPY_HW_I2C1_SCL (pin_B8)
112+
#define MICROPY_HW_I2C1_SDA (pin_B9)
113+
114+
#define MICROPY_HW_I2C2_SCL (pin_B10)
115+
#define MICROPY_HW_I2C2_SDA (pin_B11)
116+
117+
// SPI buses
118+
// NOTE: SPI1 is used for the SPI flash.
119+
#define MICROPY_HW_SPI1_NSS (pin_D6)
120+
#define MICROPY_HW_SPI1_SCK (pin_B3)
121+
#define MICROPY_HW_SPI1_MISO (pin_B4)
122+
#define MICROPY_HW_SPI1_MOSI (pin_D7)
123+
124+
#define MICROPY_HW_SPI2_NSS (pin_B12)
125+
#define MICROPY_HW_SPI2_SCK (pin_B13)
126+
#define MICROPY_HW_SPI2_MISO (pin_B14)
127+
#define MICROPY_HW_SPI2_MOSI (pin_B15)
128+
// NOTE: SPI3 is used for the QSPI flash.
129+
#define MICROPY_HW_SPI3_NSS (pin_A4)
130+
#define MICROPY_HW_SPI3_SCK (pin_B3)
131+
#define MICROPY_HW_SPI3_MISO (pin_B4)
132+
#define MICROPY_HW_SPI3_MOSI (pin_B5)
133+
// NOTE: SPI4 is used for the ST7735 LCD.
134+
#define MICROPY_HW_SPI4_NSS (pin_E11)
135+
#define MICROPY_HW_SPI4_SCK (pin_E12)
136+
#define MICROPY_HW_SPI4_MISO (pin_E13)
137+
#define MICROPY_HW_SPI4_MOSI (pin_E14)
138+
139+
// CAN buses
140+
#define MICROPY_HW_CAN1_TX (pin_B9)
141+
#define MICROPY_HW_CAN1_RX (pin_B8)
142+
143+
// USRSW is pulled low. Pressing the button makes the input go high.
144+
#define MICROPY_HW_USRSW_PIN (pin_C13) // K1 on the board.
145+
#define MICROPY_HW_USRSW_PULL (GPIO_PULLDOWN)
146+
#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
147+
#define MICROPY_HW_USRSW_PRESSED (1)
148+
149+
// LEDs
150+
#define MICROPY_HW_LED1 (pin_E3) // the only controllable LED on the board.
151+
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
152+
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
153+
154+
// SD Card SDMMC
155+
#define MICROPY_HW_SDCARD_SDMMC (1)
156+
#define MICROPY_HW_SDCARD_CK (pin_C12)
157+
#define MICROPY_HW_SDCARD_CMD (pin_D2)
158+
#define MICROPY_HW_SDCARD_D0 (pin_C8)
159+
#define MICROPY_HW_SDCARD_D1 (pin_C9)
160+
#define MICROPY_HW_SDCARD_D2 (pin_C10)
161+
#define MICROPY_HW_SDCARD_D3 (pin_C11)
162+
163+
// SD card detect switch
164+
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_D4)
165+
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
166+
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_SET)
167+
168+
// USB config
169+
#define MICROPY_HW_USB_FS (1)
170+
171+
void WeAct_Core_early_init(void);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
USE_MBOOT ?= 0
2+
3+
# MCU settings
4+
MCU_SERIES = h7
5+
CMSIS_MCU = STM32H743xx
6+
MICROPY_FLOAT_IMPL = double
7+
AF_FILE = boards/stm32h743_af.csv
8+
9+
ifeq ($(USE_MBOOT),1)
10+
# When using Mboot everything goes after the bootloader
11+
LD_FILES = boards/stm32h723.ld boards/common_bl.ld
12+
TEXT0_ADDR = 0x08020000
13+
else
14+
# When not using Mboot everything goes at the start of flash
15+
LD_FILES = boards/WEACTSTUDIO_MINI_STM32H743/weact_stm32h743.ld boards/common_basic.ld
16+
TEXT0_ADDR = 0x08000000
17+
endif
18+
19+
# MicroPython settings
20+
MICROPY_VFS_LFS2 = 1
21+
22+
FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest.py
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
A0,PA0
2+
A1,PA1
3+
A2,PA2
4+
A3,PA3
5+
A4,PA4
6+
A5,PA5
7+
A6,PA6
8+
A7,PA7
9+
A8,PA8
10+
A9,PA9
11+
A10,PA10
12+
A11,PA11
13+
A12,PA12
14+
A15,PA15
15+
B0,PB0
16+
B1,PB1
17+
B2,PB2
18+
B3,PB3
19+
B4,PB4
20+
B5,PB5
21+
B6,PB6
22+
B7,PB7
23+
B8,PB8
24+
B9,PB9
25+
B10,PB10
26+
B11,PB11
27+
B12,PB12
28+
B13,PB13
29+
B14,PB14
30+
B15,PB15
31+
C0,PC0
32+
C1,PC1
33+
C2,PC2
34+
C3,PC3
35+
C4,PC4
36+
C5,PC5
37+
C6,PC6
38+
C7,PC7
39+
C8,PC8
40+
C9,PC9
41+
C10,PC10
42+
C11,PC11
43+
C12,PC12
44+
C13,PC13
45+
D0,PD0
46+
D1,PD1
47+
D2,PD2
48+
D3,PD3
49+
D4,PD4
50+
D5,PD5
51+
D6,PD6
52+
D7,PD7
53+
D8,PD8
54+
D9,PD9
55+
D10,PD10
56+
D11,PD11
57+
D12,PD12
58+
D13,PD13
59+
D14,PD14
60+
D15,PD15
61+
E0,PE0
62+
E1,PE1
63+
E2,PE2
64+
E3,PE3
65+
E4,PE4
66+
E5,PE5
67+
E6,PE6
68+
E7,PE7
69+
E8,PE8
70+
E9,PE9
71+
E10,PE10
72+
E11,PE11
73+
E11,PE11
74+
E12,PE12
75+
E13,PE13
76+
E14,PE14
77+
E15,PE15
78+
LED_BLUE,PE3
79+
KEY_1,PC13
80+
QSPI_CS,PB6
81+
QSPI_CLK,PB2
82+
QSPI_D0,PD11
83+
QSPI_D1,PD12
84+
QSPI_D2,PE2
85+
QSPI_D3,PD13
86+
USB_DM,PA11
87+
USB_DP,PA12
88+
OSC32_IN,PC14
89+
OSC32_OUT,PC15
90+
SDIO_D0,PC8
91+
SDIO_D1,PC9
92+
SDIO_D2,PC10
93+
SDIO_D3,PC11
94+
SDIO_CMD,PD2
95+
SDIO_CK,PC12
96+
SD_SW,PD4
97+
OTG_FS_POWER,PD10
98+
OTG_FS_OVER_CURRENT,PG7
99+
USB_VBUS,PA9
100+
USB_ID,PA10

0 commit comments

Comments
 (0)