1.. zephyr:board:: olimexino_stm32
2
3Overview
4********
5
6The OLIMEXINO-STM32 board is based on the STMicroelectronics STM32F103RB ARM
7Cortex-M3 CPU.
8
9More information about the board can be found at the
10`OLIMEXINO-STM32 website`_ and `OLIMEXINO-STM32 user manual`_.
11The `ST STM32F103xB Datasheet`_ contains the processor's
12information and the datasheet.
13
14Supported Features
15==================
16
17The olimexino_stm32 board configuration supports the following
18hardware features:
19
20+-----------+------------+-------------------------+
21| Interface | Controller | Driver/Component        |
22+===========+============+=========================+
23| NVIC      | on-chip    | nested vectored         |
24|           |            | interrupt controller    |
25+-----------+------------+-------------------------+
26| SYSTICK   | on-chip    | system clock            |
27+-----------+------------+-------------------------+
28| UART      | on-chip    | serial port             |
29+-----------+------------+-------------------------+
30| GPIO      | on-chip    | gpio                    |
31+-----------+------------+-------------------------+
32| I2C       | on-chip    | i2c                     |
33+-----------+------------+-------------------------+
34| SPI       | on-chip    | spi                     |
35+-----------+------------+-------------------------+
36| USB       | on-chip    | USB device              |
37+-----------+------------+-------------------------+
38| WATCHDOG  | on-chip    | independent watchdog    |
39+-----------+------------+-------------------------+
40| CAN       | on-chip    | Controller Area Network |
41+-----------+------------+-------------------------+
42
43Other hardware features have not been enabled yet for this board.
44
45Pin Mapping
46===========
47
48.. figure:: img/olimexino-stm32-front.jpg
49     :align: center
50     :alt: OLIMEXINO-STM32 connectors
51
52     OLIMEXINO-STM32 connectors
53
54LED
55---
56
57* LED1 (green) = PA5
58* LED2 (yellow) = PA1
59* PWR_LED (red) = power
60
61Push buttons
62------------
63
64* BUT = PC9 / TIM3CH4 / BOOT0
65* RST = NRST
66
67External Connectors
68-------------------
69
70SWD
71
72+-------+--------------+-------------------------+
73| PIN # | Signal Name  | STM32F103RB Functions   |
74+=======+==============+=========================+
75| 1     | VCC          | N/A                     |
76+-------+--------------+-------------------------+
77| 2     | TMS / SWDIO  | JTMS / SWDIO / PA13     |
78+-------+--------------+-------------------------+
79| 3     | GND          | N/A                     |
80+-------+--------------+-------------------------+
81| 4     | TCK / SWCLK  | JTCK / SWCLK / PA14     |
82+-------+--------------+-------------------------+
83| 5     | GND          | N/A                     |
84+-------+--------------+-------------------------+
85| 6     | TDO / SWO    | JTDO /TIM2_CH2 / PB3 /  |
86|       |              | TRACESWO / SPI1_SCK     |
87+-------+--------------+-------------------------+
88| 7     | Cut off      | N/A                     |
89+-------+--------------+-------------------------+
90| 8     | TDI          | JTDI / TIM2_CH1_ETR /   |
91|       |              | PA15 / SPI1_NSS         |
92+-------+--------------+-------------------------+
93| 9     | GND          | N/A                     |
94+-------+--------------+-------------------------+
95| 10    | RESET        | NRST                    |
96+-------+--------------+-------------------------+
97
98UEXT
99
100+-------+--------------+-------------------------+
101| PIN # | Signal Name  | STM32F103RB Functions   |
102+=======+==============+=========================+
103| 1     | VCC          | N/A                     |
104+-------+--------------+-------------------------+
105| 2     | GND          | N/A                     |
106+-------+--------------+-------------------------+
107| 3     | D7 (TXD1)    | PA9 / USART1_TX /       |
108|       |              | TIM1_CH2                |
109+-------+--------------+-------------------------+
110| 4     | D8 (RXD1)    | PA10 / USART1_RX /      |
111|       |              | TIM1_CH3                |
112+-------+--------------+-------------------------+
113| 5     | D29 (SCL2)   | PB10 / I2C2_SCL /       |
114|       |              | USART3_TX / TIM2_CH3    |
115+-------+--------------+-------------------------+
116| 6     | D30 (SDA2)   | PB11 / I2C2_SDA /       |
117|       |              | USART3_RX / TIM2_CH4    |
118+-------+--------------+-------------------------+
119| 7     | D12 (MISO1)  | PA6 / SPI1_MISO /       |
120|       |              | ADC12_IN6 / TIM3_CH1 /  |
121|       |              | TIM1_BKIN               |
122+-------+--------------+-------------------------+
123| 8     | D11 (MOSI1)  | PA7 / SPI1_MOSI /       |
124|       |              | ADC12_IN7 / TIM3_CH2 /  |
125|       |              | TIM1_CH1N               |
126+-------+--------------+-------------------------+
127| 9     | D13 (SCK /   | PA5 / SPI1_SCK /        |
128|       | LED1)        | ADC12_IN5               |
129+-------+--------------+-------------------------+
130| 10    | UEXT_#CS     | N/A                     |
131+-------+--------------+-------------------------+
132
133EXT
134
135+-------+--------------+-------------------------+
136| PIN # | Signal Name  | STM32F103RB Functions   |
137+=======+==============+=========================+
138| 1     | D23_EXT      | PC15 / OSC32_OUT        |
139+-------+--------------+-------------------------+
140| 2     | D24 (CANTX)  | PB9 / TIM4_CH4 /        |
141|       |              | I2C1_SDA / CANTX        |
142+-------+--------------+-------------------------+
143| 3     | D25 (MMC_CS) | PD2 / TIM3_ETR          |
144+-------+--------------+-------------------------+
145| 4     | D26          | PC10 / USART3_TX        |
146+-------+--------------+-------------------------+
147| 5     | D27          | PB0 / ADC12_IN8 /       |
148|       |              | TIM3_CH3 / TIM1_CH2N    |
149+-------+--------------+-------------------------+
150| 6     | D28          | PB1 / ADC12_IN9 /       |
151|       |              | TIM3_CH4 / TIM1_CH3N    |
152+-------+--------------+-------------------------+
153| 7     | D29 (SCL2)   | PB10 / I2C2_SCL /       |
154|       |              | USART3_TX / TIM2_CH3    |
155+-------+--------------+-------------------------+
156| 8     | D30 (SDA2)   | PB11 / I2C2_SDA /       |
157|       |              | USART3_RX / TIM2_CH4    |
158+-------+--------------+-------------------------+
159| 9     | D31 (#SS2)   | PB12 / SPI2_NSS /       |
160|       |              | I2C2_SMBAI / USART3_CK /|
161|       |              | TIM1_BKIN               |
162+-------+--------------+-------------------------+
163| 10    | D32 (SCK2)   | PB13 / SPI2_SCK/        |
164|       |              | USART3_CTS / TIM1_CH1N  |
165+-------+--------------+-------------------------+
166| 11    | D33 (MISO2)  | PB14 / SPI2_MISO /      |
167|       |              | USART3_RTS / TIM1_CH2N  |
168+-------+--------------+-------------------------+
169| 12    | D34 (MOSI2)  | PB15 / SPI2_MOSI /      |
170|       |              | TIM1_CH3N               |
171+-------+--------------+-------------------------+
172| 13    | D35          | PC6 / TIM3_CH1          |
173+-------+--------------+-------------------------+
174| 14    | D36          | PC7 / TIM3_CH2          |
175+-------+--------------+-------------------------+
176| 15    | D37          | PC8 / TIM3_CH3          |
177+-------+--------------+-------------------------+
178| 16    | GND          | N/A                     |
179+-------+--------------+-------------------------+
180
181Arduino Headers
182---------------
183
184CON1 power
185
186+-------+--------------+-------------------------+
187| PIN # | Signal Name  | STM32F103RB Functions   |
188+=======+==============+=========================+
189| 1     | RESET        | NRST                    |
190+-------+--------------+-------------------------+
191| 2     | VCC (3V3)    | N/A                     |
192+-------+--------------+-------------------------+
193| 3     | VDD (3V3A)   | N/A                     |
194+-------+--------------+-------------------------+
195| 4     | GND          | N/A                     |
196+-------+--------------+-------------------------+
197| 5     | GND          | N/A                     |
198+-------+--------------+-------------------------+
199| 6     | VIN          | N/A                     |
200+-------+--------------+-------------------------+
201
202CON2 analog
203
204+-------+--------------+-------------------------+
205| PIN # | Signal Name  | STM32F103RB Functions   |
206+=======+==============+=========================+
207| 1     | D15 (A0)     | PC0 / ADC12_IN10        |
208+-------+--------------+-------------------------+
209| 2     | D16 (A1)     | PC1 / ADC12_IN11        |
210+-------+--------------+-------------------------+
211| 3     | D17 (A2)     | PC2 / ADC12_IN12        |
212+-------+--------------+-------------------------+
213| 4     | D18 (A3)     | PC3 / ADC12_IN13        |
214+-------+--------------+-------------------------+
215| 5     | D19 (A4)     | PC4 / ADC12_IN14        |
216+-------+--------------+-------------------------+
217| 6     | D20 (A5)     | PC5 / ADC12_IN15        |
218+-------+--------------+-------------------------+
219
220CON3 digital
221
222+-------+--------------+-------------------------+
223| PIN # | Signal Name  | STM32F103RB Functions   |
224+=======+==============+=========================+
225| 1     | D0 (RXD2)    | PA3 / USART2_RX /       |
226|       |              | ADC12_IN3 / TIM2_CH4    |
227+-------+--------------+-------------------------+
228| 2     | D1 (TXD2)    | PA2 / USART2_TX /       |
229|       |              | ADC12_IN2 / TIM2_CH3    |
230+-------+--------------+-------------------------+
231| 3     | D2           | PA0 / WKUP /            |
232|       |              | USART2_CTS / ADC12_IN0 /|
233|       |              | TIM2_CH1                |
234+-------+--------------+-------------------------+
235| 4     | D3 (LED2)    | PA1 / USART2_RTS /      |
236|       |              | ADC12_IN1 / TIM2_CH2    |
237+-------+--------------+-------------------------+
238| 5     | D4           | PB5 / I2C1_SMBAI /      |
239|       |              | TIM3_CH2 / SPI1_MOSI    |
240+-------+--------------+-------------------------+
241| 6     | D5           | PB6 / I2C1_SCL /        |
242|       |              | TIM4_CH1 / USART1_TX    |
243+-------+--------------+-------------------------+
244| 7     | D6           | PA8 / USART1_CK /       |
245|       |              | TIM1_CH1 / MCO          |
246+-------+--------------+-------------------------+
247| 8     | D7 (TXD1)    | PA9 / USART1_TX /       |
248|       |              | TIM1_CH2                |
249+-------+--------------+-------------------------+
250
251CON4 digital
252
253+-------+--------------+-------------------------+
254| PIN # | Signal Name  | STM32F103RB Functions   |
255+=======+==============+=========================+
256| 1     | D8 (RXD1)    | PA10 / USART1_RX /      |
257|       |              | TIM1_CH3                |
258+-------+--------------+-------------------------+
259| 2     | D9           | PB7 / I2C1_SDA /        |
260|       |              | TIM4_CH2 / USART1_RX    |
261+-------+--------------+-------------------------+
262| 3     | D10 (#SS1)   | PA4 / SPI1_NSS /        |
263|       |              | USART2_CK / ADC12_IN4   |
264+-------+--------------+-------------------------+
265| 4     | D11 (MOSI1)  | PA7 / SPI1_MOSI /       |
266|       |              | ADC12_IN7 / TIM3_CH2 /  |
267|       |              | TIM1_CH1N               |
268+-------+--------------+-------------------------+
269| 5     | D12 (MISO1)  | PA6 / SPI1_MISO /       |
270|       |              | ADC12_IN6 / TIM3_CH1 /  |
271|       |              | TIM1_BKIN               |
272+-------+--------------+-------------------------+
273| 6     | D13 (SCK1 /  | PA5 / SPI1_SCK /        |
274|       | LED1)        | ADC12_IN5               |
275+-------+--------------+-------------------------+
276| 7     | GND          | N/A                     |
277+-------+--------------+-------------------------+
278| 8     | D14 (CANRX)  | PB8 / TIM4_CH3 /        |
279|       |              | I2C1_SCL / CANRX        |
280+-------+--------------+-------------------------+
281
282CAN
283
284+-------+-------------+
285| PIN # | Signal Name |
286+=======+=============+
287| 1     | GND         |
288+-------+-------------+
289| 2     | CAN L       |
290+-------+-------------+
291| 3     | CAN H       |
292+-------+-------------+
293
294System Clock
295============
296
297OLIMEXINO-STM32 has two external oscillators. The frequency of
298the slow clock is 32.768 kHz. The frequency of the main clock
299is 8 MHz. The processor can setup HSE to drive the master clock,
300which can be set as high as 72 MHz.
301
302Serial Port
303===========
304
305OLIMEXINO-STM32 board has up to 3 U(S)ARTs. The Zephyr console output is
306assigned to USART1. Default settings are 115200 8N1.
307
308SPI
309===
310
311OLIMEXINO-STM32 board has up to 2 SPIs. The default SPI mapping for Zephyr is:
312
313- SPI1_NSS  : PA4
314- SPI1_SCK  : PA5
315- SPI1_MISO : PA6
316- SPI1_MOSI : PA7
317
318I2C
319===
320
321The OLIMEXINO-STM32 board supports two I2C devices. The default I2C mapping for
322Zephyr is:
323
324- I2C1_SCL : PB6
325- I2C1_SDA : PB7
326- I2C2_SCL : PB10
327- I2C2_SDA : PB11
328
329USB
330===
331
332OLIMEXINO-STM32 board has a USB 2.0 full-speed device interface available
333through its mini USB connector.
334
335- USB_DM : PA11
336- USB_DP : PA12
337
338CAN
339===
340
341OLIMEXINO-STM32 board has a CAN interface with transceiver on board.
342CAN is accessible through a screw terminal.
343
344- CAN_RX : PB8
345- CAN_TX : PB9
346
347Jumpers
348=======
349
350The Zephyr kernel uses the OLIMEXINO-STM32 default jumper
351settings. Note that all jumpers on the board are SMD type.
352You will need to solder, unsolder, or cut them in order to
353reconfigure them.
354
355The default jumper settings for the OLIMEXIMO-STM32E are:
356
357+---------------+------------+---------------+
358| Jumper Name   | Open       | Close         |
359+===============+============+===============+
360|  LED1_E       |            |      x        |
361+---------------+------------+---------------+
362|  LED2_E       |            |      x        |
363+---------------+------------+---------------+
364|  D23_E        |     x      |               |
365+---------------+------------+---------------+
366|  R-T          |     x      |               |
367+---------------+------------+---------------+
368|  P10_E        |            |      x        |
369+---------------+------------+---------------+
370
371+---------------+------------+---------------+
372| Jumper Name   | D10        | D4            |
373+===============+============+===============+
374|  D10/D4       |            |      x        |
375+---------------+------------+---------------+
376
377Flashing Zephyr onto OLIMEXINO-STM32
378************************************
379
380Flashing the Zephyr kernel onto OLIMEXINO-STM32 requires the
381`stm32flash tool`_.
382
383Building stm32flash command line tool
384=====================================
385
386To build the stm32flash tool, follow the steps below:
387
388#. Checkout the stm32flash tool's code from the repository.
389
390  .. code-block:: console
391
392     $ git clone http://git.code.sf.net/p/stm32flash/code stm32flash
393     $ cd stm32flash
394
395#. Build the stm32flash tool.
396
397  .. code-block:: console
398
399     $ make
400
401#. The resulting binary is available at :file:`stm32flash`.
402
403Flashing an Application to OLIMEXINO-STM32
404==========================================
405
406To upload an application to the OLIMEXINO-STM32 board a TTL(3.3V)
407serial adapter is required. This tutorial uses the
408:zephyr:code-sample:`button` sample application.
409
410#. Connect the serial cable to the UEXT lines of the UART
411   interface (pin #3=TX and pin #4=RX).
412
413#. Power the OLIMEXINO-STM32 via the mini USB.
414
415#. Reset the board while holding the button (BUT).
416
417#. To build the application and flash it, enter:
418
419   .. zephyr-app-commands::
420      :zephyr-app: samples/basic/button
421      :board: olimexino_stm32
422      :goals: flash
423
424#. Run your favorite terminal program to listen for output.
425
426   .. code-block:: console
427
428      $ minicom -D /dev/ttyUSB0 -b 115200
429
430   The :code:`-b` option sets baud rate ignoring the value
431   from config.
432
433#. Press the Reset button and you should see the output of
434   button application in your terminal. The state of the BUT
435   button's GPIO line is monitored and printed to the serial
436   console. When the input button gets pressed, the interrupt
437   handler prints information about this event along with its
438   timestamp.
439
440.. note::
441   Make sure your terminal program is closed before flashing
442   the binary image, or it will interfere with the flashing
443   process.
444
445.. _OLIMEXINO-STM32 website:
446   https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/
447
448.. _OLIMEXINO-STM32 user manual:
449   https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/resources/OLIMEXINO-STM32.pdf
450
451.. _ST STM32F103xB Datasheet:
452   https://www.st.com/resource/en/datasheet/stm32f103tb.pdf
453
454.. _stm32flash tool:
455   https://sourceforge.net/p/stm32flash/wiki/Home/
456