8000 ports/stm32/boards: Add WEACT_STM32H743 board. · micropython/micropython@f1f1082 · GitHub
[go: up one dir, main page]

Skip to content

Commit f1f1082

Browse files
mattytrentinipi-mst
authored andcommitted
ports/stm32/boards: Add WEACT_STM32H743 board.
Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
1 parent e2532e0 commit f1f1082

File tree

9 files changed

+411
-0
lines changed

9 files changed

+411
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2023 Matt Trenitni
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "storage.h"
28+
#include "qspi.h"
29+
30+
#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
31+
// Shared cache for first and second SPI block devices
32+
STATIC mp_spiflash_cache_t spi_bdev_cache;
33+
#endif
34+
35+
// First external SPI flash uses hardware QSPI interface
36+
const mp_spiflash_config_t spiflash_config = {
37+
.bus_kind = MP_SPIFLASH_BUS_QSPI,
38+
.bus.u_qspi.data = NULL,
39+
.bus.u_qspi.proto = &qspi_proto,
40+
#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
41+
.cache = &spi_bdev_cache,
42+
#endif
43+
};
44+
45+
spi_bdev_t spi_bdev;
Lines changed: 13 additions & 0 deletions
67F4
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: 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: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/*
2+
* The MIT License (MIT)
3+
* Copyright (c) 2023 Matt Trentini
4+
*/
5+
6+
#define MICROPY_HW_BOARD_NAME "WEACT_STM32H743"
7+
#define MICROPY_HW_MCU_NAME "STM32H743VIT6"
8+
#define MICROPY_HW_FLASH_FS_LABEL "WEACT_STM32H743"
9+
10+
#define MICROPY_FATFS_EXFAT (1)
11+
#define MICROPY_HW_ENABLE_RTC (1)
12+
#define MICROPY_HW_ENABLE_RNG (1)
13+
#define MICROPY_HW_ENABLE_ADC (1)
14+
#define MICROPY_HW_ENABLE_DAC (1)
15+
#define MICROPY_HW_ENABLE_USB (1)
16+
#define MICROPY_HW_HAS_SWITCH (1)
17+
#define MICROPY_HW_HAS_FLASH (1)
18+
#define MICROPY_HW_ENABLE_SERVO (1)
19+
#define MICROPY_HW_ENABLE_TIMER (1)
20+
#define MICROPY_HW_ENABLE_SDCARD (1)
21+
#define MICROPY_HW_ENABLE_MMCARD (0)
22+
23+
// Flash storage config
24+
#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
25+
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
26+
27+
// Clock config
28+
#define MICROPY_HW_CLK_PLLM (5)
29+
#define MICROPY_HW_CLK_PLLN (160)
30+
#define MICROPY_HW_CLK_PLLP (2)
31+
#define MICROPY_HW_CLK_PLLQ (4)
32+
#define MICROPY_HW_CLK_PLLR (2)
33+
#define MICROPY_HW_CLK_PLLVCI (RCC_PLL1VCIRANGE_1)
34+
#define MICROPY_HW_CLK_PLLVCO (RCC_PLL1VCOWIDE)
35+
#define MICROPY_HW_CLK_PLLFRAC (0)
36+
37+
#define MICROPY_HW_CLK_PLL3M (25)
38+
#define MICROPY_HW_CLK_PLL3N (240)
39+
#define MICROPY_HW_CLK_PLL3P (2)
40+
#define MICROPY_HW_CLK_PLL3Q (5)
41+
#define MICROPY_HW_CLK_PLL3R (2)
42+
#define MICROPY_HW_CLK_PLL3VCI (RCC_PLL3VCIRANGE_1)
43+
#define MICROPY_HW_CLK_PLL3VCO (RCC_PLL3VCOWIDE)
44+
#define MICROPY_HW_CLK_PLL3FRAC (0)
45+
46+
// 32kHz crystal for RTC
47+
#define MICROPY_HW_RTC_USE_LSE (1)
48+
#define MICROPY_HW_RTC_USE_US (0)
49+
50+
#if (MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE == 0)
51+
// W25Q64 for storage
52+
#define MICROPY_HW_QSPI_PRESCALER (2) // 100 MHz
53+
#define MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 (26)
54+
#define MICROPY_HW_SPIFLASH_SIZE_BITS (64 * 1024 * 1024)
55+
#define MICROPY_HW_QSPIFLASH_CS (pin_B6)
56+
#define MICROPY_HW_QSPIFLASH_SCK (pin_B2)
57+
#define MICROPY_HW_QSPIFLASH_IO0 (pin_D11)
58+
#define MICROPY_HW_QSPIFLASH_IO1 (pin_D12)
59+
#define MICROPY_HW_QSPIFLASH_IO2 (pin_E2)
60+
#define MICROPY_HW_QSPIFLASH_IO3 (pin_D13)
61+
62+
// SPI flash, block device config
63+
extern const struct _mp_spiflash_config_t spiflash_config;
64+
extern struct _spi_bdev_t spi_bdev;
65+
#define MICROPY_HW_BDEV_IOCTL(op, arg) ( \
66+
(op) == BDEV_IOCTL_NUM_BLOCKS ? (MICROPY_HW_SPIFLASH_SIZE_BITS / 8 / FLASH_BLOCK_SIZE) : \
67+
(op) == BDEV_IOCTL_INIT ? spi_bdev_ioctl(&spi_bdev, (op), (uint32_t)&spiflash_config) : \
68+
spi_bdev_ioctl(&spi_bdev, (op), (arg)) \
69+
)
70+
#define MICROPY_HW_BDEV_READBLOCKS(dest, bl, n) spi_bdev_readblocks(&spi_bdev, (dest), (bl), (n))
71+
#define MICROPY_HW_BDEV_WRITEBLOCKS(src, bl, n) spi_bdev_writeblocks(&spi_bdev, (src), (bl), (n))
72+
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev)
73+
#endif
74+
75+
// 4 wait states
76+
#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_2
77+
78+
// UART
79+
#define MICROPY_HW_UART1_TX (pin_A9)
80+
#define MICROPY_HW_UART1_RX (pin_A10)
81+
82+
#define MICROPY_HW_UART2_TX (pin_A2)
83+
#define MICROPY_HW_UART2_RX (pin_A3)
84+
85+
// I2C buses
86+
#define MICROPY_HW_I2C1_SCL (pin_B8)
87+
#define MICROPY_HW_I2C1_SDA (pin_B9)
88+
89+
#define MICROPY_HW_I2C2_SCL (pin_B10)
90+
#define MICROPY_HW_I2C2_SDA (pin_B11)
91+
92+
// SPI buses
93+
// NOTE: SPI3 is used for the QSPI flash.
94+
#define MICROPY_HW_SPI1_NSS (pin_A4)
95+
#define MICROPY_HW_SPI1_SCK (pin_A5)
96+
#define MICROPY_HW_SPI1_MISO (pin_A6)
97+
#define MICROPY_HW_SPI1_MOSI (pin_A7)
98+
99+
#define MICROPY_HW_SPI2_NSS (pin_B12)
100+
#define MICROPY_HW_SPI2_SCK (pin_B13)
101+
#define MICROPY_HW_SPI2_MISO (pin_B14)
102+
#define MICROPY_HW_SPI2_MOSI (pin_B15)
103+
104+
#define MICROPY_HW_SPI4_NSS (pin_E11)
105+
#define MICROPY_HW_SPI4_SCK (pin_E12)
106+
#define MICROPY_HW_SPI4_MOSI (pin_E14)
107+
#define MICROPY_HW_SPI4_MISO (pin_E13)
108+
// https://community.st.com/t5/embedded-software-mcus/issue-with-bootloader-on-stm32h743-using-boot0-and-inline/td-p/73183
109+
110+
// CAN buses
111+
#define MICROPY_HW_CAN1_TX (pin_B9)
112+
#define MICROPY_HW_CAN1_RX (pin_B8)
113+
114+
// USRSW
115+
#define MICROPY_HW_USRSW_PIN (pin_C13) // K1 on the board.
116+
#define MICROPY_HW_USRSW_PULL (GPIO_NOPULL)
117+
#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
118+
#define MICROPY_HW_USRSW_PRESSED (0)
119+
120+
// LEDs
121+
#define MICROPY_HW_LED1 (pin_E3) // the only controllable LED on the board.
122+
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
123+
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
124+
125+
// SD Card SDMMC
126+
#define MICROPY_HW_SDCARD_SDMMC (1)
127+
#define MICROPY_HW_SDCARD_CK (pin_C12)
128+
#define MICROPY_HW_SDCARD_CMD (pin_D2)
129+
#define MICROPY_HW_SDCARD_D0 (pin_C8)
130+
#define MICROPY_HW_SDCARD_D1 (pin_C9)
131+
#define MICROPY_HW_SDCARD_D2 (pin_C10)
132+
#define MICROPY_HW_SDCARD_D3 (pin_C11)
133+
134+
// USB config
135+
#define MICROPY_HW_USB_FS (1)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# MCU settings
2+
MCU_SERIES = h7
3+
CMSIS_MCU = STM32H743xx
4+
MICROPY_FLOAT_IMPL = double
5+
AF_FILE = boards/stm32h743_af.csv
6+
LD_FILES = boards/WEACT_STM32H743/weact_stm32h743.ld boards/common_basic.ld
7+
TEXT0_ADDR = 0x08000000
8+
9+
# MicroPython settings
10+
MICROPY_PY_SSL = 1
11+
MICROPY_SSL_MBEDTLS = 1
12+
MICROPY_PY_LWIP = 1
13+
MICROPY_PY_USSL = 1
14+
MICROPY_VFS_LFS2 = 1
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
PA0,PA0
2+
PA1,PA1
3+
PA2,PA2
4+
PA3,PA3
5+
PA4,PA4
6+
PA5,PA5
7+
PA6,PA6
8+
PA7,PA7
9+
PA8,PA8
10+
PA9,PA9
11+
PA10,PA10
12+
PA11,PA11
13+
PA12,PA12
14+
PA13,PA13
15+
PA14,PA14
16+
PA15,PA15
17+
PB0,PB0
18+
PB1,PB1
19+
PB2,PB2
20+
PB3,PB3
21+
PB4,PB4
22+
PB5,PB5
23+
PB6,PB6
24+
PB7,PB7
25+
PB8,PB8
26+
PB9,PB9
27+
PB10,PB10
28+
PB11,PB11
29+
PB12,PB12
30+
PB13,PB13
31+
PB14,PB14
32+
PB15,PB15
33+
PC0,PC0
34+
PC1,PC1
35+
PC2,PC2
36+
PC3,PC3
37+
PC4,PC4
38+
PC5,PC5
39+
PC6,PC6
40+
PC7,PC7
41+
PC8,PC8
42+
PC9,PC9
43+
PC10,PC10
44+
PC11,PC11
45+
PC12,PC12
46+
PC13,PC13
47+
PC14,PC14
48+
PC15,PC15
49+
PD0,PD0
50+
PD1,PD1
51+
PD2,PD2
52+
PD3,PD3
53+
PD4,PD4
54+
PD5,PD5
55+
PD6,PD6
56+
PD7,PD7
57+
PD8,PD8
58+
PD9,PD9
59+
PD10,PD10
60+
PD11,PD11
61+
PD12,PD12
62+
PD13,PD13
63+
PD14,PD14
64+
PD15,PD15
65+
PE0,PE0
66+
PE1,PE1
67+
PE2,PE2
68+
PE3,PE3
69+
PE4,PE4
70+
PE5,PE5
71+
PE6,PE6
72+
PE7,PE7
73+
PE8,PE8
74+
PE9,PE9
75+
PE10,PE10
76+
PE11,PE11
77+
PE12,PE12
78+
PE13,PE13
79+
PE14,PE14
80+
PE15,PE15
81+
LED_BLUE,PE3
82+
KEY_1,PC13
83+
QSPI_CS,PB6
84+
QSPI_CLK,PB2
85+
QSPI_D0,PD11
86+
QSPI_D1,PD12
87+
QSPI_D2,PE2
88+
QSPI_D3,PD13
89+
USB_DM,PA11
90+
USB_DP,PA12
91+
DCMI_SDA,PB11
92+
DCMI_SCL,PB10
93+
DCMI_RESET,PC4
94+
DCMI_CH1,PA4
95+
DCMI_PWDN,PA7
96+
DCMI_HREF,PA4
97+
DCMI_VSYNC,PB7
98+
DCMI_D0,PC6
99+
DCMI_D1,PC7
100+
DCMI_D2,PE0
101+
DCMI_D3,PE1
102+
DCMI_D4,PE4
103+
DCMI_D5,PD3
104+
DCMI_D6,PE5
105+
DCMI_D7,PE6
106+
DCMI_PCLK,PA6
107+
DCMI_XCLK,PA8
108+
OSC32_IN,PC14
109+
OSC32_OUT,PC15
110+
SDIO_CK,PC12
111+
SDIO_CMD,PD2
112+
SDIO_D0,PC8
113+
SDIO_D1,PC9
114+
SDIO_D2,PC10
115+
SDIO_D3,PC11
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
#ifndef MICROPY_INCLUDED_STM32H7XX_HAL_CONF_H
6+
#define MICROPY_INCLUDED_STM32H7XX_HAL_CONF_H
7+
8+
#include "boards/stm32h7xx_hal_conf_base.h"
9+
10+
// Oscillator values in Hz
11+
#define HSE_VALUE (25000000)
12+
#define LSE_VALUE (32768)
13+
#define EXTERNAL_CLOCK_VALUE (12288000)
14+
15+
// Oscillator timeouts in ms
16+
#define HSE_STARTUP_TIMEOUT (5000)
17+
#define LSE_STARTUP_TIMEOUT (5000)
18+
19+
#endif // MICROPY_INCLUDED_STM32H7XX_HAL_CONF_H

0 commit comments

Comments
 (0)
0