Support for cheap stm32f103c8 based boards such as bluepill and blackpill. More...
Support for cheap stm32f103c8 based boards such as bluepill and blackpill.
The bluepill and the blackpill are STM32F103 based board which can be bought for around 2€ on sides like AliExpress, eBay and others. Although the STM32F130C8 MCU nominally has 64 KiB flash, most actually have 128 KiB flash.
There are also versions that only report to have 32 KiB, but actually have 64 KiB.
|Flash||32 KiB/ 64 KiB / 128 KiB|
|Frequency||up to 72 MHz|
|ADC||2x 12-bit, 10 channels|
|Vcc||2.0 to 3.6 V|
To program and debug the board you need a SWD capable debugger. The easiest way is using OpenOCD. By default RIOT uses the hardware reset signal and connects to the chip under reset for flashing. This is required to reliably connect to the device even when the MCU is in a low power mode. Therefore not only SWDIO and SWCLK, but also the RST pin of your debugger need to be connected to the board. Once the device is connected to the debugger and OpenOCD is installed, you can flash the device with:
$ make BOARD=bluepill flash
Or for the blackpill with:
$ make BOARD=blackpill flash
To make use of the entire 128 KiB flash, compile and flash your application with:
$ make BOARD=bluepill-128kib flash
Or for the blackpill with:
$ make BOARD=blackpill-128kib flash
This sets the
CPU_MODEL make variable to
stm32f103cb, the default value is
stm32f103c8. These two CPU models basically only have one major difference, the former has 128 KiB flash while the latter has 64 KiB.
Flashing for the 128KiB version currently (as of September 2019) requires the development version of OpenOCD.
The default UART port used is UART2, which uses pins A2 (TX) and A3 (RX). To use it, configure your UART to operate at a baudrate of 115200/8N1.
PWM is available at pins A8 to A11.
The Micro-USB port is sometimes not soldered properly. Also, it is usually equipped with an incorrect resistor. This can be fixed multiple ways.
Please check whether the debugger is properly connected, including the hardware reset signal pin.
|Pin on Debugger||Pin on Blue Pill|
|VDD (3.3V) (*)||3.3|
|Target VCC (**)||3.3|
Most very cheap SWD debuggers (especially those imported for about 2€ from far east) do not have a Target VCC pin; they will still work just fine. On these cheap debuggers the pin to send the reset signal to the board is often either not present or defunct. You can work around this by pressing the reset button when OpenOCD wants to connect to the Blue Pill. Hit the reset button again after flashing in order to boot the newly flashed image.
The board is sold under different names. On some sites it is called
blue pill. On others you might find it by searching for
|Peripheral MCU configuration for the bluepill/blackpill board. |
|Board specific configuration of direct mapped GPIOs. |
|Peripheral MCU configuration for the bluepill/blackpill boards. |