ST-LINK V2.1 doesn't connect COM port for serial monitor

Post here first, or if you can't find a relevant section!
justinjools
Posts: 41
Joined: Thu May 02, 2024 11:10 am

ST-LINK V2.1 doesn't connect COM port for serial monitor

Post by justinjools »

I am using ST-LINK V2.1, while it uploads fine, it tries to connect to the COM port then times out. I have tried different board variations and other settings but doesn't make any difference.

It's showing up under
Ports(COM &LPT)
> STMicroelectronics STLink Virtual COM Port (COM6)

I also reinstalled the ST-LINK, ST-LINK/V2, ST-LINK/V2-1, STLINK-V3 USB driver

Any ideas?
Attachments
Serial_monitor.jpg
Serial_monitor.jpg (73.31 KiB) Viewed 2797 times
Last edited by justinjools on Wed Jul 03, 2024 5:05 pm, edited 1 time in total.
STM32ardui
Posts: 139
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: ST-LINK V2.1 doesn't connect COM port for serial monitor

Post by STM32ardui »

It will not help, if you open another thread and one more and one more again.
You need to understand, what other users explain.


1. STLink V2.1 has 4 pins: 3,4V, SWDIO, SWCLK, GND. And (most) of STM32 boards have a pinheader for this connection.

2. There is no COM-port. You can see STLink V2.1 in STM32CubeProgrammer. And in Arduino IDE you have to choose "Upload method: STM32CubeProgrammer (SWD)". And you don't need to set board into bootmode, STM32CubeProgrammer does it automaticly.
upload.jpg
upload.jpg (73.8 KiB) Viewed 2786 times

3. If you want to upload via a serial interface (RX/TX), you have to use a USB/Serial-adapter (other name: FTDI-adapter). And you have to set your board into bootmode. On a BluePill-board you have jumper, on a Blackpill-board buttons.
BennehBoy
Posts: 138
Joined: Sat Jan 04, 2020 2:38 am
Answers: 1

Re: ST-LINK V2.1 doesn't connect COM port for serial monitor

Post by BennehBoy »

Also....

Which UART is mapped to the arduino 'serial' depends upon which options you selected in the board configuration menu...

This could mean:

No serial
serial is presented to the GPIO pins specified in the variant file for your board
serial is presented over USB (CDC)

If you have a GENUINE ST Link v2.1 you can potentially connect the relevant GPIO pins that device, but I am unsure what COM port that would present to the OS (if any).

If you have a Chinese copy ST Link v2.1 then there's no option for serial.

Probably best to select the correct settings to have serial presented as USB CDC in the 'Tools' menu:
"USB Support (if available) -> CDC (Generic 'Serial' supersede U(S)ART) " & "U(S)ART Support -> "Enabled (Generic 'Serial')"

Your board will then present as a generic COM port, assuming you have the correct drivers installed.

See the wiki.
ag123
Posts: 1798
Joined: Thu Dec 19, 2019 5:30 am
Answers: 28

Re: ST-LINK V2.1 doesn't connect COM port for serial monitor

Post by ag123 »

I need to make an assumption that you are using a stm32f103c8 'blue pill' board
https://stm32-base.org/boards/STM32F051C8T6-Blue-Pill

and that you are using st-link v2
https://www.adafruit.com/product/2548

like what @STM32ardui mentions, you need to connect the wires appropriately to the 4 pins at the 'bottom' of the blue pill board marked 3v3, swdio, swclk, GND to the st-link v2 dongle accordingly, then that st-link v2 dongle has its own usb (cable) to your pc.

This is your 'programming' dongle / cable.

Next, get another usb (phone) cable, connect to the usb port of the 'blue pill' itself.

This is your 'serial' connection to your 'blue pill board' for your sketch to show you stuff using

Code: Select all

Serial.println("xxyy");
commands

and before you build your sketch you need to select USB Support -> CDC (generic 'Serial' supersede U(S)ART)
usb support (CDC Serial)
usb support (CDC Serial)
usbcdcserial.png (18.2 KiB) Viewed 2764 times
and your sketch should look like

Code: Select all

void setup() {
	pinMode(LED_BUILTIN, OUTPUT);
	Serial.begin();
}

void loop() {
	digitalWrite(LED_BUILTIN, ! digitalRead(LED_BUILTIN));
	if( Serial.available() ) {
		// echo everything you typed back to you
		while(Serial.available()) {
			Serial.write(Serial.read());
		}
	}
	delay(1000);
}
so you need 2 usb (phone) cables, one goes to the programmer st-link v2 for *programming*, the other usb (phone) cable goes to the blue pill that responds to your *sketch*
Last edited by ag123 on Wed Jul 03, 2024 6:11 pm, edited 2 times in total.
fpiSTM
Posts: 1838
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 102
Location: Le Mans
Contact:

Re: ST-LINK V2.1 doesn't connect COM port for serial monitor

Post by fpiSTM »

Pay attention to not connect 3.3V pin and the USB of the board at the same time. Else you will see the blue magic smoke :mrgreen:
STM32ardui
Posts: 139
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: ST-LINK V2.1 doesn't connect COM port for serial monitor

Post by STM32ardui »

ag123 wrote: Wed Jul 03, 2024 5:47 pm you need to connect the wires appropriately to the 4 pins at the 'bottom' of the blue pill board marked 3v3, swdio, swclk, GND to the st-link v2 dongle accordingly, then that st-link v2 dongle has its own usb (cable) to your pc.

This is your 'programming' dongle / cable.

Next, get another usb (phone) cable, connect to the usb port of the 'blue pill' itself.
Such a "chinese made" STLink normally outputs 3,3V to the BluePill-board. And by USB-cable board will get addition 5 V. For the board in your link is a warning:
Warning: The +5V pins on this board are directly connected to the +5V pin of the USB connector. There is no protection in place. Do not power this board through USB and an external power supply at the same time.


So I guess it would be better to power Bluepill by USB-cable and conncect on SWD-side only GNS, SWDIO and SWCLK?
ag123
Posts: 1798
Joined: Thu Dec 19, 2019 5:30 am
Answers: 28

Re: ST-LINK V2.1 doesn't connect COM port for serial monitor

Post by ag123 »

agreed, just '3 pins' swdio, swclk, gnd is adequate and safer.

btw I've been a 'can't be bothered' e.g. connect 3v3 to 3v3 as well. no magic blue smoke provide one is not silly enough to connect VCC (5v !) to 3v3.
the idea is that if both sides are 3v3, then that 'in theory' no current flows
:mrgreen:

oh and another tip for op. if one gets the stm32f401 or stm32f411 'black pill'
e.g.
https://github.com/WeActStudio/WeActStu ... iSTM32F4x1
then you won't need the st-link v2 if you just want to program the board.
rather under Upload method, select > STM32CubeProgrammer (DFU)
upload method DFU
upload method DFU
stm32cubedfu.png (24.9 KiB) Viewed 2752 times
and simply connect the usb (phone) cable to the board. (no st-link is needed)

before you click 'upload' (in the Arduino IDE) you need to do this
  • press both reset and boot0
  • hold boot0, release reset
  • release boot0 3 seconds later
I'm not sure if in windows you would see any responses, but that puts your board/chip in DFU (programming) mode
then you click upload to upload the sketch/firmware.
it should start programming and shouldn't take too long.

then when you simply press reset, your sketch should run.

for stm32f103, you need the st-link dongle and the 2 usb cable approach, one for the st-link (programmer) and the other is the *serial* connection to the board.
STM32CubeProgrammer (DFU) doesn't work on stm32f103, it is only available in some socs e.g. stm32f4xx / g4xx family.

stm32f401 or stm32f411 is recommended for 'beginners'
- fast (faster than stm32f103, has 'ART accelerator' and fpu)
- has more sram like 32k or more
- has more flash for the stm32f4xxceu ones like 512k flash
one can practically load 'huge' sketch into it and not be bothered about pinch to save on every byte of the compiled sketch binary.
most things should 'just works'
Last edited by ag123 on Wed Jul 03, 2024 6:50 pm, edited 1 time in total.
justinjools
Posts: 41
Joined: Thu May 02, 2024 11:10 am

Re: ST-LINK V2.1 doesn't connect COM port for serial monitor

Post by justinjools »

1. I have the 4 pins corrected connected.

2. Upload method: STM32CubeProgrammer (SWD). I already have selected.

3. It uploads fine, and I can see the com port in device manager.
Ports(COM &LPT)
> STMicroelectronics STLink Virtual COM Port (COM6)

I already have selected:
CDC (Generic 'Serial' supersede U(S)ART) " & "U(S)ART Support -> "Enabled (Generic 'Serial')"

@ BennehBoy
I am using WeAct Mini Debugger STLink V2.1 which I have read works fine for other users.
I do also have a official ST-LINK V3Minnie but have yet to figure out to connect to the STM32 blue/black.

@ag123 I'm using WeAct MiniDebugger ST-LINKV2.1. It does USB over the SWD/Serial connection. It is showing up in device manager as mentioned above.
https://github.com/WeActStudio/WeActStudio.MiniDebugger

PS. I only posted this for this problem. I did have a related problem for V2 which you might be referring but that was a different problem: being ST-LINK V2 doesn't work with STM32 black pill. I have just received V2.1 because of this and testing with STM32 blue. I did an extensive search before and came up with nothing except reinstall driver to answer your initial curt response.
ag123
Posts: 1798
Joined: Thu Dec 19, 2019 5:30 am
Answers: 28

Re: ST-LINK V2.1 doesn't connect COM port for serial monitor

Post by ag123 »

remember 2 usb (phone) cables, 1 goes to programmer (e.g. st-link v2), the other goes to the board (this is your serial com port) that USB (CDC) Serial thing.

about that weact st-link v2 dongle, if you want to use the comm (uart) port, you would need to connect e.g. PA9 tx PA10 rx to separate pins on the weact st-link dongle.
make sure boot0 is at gnd so that it doesn't trip stm32f103 into programming mode on reset.
based on the picture provided on weact's github
Image
they don't seem to provide separate pins to connect PA9 tx PA10 rx from the stm32f103 dev board.

in this case, you may be better working with 2 usb (phone) cables 1 cable to the weact st-link v2, the other to the blue pill usb port and to use USB (CDC) Serial for the blue pill

edit: incorrect, weact use a mini FPC connector it seemed and that there are more wires, if you use the u(s)art instead, pa9 tx, pa10 rx need to connect to the dupont wires accordingly for weact's dongle for rx and tx

oh and if you are using USB (CDC) Serial, and you have pa9 tx, pa10 rx connected to the WeAct st-link dongle rx, and tx lines.
in your sketch, that is normally Serial1 or Serial2 for the uart
https://github.com/stm32duino/Arduino_C ... wareserial
e.g. try

Code: Select all

void setup() {
	Serial1.begin(115200);
}

void loop() {
	Serial1.println("hello world");
	delay(1000);
}
that should go to the uart

but if you use USB (CDC) Serial, i.e. normal usb (phone) cable

Code: Select all

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

void loop() {
	Serial.println("hello world");
	delay(1000);
}
this goes to a separate 'virtual com port', i.e. the blue pill presents itself as a com port and that doesn't need the usart.
it can go up to usb full speed 12 Mbps, but that this bandwidth is shared by the number of usb devices you have connected on the usb bus.
Last edited by ag123 on Wed Jul 03, 2024 8:01 pm, edited 3 times in total.
STM32ardui
Posts: 139
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: ST-LINK V2.1 doesn't connect COM port for serial monitor

Post by STM32ardui »

justinjools wrote: Wed Jul 03, 2024 6:46 pm I am using WeAct Mini Debugger STLink V2.1 which I have read works fine for other users.
I would not call BlackPill with STM32F411CEUS a new board ...
Until now I used WeAct Mini Debugger STLink V2.1 with STM32F411, STM32C011 and STM32G431.

@ag123:
This debugger has pins for SWD and UART, so you need only one USB cable to computer. In device manager of Win10 you can see both connections.


justinjools wrote: Wed Jul 03, 2024 6:46 pm I do also have a official ST-LINK V3Minnie but have yet to figure out to connect to the STM32 blue/black.
I don't know it.
Does it has pinheader with 1,27 mm pitch?
There must be a user manual and inside description of signals on connectors. So you need a cable form 1,27mm to 2,54mm?
Post Reply

Return to “General discussion”