1.. _stm32_min_dev:
2
3STM32 Minimum Development Board
4###############################
5
6Overview
7********
8
9The STM32 Minimum Development Board, is a popular and inexpensive
10breadboard-friendly breakout board for the `STM32F103x8`_ CPU. There
11are two variants of the board:
12
13- Blue Pill Board
14- Black Pill Board
15
16Zephyr applications can use the stm32_min_dev_blue or stm32_min_dev_black board
17configuration to use these boards.
18
19.. figure:: img/stm32_min_dev.jpg
20     :width: 500px
21     :align: center
22     :height: 350px
23     :alt: STM32 Minimum Development Board
24
25     STM32 Minimum Development Board
26
27As the name suggests, these boards have the bare minimum components required to
28power on the CPU. For practical use, you'll need to add additional components
29and circuits using a breadboard, for example.
30
31Pin Mapping
32===========
33
34This port is a starting point for your own customizations and not a complete
35port for a specific board. Most of the GPIOs on the STM32 SoC has been exposed
36in the external header with silk screen labels that match the SoC's pin names.
37
38Each board vendor has their own variations in pin mapping on their boards'
39external connectors and placement of components. Many vendors use port PC13/PB12
40for connecting an LED, so only this device is supported by our Zephyr port.
41Additional device support is left for the user to implement.
42
43More information on hooking up peripherals and lengthy how to articles can be
44found at `EmbedJournal`_.
45
46The pinout diagram of STM32 Minimum Development Blue Pill board can be seen
47below. The Black Pill's one is similar:
48
49.. figure:: img/stm32_min_dev_pinout_blue.jpg
50     :width: 500px
51     :align: center
52     :height: 350px
53     :alt: Pinout for STM32 Minimum Development Blue Pill Board
54
55     Pinout for STM32 Minimum Development Blue Pill Board
56
57
58STLinkV2 connection:
59====================
60
61The board can be flashed by using STLinkV2 with the following connections.
62
63+--------+---------------+
64| Pin    | STLINKv2      |
65+========+===============+
66| G      | GND           |
67+--------+---------------+
68| CLK    | Clock         |
69+--------+---------------+
70| IO     | SW IO         |
71+--------+---------------+
72| V3     | VCC           |
73+--------+---------------+
74
75Boot Configuration
76==================
77
78The boot configuration for this board is configured through jumpers on B0 (Boot 0)
79and B1 (Boot 1). The pins B0 and B1 are present in between logic 0 and 1 lines. The
80silk screen on the PCB reads BX- or BX+ to indicate 0 and 1 logic lines for B0 and B1
81respectively.
82
83+--------+--------+-------------------+---------------------------------------------+
84| Boot 1 | Boot 0 | Boot Mode         | Aliasing                                    |
85+========+========+===================+=============================================+
86| X      | 0      | Main Flash Memory | Main flash memory is selected as boot space |
87+--------+--------+-------------------+---------------------------------------------+
88| 0      | 1      | System Memory     | System memory is selected as boot space     |
89+--------+--------+-------------------+---------------------------------------------+
90| 1      | 1      | Embedded SRAM     | Embedded SRAM is selected as boot space     |
91+--------+--------+-------------------+---------------------------------------------+
92
93
94Supported Features
95==================
96
97The stm32_min_dev board configuration supports the following hardware features:
98
99+-----------+------------+----------------------+
100| Interface | Controller | Driver/Component     |
101+===========+============+======================+
102| NVIC      | on-chip    | nested vectored      |
103|           |            | interrupt controller |
104+-----------+------------+----------------------+
105| SYSTICK   | on-chip    | system clock         |
106+-----------+------------+----------------------+
107| UART      | on-chip    | serial port          |
108+-----------+------------+----------------------+
109| GPIO      | on-chip    | gpio                 |
110+-----------+------------+----------------------+
111| I2C       | on-chip    | i2c                  |
112+-----------+------------+----------------------+
113| PWM       | on-chip    | pwm                  |
114+-----------+------------+----------------------+
115| SPI       | on-chip    | spi                  |
116+-----------+------------+----------------------+
117| USB       | on-chip    | USB device           |
118+-----------+------------+----------------------+
119| ADC       | on-chip    | adc                  |
120+-----------+------------+----------------------+
121
122Other hardware features are not supported by the Zephyr kernel.
123
124Connections and IOs
125===================
126
127Default Zephyr Peripheral Mapping:
128----------------------------------
129
130- UART_1 TX/RX: PA9/PA10
131- UART_2 TX/RX: PA2/PA3
132- UART_3 TX/RX: PB10/PB11
133- I2C_1 SCL/SDA : PB6/PB7
134- I2C_2 SCL/SDA : PB10/PB11
135- PWM_1_CH1: PA8
136- SPI_1 NSS_OE/SCK/MISO/MOSI: PA4/PA5/PA6/PA7
137- SPI_2 NSS_OE/SCK/MISO/MOSI: PB12/PB13/PB14/PB15
138- USB_DC DM/DP: PA11/PA12
139- ADC_1: PA0
140
141System Clock
142------------
143
144The on-board 8Mhz crystal is used to produce a 72Mhz system clock with PLL.
145
146Serial Port
147-----------
148
149STM32 Minimum Development Board has 3 U(S)ARTs. The Zephyr console output is
150assigned to UART_1. Default settings are 115200 8N1.
151
152On-Board LEDs
153-------------
154
155The board has one on-board LED that is connected to PB12/PC13 on the black/blue
156variants respectively.
157
158Programming and Debugging
159*************************
160
161Applications for the ``stm32_min_dev_(blue|black)`` board configuration can be
162built and flashed in the usual way (see :ref:`build_an_application` and
163:ref:`application_run` for more details).
164
165Flashing
166========
167
168Here is an example for the :ref:`blinky-sample` application.
169
170.. zephyr-app-commands::
171   :zephyr-app: samples/basic/blinky
172   :board: stm32_min_dev_blue
173   :goals: build flash
174
175Debugging
176=========
177
178You can debug an application in the usual way.  Here is an example for the
179:ref:`hello_world` application.
180
181.. zephyr-app-commands::
182   :zephyr-app: samples/hello_world
183   :board: stm32_min_dev_blue
184   :maybe-skip-config:
185   :goals: debug
186
187.. _STM32F103x8:
188        http://www.st.com/resource/en/datasheet/stm32f103c8.pdf
189.. _EmbedJournal:
190        https://embedjournal.com/tag/stm32-min-dev/
191