Showing results for 
Search instead for 
Did you mean: 

Unable to configure serial port Error for USB CDC

Associate II
Posted on March 08, 2016 at 00:24

The target is

a custom board based on the STM32F373VC. The project was created by STM32CubeMX with the USB Communications Device Class option enabled.

Windows 7's Device Manager shows the connection is working. This is evidenced by �STMicroelectronics Virtual COM Port (COM9)� appearing under �Ports (COM & LPT)�. When Properties is opened on this line the message �This device is working properly.� appears in the General tab's Device status field.

When I attempt to open a terminal emulator session with KiTTY (fork of PuTTY), KiTTY opens a pop up window with the error message:

Unable to open connection to


Unable to configure serial port.

I did not know what to enter in KiTTY for a baud rate, number of bits, parity, and stop bits, so I left these port settings at default.

Why is Window's 7 unable to configure the serial port?

What should the terminal emulator's port settings be?

#cdc #cdc #usb #usbd-cdc-configure-error
Associate II
Posted on March 08, 2016 at 18:12

Hi Stephen,


1)  Is it FS or HS ?  Often I had problems with HS getting work when COM port is assigned. 

2) Make sure that there is no two instance of terminal device so that the connection has been established with passive and not with active instance. Try to connect with other terminal software as a part of troubleshooting, I use Tera Term and it works fine. 

3) Set the terminal port settings to default values or try  to have the same settings as in the Line Coding descriptor.

4)   I often use python code using serial package to read COM port. I recommend you to check with the script before debugging firmware.

Wish you good luck.



Senior II
Posted on March 08, 2016 at 19:30

Hi Stephen,

install Virtual Com port driver from this

.If problem still persists simply replace the VID and PID fields from inf files(generally available in C:\Program Files\STMicroelectronics\Software\Virtual COMPort Driver) with the VID and PID provided in your usb_desc.c file under devicedescriptor.


Associate II
Posted on March 09, 2016 at 00:07

It is FS.

There was only one instance of KiTTY running.

It works fine when I use it to communicate with the board using the boards UART interface. The UART interface IC is connected to the processor's USART2 pins.

I am unable to find a Line Coding descriptor. I did find



   static int8_t CDC_Control_FS (uint8_t cmd, uint8_t* pbuf, uint16_t length)

in file usbd_cdc_if.c. It does not do anything. There is only a switch case statement with a lot of cases in it none of which have any code in them. In case CDC_SET_LINE_CODING there is described in comments a line coding structure.  I assume this would be the structure of pbuf if cmd were equal to CDC_SET_LINE_CODING. But even if I added code here I do not see it would do any good



akpoints I set within

CDC_Control_FS() show it is

not called at all when the board starts up. If I cycle the USB cable connection at the PC it does get called twice, once with cmd equal to DC_GET_LINE_CODING and again with cmd equal to CDC_SET_CONTROL_LINE_STATE. It is seeking to read back something that was never set.

Where is this Line Coding Descriptor? I need to

try configuring KiTTY to match this. Would that I cannot find this explain why I cannot connect KiTTY to the USB driver? Is there something regarding this in STM32CubeMX that I missed?

Associate II
Posted on March 09, 2016 at 00:09

This very driver is the one that is in use, and the one I have this problem with.

Senior II
Posted on March 09, 2016 at 18:47

Hi Stephen, 

If sill getting the same issue, this [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/usb%20enumeration%20errors%2c%20new%20project%20from%20cubemx&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&currentviews=172]discussion may help you to solve your issue.


Posted on March 11, 2016 at 15:15

For most of ''serial'' terminal application on Windows, GET_LINE_CODING should return exactly the by SET_LINE_CODING.

If you would bind the CDC interface to a UART on STM32F, refer to CDC_Itf_Control() implementation (same as CDC_Control_FS()) in this example file. \STM32Cube_FW_F3_V1.4.0\Projects\STM32373C_EVAL\Applications\USB_Device\CDC_Standalone\Src\usbd_cdc_interface.c If you don't bind CDC interface to any UART, and just use bulk IN/OUT, this simple implementation is enough.

static uint8_t lineCoding[7] // <------- add these three lines
// 115200bps, 1stop, no parity, 8bit
= {0x00, 0xC2, 0x01, 0x00, 0x00, 0x00, 0x08};
static int8_t CDC_Control_FS (uint8_t cmd, uint8_t* pbuf, uint16_t length)
switch (cmd)
memcpy( lineCoding, pbuf, sizeof(lineCoding) ); // <-- add this line
memcpy( pbuf, lineCoding, sizeof(lineCoding) ); // <-- add this line