Video :

 

 

In the previous post we explored the ways of uploading code on to STM32 using UART1 & Serial Wire Interface.

Its also possible to upload code through USB port of STM32. By default Bluepill modules are not shipped with boot loader. To enable USB uploading we need to flash a bootloader.

This post is related to USB uploading on to an Arduino core Bluepill.

Firmware (.bin file) for bootloader can be flashed only through UART1 of STM32

USB-TTL module built on CP2102 is used for this purpose.

Connection details as below :

PA9 Tx   to Rx of USB-TTL

PA10 Rx  to  Tx of USB-TTL

5v to 5v , GND to GND

 

IMG_20181109_120316

Plug in the USB-TTL module to PC after installing the CP2102 driver

https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

A port will be allotted to the module.

On STM32 Bluepill shift the BOOT 0 jumper to 1 position & press Reset button.

Image 1

Before proceeding , collect the following Software tool , driver & .bin file

Image 2

 

https://github.com/rogerclarkmelbourne

 

https://github.com/rogerclarkmelbourne/Arduino_STM32/archive/794d078de080054ea39095f8980bdcc2de9f3020.zip

Firmware .bin file can be downloaded from Roger Clark’s github. Ensure to download the bin file with suffix _pc13,bin  ,  as the built in LED of our module is mapped to PC13.

Image 3

Flasher tool can be downloaded from :

https://www.st.com/en/development-tools/flasher-stm32.html

 

Image 5

Install the Flasher tool

 

Image 6

Note the install location of the tool & create a shortcut manually.

 

Image 4

Start the Flash Loader software.

The UART port is automatically detected .

Image 5

Click next.

If you get an Error saying No Response from Target , ensure that BOOT 0 jumper is placed on 1 position & start the flash loader again.

 

Image 2

 

Image 6

Now the Target is readable. Click Next.

 

Image 7

Target Device is automatically detected.Click Next.

Image 8

 

Select Download to Device & browse to location of .bin file.

Image 10

 

Now the   boot loader is installed successfully.

Image 10

 

Now replace the BOOT0 jumper back to 0 position & then remove

USB-TTL module.With power on position , the Boot  0 jumper must be set back to 0.

Connect the usb of STM32 to that of PC.

Image 14

Open Device manager.

Under Ports you may see an exclamation mark or just a USB serial device.

Related driver should be installed , so that it shows Maple Serial COM port.

You can download the driver here :

https://github.com/rogerclarkmelbourne/Arduino_STM32/archive/794d078de080054ea39095f8980bdcc2de9f3020.zip

Just Double click the install_drivers batch file .

bp1

Now you can see Maple Serial COM port under Device Manager.

Image 11

Open the Arduino IDE.

Select Board as Generic STM32F103C Series.

Select Upload method as STM32duino bootloader.

 

Image 12

 

Select the Maple Port

Image 13

 

Now upload the blink sketch ( with LED_BUILTIN defined as PC13)

There is no need to shift BOOT0 jumper to upload code.Directly through USB you can do the upload.

boot1

With some PCs you may get upload done , but the USB port resets before starting to function with the newly uploaded code.

 

Image 14

This is caused by the faulty R10 value resistor seen back to the board.

Most PC USBs accept this pull up value.But sometimes you get the Reset error.

 

Image 16

 

The Blue Pill  has  design fault as it uses a 10k USB pull up resistor, but the USB spec requires 1.5k

You can remove the smd resistor R10 & replace with a 1.5k resistor.

BP2

Or simply solder a 1.8k resistor between PA12 & 3.3V , if you cannot handle SMD component.

blog_image