1.. zephyr:board:: olimex_stm32_h407
2
3Overview
4********
5
6The OLIMEX-STM32-H407 is open source hardware and is based on
7the STMicroelectronics STM32F407ZG ARM Cortex-M4 CPU.
8
9.. figure:: img/olimex_stm32_h407.jpg
10     :align: center
11     :alt: OLIMEX-STM32-H407
12
13     OLIMEX-STM32-H407
14
15Hardware
16********
17
18Information about the board can be found at the
19`OLIMEX-STM32-H407 website`_ and `OLIMEX-STM32-H407 user manual`_.
20The `ST STM32F407ZG Datasheet`_ contains the processor's
21information and the datasheet.
22
23Supported Features
24==================
25
26The olimex_stm32_h407 board configuration supports the following
27hardware features:
28
29+-----------+------------+----------------------+
30| Interface | Controller | Driver/Component     |
31+===========+============+======================+
32| NVIC      | on-chip    | nested vectored      |
33|           |            | interrupt controller |
34+-----------+------------+----------------------+
35| SYSTICK   | on-chip    | system clock         |
36+-----------+------------+----------------------+
37| UART      | on-chip    | serial port          |
38+-----------+------------+----------------------+
39| GPIO      | on-chip    | gpio                 |
40+-----------+------------+----------------------+
41
42Other hardware features have not been enabled yet for this board.
43
44Pin Mapping
45===========
46
47.. figure:: img/olimex-stm32-h407-front.jpg
48     :align: center
49     :alt: OLIMEX-STM32-H407 connectors
50
51     OLIMEX-STM32-H407 connectors
52
53LED
54---
55
56* LED (green) = PC13
57* PWR_LED (red) = power
58
59Push buttons
60------------
61
62* BUT = PA0
63* RST = NRST
64
65External Connectors
66-------------------
67
68JTAG/SWD debug
69
70+-------+--------------+-------+--------------+
71| PIN # | Signal Name  | Pin # | Signal Name  |
72+=======+==============+=======+==============+
73| 1     | +3.3V        | 11    | -            |
74+-------+--------------+-------+--------------+
75| 2     | +3.3V        | 12    | GND          |
76+-------+--------------+-------+--------------+
77| 3     | PB4 / TRST   | 13    | PB3 / TDO    |
78+-------+--------------+-------+--------------+
79| 4     | GND          | 14    | GND          |
80+-------+--------------+-------+--------------+
81| 5     | PA15 / TDI   | 15    | PB4 / TRST   |
82+-------+--------------+-------+--------------+
83| 6     | GND          | 16    | GND          |
84+-------+--------------+-------+--------------+
85| 7     | PA13 / TMS   | 17    | -            |
86+-------+--------------+-------+--------------+
87| 8     | GND          | 18    | GND          |
88+-------+--------------+-------+--------------+
89| 9     | PA14 / TCK   | 19    | +5V_JTAG     |
90+-------+--------------+-------+--------------+
91| 10    | GND          | 20    | GND          |
92+-------+--------------+-------+--------------+
93
94UEXT
95
96+-------+-----------------------+----------------+
97| PIN # | Wire   Name           | STM32F407 port |
98+=======+=======================+================+
99| 1     | +3.3V                 | -              |
100+-------+-----------------------+----------------+
101| 2     | GND                   | -              |
102+-------+-----------------------+----------------+
103| 3     | PC6/USART6_TX         | PC6            |
104+-------+-----------------------+----------------+
105| 4     | PC7/USART6_RX         | PC7            |
106+-------+-----------------------+----------------+
107| 5     | PB8/I2C1_SCL          | PB8            |
108+-------+-----------------------+----------------+
109| 6     | PB9/I2C1_SDA          | PB9            |
110+-------+-----------------------+----------------+
111| 7     | PC2/SPI2_MISO         | PC2            |
112+-------+-----------------------+----------------+
113| 8     | PC3/SPI2_MOSI         | PC3            |
114+-------+-----------------------+----------------+
115| 9     | PB10/SPI_SCK/UART3_TX | PB10           |
116+-------+-----------------------+----------------+
117| 10    | RB7/UEXT_CS           | PB7            |
118+-------+-----------------------+----------------+
119
120Arduino Headers
121---------------
122
123CON1 power
124
125+-------+--------------+-------------------------+
126| Pin   | Signal Name  | STM32F407 Pin#          |
127+=======+==============+=========================+
128| RST   | RESET        | 25                      |
129+-------+--------------+-------------------------+
130| 3V3   | VCC (3V3)    | N/A                     |
131+-------+--------------+-------------------------+
132| 5V    | VDD (5V)     | N/A                     |
133+-------+--------------+-------------------------+
134| GND   | GND          | N/A                     |
135+-------+--------------+-------------------------+
136| GND   | GND          | N/A                     |
137+-------+--------------+-------------------------+
138| VIN   | VIN          | N/A                     |
139+-------+--------------+-------------------------+
140
141CON2 analog
142
143+-------+--------------+-------------------------+
144| Pin   | Signal Name  | STM32F407 Pin#          |
145+=======+==============+=========================+
146| A0    | PC0          | 26                      |
147+-------+--------------+-------------------------+
148| A1    | PC1          | 27                      |
149+-------+--------------+-------------------------+
150| A2    | PB0          | 46                      |
151+-------+--------------+-------------------------+
152| A3    | PB1          | 47                      |
153+-------+--------------+-------------------------+
154| A4    | PC4          | 44                      |
155+-------+--------------+-------------------------+
156| A5    | PC5          | 45                      |
157+-------+--------------+-------------------------+
158
159CON3 digital
160
161+-------+---------------+-------------------------+
162| Pin   | Signal Name   | STM32F407 Pin#          |
163+=======+===============+=========================+
164| D0    | PA3/USART2_RX | 37                      |
165+-------+---------------+-------------------------+
166| D1    | PA2/USART2_TX | 36                      |
167+-------+---------------+-------------------------+
168| D2    | PG7           | 92                      |
169+-------+---------------+-------------------------+
170| D3    | PG8           | 93                      |
171+-------+---------------+-------------------------+
172| D4    | PG12          | 127                     |
173+-------+---------------+-------------------------+
174| D5    | PG13          | 128                     |
175+-------+---------------+-------------------------+
176| D6    | PG14          | 129                     |
177+-------+---------------+-------------------------+
178| D7    | PG15          | 132                     |
179+-------+---------------+-------------------------+
180
181CON4 digital
182
183+-------+--------------+-------------------------+
184| Pin   | Signal Name  | STM32F407 Pin#          |
185+=======+==============+=========================+
186| D8    | PA1          | 35                      |
187+-------+--------------+-------------------------+
188| D9    | PB11         | 70                      |
189+-------+--------------+-------------------------+
190| D10   | PA4          | 40                      |
191+-------+--------------+-------------------------+
192| D11   | PA7          | 43                      |
193+-------+--------------+-------------------------+
194| D12   | PA6          | 42                      |
195+-------+--------------+-------------------------+
196| D13   | PA5          | 41                      |
197+-------+--------------+-------------------------+
198| GND   | AGND         | 31                      |
199+-------+--------------+-------------------------+
200| AREF  | AREF         | 32                      |
201+-------+--------------+-------------------------+
202
203PD
204
205+-------+--------------+-------+--------------+
206| PIN # | Signal Name  | Pin # | Signal Name  |
207+=======+==============+=======+==============+
208| 1     | +3.3V        | 11    | PD8          |
209+-------+--------------+-------+--------------+
210| 2     | GND          | 12    | PD9          |
211+-------+--------------+-------+--------------+
212| 3     | PD0          | 13    | PD10         |
213+-------+--------------+-------+--------------+
214| 4     | PD1          | 14    | PD11         |
215+-------+--------------+-------+--------------+
216| 5     | PD2/SD_CMD   | 15    | PD12         |
217+-------+--------------+-------+--------------+
218| 6     | PD3          | 16    | PD13         |
219+-------+--------------+-------+--------------+
220| 7     | PD4          | 17    | PD14         |
221+-------+--------------+-------+--------------+
222| 8     | PD5          | 18    | PD15         |
223+-------+--------------+-------+--------------+
224| 9     | PD6          | 19    | +5V          |
225+-------+--------------+-------+--------------+
226| 10    | PD7          | 20    | GND          |
227+-------+--------------+-------+--------------+
228
229PE
230
231+-------+--------------+-------+--------------+
232| PIN # | Signal Name  | Pin # | Signal Name  |
233+=======+==============+=======+==============+
234| 1     | +3.3V        | 11    | PE8          |
235+-------+--------------+-------+--------------+
236| 2     | GND          | 12    | PE9          |
237+-------+--------------+-------+--------------+
238| 3     | PE0          | 13    | PE10         |
239+-------+--------------+-------+--------------+
240| 4     | PE1          | 14    | PE11         |
241+-------+--------------+-------+--------------+
242| 5     | PE2          | 15    | PE12         |
243+-------+--------------+-------+--------------+
244| 6     | PE3          | 16    | PE13         |
245+-------+--------------+-------+--------------+
246| 7     | PE4          | 17    | PE14         |
247+-------+--------------+-------+--------------+
248| 8     | PE5          | 18    | PE15         |
249+-------+--------------+-------+--------------+
250| 9     | PE6          | 19    | +5V          |
251+-------+--------------+-------+--------------+
252| 10    | PE7          | 20    | GND          |
253+-------+--------------+-------+--------------+
254
255PF
256
257+-------+--------------+-------+--------------+
258| PIN # | Signal Name  | Pin # | Signal Name  |
259+=======+==============+=======+==============+
260| 1     | +3.3V        | 11    | PF8          |
261+-------+--------------+-------+--------------+
262| 2     | GND          | 12    | PF9          |
263+-------+--------------+-------+--------------+
264| 3     | PF0          | 13    | PF10         |
265+-------+--------------+-------+--------------+
266| 4     | PF1          | 14    | PF11         |
267+-------+--------------+-------+--------------+
268| 5     | PF2          | 15    | PF12         |
269+-------+--------------+-------+--------------+
270| 6     | PF3          | 16    | PF13         |
271+-------+--------------+-------+--------------+
272| 7     | PF4          | 17    | PF14         |
273+-------+--------------+-------+--------------+
274| 8     | PF5          | 18    | PF15         |
275+-------+--------------+-------+--------------+
276| 9     | PF6          | 19    | +5V          |
277+-------+--------------+-------+--------------+
278| 10    | PF7          | 20    | GND          |
279+-------+--------------+-------+--------------+
280
281PG
282
283+-------+--------------+-------+--------------+
284| PIN # | Signal Name  | Pin # | Signal Name  |
285+=======+==============+=======+==============+
286| 1     | +3.3V        | 11    | PG8/D3       |
287+-------+--------------+-------+--------------+
288| 2     | GND          | 12    | PG9          |
289+-------+--------------+-------+--------------+
290| 3     | PG0          | 13    | PG10         |
291+-------+--------------+-------+--------------+
292| 4     | PG1          | 14    | PG11         |
293+-------+--------------+-------+--------------+
294| 5     | PG2          | 15    | PG12/D4      |
295+-------+--------------+-------+--------------+
296| 6     | PG3          | 16    | PG13/D5      |
297+-------+--------------+-------+--------------+
298| 7     | PG4          | 17    | PG14/D6      |
299+-------+--------------+-------+--------------+
300| 8     | PG5          | 18    | PG15/D7      |
301+-------+--------------+-------+--------------+
302| 9     | PG6          | 19    | +5V          |
303+-------+--------------+-------+--------------+
304| 10    | PG7/D2       | 20    | GND          |
305+-------+--------------+-------+--------------+
306
307System Clock
308============
309
310OLIMEX-STM32-H407 has two external oscillators. The frequency of
311the slow clock is 32.768 kHz. The frequency of the main clock
312is 12 MHz. The processor can setup HSE to drive the master clock,
313which can be set as high as 168 MHz.
314
315Programming and Debugging
316*************************
317The OLIMEX-STM32-H407 board does not include an embedded debug tool
318interface. You will need to use ST tools or an external JTAG probe.
319In the following examples the Olimex ARM-USB-OCD-H is used.
320
321If you have an external JTAG probe compliant with the default Zephyr OpenOCD
322configuration, however, then applications for the ``olimex_stm32_h407`` board
323configuration can be built and flashed in the usual way (see
324:ref:`build_an_application` and :ref:`application_run` for more details).
325
326Flashing an application to the Olimex-STM32-H407
327================================================
328
329Connect the ARM-USB-OCD-H debugger to your host computer and to the JTAG port
330of the OLIMEX-STM32-H407 board. Then build and flash an application.
331
332Here is an example for the :zephyr:code-sample:`hello_world` application.
333
334.. zephyr-app-commands::
335   :zephyr-app: samples/hello_world
336   :board: olimex_stm32_h407
337   :goals: build flash
338
339Run a serial host program to connect with your board:
340
341.. code-block:: console
342
343   $ minicom -D /dev/ttyUSB0
344
345After resetting the board, you should see the following message:
346
347.. code-block:: console
348
349   ***** BOOTING ZEPHYR OS v1.11.0 - BUILD: Mar 12 2018 03:12:40 *****
350   Hello World! arm
351
352
353Debugging
354=========
355
356Provided that you have a JTAG probe, you can debug an application in the usual
357way.  Here is an example for the :zephyr:code-sample:`hello_world` application.
358
359.. zephyr-app-commands::
360   :zephyr-app: samples/hello_world
361   :board: olimex_stm32_h407
362   :maybe-skip-config:
363   :goals: debug
364
365.. _OLIMEX-STM32-H407 website:
366   https://www.olimex.com/Products/ARM/ST/STM32-H407/open-source-hardware
367
368.. _OLIMEX-STM32-H407 user manual:
369   https://www.olimex.com/Products/ARM/ST/STM32-H407/resources/STM32-H407.pdf
370
371.. _ST STM32F407ZG Datasheet:
372   https://www.st.com/resource/en/reference_manual/dm00031020.pdf
373