Skip to content

Commit 5ae78fb

Browse files
bpbradleyMaureenHelm
authored andcommitted
boards: add support for stm32f401_mini
Adds support for the stm32f401cc based stm32 mini f401 board. Signed-off-by: Brian Bradley <[email protected]>
1 parent 585eb7f commit 5ae78fb

File tree

10 files changed

+383
-0
lines changed

10 files changed

+383
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2022 Brian Bradley
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# STM32 Mini F401 Board
5+
6+
config BOARD_STM32F401_MINI
7+
bool "STM32 Mini F401 Board"
8+
depends on SOC_STM32F401XC
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2022 Brian Bradley
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# STM32 Mini F401 board definitions
5+
6+
if BOARD_STM32F401_MINI
7+
8+
config BOARD
9+
default "stm32f401_mini"
10+
11+
config SPI_STM32_INTERRUPT
12+
default y
13+
depends on SPI
14+
15+
endif # BOARD_STM32F401_MINI

boards/arm/stm32f401_mini/board.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
board_runner_args(dfu-util "--pid=0483:df11" "--alt=0" "--dfuse")
4+
board_runner_args(jlink "--device=STM32F401CC" "--speed=4000")
5+
6+
include(${ZEPHYR_BASE}/boards/common/dfu-util.board.cmake)
7+
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
8+
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
9+
include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake)
578 KB
Loading
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
.. _stm32f401_mini:
2+
3+
STM32 Mini F401
4+
###############
5+
6+
Overview
7+
********
8+
9+
The STM32 Mini F401 is an extremely low cost and bare-bones
10+
development board featuring the STM32F401CC, see `STM32F401CC website`_.
11+
More info about the board with schematics available `here <stm32-base-board-page>`_
12+
13+
.. image:: img/STM32_Mini_F401-1.jpg
14+
:align: center
15+
:alt: STM32 Mini F401
16+
17+
Hardware
18+
********
19+
20+
The STM32F401CC based board provides the following
21+
hardware components:
22+
23+
- STM32F401CCU6 in UFQFPN48 package
24+
- ARM |reg| 32-bit Cortex |reg| -M4 CPU with FPU
25+
- 84 MHz max CPU frequency
26+
- VDD from 1.7 V to 3.6 V
27+
- 256 KB Flash
28+
- 64 KB SRAM
29+
- GPIO with external interrupt capability
30+
- 1x12-bit, 2.4 MSPS ADC with 16 channels
31+
- DMA Controller
32+
- Up to 11 Timers (six 16-bit, two 32-bit, two watchdog timers and a SysTick timer)
33+
- USART/UART (3)
34+
- I2C (3)
35+
- SPI/I2S (4)
36+
- SDIO
37+
- USB 2.0 full-speed device/host/OTG controller with on-chip PHY
38+
- CRC calculation unit
39+
- 96-bit unique ID
40+
- RTC
41+
42+
Supported Features
43+
==================
44+
45+
The Zephyr stm32f401_mini board configuration supports the following
46+
hardware features:
47+
48+
+------------+------------+-------------------------------------+
49+
| Interface | Controller | Driver/Component |
50+
+============+============+=====================================+
51+
| NVIC | on-chip | nested vector interrupt controller |
52+
+------------+------------+-------------------------------------+
53+
| SYSTICK | on-chip | system clock |
54+
+------------+------------+-------------------------------------+
55+
| UART | on-chip | serial port |
56+
+------------+------------+-------------------------------------+
57+
| GPIO | on-chip | gpio |
58+
+------------+------------+-------------------------------------+
59+
| PINMUX | on-chip | pinmux |
60+
+------------+------------+-------------------------------------+
61+
| FLASH | on-chip | flash |
62+
+------------+------------+-------------------------------------+
63+
| SPI | on-chip | spi |
64+
+------------+------------+-------------------------------------+
65+
| I2C | on-chip | i2c |
66+
+------------+------------+-------------------------------------+
67+
| ADC | on-chip | ADC Controller |
68+
+------------+------------+-------------------------------------+
69+
| USB OTG FS | on-chip | USB device |
70+
+------------+------------+-------------------------------------+
71+
72+
The default configuration can be found in the defconfig file:
73+
74+
``boards/arm/stm32f401_mini/stm32f401_mini_defconfig``
75+
76+
Default Zephyr Peripheral Mapping:
77+
----------------------------------
78+
79+
- UART_1 TX/RX : PA9/PA10
80+
- I2C1 SCL/SDA : PB8/PB9
81+
- SPI1 CS/SCK/MISO/MOSI : PA4/PA5/PA6/PA7
82+
- PWM_4_CH1 : PB6
83+
- PWM_4_CH2 : PB7
84+
- ADC_1 : PA1
85+
- SW0 : PB2 (routed to BOOT1 dip switch)
86+
- LED0 : PC13
87+
88+
Clock Sources
89+
-------------
90+
91+
The board has two external oscillators. The frequency of the slow clock (LSE) is
92+
32.768 kHz. The frequency of the main clock (HSE) is 25 MHz.
93+
94+
The default configuration sources the system clock from the PLL, which is
95+
derived from HSE, and is set at 84MHz.
96+
97+
Programming and Debugging
98+
*************************
99+
100+
There are 2 main entry points for flashing STM32F4X SoCs, one using the ROM
101+
bootloader, and another by using the SWD debug port (which requires additional
102+
hardware). Flashing using the ROM bootloader requires a special activation
103+
pattern, which can be triggered by using the BOOT0 pin, which on this board
104+
is a dip switch.
105+
106+
Flashing
107+
========
108+
109+
Installing dfu-util
110+
-------------------
111+
112+
It is recommended to use at least v0.8 of `dfu-util`_. The package available in
113+
debian/ubuntu can be quite old, so you might have to build dfu-util from source.
114+
115+
There is also a Windows version which works, but you may have to install the
116+
right USB drivers with a tool like `Zadig`_.
117+
118+
Flashing an Application
119+
-----------------------
120+
121+
Connect a USB-C cable and the board should power ON. Force the board into DFU mode
122+
by setting the BOOT0 dip switch position to ON. Reset the board with the NRST button.
123+
124+
The dfu-util runner is supported on this board and so a sample can be built and
125+
tested easily.
126+
127+
.. zephyr-app-commands::
128+
:zephyr-app: samples/basic/blinky
129+
:board: stm32f401_mini
130+
:goals: build flash
131+
132+
Debugging
133+
=========
134+
135+
The board can be debugged by installing the included 100 mil (0.1 inch) header,
136+
and attaching an SWD debugger to the 3V3 (3.3V), GND, SCK, and DIO
137+
pins on that header.
138+
139+
References
140+
**********
141+
142+
.. target-notes::
143+
144+
.. _Zadig:
145+
https://zadig.akeo.ie/
146+
147+
.. _stm32-base-board-page:
148+
https://stm32-base.org/boards/STM32F401CCU6-STM32-Mini-F401
149+
150+
.. _dfu-util:
151+
http://dfu-util.sourceforge.net/build.html
152+
153+
.. _STM32F401CC website:
154+
https://www.st.com/en/microcontrollers-microprocessors/stm32f401cc.html
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/*
2+
* Copyright (c) 2022 Brian Bradley ([email protected])
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/dts-v1/;
8+
#include <st/f4/stm32f401Xc.dtsi>
9+
#include <st/f4/stm32f401c(b-c)ux-pinctrl.dtsi>
10+
11+
/ {
12+
model = "STM32 Mini F401";
13+
compatible = "stm32f401_mini";
14+
15+
chosen {
16+
zephyr,console = &usart1;
17+
zephyr,shell-uart = &usart1;
18+
zephyr,sram = &sram0;
19+
zephyr,flash = &flash0;
20+
};
21+
22+
leds {
23+
compatible = "gpio-leds";
24+
user_led: led {
25+
gpios = <&gpioc 13 GPIO_ACTIVE_LOW>;
26+
label = "User LED";
27+
};
28+
};
29+
30+
gpio_keys {
31+
compatible = "gpio-keys";
32+
boot1: button {
33+
label = "BOOT1";
34+
gpios = <&gpiob 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
35+
};
36+
};
37+
38+
aliases {
39+
led0 = &user_led;
40+
sw0 = &boot1;
41+
};
42+
};
43+
44+
&flash0 {
45+
partitions {
46+
compatible = "fixed-partitions";
47+
#address-cells = <1>;
48+
#size-cells = <1>;
49+
50+
boot_partition: partition@0 {
51+
label = "mcuboot";
52+
reg = <0x00000000 0x00010000>;
53+
read-only;
54+
};
55+
slot0_partition: partition@20000 {
56+
label = "image-0";
57+
reg = <0x00020000 0x00020000>;
58+
};
59+
slot1_partition: partition@40000 {
60+
label = "image-1";
61+
reg = <0x00040000 0x00020000>;
62+
};
63+
scratch_partition: partition@60000 {
64+
label = "image-scratch";
65+
reg = <0x00060000 0x00020000>;
66+
};
67+
};
68+
};
69+
70+
&timers4 {
71+
status = "okay";
72+
73+
pwm4: pwm {
74+
status = "okay";
75+
pinctrl-0 = <&tim4_ch1_pb6 &tim4_ch2_pb7>;
76+
pinctrl-names = "default";
77+
};
78+
};
79+
80+
&usart1 {
81+
pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
82+
pinctrl-names = "default";
83+
status = "okay";
84+
current-speed = <115200>;
85+
};
86+
87+
&i2c1 {
88+
pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>;
89+
pinctrl-names = "default";
90+
status = "okay";
91+
clock-frequency = <I2C_BITRATE_FAST>;
92+
};
93+
94+
&spi1 {
95+
pinctrl-0 = <&spi1_sck_pa5 &spi1_nss_pa4
96+
&spi1_miso_pa6 &spi1_mosi_pa7>;
97+
pinctrl-names = "default";
98+
status = "okay";
99+
};
100+
101+
&rtc {
102+
status = "okay";
103+
};
104+
105+
zephyr_udc0: &usbotg_fs {
106+
pinctrl-0 = <&usb_otg_fs_dm_pa11 &usb_otg_fs_dp_pa12>;
107+
pinctrl-names = "default";
108+
status = "okay";
109+
};
110+
111+
&adc1 {
112+
pinctrl-0 = <&adc1_in1_pa1>;
113+
pinctrl-names = "default";
114+
status = "okay";
115+
};
116+
117+
&clk_hse {
118+
clock-frequency = <DT_FREQ_M(25)>;
119+
status = "okay";
120+
};
121+
122+
&pll {
123+
div-m = <25>;
124+
mul-n = <336>;
125+
div-p = <4>;
126+
div-q = <7>;
127+
clocks = <&clk_hse>;
128+
status = "okay";
129+
};
130+
131+
&rcc {
132+
clocks = <&pll>;
133+
clock-frequency = <DT_FREQ_M(84)>;
134+
ahb-prescaler = <1>;
135+
apb1-prescaler = <2>;
136+
apb2-prescaler = <1>;
137+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
identifier: stm32f401_mini
2+
name: STM32 Mini F401
3+
type: mcu
4+
arch: arm
5+
toolchain:
6+
- zephyr
7+
- gnuarmemb
8+
- xtools
9+
supported:
10+
- counter
11+
- spi
12+
- usb
13+
- i2c
14+
- uart
15+
- pwm
16+
- adc
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
CONFIG_SOC_SERIES_STM32F4X=y
4+
CONFIG_SOC_STM32F401XC=y
5+
6+
# Enable MPU
7+
CONFIG_ARM_MPU=y
8+
9+
# Enable HW stack protection
10+
CONFIG_HW_STACK_PROTECTION=y
11+
12+
# Serial Drivers
13+
CONFIG_SERIAL=y
14+
CONFIG_UART_INTERRUPT_DRIVEN=y
15+
CONFIG_CONSOLE=y
16+
CONFIG_UART_CONSOLE=y
17+
18+
# Enable GPIO
19+
CONFIG_GPIO=y
20+
21+
# Clock configuration
22+
CONFIG_CLOCK_CONTROL=y
23+
24+
# enable pin controller
25+
CONFIG_PINCTRL=y
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
source [find interface/stlink.cfg]
2+
3+
transport select hla_swd
4+
5+
source [find target/stm32f4x.cfg]
6+
7+
reset_config srst_only
8+
9+
$_TARGETNAME configure -event gdb-attach {
10+
echo "Debugger attaching: halting execution"
11+
reset halt
12+
gdb_breakpoint_override hard
13+
}
14+
15+
$_TARGETNAME configure -event gdb-detach {
16+
echo "Debugger detaching: resuming execution"
17+
resume
18+
}

tests/drivers/adc/adc_api/src/test_adc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211

212212
#elif defined(CONFIG_BOARD_NUCLEO_L476RG) || \
213213
defined(CONFIG_BOARD_BLACKPILL_F411CE) || \
214+
defined(CONFIG_BOARD_STM32F401_MINI) || \
214215
defined(CONFIG_BOARD_BLACKPILL_F401CE) || \
215216
defined(CONFIG_BOARD_NUCLEO_L4R5ZI) || \
216217
defined(CONFIG_BOARD_MIKROE_CLICKER_2)

0 commit comments

Comments
 (0)