cancel
Showing results for 
Search instead for 
Did you mean: 

STLink V2 VCP COM port doesn't show up in Windows

ifconfig
Associate II

I'm trying to get myself situated to program comfortably with my STM32 Blue Pill and STLink V2 USB interface. However, I've run into an issue when trying to gain access to the VCP (Virtual COM Port) that the STLink is supposed to open up for me when I plug it into my computer. I've installed the latest drivers from the ST website.

I upload the USB bootloader to the STM32 and then upload a program over the STLink.

After this, I no longer have access to a serial port over the USB connection to the blue pill or STLink (which never worked previously, and is what I'm trying to get working).

In accordance with multiple sources I've found online, I expect to see a COM port for serial communication, but I don't. All I see in Device Manager is the STLink programmer.

Device Manager Screenshot: https://i.stack.imgur.com/jHP9B.png

Does anyone know how to fix this situation and properly configure the STLink to show its COM port? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

That, or use the PB3/TDO/SWO connection, where you can output via the ITM/SWV (serial wire viewer) in a fashion similar to the debug communication channel that older ARM parts used.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

8 REPLIES 8
jovial_canopy
Associate II

How is your ST link connect to the Blue pill, via the SWD port?

If you meant the USB CDC Virtual COMM Port, it work via the USB connector directly, instead of through the ST Link. Don't forget to add "USB_DEVICE" in the middleware.

ifconfig
Associate II

I have the `SWDIO` and `SWCLK` pins on the Blue Pill board connected to my STLink V2. I'm not sure what you're talking about by middleware. I mean the kind of serial port that will allow me to send serial messages back to my computer over the STLink's USB connection. (accessible via the Arduino `Serial.println()`) I'm using PlatformIO to develop for the STM32 with the Arduino framework.

The stand-alone ST-LINK V2 does not provide a serial port. The mbed one on Nucleo and more recent DISCO boards has one connected to the local target. The V3 has a breakout board to escape a UART

Some boot-leg devices using the mbed variant (V2-1 I suppose) might provide a UART

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ifconfig
Associate II

So, then am I forced to hook up a FTDI adapter to UART1 for Serial comms?

That, or use the PB3/TDO/SWO connection, where you can output via the ITM/SWV (serial wire viewer) in a fashion similar to the debug communication channel that older ARM parts used.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

If you are not using CubeMX, probably there is no "middleware" things. Right now I use the micro USB port on blue pill to realize the virtual com port function. You can check this video for the details: https://www.youtube.com/watch?v=AYICE0gU-Sg I don't know whether Arduino framework has it or not.

You may want to extend the CDC_Receive_FS() function to let the MCU interact with your command. Otherwise, just use CDC_Transmit_FS() function to send whatever data you want to your host PC. I wrote another simple function to wrap it, such that I can print out strings directly.

void usb_cdc_send_string(char *str_buf) {
  uint16_t len_str = 0;
  char *p = str_buf;
  // auto count the string length.
  while (len_str < 1024 and (*p != '\0') and (*p != '\n')) {
    len_str++;
    p++;
  }
  if (*p == '\n') {
    len_str += 1; // count the '\n'
  }
  CDC_Transmit_FS((uint8_t *)str_buf, len_str);
  // wait for the transmission completes.
  HAL_Delay(1 + len_str / 10); // choose this delay empirically
}
 
/* Call it by */
usb_cdc_send_string("[INFO] initialization complete!\n");

So far I don't think ST Link (V2) has the virtual com port functionality.

Interesting. Is this code snippet specific to STM32CubeMX?

I think it is possible to integrate it into the Arduino framwork.

You can first use the CubeMX to generate the two folders, "USB_DEVICE" and "Middlewares/ST/STM32_USB_Device_Library", which provides all the necessary code for enabling the VCP (I have an example in the attachment, for STM32F103C8x MCUs).

Then in your main.c, include "usb_device.h" and "usbd_cdc_if.h". Next, called the MX_USB_DEVICE_Init() in your initialization step.

I think these steps are enough for the VCP for arduino, although I haven't try that myself.