Skip to content

Commit ae646d4

Browse files
committed
stm32/boards: Update board definition for WeAct_H743VI.
Add ROMFS feature. Combined efforts from #12540: * Change peripheral ports, pin definitions. * Add QSPI definition. * Change board definition name: WeAct_H743VI-> WEACT_STM32H743. * Add deploy.md. Signed-off-by: Yuuki NAGAO <[email protected]>
1 parent 50c8e5c commit ae646d4

File tree

12 files changed

+221
-126
lines changed

12 files changed

+221
-126
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "storage.h"
22
#include "spi.h"
3+
#include "qspi.h"
34
#include "py/mpconfig.h"
45

56
#if !MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
@@ -30,4 +31,16 @@ const mp_spiflash_config_t spiflash_config = {
3031

3132
spi_bdev_t spi_bdev;
3233

34+
// Second external SPI flash uses hardware QSPI interface
35+
const mp_spiflash_config_t spiflash2_config = {
36+
.bus_kind = MP_SPIFLASH_BUS_QSPI,
37+
.bus.u_qspi.data = NULL,
38+
.bus.u_qspi.proto = &qspi_proto,
39+
#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
40+
.cache = &spi_bdev_cache,
41+
#endif
42+
};
43+
44+
spi_bdev_t spi_bdev2;
45+
3346
#endif
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": "STM32H743VIT6",
10+
"product": "WeAct Studio STM32H743",
11+
"url": "https://github.com/WeActStudio/MiniSTM32H7xx",
12+
"vendor": "WeAct Studio"
13+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#include "py/mphal.h"
2+
#include "storage.h"
23

34
void WeAct_Core_early_init(void) {
45
// Turn off the USB switch.
56
mp_hal_pin_output(pyb_pin_OTG_FS_POWER);
67
mp_hal_pin_low(pyb_pin_OTG_FS_POWER);
8+
9+
// Explicitly init SPI2 because it's not enabled as a block device
10+
spi_bdev_ioctl(&spi_bdev2, BDEV_IOCTL_INIT, (uint32_t)&spiflash2_config);
711
}
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: 106 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,68 @@
1-
#define MICROPY_HW_BOARD_NAME "WeAct Studio Core"
2-
#define MICROPY_HW_MCU_NAME "STM32H743VI"
1+
#define MICROPY_HW_BOARD_NAME "WEACT_STM32H743"
2+
#define MICROPY_HW_MCU_NAME "STM32H743VIT6"
3+
#define MICROPY_HW_FLASH_FS_LABEL "WEACT_STM32H743"
34

5+
#define MICROPY_FATFS_EXFAT (1)
46
#define MICROPY_HW_ENABLE_RTC (1)
5-
#define MICROPY_HW_ENABLE_SERVO (1)
6-
#define MICROPY_HW_ENABLE_RNG (0) // RNG needs proper configuration
7+
#define MICROPY_HW_ENABLE_RNG (1)
78
#define MICROPY_HW_ENABLE_ADC (1)
89
#define MICROPY_HW_ENABLE_DAC (1)
910
#define MICROPY_HW_ENABLE_USB (1)
10-
#define MICROPY_HW_ENABLE_SDCARD (1)
1111
#define MICROPY_HW_HAS_SWITCH (1)
1212
#define MICROPY_HW_HAS_FLASH (1)
13+
#define MICROPY_HW_ENABLE_SERVO (1)
14+
#define MICROPY_HW_ENABLE_TIMER (1)
15+
#define MICROPY_HW_ENABLE_SDCARD (1)
16+
#define MICROPY_HW_ENABLE_MMCARD (0)
17+
18+
// ROMFS config
19+
#define MICROPY_HW_ROMFS_ENABLE_EXTERNAL_QSPI (1)
20+
#define MICROPY_HW_ROMFS_QSPI_SPIFLASH_OBJ (&spi_bdev2.spiflash)
21+
#define MICROPY_HW_ROMFS_ENABLE_PART0 (1)
22+
23+
// Flash storage config
24+
#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
25+
// Disable internal filesystem to use spiflash.
26+
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
27+
28+
#if (MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE == 0)
29+
// W25Q64 for storage
30+
#define MICROPY_HW_SPIFLASH_SIZE_BYTES (8 * 1024 * 1024)
31+
32+
// SPI flash #1, for R/W storage
33+
#define MICROPY_HW_SPIFLASH_CS (pin_D6)
34+
#define MICROPY_HW_SPIFLASH_SCK (pin_B3)
35+
#define MICROPY_HW_SPIFLASH_MOSI (pin_D7)
36+
#define MICROPY_HW_SPIFLASH_MISO (pin_B4)
37+
38+
// External SPI Flash configuration
39+
#define MICROPY_HW_SPI_IS_RESERVED(id) (id == 1)
40+
41+
// SPI flash #1, block device config
42+
extern const struct _mp_spiflash_config_t spiflash_config;
43+
extern struct _spi_bdev_t spi_bdev;
44+
45+
#define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev)
46+
#define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config)
47+
#define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES (MICROPY_HW_SPIFLASH_SIZE_BITS / 8)
48+
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
49+
#define MICROPY_HW_SPIFLASH_SIZE_BITS (MICROPY_HW_SPIFLASH_SIZE_BYTES * 8)
50+
51+
// SPI flash #2, to be memory mapped
52+
#define MICROPY_HW_QSPI_PRESCALER (2) // 120 MHz
53+
#define MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 (26)
54+
#define MICROPY_HW_QSPIFLASH_CS (pin_B6)
55+
#define MICROPY_HW_QSPIFLASH_SCK (pin_B2)
56+
#define MICROPY_HW_QSPIFLASH_IO0 (pin_D11)
57+
#define MICROPY_HW_QSPIFLASH_IO1 (pin_D12)
58+
#define MICROPY_HW_QSPIFLASH_IO2 (pin_E2)
59+
#define MICROPY_HW_QSPIFLASH_IO3 (pin_D13)
60+
61+
// SPI flash #2, block device config
62+
extern const struct _mp_spiflash_config_t spiflash2_config;
63+
extern struct _spi_bdev_t spi_bdev2;
64+
65+
#endif
1366

1467
#define MICROPY_BOARD_EARLY_INIT WeAct_Core_early_init
1568

@@ -35,107 +88,88 @@
3588
#define MICROPY_HW_CLK_PLL3VCO (RCC_PLL3VCOWIDE)
3689
#define MICROPY_HW_CLK_PLL3FRAC (0)
3790

38-
// 3 wait states
39-
#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_6
40-
41-
// The board has an external 32kHz crystal attached
91+
// 32kHz crystal for RTC
4292
#define MICROPY_HW_RTC_USE_LSE (1)
93+
#define MICROPY_HW_RTC_USE_US (0)
4394

44-
// UART config
45-
#define MICROPY_HW_UART1_TX (pin_B14)
46-
#define MICROPY_HW_UART1_RX (pin_B15)
47-
#define MICROPY_HW_UART2_TX (pin_D5)
48-
#define MICROPY_HW_UART2_RX (pin_D6)
49-
#define MICROPY_HW_UART2_RTS (pin_D4)
50-
#define MICROPY_HW_UART2_CTS (pin_D3)
51-
#define MICROPY_HW_UART3_TX (pin_D8)
52-
#define MICROPY_HW_UART3_RX (pin_D9)
53-
#define MICROPY_HW_UART5_TX (pin_B6)
54-
#define MICROPY_HW_UART5_RX (pin_B12)
95+
// 6 wait states
96+
#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_6
97+
98+
// UART
99+
#define MICROPY_HW_UART1_TX (pin_A9)
100+
#define MICROPY_HW_UART1_RX (pin_A10)
101+
#define MICROPY_HW_UART2_TX (pin_A2)
102+
#define MICROPY_HW_UART2_RX (pin_A3)
103+
#define MICROPY_HW_UART3_TX (pin_B10)
104+
#define MICROPY_HW_UART3_RX (pin_B11)
105+
#define MICROPY_HW_UART4_TX (pin_C11)
106+
#define MICROPY_HW_UART4_RX (pin_C10)
107+
#define MICROPY_HW_UART5_TX (pin_B12) // or SPI2
108+
#define MICROPY_HW_UART5_RX (pin_B13) // or SPI2
55109
#define MICROPY_HW_UART6_TX (pin_C6)
56110
#define MICROPY_HW_UART6_RX (pin_C7)
57-
#define MICROPY_HW_UART7_TX (pin_F7)
58-
#define MICROPY_HW_UART7_RX (pin_F6)
59-
#define MICROPY_HW_UART8_TX (pin_E1)
60-
#define MICROPY_HW_UART8_RX (pin_E0)
61-
62-
#define MICROPY_HW_UART_REPL PYB_UART_3
63-
#define MICROPY_HW_UART_REPL_BAUD 115200
111+
#define MICROPY_HW_UART7_TX (pin_E8)
112+
#define MICROPY_HW_UART7_RX (pin_E7)
64113

65114
// I2C buses
66115
#define MICROPY_HW_I2C1_SCL (pin_B8)
67116
#define MICROPY_HW_I2C1_SDA (pin_B9)
68-
#define MICROPY_HW_I2C2_SCL (pin_F1)
69-
#define MICROPY_HW_I2C2_SDA (pin_F0)
70-
#define MICROPY_HW_I2C4_SCL (pin_F14)
71-
#define MICROPY_HW_I2C4_SDA (pin_F15)
117+
118+
#define MICROPY_HW_I2C2_SCL (pin_B10)
119+
#define MICROPY_HW_I2C2_SDA (pin_B11)
72120

73121
// SPI buses
74-
#define MICROPY_HW_SPI2_NSS (pin_A11)
75-
#define MICROPY_HW_SPI2_SCK (pin_A9)
122+
// NOTE: SPI1 is used for the SPI flash.
123+
#define MICROPY_HW_SPI1_NSS (pin_D6)
124+
#define MICROPY_HW_SPI1_SCK (pin_B3)
125+
#define MICROPY_HW_SPI1_MISO (pin_B4)
126+
#define MICROPY_HW_SPI1_MOSI (pin_D7)
127+
128+
#define MICROPY_HW_SPI2_NSS (pin_B12)
129+
#define MICROPY_HW_SPI2_SCK (pin_B13)
76130
#define MICROPY_HW_SPI2_MISO (pin_B14)
77-
#define MICROPY_HW_SPI2_MOSI (pin_C1)
131+
#define MICROPY_HW_SPI2_MOSI (pin_B15)
132+
// NOTE: SPI3 is used for the QSPI flash.
78133
#define MICROPY_HW_SPI3_NSS (pin_A4)
79134
#define MICROPY_HW_SPI3_SCK (pin_B3)
80135
#define MICROPY_HW_SPI3_MISO (pin_B4)
81136
#define MICROPY_HW_SPI3_MOSI (pin_B5)
137+
// NOTE: SPI4 is used for the ST7735 LCD.
82138
#define MICROPY_HW_SPI4_NSS (pin_E11)
83139
#define MICROPY_HW_SPI4_SCK (pin_E12)
84140
#define MICROPY_HW_SPI4_MISO (pin_E13)
85141
#define MICROPY_HW_SPI4_MOSI (pin_E14)
86142

143+
// CAN buses
144+
#define MICROPY_HW_CAN1_TX (pin_B9)
145+
#define MICROPY_HW_CAN1_RX (pin_B8)
146+
87147
// USRSW is pulled low. Pressing the button makes the input go high.
88-
#define MICROPY_HW_USRSW_PIN (pin_C13)
148+
#define MICROPY_HW_USRSW_PIN (pin_C13) // K1 on the board.
89149
#define MICROPY_HW_USRSW_PULL (GPIO_PULLDOWN)
90150
#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
91151
#define MICROPY_HW_USRSW_PRESSED (1)
92152

93153
// LEDs
94-
#define MICROPY_HW_LED1 (pin_E3) // blue
154+
#define MICROPY_HW_LED1 (pin_E3) // the only controllable LED on the board.
95155
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
96156
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
97157

98-
// USB config
99-
#define MICROPY_HW_USB_FS (1)
100-
101-
// FDCAN bus
102-
#define MICROPY_HW_CAN1_NAME "FDCAN1"
103-
#define MICROPY_HW_CAN1_TX (pin_D1)
104-
#define MICROPY_HW_CAN1_RX (pin_D0)
158+
// SD Card SDMMC
159+
#define MICROPY_HW_SDCARD_SDMMC (1)
160+
#define MICROPY_HW_SDCARD_CK (pin_C12)
161+
#define MICROPY_HW_SDCARD_CMD (pin_D2)
162+
#define MICROPY_HW_SDCARD_D0 (pin_C8)
163+
#define MICROPY_HW_SDCARD_D1 (pin_C9)
164+
#define MICROPY_HW_SDCARD_D2 (pin_C10)
165+
#define MICROPY_HW_SDCARD_D3 (pin_C11)
105166

106167
// SD card detect switch
107168
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_D4)
108169
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
109170
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_SET)
110171

111-
// SPI1 is not accessible because SPI flash module is used.
112-
#define MICROPY_HW_SPI1_NSS (pin_D6)
113-
#define MICROPY_HW_SPI1_SCK (pin_B3)
114-
#define MICROPY_HW_SPI1_MISO (pin_B4)
115-
#define MICROPY_HW_SPI1_MOSI (pin_D7)
116-
117-
// External SPI Flash configuration
118-
#define MICROPY_HW_SPI_IS_RESERVED(id) (id == 1)
119-
120-
// Disable internal filesystem to use spiflash.
121-
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
122-
123-
// 8MB SPI flash
124-
#define MICROPY_HW_SPIFLASH_SIZE_BYTES (8 * 1024 * 1024)
125-
126-
// SPI flash pins
127-
#define MICROPY_HW_SPIFLASH_CS (pyb_pin_FLASH_CS)
128-
#define MICROPY_HW_SPIFLASH_SCK (pyb_pin_FLASH_SCK)
129-
#define MICROPY_HW_SPIFLASH_MOSI (pyb_pin_FLASH_MOSI)
130-
#define MICROPY_HW_SPIFLASH_MISO (pyb_pin_FLASH_MISO)
131-
132-
extern const struct _mp_spiflash_config_t spiflash_config;
133-
extern struct _spi_bdev_t spi_bdev;
134-
#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
135-
#define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev)
136-
#define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config)
137-
#define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES (MICROPY_HW_SPIFLASH_SIZE_BITS / 8)
138-
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
139-
#define MICROPY_HW_SPIFLASH_SIZE_BITS (MICROPY_HW_SPIFLASH_SIZE_BYTES * 8)
172+
// USB config
173+
#define MICROPY_HW_USB_FS (1)
140174

141175
void WeAct_Core_early_init(void);

ports/stm32/boards/WeAct_H743VI/mpconfigboard.mk renamed to ports/stm32/boards/WEACT_STM32H743/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LD_FILES = boards/stm32h723.ld boards/common_bl.ld
1212
TEXT0_ADDR = 0x08020000
1313
else
1414
# When not using Mboot everything goes at the start of flash
15-
LD_FILES = boards/stm32h723.ld boards/common_basic.ld
15+
LD_FILES = boards/WEACT_STM32H743/weact_stm32h743.ld boards/common_basic.ld
1616
TEXT0_ADDR = 0x08000000
1717
endif
1818

ports/stm32/boards/WeAct_H743VI/pins.csv renamed to ports/stm32/boards/WEACT_STM32H743/pins.csv

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -75,44 +75,26 @@ E12,PE12
7575
E13,PE13
7676
E14,PE14
7777
E15,PE15
78-
DAC1,PA4
79-
DAC2,PA5
80-
LED1,PE3
81-
SW,PC13
82-
I2C1_SDA,PB9
83-
I2C1_SCL,PB8
84-
I2C2_SDA,PF0
85-
I2C2_SCL,PF1
86-
I2C4_SCL,PF14
87-
I2C4_SDA,PF15
88-
SD_D0,PC8
89-
SD_D1,PC9
90-
SD_D2,PC10
91-
SD_D3,PC11
92-
SD_CMD,PD2
93-
SD_CK,PC12
94-
SD_SW,PG2
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
9597
OTG_FS_POWER,PD10
9698
OTG_FS_OVER_CURRENT,PG7
9799
USB_VBUS,PA9
98100
USB_ID,PA10
99-
USB_DM,PA11
100-
USB_DP,PA12
101-
UART2_TX,PD5
102-
UART2_RX,PD6
103-
UART2_RTS,PD4
104-
UART2_CTS,PD3
105-
UART3_TX,PD8
106-
UART3_RX,PD9
107-
UART5_TX,PB6
108-
UART5_RX,PB12
109-
UART6_TX,PC6
110-
UART6_RX,PC7
111-
UART7_TX,PF7
112-
UART7_RX,PF6
113-
UART8_TX,PE1
114-
UART8_RX,PE0
115-
-FLASH_CS,PD6
116-
-FLASH_SCK,PB3
117-
-FLASH_MISO,PB4
118-
-FLASH_MOSI,PD7

ports/stm32/boards/WeAct_H743VI/stm32h7xx_hal_conf.h renamed to ports/stm32/boards/WEACT_STM32H743/stm32h7xx_hal_conf.h

File renamed without changes.

0 commit comments

Comments
 (0)