Skip to main content
Visitor II
November 21, 2019
Solved

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

  • November 21, 2019
  • 4 replies
  • 10429 views

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!

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    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.

    4 replies

    Visitor II
    November 22, 2019

    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.

    ifconfigAuthor
    Visitor II
    November 22, 2019

    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.

    Visitor II
    November 22, 2019

    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.

    ifconfigAuthor
    Visitor II
    November 22, 2019

    Interesting. Is this code snippet specific to STM32CubeMX?

    Graduate II
    November 22, 2019

    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

    ifconfigAuthor
    Visitor II
    November 22, 2019

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

    Graduate II
    November 22, 2019

    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.