Bluepill STM32F103C8 support for Mbed OS 6

Bluepill board support for Mbed OS 6

Warning

It does not work with the Mbed Online Compiler.

This is an example of configuration for the Bluepill board for Mbed OS 6.

It shows how to create a custom board support based on Mbed OS and how to compile a simple Blinky application.

Note this project makes use of the full Mbed OS with RTOS included. It's possible to make changes in the configuration to support the Baremetal profile and reduce memory requirements - see this.

Example application

This repository includes blinky.cpp as an example application to demonstrate how to use the Bluepill custom board support. It's expected to work out of the box using both Mbed CLI and Mbed Studio. Note this test application can be ignored using the MBED_BLINKY_EXAMPLE macro in mbed_app.json, so you can add your own files and application on top of this project.

You can follow these steps to import and compile with Mbed CLI:

mbed import https://os.mbed.com/users/hudakz/code/mbed-os-bluepill
mbed compile -t GCC_ARM -m bluepill

Bluepill and Mbed OS version support

BluepillMbed OS (hash)Status
preview6.2.0 (#a2ada74770 )Compiles and runs ok

Updating Mbed OS

Note not every version of Mbed OS is being tested, therefore update at your own risk. Unless strictly required, you should stick to versions of Mbed OS that are known to work ok.

If you do want to udpate Mbed OS, then follow these steps:

cd mbed-os
mbed update <mbed-os hash / tag>

Testing

This application has been tested on the Bluepill board and runs ok: it blinks and LED and sends a message over the serial port (115200 bauds - see mbed_app.json).

However, it's recomended to run regression tests based on the Greentea framework whether possible (more details to be added).

Programming with STLink programming utility

The Bluepill board doesn't have a programming interface on board. However, it's easy to connect an external adapter such as the STLink/V2 and get it working in minutes.

Use the STM32 ST-Link utility to program the binary into the device.

https://os.mbed.com/media/uploads/hudakz/stlink-prog.png

Wire the Bluepill to the STLink and serial adapter as follow:

BluepillSTLink (20-pin JTAG)Serial adapter
SDWIO (CN4)7-
SWCLK (CN4)9-
RESET15-
GND4GND
TX (PA_2)-RX
RX (PA_3)-TX

ST-LINK/V2 JTAG pintout
https://os.mbed.com/media/uploads/hudakz/jtag_pinout.png

This is the pinout of the Bluepill board: /media/uploads/hudakz/stm32f103c8t6_pinout_voltage01.png

https://os.mbed.com/media/uploads/hudakz/connections.jpg

Additional example programs

Bare metal on Bluepill
Bare metal with EventQueue on Bluepill

Warning

The examples above are not meant to be compiled with the online compiler. Follow these steps to import and compile them with Mbed CLI:

mbed import Program's_URL
mbed compile -t GCC_ARM -m bluepill

Known issues

  • Please check the issues reported.
Committer:
hudakz
Date:
Wed May 13 12:25:39 2020 +0000
Revision:
0:2577a4fb6e72
Bluepill STM32F103C8 support for Mbed OS 6

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hudakz 0:2577a4fb6e72 1 # Bluepill board support for Mbed OS 6
hudakz 0:2577a4fb6e72 2
hudakz 0:2577a4fb6e72 3 This is an example of configuration for the [Bluepill](https://os.mbed.com/users/hudakz/code/STM32F103C8T6_Hello/) board for the upcoming version of Mbed OS 6 (beta at this time).
hudakz 0:2577a4fb6e72 4
hudakz 0:2577a4fb6e72 5 It shows how to create a custom board support based on Mbed OS and how to compile a simple Blinky application.
hudakz 0:2577a4fb6e72 6
hudakz 0:2577a4fb6e72 7 Note this project makes use of the full Mbed OS with RTOS included. It's possible to make changes in the configuration to support the Baremetal profile and reduce memory requirements - see [this](https://os.mbed.com/docs/mbed-os/v5.15/reference/mbed-os-bare-metal.html).
hudakz 0:2577a4fb6e72 8
hudakz 0:2577a4fb6e72 9 ### Example application
hudakz 0:2577a4fb6e72 10
hudakz 0:2577a4fb6e72 11 This repository includes `blinky.cpp` as an example application to demonstrate how to use the Bluepill custom board support. It's expected to work out of the box using both Mbed CLI and Mbed Studio.
hudakz 0:2577a4fb6e72 12
hudakz 0:2577a4fb6e72 13 Note this test application can be ignored using the `MBED_BLINKY_EXAMPLE` macro in `mbed_app.json`, so you can add your own files and application on top of this project.
hudakz 0:2577a4fb6e72 14
hudakz 0:2577a4fb6e72 15 You can follow these steps to import and compile with Mbed CLI:
hudakz 0:2577a4fb6e72 16
hudakz 0:2577a4fb6e72 17 ```
hudakz 0:2577a4fb6e72 18 $ mbed import https://github.com/MarceloSalazar/mbed-os-bluepill
hudakz 0:2577a4fb6e72 19 $ mbed compile -t GCC_ARM -m bluepill
hudakz 0:2577a4fb6e72 20 ```
hudakz 0:2577a4fb6e72 21
hudakz 0:2577a4fb6e72 22 ### Bluepill and Mbed OS version support
hudakz 0:2577a4fb6e72 23
hudakz 0:2577a4fb6e72 24 | Bluepill | Mbed OS (hash) | Status |
hudakz 0:2577a4fb6e72 25 | ----------------- | ----------------------------------------- | ------------------- |
hudakz 0:2577a4fb6e72 26 | preview | beta ([#1b2a68ae](https://github.com/ARMmbed/mbed-os/#1b2a68ae204b70a7aaf3818dc8fa3881250b13b0)) | Compiles and runs ok |
hudakz 0:2577a4fb6e72 27
hudakz 0:2577a4fb6e72 28 ### Updating Mbed OS
hudakz 0:2577a4fb6e72 29
hudakz 0:2577a4fb6e72 30 Note not every version of Mbed OS is being tested, therefore update at your own risk.
hudakz 0:2577a4fb6e72 31 Unless strictly required, you should stick to versions of Mbed OS that are known to work ok.
hudakz 0:2577a4fb6e72 32
hudakz 0:2577a4fb6e72 33 If you do want to udpate Mbed OS, then follow these steps:
hudakz 0:2577a4fb6e72 34
hudakz 0:2577a4fb6e72 35 ```
hudakz 0:2577a4fb6e72 36 cd mbed-os
hudakz 0:2577a4fb6e72 37 mbed update <mbed-os hash / tag>
hudakz 0:2577a4fb6e72 38 ```
hudakz 0:2577a4fb6e72 39
hudakz 0:2577a4fb6e72 40 ### Testing
hudakz 0:2577a4fb6e72 41
hudakz 0:2577a4fb6e72 42 This application has been tested on the Bluepill board and runs ok: it blinks and LED and sends a message over the serial port (115200 bauds - see `mbed_app.json`).
hudakz 0:2577a4fb6e72 43
hudakz 0:2577a4fb6e72 44 However, it's recomended to run regression tests based on the [Greentea](https://os.mbed.com/docs/mbed-os/latest/tools/greentea-testing-applications.html) framework whether possible (more details to be added).
hudakz 0:2577a4fb6e72 45
hudakz 0:2577a4fb6e72 46 ### Programming with STLink programming utility
hudakz 0:2577a4fb6e72 47
hudakz 0:2577a4fb6e72 48 The Bluepill board doesn't have a programming interface on board. However, it's easy to connect an external adapter such as the [STLink/V2](https://www.st.com/en/development-tools/st-link-v2.html) and get it working in minutes.
hudakz 0:2577a4fb6e72 49
hudakz 0:2577a4fb6e72 50 Use the [STM32 ST-Link utility](https://www.st.com/en/development-tools/stsw-link004.html) to program the binary into the device.
hudakz 0:2577a4fb6e72 51
hudakz 0:2577a4fb6e72 52 ![STLink](/img/stlink-prog.png)
hudakz 0:2577a4fb6e72 53
hudakz 0:2577a4fb6e72 54 Wire the Bluepill to the STLink and serial adapter as follow:
hudakz 0:2577a4fb6e72 55
hudakz 0:2577a4fb6e72 56 | Bluepill | STLink (20-pin JTAG) | Serial adapter |
hudakz 0:2577a4fb6e72 57 | ------------- | ----------------------|------------------|
hudakz 0:2577a4fb6e72 58 | RESET | 15 |- |
hudakz 0:2577a4fb6e72 59 | SDWIO (CN4) | 7 |- |
hudakz 0:2577a4fb6e72 60 | SWCLK (CN4) | 9 |- |
hudakz 0:2577a4fb6e72 61 | GND | 15 |GND |
hudakz 0:2577a4fb6e72 62 | TX (PA_2) | - |RX |
hudakz 0:2577a4fb6e72 63 | RX (PA_3) | - |TX |
hudakz 0:2577a4fb6e72 64
hudakz 0:2577a4fb6e72 65 The standard JTAG pintout can be seen [here](http://www.keil.com/support/man/docs/ulinkpro/ulinkpro_hw_if_jtag20.htm)
hudakz 0:2577a4fb6e72 66
hudakz 0:2577a4fb6e72 67 This is the pinout of the Bluepill board:
hudakz 0:2577a4fb6e72 68 ![Board-pinout](https://os.mbed.com/media/uploads/hudakz/stm32f103c8t6_pinout_voltage01.png)
hudakz 0:2577a4fb6e72 69
hudakz 0:2577a4fb6e72 70 ![HW-connections](/img/connections.jpg)
hudakz 0:2577a4fb6e72 71
hudakz 0:2577a4fb6e72 72 ### Known issues
hudakz 0:2577a4fb6e72 73
hudakz 0:2577a4fb6e72 74 - Please check [issues](https://github.com/MarceloSalazar/mbed-os-bluepill/issues) reported on GitHub.
hudakz 0:2577a4fb6e72 75