Page 1 of 1

Unable to upload a skect to STM32 Bluepill

Posted: Sat May 20, 2023 3:29 pm
by nounours18200
I have been using Arduino Nanos for years, but I am unable to transfer a sketch to a STM32 Bluepill (STM32FC103C8).

I have followed this tutorial : https://www.sgbotic.com/index.php?dispa ... page_id=48 , and for information I have previously trried using PlatformIO under VScore: Platformio tells that everything is SUCCESS but nothing happens (Led is not blinking, let me think that the sketch has not been uploaded).

section 1- "Arduino Bootloader" of the Tutorial because i would like to avoir using the ST-Link.

I have selected:
  • Bluepill Generic STM32F103C8 as indicated
    USB Support, select CDC (generic "Serial" supersede U(S)ART)
    Upload method, select HID Bootloader 2.2
    The COM port already selected is COM3 on my PC.
all exactly as written on the tutorial.

But when I try to upload the sketch, i get the following error:

Code: Select all


+-----------------------------------------------------------------------+
|         HID-Flash v2.2.1 - STM32 HID Bootloader Flash Tool            |
|     (c)      2018 - Bruno Freitas       http://www.brunofreitas.com   |
|     (c) 2018-2019 - Vassilis Serasidis  https://www.serasidis.gr      |
|   Customized for STM32duino ecosystem   https://www.stm32duino.com    |
+-----------------------------------------------------------------------+

> Trying to open the [COM3]...
> unable to set comport cfg settings
> Unable to open the [COM3]
> Searching for [1209:BEBA] device...
##########
Error - [1209:BEBA] device is not found :(> Searching for [COM3] ...
> unable to set comport cfg settings
> unable to set comport cfg settings
> unable to set comport cfg settings
> unable to set comport cfg settings
> unable to set comport cfg settings
> Finish
le port série sélectionné > Finish
 n'existe pas ou votre Arduino n'est pas connectée

meaning that the Serial port does not exist or the Arduino is not connected, whereas the bluepill is connected wia a USBA-USB-C cable.

Can you help becasue I have trying different methods for 3 days without any success...

Re: Unable to upload a skect to STM32 Bluepill

Posted: Sat May 20, 2023 3:49 pm
by ag123
not the right way, you need to get a st-link (or usb-uart) dongle.
https://www.adafruit.com/product/2548
https://www.st.com/en/development-tools/st-link-v2.html
there is a new much faster one st-link v3 etc, but st-link v2 is adequate, a little old school but works.
those 4 pins at the bottom is for st-link

then you need to read starting from section 2 on the same page
https://www.sgbotic.com/index.php?dispa ... =48#stlink
you need to install stm32cube programmer
https://www.st.com/en/development-tools ... eprog.html

and also review the official wiki
https://github.com/stm32duino/Arduino_Core_STM32/wiki
https://github.com/stm32duino/Arduino_C ... ng-Started

Re: Unable to upload a skect to STM32 Bluepill

Posted: Sat May 20, 2023 10:04 pm
by GonzoG
Blue pills usually do not have usb bootloader flashed. You need to do it yourself and for this you need ST-Link or USB-TTL adapter.

Re: Unable to upload a skect to STM32 Bluepill

Posted: Mon May 22, 2023 2:15 pm
by nounours18200
Problem solved, and the cause was simpler than you suggested: the STM32 Bluepill has its bluit-in Led connected to PB2, and not to PC13 as usual !!

See image:
Bluepill.JPG
Bluepill.JPG (28.4 KiB) Viewed 6474 times
I just had to change the code in the program from "#define LED_BUILTIN PC13" to "#define LED_BUILTIN PB2" and everything works perfectly !

I don't understand why this clone does not use PC13 as usual but that's it ???

Because PB2 cannot be accessed from the external pins, it does not impact an already designed PCB, it just impacts the code. Will have to take care with the future clones that will surely use PC13...

Thank you all, problem solved.