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