Skip to content

Commit b4d546d

Browse files
miketlkdpgeorge
authored andcommitted
stm32/boards/STM32F469DISC: Add new board definition files.
Signed-off-by: Mike Tolkachev <contact@miketolkachev.dev>
1 parent cad9bb3 commit b4d546d

File tree

6 files changed

+418
-0
lines changed

6 files changed

+418
-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) 2025 Mike Tolkachev <contact@miketolkachev.dev>
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+
static mp_spiflash_cache_t spi_bdev_cache;
32+
#endif
33+
34+
// External SPI flash uses QSPI interface
35+
const mp_spiflash_config_t spiflash_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 flash device instance
45+
spi_bdev_t spi_bdev;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2025 Mike Tolkachev <contact@miketolkachev.dev>
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 "py/mphal.h"
28+
#include "storage.h"
29+
#include "boardctrl.h"
30+
#include "qspi.h"
31+
32+
// Micron N25Q128A13EF840F of original STM32F469I-DISCO board
33+
static const mp_spiflash_chip_params_t chip_params_n25q128a13ef840f = {
34+
.jedec_id = 0, // Not used for detection
35+
.memory_size_bytes_log2 = MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2,
36+
.qspi_prescaler = MICROPY_HW_QSPI_PRESCALER,
37+
.qread_num_dummy = MICROPY_HW_QSPIFLASH_DUMMY_CYCLES
38+
};
39+
40+
// Early board initialization hook called before file system is mounted
41+
void STM32F469DISC_board_early_init(void) {
42+
// Initialize QSPI flash device parameters
43+
MICROPY_HW_BDEV_SPIFLASH->spiflash.chip_params = &chip_params_n25q128a13ef840f;
44+
}
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2025 Mike Tolkachev <contact@miketolkachev.dev>
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+
// This board is configured to communicate over USB port, not ST-Link
28+
29+
#define MICROPY_HW_BOARD_NAME "F469DISC"
30+
#define MICROPY_HW_MCU_NAME "STM32F469"
31+
32+
// Use external QSPI flash for storage by default
33+
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
34+
35+
#define MICROPY_HW_HAS_SWITCH (1)
36+
#define MICROPY_HW_HAS_FLASH (1)
37+
#define MICROPY_HW_ENABLE_RNG (1)
38+
#define MICROPY_HW_ENABLE_RTC (1)
39+
#define MICROPY_HW_ENABLE_DAC (1)
40+
#define MICROPY_HW_ENABLE_USB (1)
41+
#define MICROPY_HW_ENABLE_SDCARD (1)
42+
43+
#define MICROPY_BOARD_EARLY_INIT STM32F469DISC_board_early_init
44+
void STM32F469DISC_board_early_init(void);
45+
46+
// QSPI flash storage configuration
47+
#if !BUILDING_MBOOT
48+
#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
49+
#endif
50+
#define MICROPY_HW_SPIFLASH_SOFT_RESET (1)
51+
#define MICROPY_HW_SPIFLASH_SIZE_BITS (128 * 1024 * 1024)
52+
#define MICROPY_HW_SPIFLASH_CHIP_PARAMS (1) // enable extended parameters
53+
#define MICROPY_HW_QSPI_PRESCALER (3)
54+
#define MICROPY_HW_QSPIFLASH_DUMMY_CYCLES (4)
55+
#define MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 (27)
56+
#define MICROPY_HW_QSPIFLASH_CS (pyb_pin_QSPI_CS)
57+
#define MICROPY_HW_QSPIFLASH_SCK (pyb_pin_QSPI_CLK)
58+
#define MICROPY_HW_QSPIFLASH_IO0 (pyb_pin_QSPI_D0)
59+
#define MICROPY_HW_QSPIFLASH_IO1 (pyb_pin_QSPI_D1)
60+
#define MICROPY_HW_QSPIFLASH_IO2 (pyb_pin_QSPI_D2)
61+
#define MICROPY_HW_QSPIFLASH_IO3 (pyb_pin_QSPI_D3)
62+
63+
// QSPI flash block device configuration
64+
extern const struct _mp_spiflash_config_t spiflash_config;
65+
extern struct _spi_bdev_t spi_bdev;
66+
#define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev)
67+
#define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config)
68+
#define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES (MICROPY_HW_SPIFLASH_SIZE_BITS / 8)
69+
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
70+
71+
// HSE is 8MHz
72+
#define MICROPY_HW_CLK_PLLM (8)
73+
#define MICROPY_HW_CLK_PLLN (336)
74+
#define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV2)
75+
#define MICROPY_HW_CLK_PLLQ (7)
76+
77+
#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_6
78+
79+
// UART config
80+
#define MICROPY_HW_UART3_NAME "YB"
81+
#define MICROPY_HW_UART3_TX (pin_B10)
82+
#define MICROPY_HW_UART3_RX (pin_B11)
83+
#define MICROPY_HW_UART6_NAME "YA"
84+
#define MICROPY_HW_UART6_TX (pin_G14)
85+
#define MICROPY_HW_UART6_RX (pin_G9)
86+
#define MICROPY_HW_UART2_NAME "UART2"
87+
#define MICROPY_HW_UART2_TX (pin_A2) // Needed to enable AF
88+
#define MICROPY_HW_UART2_RX (pin_A3) // Dummy, not routed on PCB
89+
#define MICROPY_HW_UART2_CK (pin_A4)
90+
91+
// I2C buses
92+
#define MICROPY_HW_I2C1_SCL (pin_B8)
93+
#define MICROPY_HW_I2C1_SDA (pin_B9)
94+
95+
// SPI
96+
#define MICROPY_HW_SPI2_NSS (pin_B9)
97+
#define MICROPY_HW_SPI2_SCK (pin_D3)
98+
#define MICROPY_HW_SPI2_MISO (pin_B14)
99+
#define MICROPY_HW_SPI2_MOSI (pin_B15)
100+
101+
// CAN buses
102+
#define MICROPY_HW_CAN1_TX (pin_B9)
103+
#define MICROPY_HW_CAN1_RX (pin_B8)
104+
105+
// USRSW is pulled low. Pressing the button makes the input go high.
106+
#define MICROPY_HW_USRSW_PIN (pin_A0)
107+
#define MICROPY_HW_USRSW_PULL (GPIO_NOPULL)
108+
#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
109+
#define MICROPY_HW_USRSW_PRESSED (1)
110+
111+
// LEDs
112+
#define MICROPY_HW_LED1 (pin_G6) // green
113+
#define MICROPY_HW_LED2 (pin_D4) // orange
114+
#define MICROPY_HW_LED3 (pin_D5) // red
115+
#define MICROPY_HW_LED4 (pin_K3) // blue
116+
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
117+
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
118+
119+
// SD Card SDMMC
120+
#define MICROPY_HW_SDCARD_CK (pin_C12)
121+
#define MICROPY_HW_SDCARD_CMD (pin_D2)
122+
#define MICROPY_HW_SDCARD_D0 (pin_C8)
123+
#define MICROPY_HW_SDCARD_D1 (pin_C9)
124+
#define MICROPY_HW_SDCARD_D2 (pin_C10)
125+
#define MICROPY_HW_SDCARD_D3 (pin_C11)
126+
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_G2)
127+
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
128+
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
129+
130+
// USB config
131+
#define MICROPY_HW_USB_FS (1)
132+
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
133+
#define MICROPY_HW_USB_OTG_ID_PIN (pin_A10)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# MCU settings
2+
MCU_SERIES = f4
3+
CMSIS_MCU = STM32F469xx
4+
MICROPY_FLOAT_IMPL = double
5+
AF_FILE = boards/stm32f479_af.csv
6+
7+
ifeq ($(USE_MBOOT),1)
8+
# When using Mboot all the text goes together after the filesystem
9+
LD_FILES = boards/stm32f469xi.ld boards/common_blifs.ld
10+
TEXT0_ADDR = 0x08020000
11+
else
12+
# When not using Mboot the ISR text goes first, then the rest after the filesystem
13+
LD_FILES = boards/stm32f469xi.ld boards/common_ifs.ld
14+
TEXT0_ADDR = 0x08000000
15+
TEXT1_ADDR = 0x08020000
16+
endif
17+
18+
# MicroPython settings
19+
MICROPY_PY_SSL = 1
20+
MICROPY_SSL_MBEDTLS = 1
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
A0,PB1
2+
A1,PC2
3+
A2,PC3
4+
A3,PC4
5+
A4,PC5
6+
A5,PA4
7+
D0,PG9
8+
D1,PG14
9+
D2,PG13
10+
D3,PA1
11+
D4,PG12
12+
D5,PA2
13+
D6,PA6
14+
D7,PG11
15+
D8,PG10
16+
D9,PA7
17+
D10,PH6
18+
D11,PB15
19+
D12,PB14
20+
D13,PD3
21+
D14,PB9
22+
D15,PB8
23+
LED1,PG6
24+
LED2,PD4
25+
LED3,PD5
26+
LED4,PK3
27+
SW,PA0
28+
TP1,PH2
29+
TP2,PI8
30+
TP3,PH15
31+
AUDIO_INT,PD6
32+
AUDIO_SDA,PH8
33+
AUDIO_SCL,PH7
34+
EXT_SDA,PB9
35+
EXT_SCL,PB8
36+
EXT_RST,PG3
37+
SD_D0,PC8
38+
SD_D1,PC9
39+
SD_D2,PC10
40+
SD_D3,PC11
41+
SD_CK,PC12
42+
SD_CMD,PD2
43+
SD_SW,PC2
44+
LCD_BL_CTRL,PK3
45+
LCD_INT,PI13
46+
LCD_SDA,PH8
47+
LCD_SCL,PH7
48+
OTG_FS_POWER,PD5
49+
OTG_FS_OVER_CURRENT,PD4
50+
OTG_HS_OVER_CURRENT,PE3
51+
USB_VBUS,PA9
52+
USB_ID,PA10
53+
USB_DM,PA11
54+
USB_DP,PA12
55+
USB_HS_CLK,PA5
56+
USB_HS_STP,PC0
57+
USB_HS_NXT,PH4
58+
USB_HS_DIR,PI11
59+
USB_HS_D0,PA3
60+
USB_HS_D1,PB0
61+
USB_HS_D2,PB1
62+
USB_HS_D3,PB10
63+
USB_HS_D4,PB11
64+
USB_HS_D5,PB12
65+
USB_HS_D6,PB13
66+
USB_HS_D7,PB5
67+
UART1_TX,PB10
68+
UART1_RX,PB11
69+
UART6_TX,PG14
70+
UART6_RX,PG9
71+
CAN2_TX,PB13
72+
CAN2_RX,PB12
73+
QSPI_CS,PB6
74+
QSPI_CLK,PF10
75+
QSPI_D0,PF8
76+
QSPI_D1,PF9
77+
QSPI_D2,PF7
78+
QSPI_D3,PF6
79+
FMC_SDCKE0,PH2
80+
FMC_SDNE0,PH3
81+
FMC_SDCLK,PG8
82+
FMC_SDNCAS,PG15
83+
FMC_SDNRAS,PF11
84+
FMC_SDNWE,PH5
85+
FMC_BA0,PG4
86+
FMC_BA1,PG5
87+
FMC_NBL0,PE0
88+
FMC_NBL1,PE1
89+
FMC_NBL2,PI4
90+
FMC_NBL3,PI5
91+
FMC_A0,PF0
92+
FMC_A1,PF1
93+
FMC_A2,PF2
94+
FMC_A3,PF3
95+
FMC_A4,PF4
96+
FMC_A5,PF5
97+
FMC_A6,PF12
98+
FMC_A7,PF13
99+
FMC_A8,PF14
100+
FMC_A9,PF15
101+
FMC_A10,PG0
102+
FMC_A11,PG1
103+
FMC_A12,PG2
104+
FMC_D0,PD14
105+
FMC_D1,PD15
106+
FMC_D2,PD0
107+
FMC_D3,PD1
108+
FMC_D4,PE7
109+
FMC_D5,PE8
110+
FMC_D6,PE9
111+
FMC_D7,PE10
112+
FMC_D8,PE11
113+
FMC_D9,PE12
114+
FMC_D10,PE13
115+
FMC_D11,PE14
116+
FMC_D12,PE15
117+
FMC_D13,PD8
118+
FMC_D14,PD9
119+
FMC_D15,PD10
120+
FMC_D16,PH8
121+
FMC_D17,PH9
122+
FMC_D18,PH10
123+
FMC_D19,PH11
124+
FMC_D20,PH12
125+
FMC_D21,PH13
126+
FMC_D22,PH14
127+
FMC_D23,PH15
128+
FMC_D24,PI0
129+
FMC_D25,PI1
130+
FMC_D26,PI2
131+
FMC_D27,PI3
132+
FMC_D28,PI6
133+
FMC_D29,PI7
134+
FMC_D30,PI9
135+
FMC_D31,PI10

0 commit comments

Comments
 (0)