Can't open serial monitor using ST Link and STM32F103C8

Post here all questions related to LibMaple core if you can't find a relevant section!
walla121
Posts: 6
Joined: Wed Jan 08, 2020 7:17 pm

Can't open serial monitor using ST Link and STM32F103C8

Post by walla121 »

Hi, I started using STM32F103C8 (Blue Pill) and I have encountered a problem. I am using ST-LINK v2 for communication and Arduino IDE. I installed everything right and when I upload code over ST-LINK, it is working, so the communication is fine.

You can see that i uploaded a blink and it's working:
Image

The problem I have is that I can't use serial monitor because it gives me this error:
Image

And I can't select port to fix that problem:
Image

So can you please help me to fix this problem because for my project I have to use serial communication. I have tried to use this TTL UART module for uploading method and it didn't even upload code and blinking wasn't working, but it was recognized on PORT 3 in Arduino IDE, so the only working method for me is using ST LINK.
ag123
Posts: 1668
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by ag123 »

did you connect your usb cable?
stm32duinos does usb-serial the favorite option, no need dongles ;)
and for blue pills be wary of fakes and possibly defective ones.
User avatar
Juraj
Posts: 47
Joined: Fri Jan 03, 2020 7:47 pm
Answers: 1
Location: Slovakia
Contact:

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by Juraj »

ST-Link is not a Serial adapter, it is a programmer. You can't open a Serial Monitor over ST-Link.
to see the Serial prints connect the Blue Pill with USB cable. without bootloader listening on USB you can't upload over USB but it works as Serial (or Serial1?) with Serial Monitor or other terminal program
walla121
Posts: 6
Joined: Wed Jan 08, 2020 7:17 pm

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by walla121 »

Juraj wrote: Thu Jan 09, 2020 3:59 pm ST-Link is not a Serial adapter, it is a programmer. You can't open a Serial Monitor over ST-Link.
to see the Serial prints connect the Blue Pill with USB cable. without bootloader listening on USB you can't upload over USB but it works as Serial (or Serial1?) with Serial Monitor or other terminal program
So I should only upload a code over ST-Link but for use of Serial monitor I should connect it on USB... Can you give me some tutorial? And can I connect it through this?
ag123 wrote: Thu Jan 09, 2020 12:35 pm did you connect your usb cable?
stm32duinos does usb-serial the favorite option, no need dongles ;)
and for blue pills be wary of fakes and possibly defective ones.
Yes, when I connect with usb it is recognized on port but can't upload my code. And how can I check if it's fake or original?
ag123
Posts: 1668
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by ag123 »

install your sketch using st link, and connect to the pill board using a separate usb-cable
when the sketch/firmware is running, st-link is no longer needed. it is used to flash the firmware (and do debug, beyond scope to describe debug, one can find plenty of articles in web searches)

you can also install a boot loader
https://github.com/rogerclarkmelbourne/ ... ill-Boards
^^the various mods are not needed, the key step is to get the boot loader firmware, and install the firmware using st-link
after that you can place your st-link aside and the Arduino ide can flash the sketch just from that usb cable alone. no st-link needed after that
the command is actually

Code: Select all

dfu-util -a 2 -RD sketch.bin
to install a sketch outside of the Arduino ide. provided the boot loader is previously installed on the board using st-link

and you have to choose the correct upload method (stm32duino boot loader) when you are building your sketch

for the details, review the various wiki
https://github.com/rogerclarkmelbourne/ ... STM32/wiki
http://docs.leaflabs.com/docs.leaflabs.com/index.html
http://docs.leaflabs.com/docs.leaflabs.com/index.html

in the arduino IDE, your compiled sketch is actually in a temporary folder
https://forum.arduino.cc/index.php?topic=492544.0
and in a folder in /tmp in linux
the sketch binary is a sketch.bin file. that file is the binary firmware of your compiled sketch which you can install on the device etc
that file is one that you can use that dfu-util command to install on the device if the boot loader is installed prior and you choose stm32 duino boot loader as the upload method when you are building your sketch (i.e. click verify)
if you choose st-link as upload and build your sketch, you would need to use st-link to install your sketch, and it is similar to how the boot loader is installed in the first link given above


a fake chip will fail in various ways if you tried the steps in the various popular documented ways and it doesn't work.
if you are able to get a blinky to run on the board, chances are that it isn't fake. but u'd not know really
until you hit trouble again
User avatar
Juraj
Posts: 47
Joined: Fri Jan 03, 2020 7:47 pm
Answers: 1
Location: Slovakia
Contact:

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by Juraj »

BluePill has an USB connector. you don't need the USB-to-TTL adapter.
without the stm32duino bootloader you can't upload over USB , but you should be able to print to Serial Monitor over USB with Serial like on any Arduino.

the ST-Link doesn't use 'com' port for upload, so you can have the com port of the Blue Pill USB connector selected in Arduino IDE. the upload will go over the ST-Link if you select it for upload (over programmer) and the Serial Monitor will use the selected USB port.

to flash the bootloader you can use the ST-Link programmer. so again no need for an USB-to-TTL-Serial adapter
hobbya
Posts: 49
Joined: Thu Dec 19, 2019 3:27 pm
Answers: 1

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by hobbya »

Here comes the 3rd option: get a STLink v2.1 (99.9% in the market are all v2) and it can support code upload and virtual com port at the same time.
Or you get a Nucleo-64 board for your development. All Nucleo series come with STLink v2.1 on board.
If you love to DIY then you may take a look here https://weekly-geekly.github.io/article ... index.html.
Last edited by hobbya on Sun Jan 12, 2020 11:15 am, edited 2 times in total.
walla121
Posts: 6
Joined: Wed Jan 08, 2020 7:17 pm

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by walla121 »

Juraj wrote: Thu Jan 09, 2020 8:49 pm BluePill has an USB connector. you don't need the USB-to-TTL adapter.
without the stm32duino bootloader you can't upload over USB , but you should be able to print to Serial Monitor over USB with Serial like on any Arduino.

the ST-Link doesn't use 'com' port for upload, so you can have the com port of the Blue Pill USB connector selected in Arduino IDE. the upload will go over the ST-Link if you select it for upload (over programmer) and the Serial Monitor will use the selected USB port.

to flash the bootloader you can use the ST-Link programmer. so again no need for an USB-to-TTL-Serial adapter
I flashed bootloader using ST-Link and now when I connect it directly through USB it doesn't recognize it and I can't upload any sketch now.
Image

ag123 wrote: Thu Jan 09, 2020 4:51 pm you can also install a boot loader
https://github.com/rogerclarkmelbourne/ ... ill-Boards
^^the various mods are not needed, the key step is to get the boot loader firmware, and install the firmware using st-link
after that you can place your st-link aside and the Arduino ide can flash the sketch just from that usb cable alone. no st-link needed after that
the command is actually

Code: Select all

dfu-util -a 2 -RD sketch.bin
to install a sketch outside of the Arduino ide. provided the boot loader is previously installed on the board using st-link

and you have to choose the correct upload method (stm32duino boot loader) when you are building your sketch
I installed bootloader by this tutorial...

I am a beginner at this, so please understand me.
ag123
Posts: 1668
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by ag123 »

walla121 wrote: Fri Jan 10, 2020 1:40 pm I installed bootloader by this tutorial...

I am a beginner at this, so please understand me.
if you are using windows follow these instructions to get usb-serial and DFU working
https://github.com/rogerclarkmelbourne/ ... stallation
^^ please read the instructions here as well
If using Maple or Maple mini, you need to install drivers for the Serial and DFU (upload devices). Please open a cmd window (run as administrator), navigate to the folder: /drivers/win/ and run: install_drivers.bat. Note: This doesn't actually install drivers. Windows comes pre-installed with a compatible Serial USB driver and a DFU (upload) driver. However the built in drivers need to be associated with the USB ID of the Maple serial and DFU devices. The batch file and wdi-simple.exe do the clever stuff to convince Windows 7 or newer, that it should use its drivers with the Maple serial and DFU devices.
Last edited by ag123 on Sat Jan 11, 2020 1:48 am, edited 1 time in total.
walla121
Posts: 6
Joined: Wed Jan 08, 2020 7:17 pm

Re: Can't open serial monitor using ST Link and STM32F103C8

Post by walla121 »

ag123 wrote: Fri Jan 10, 2020 2:26 pm
walla121 wrote: Fri Jan 10, 2020 1:40 pm I installed bootloader by this tutorial...

I am a beginner at this, so please understand me.
if you are using windows follow these instructions to get usb-serial and DFU working
https://github.com/rogerclarkmelbourne/ ... stallation
^^ please read the instructions here as well
If using Maple or Maple mini, you need to install drivers for the Serial and DFU (upload devices). Please open a cmd window (run as administrator), navigate to the folder: /drivers/win/ and run: install_drivers.bat. Note: This doesn't actually install drivers. Windows comes pre-installed with a compatible Serial USB driver and a DFU (upload) driver. However the built in drivers need to be associated with the USB ID of the Maple serial and DFU devices. The batch file and wdi-simple.exe do the clever stuff to convince Windows 7 or newer, that it should use its drivers with the Maple serial and DFU devices.
note that if you followed instructions in this link provided, you actually installed 2 cores
- the stm32duino official core - that is the one that you already have
- the instructions in this link here is for the libmaple core - deemed the community core
they are 2 different implementations of arduino on stm32
I did everything as it was described in tutorial, flashing bootloader was succes, everything went ok, but windows still can't recognize it. I am thinking that maybe it is problem with that resistor and maybe i have to mod it... I think I will be sticking to ST-Link for uploading codes and USB-UART for serial. But thanks for help

And one more question, can you tell me how to reset my Blue Pill to factory bootloader (how to delete stm32 bootloader that I installed)
Post Reply

Return to “General discussion”