SIMPLE QUESTION BLUE PILL COMMUNICATIONS SETTINGS

Post here first, or if you can't find a relevant section!
RobertoBerner
Posts: 36
Joined: Tue May 09, 2023 10:45 pm

SIMPLE QUESTION BLUE PILL COMMUNICATIONS SETTINGS

Post by RobertoBerner »

Hi all !
I am new to STM32 but I have experience with C and other MCUs families.
I need to make it work with Arduino IDE, now using Arduino IDE version 1.8.15
If I want to run this basic code on my Blue Pill board with STM32F103C8T6, I am having trouble to use the native USB connection to program and also to Serial.print to the IDE console terminal.

Code: Select all

void setup() 
{
  Serial.begin(9600);
}

void loop() 
{
  Serial.println("Hello");
  delay(1000);
}
Here are the board & communication settings by STMicroelectronics:

- Board: Generic STM32F1 series
- Board port number: "BluePill F103C8"
- U(S)ART support "Enabled" (Generic serial)
- USB support (if available): "CDC (generic Serial)
- USB speed (if available): "Low/Full Speed"
- Optimize: "Smallest (-Os default)
- Upload method: HID Bootloader 2.0
- Port: COM12
- Get Board Info: working fine

With this configuration I am unable to program my BluePill. This is what I get:
> Trying to open the [COM12]...
> Toggling DTR...
> Searching for [1209:BEBA] device...
##########
Error - [1209:BEBA] device is not found :(> Searching for [COM12] ...
Error - [1209:BEBA] device is not found :(> Searching for [COM12] ...

> Finish
Note: My BluePill has been previously programmed via USB but with STM32F1xx/GD32F1xx boards by stmduino
In this case, the settings change as follows:

- Board: "Generic STM32F103C8 series"
- Variant: STM32F103C8 (20K RAM; 64K Flash)
- Upload method "STM32duino bootloader"
- CPU speed (MHz): 72 MHz (Normal)
- Optimize: "Smallest (default)"
- Port: COM12
- Get board info: working fine


This means that the bootloader works. But I am working in a project that need a timer interrupt event.
The timer functions compile if I use the first setting configuration by STMicroelectronics, but I am unable to program.

If I don't use the timer library, and using the second configuration by stmduino, I am able to program the BluePill using the classic USB connection.
I need help to know how the STMicroelectronics libraries can be used and still program the board via USB from the Arduino IDE.

Thank you
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 26
Location: Prudnik, Poland

Re: SIMPLE QUESTION BLUE PILL COMMUNICATIONS SETTINGS

Post by GonzoG »

You don't have HID bootloader on your board.
stm32duino bootloader is based on Maple bootloader and you need to select "Maple bootloader 2.0" or flash HID bootloader: https://github.com/Serasidis/STM32_HID_Bootloader
RobertoBerner
Posts: 36
Joined: Tue May 09, 2023 10:45 pm

Re: SIMPLE QUESTION BLUE PILL COMMUNICATIONS SETTINGS

Post by RobertoBerner »

OK, here's what I have in the table:

hid_generic_pc13.bin (downloaded from https://github.com/Serasidis/STM32_HID_ ... /tag/2.2.2)
hid-flash.exe (downloaded from https://github.com/Serasidis/STM32_HID_ ... r/releases)

My BluePill has LED in PC13 as written over the board

The hid-flash.exe says:

+-----------------------------------------------------------------------+
| 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 |
+-----------------------------------------------------------------------+

Usage: hid-flash <bin_firmware_file> <comport> <delay (optional)>
-------------------------------------------------------------------------

From the literature here https://github.com/Serasidis/STM32_HID_ ... /tag/2.2.2 ...
... I should do this:

hid-flash hid_generic_pc13.bin COMx <ENTER> with the BluePill on the USB and one jumper in 3.3V

Problem: after last Arduino program upload now my board does not show any COM port over USB
It shows under LibUSB-Win32 Devices : Maple-DFU
So, what COMx port should I use ?
I tested all 4 boot jumper combinations.
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 26
Location: Prudnik, Poland

Re: SIMPLE QUESTION BLUE PILL COMMUNICATIONS SETTINGS

Post by GonzoG »

You need a programmer to flash bootloader to F103 (ST-Link or usb-ttl). There is no other way. There are instructions how to flash HID bootloader.

hid_flash tool is for flashing your programs using HID bootloader.
RobertoBerner
Posts: 36
Joined: Tue May 09, 2023 10:45 pm

Re: SIMPLE QUESTION BLUE PILL COMMUNICATIONS SETTINGS

Post by RobertoBerner »

OK, I have both ST-Link and a Serial TTL to USB cable.
I am a newbie to STM32, and I thank all the help I am receiving.
Could you please give me some clue on how to flash the HID-bootloader by using this serial tools?
The hid_generic_pc13.bin file is still OK ?

I understand that once you have the HID-bootloader installed, the USB connection is able to flash programs from Arduino IDE and also keep the COMx port working after loading ?
RobertoBerner
Posts: 36
Joined: Tue May 09, 2023 10:45 pm

Re: SIMPLE QUESTION BLUE PILL COMMUNICATIONS SETTINGS

Post by RobertoBerner »

PROBLEM SOLVED !

I could successfully flashed the HID-bootloader to my BluePill.
Now I can program from Arduino IDE and also Serial.print to the serial monitor.
I used my ST-Link and the STM32CubeProgrammer to flash the hid_generic_pc13.bin file.
An excellent YouTube video explains the process very clearly.

https://www.youtube.com/watch?v=Myon8H111PQ&t=425s

Having reached this point, I have a next issue to consult in another post.

Thank you all !
Roberto
RobertoBerner
Posts: 36
Joined: Tue May 09, 2023 10:45 pm

Re: SIMPLE QUESTION BLUE PILL COMMUNICATIONS SETTINGS

Post by RobertoBerner »

Hello friends, after some time, I would like to add something about my newbie experience.

I started using the bootloader but...

I reached the point in which I had to reFLASH the HID bootloader each time before Arduino uploads, because the bootloader under certain conditions, got corrupted. Later I found that this is a very well known issue. Sometimes the bootloader simply fails to switch between USB mode to COM mode so Arduino can't program the part.

Erased the FLASH and returned to ST-Link V2, despite the lack of the serial monitor is a burden. Any ideas or a better approach?

Roberto
hobbya
Posts: 49
Joined: Thu Dec 19, 2019 3:27 pm
Answers: 1

Re: SIMPLE QUESTION BLUE PILL COMMUNICATIONS SETTINGS

Post by hobbya »

I always use STLink v2.1. It comes with a virtual com port.
STLink v2 do not have the virtual com port.

Some more info here:
https://stm32world.com/wiki/DIY_STM32_P ... Link/V2-1)

Nucleo boards also has a built-in STLink v2.1 and it can be "broken off" from the board:
https://jeelabs.org/book/1547a/index.html

Some shops sell the above e.g.
https://modtronix.com/product/pgm-nucleo/

Certainly you can also look for STLINK v3 but it is more expensive.
RobertoBerner
Posts: 36
Joined: Tue May 09, 2023 10:45 pm

Re: SIMPLE QUESTION BLUE PILL COMMUNICATIONS SETTINGS

Post by RobertoBerner »

Hello hobbya, thank you for this excellent information.
I will take a closer look tomorrow, but I find interesting the 6 pin ST-Link V2.1
However I understand that the VCOM port ends in TX/RX pins and that these pins need to be connected to TX/RX in the Bluepill (STM32F103C8T6) with 2 wires. If so, this is really convenient.

Thank you very much, greetings from Buenos Aires
Roberto
hobbya
Posts: 49
Joined: Thu Dec 19, 2019 3:27 pm
Answers: 1

Re: SIMPLE QUESTION BLUE PILL COMMUNICATIONS SETTINGS

Post by hobbya »

Yes your understanding is correct.
v2.1 has Tx/Rx pins which can be connected to the Bluepill serial port.
Post Reply

Return to “General discussion”