You are on page 1of 36

ELECTRONICS

HUB
PROJECTS | TUTORIALS | REVIEWS | KITS

HOME PROJECTS MINI PROJECTS ARDUINO FREE CIRCUITS TUTORIALS SYMBOLS DIY REVIEWS

CONTACT US

YOU ARE HERE: HOME / STM32 / HOW TO UPLOAD STM32F103C8T6 USB BOOTLOADER? PROGRAM STM32 BLUE PILL VIA USB

How to Upload STM32F103C8T6 USB


Bootloader? Program STM32 Blue Pill
via USB
FEBRUARY 25, 2020 BY RAVI — 1 COMMENT
In this tutorial, I will show you how to upload a USB Bootloader on the
STM32F103C8T6 Blue Pill board. Using the STM32F103C8T6 USB Bootloader, you
can easily program the Blue Pill Board just by using the on-board USB port without
needing any external hardware.

Important Note: I highly recommend you to go through the “GETTING STARTED


WITH STM32F103C8T6” tutorial before proceeding further as there are a lot of
configurations, settings, connections and explanation that are very important.

Table of Contents 
1. Introduction
2. Components Required
3. Circuit Diagram
4. Uploading STM32F103C8T6 USB Bootloader
4.1. Making the Connections
4.2. Download the Bootloader Binary
4.3. Upload USB Bootloader Binary to STM32
5. Using ST Flash Loader Tool to Upload USB Bootloader
6. Programming STM32F103C8T6 from USB Port
6.1. Installing Necessary Drivers
6.2. Configuring Arduino IDE
6.3. Uploading the Program
7. Conclusion
Introduction
One thing that makes the Arduino UNO (or any Arduino board for that matter) special is
its ease of programming. Just plug-in the Arduino to your PC and upload the program
using Arduino IDE. It is that simple (provided you have the right drivers and selected
the right USB Port).

The same cannot be said for the STM32F103C8T6 Blue Pill Board. If you remember in
the “Getting Started with STM32F103C8T6” tutorial, I have shown you how to upload
the program to a Generic STM32F103C8T6 board using an external USB to Serial
Adapter.

It is not that a difficult process to upload the program using the FTDI Adapter, but every
time you want to upload a program, you have switch to the Programming Mode and for
normal operation, you have to switch back to Operating Mode (toggling the BOOT0
pins between HIGH and LOW).

It would be simpler if we can just make use of the on-board microUSB port on the Blue
Pill board to upload the program. The STM32F103C8T6 USB Bootloader provides such
solution, where you can simply plug-in the Blue Pill to your PC via the USB Port and
upload the program. As an added benefit, you don’t have to fiddle with BOOT pins as
you can leave it in the Operating Mode.
Components Required
STM32F103C8T6 Blue Pill Board
USB to Serial Converter (like FTDI Programmer)
Connecting Wires
1.8KΩ Resistor (Optional)
PC

Circuit Diagram
The connections between the STM32 Blue Pill and USB to Serial converter are similar
to what I described in the Getting Started Guide. The following is the reference image
for the connections.
Uploading STM32F103C8T6 USB Bootloader
In order to upload the program via the USB Port on the Blue Pill, you need to have a
USB Bootloader installed on the MCU. Thanks to the contributions of LeafLabs (Maple
Bootloader) and rogerclarkmelbourne, a repo of bootloaders is available for a series of
boards. The source code available in GitHub at this link.

To make things easier, the repo consists of downloadable binary files of the bootloaders
(I will explain more about this in later sections).

Making the Connections

The first step is to connect the STM32 Blue Pill board to the USB to Serial Adapter as
shown in the image above. Also, the BOOT0 pins made HIGH i.e. the board is put in
Programming Mode.

Once this is done, you can connect the USB to Serial Converter to the PC and check
for the COM Port.

Download the Bootloader Binary

As mentioned earlier, this repository consists of different binary files for different types
of STM32 Boards. All these binary files are categorized based on the USER LED
Connection. For example, we know that the User LED on your Blue Pill is connected to
pin 13 of Port C i.e. PC13.
Hence, the binary is appropriately named “generic_boot20_pc13.bin”. For all generic
Blue Pill STM32F103C8T6 based boards, you can use this binary file. You can
download the binary from this GitHub link.

If you have a different / custom board. Then download appropriate binary file from the
list of binaries provided in the GitHub repository.

Upload USB Bootloader Binary to STM32

Once the hardware connections are made and you have downloaded the necessary
binary file, then you are ready to upload the STM32F103C8T6 USB Bootloader to the
MCU. For this you can make use of the STM32CubeProgrammer.

If you remember in the “Getting Started with STM32F103C8T6” guide, I have


downloaded the STM32CubeProgrammer Software from the STMicroelectronics’
official website. If you have followed that tutorial, then you already have downloaded
that software, which in my case, can be found at the location “C:\Program
Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin”. Go to a similar
location in your PC and open the “STM32CubeProgrammer.exe” file.
On the right side of the page, select “UART” as the communication mode and select
the appropriate COM Port. In my case it is COM4. Leave every thing else to the default
settings and click on connect.
Once the connection is successful, the software will read the contents of flash and
display the same. Next, click on the symbol that shows a downloading arrow. This will
open the “Erasing & Programming” option.
Click on browse and locate the previously downloaded binary file i.e.
generic_boot20_pc13.bin file. The start address will be automatically populated with
“0x08000000”. If not, enter this value. Finally, click on “Start Programming” option. The
software will start uploading the USB Bootloader to Flash of the MCU and you can see
the log below.
Once the binary is uploaded, a message saying “File download complete” will pop-up.
Click on OK and finally click on disconnect on the top right corner. This completes
uploading STM32F103C8T6 USB Bootloader to the Flash of the MCU. At this point,
you can disconnect the USB to Serial Adapter from the Blue Pill Board and also toggle
back the BOOT0 pin to LOW i.e. Operating Mode as you don’t need that.

Using ST Flash Loader Tool to Upload USB Bootloader


Instead of using the STM32CubeProgrammer software, you can use an alternative tool
called the ST Flash Loader. This is also officially provided by STMicroelectronics and
you can download it from this link.

You have to login with ST’s website to download the tool and once you have finished
downloading, extract the contents of the zip file and double click on
“flash_loader_demo_v2.8.0.exe” file. This will install the Flash Loader Tool.

After installing the tool, open it from this location “C:\Program Files
(x86)\STMicroelectronics\Software\Flash Loader Demo” by double clicking on
“STMFlashLoader Demo.exe” file.
Before proceeding further, make sure that the STM32 Blue Pill Board is connected to
the USB to Serial Programmer through USART connections and the BOOT0 pin is
made HIGH.
If you have already connected your USB to Serial Adapter to your PC, then select the
correct COM Port from the drop-down list and click on next. If every thing goes well,
you will get a message saying “Target is readable. Please click “next” to proceed”. Click
on next.
In the next page, the target related information is displayed. Click on next.
In the next page, select the option “Download to Device” and select the downloaded
binary file. After that, the start address will be automatically populated as 8000000.
When you click next, the tool will start uploading the USB Bootloader Binary to the
MCU.
If every thing goes well, then you get a message “Download operation finished
successfully”. You can close the tool.
Make sure that the BOOT0 pin made LOW and disconnect the USB to USART
Converter from STM32 Board.
Programming STM32F103C8T6 from USB Port
Installing Necessary Drivers

Before proceeding further, you need to download some drivers. First, download the
STM32 related tool for Arduino from this link. Click on Clone or download and click on
Download ZIP. Extract the contents and rename the folder as “Arduino_STM32”. Copy
this folder and paste it in “C:\Users\TrailBlazer\Documents\Arduino\hardware” directory.

NOTE: In the above path, “TrailBlazer” is my username. Replace it with yours. If the
directory Arduino\hardware is not present, then create one.

Open command prompt with admin rights and navigate to the directory
“C:\Users\TrailBlazer\Documents\Arduino\hardware\Arduino_STM32\drivers\win”. Run
the “install_drivers.bat” file first. This will install the Maple DFU Driver and Maple Serial
Driver.
Also, run the “install_STM_COM_drivers.bat” file to install the STM Serial Driver.

Configuring Arduino IDE


If your Arduino IDE is already open, close it, connect the STM32 Blue Pill to the PC
through a microUSB cable and restart the IDE. In the Arduino IDE, go to Tools and
make the necessary changes to the board selector as mentioned in the “Getting
Started to STM32F103C8T6” guide.
But you need to change the Upload Method option to “Maple DFU Bootloader 2.0”. The
rest of the settings will remain the same.

Uploading the Program

As a sample program, write a simple Blinky Sketch for STM32F103C8T6 Blue Pill
Board. Make sure that the LED is selected as PC13 and click on upload. The program
will be uploaded through the USB port of the STM32 Board.
Conclusion
A step-by-step tutorial on uploading USB Bootloader for STM32F103C8T6 Blue Pill
Board and programming it using the on-board microUSB port is demonstrated here.

Related Posts:
Interfacing HC-05 Bluetooth with STM32F103C8T6 |…
How to use ADC in STM32F103C8T6? STM32 ADC Tutorial
Interfacing 16X2 LCD with STM32F103C8T6 | STM32 Blue…
Working with Interrupts in STM32F103C8T6 Blue Pill Board
How to use SPI in STM32F103C8T6? STM32 SPI Tutorial
Getting Started with STM32F103C8T6 Blue Pill

FILED UNDER: DIY PROJECTS, STM32

Comments

Sam Tal says


APRIL 1, 2020 AT 9:43 AM

Thanks Ravi. The best and most comprehensive and detailed Arduino for STM32
explanation. Thanks.
Yet, one problem: Following successful installation of drivers, I am trying to port an
old (9 years) Maple complex program to the STM32_Smart board (STM32F103C8)
which seems to be very similar to the Blue Pill.
I could not find the “Generic STM32F1 Series” and its C8 variant on the list (But
found “Generic STM32F103C Series”).
In addition, I could not find the “upload method Maple DFU Bootloader 2.0”.
What am I doing wrong? Is this because I use a different board ?

Reply

Leave a Reply
Your email address will not be published. Required fields are marked *

Comment
Name *

Email *

Website

POST COMMENT
Search this website
PROJECTS BY CATEGORY

Arduino Projects (200+)


Electronics Projects (250+)
Mini Project Circuits (160+)
Mini Project Ideas (150+)
ECE Projects (150+)
EEE Projects (150+)
8051 Projects (110+)
Raspberry Pi Projects (101+)
Electrical Project Ideas (100+)
Embedded Projects (100+)
Latest Electronics Ideas (100+)
Microcontroller Mini Projects (100+)
Robotics Projects (100+)
VLSI Projects (100+)
Solar Projects (100+)
IOT Projects (100+)

Communication Projects (70+)


LED Projects (70+)
Power Electronics Projects (60+)
RFID Projects (60+)
Home Automation Projects (50+)
Matlab Projects (50+)
EIE Projects (50+)
Wireless Projects (50+)
LabView Projects (45+)
Zigbee Projects (45+)
GSM Projects (40+)
555 Timer Circuits (40+)
Sensor Projects (40+)
ARM Projects (60+)
DTMF Projects (30+)
PIC Projects (30+)
Electrical Mini Projects (25)
ESP8266 Projects (15)

KITS

Best Rgb Led Strip Light Kits


Arduino Starter Kit
Electronics Books Beginners
Breadboard Kits Beginners
Best Arduino Books
Diy Digital Clock Kits
Drone Kits Beginners
Best Brushless Motors
Raspberry Pi Books
Electronics Component Kits Beginners
Soldering Stations
Electronics Repair Tool Kit Beginners
Raspberry Pi Starter Kits
Best Waveform Generators
Arduino Robot Kits
Oscilloscope Kits Beginners
Raspberry Pi LCD Display Kits
Robot Cat Toys
FM Radio Kit Buy Online
Best Resistor Kits
Soldering Iron Kits
Best Power Supplies
Best Capacitor Kits
Arduino Sensors
Best Function Generator Kits
Led Christmas Lights
Best Iot Starter Kits
Best Gaming Headsets
Best Python Books
Best Robot Dog Toys
Best Robot Kits Kids
Best Solar Panel Kits
Led Strip Light Kits Buy Online
Top Robot Vacuum Cleaners
Digital Multimeter Kit Reviews
Solar Light Kits Beginners
Best Jumper Wire Kits
Best Gaming Earbuds
Best Wireless Routers
3d Printer Kits Buy Online
Best Gaming Mouse
Electric Lawn Mowers
Best Gaming Monitors

SUBSCRIBE FOR UPDATES

Enter your email address:


SUBSCRIBE

GENERAL PROJECTS PROJECTS TUTORIALS TUTORIALS

Tutorials Electrical Mini projects Capacitors Amplifiers

Symbols Electronics Microcontroller Resistors IO Devices

Courses Embedded Arduino Filters Thyristors

Calculator Power Solar Diodes DC Circuits

Contact Robotics Free circuits Transistors Number System

HomeZene ARM Home Automation TS EAMCET 2019

Best Arduino Kits IOT Seminar Topics


FOLLOW US
TechZene Electronics
Instagram
Questions
Youtube

Facebook

Google Plus

Twitter
Affiliate Disclosure | Disclaimer | Terms and Conditions | Privacy Policy
Copyright © 2020 Electronicshub.org

You might also like