cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMx IDE USB Virtual COM port code generation & implementation.

RMcmu.1
Associate II

Hi all, I've been trying to use the virtual com port on the "STM32F4DISCOVERY" with no luck. My current IDE is STM32CubeIDE v1.3.1, STM32CubeMx v5.6.1, I'm also using firmware pack FW_F4 V1.25.0.

Ive started a brand new project, used the CubeIDE board selector to select the Discovery board (STM32f407). I've Configured USB_OTG_FS to 'Device_Only' mode, SOF off, VBUS on. I have changed the USB_DEVICE "middlewares?" to, FS IP = VCP. I have also installed the VCP com drivers (I'm in windows 10). I left everything else UN-touched (I also disabled the low speed external clock, I don't have one)

Once my project was gen-ed, I included "usbd_cdc_if.h". In the main while loop I added a 1sec delay, then CDC_Transmit_FS(buff, size). Everything compiled just fine.

The issue is, I'm not receiving anything over the VCP, I have the dev kit plugged in via the otg usb port (as well as the stlink usb port for uploading code). The VCP dose show up in device manager, however putty is unable to connect. After some time passes, the VCP Com device becomes unrecognized.

So I guess my question is, dose the gen-ed code for the VCP over USB need any additional modification? I suspect I might not be implementing it right. Any information anyone can provide would be really great.

I've also tried increasing the stack and heap sizes, this didn't fix anything. Dose "CDC_Control_FS" need anything additional? all of the switch cases are empty... The USB peripheral is kind of a new concept for me, and I'm getting kinda frustrated.

Any information is welcome, I also won't say no to a tutorial / guide.

4 REPLIES 4
RMcmu.1
Associate II

After a bit more google'n and breakfast. I changed the middleware USB_DEVICE parameter settings. More specifically the Class Parameters, both USB CDC Rx Buffer Size and Tx Buffer size got reduced to 64 bytes. Once I did that everything seemed to work, so.. now I get to figure out what that means... :santa_claus: found Santa, but where the hell is waldo.

[Edit] putty still doesn't work, so that's weird, but Termite 3.4 dose.

RMcmu.1
Associate II

Hmmm, so I have concluded that I'm just dumb, and there is no problem with VCP over USB. And STM ROCKS! for providing the masses with this awesome ecosystem.

Should anybody else stumble upon this post, here are some screen shots of CubeMX, and an example VCP over USB project. Pay close attention to main.cpp & usbd_cdc_if.cpp. (File->Import->General->STM32 Project)

And for whatever reason, I still can't get putty to work.... Think that might have been my problem all along. +1 for persistence!

0693W000000WwJeQAK.jpg0693W000000WwJZQA0.jpg0693W000000WwJUQA0.jpg

RMcmu.1
Associate II

Got putty to work + some super secret internal command-line app.

This post really helped!

https://community.st.com/s/question/0D50X00009XkgIYSAZ/unable-to-configure-serial-port-error-for-usb-cdc

   // Gets added to  usbd_cdc_if.c / .cpp
   static uint8_t lineCoding[7]  = {
    0x00,  //baud 115200
    0xC2,  //baud
    0x01,  // baud
    0x00,  // baud
    0x00,  // stop bits one
    0x00,  // parity none
    0x08   //# of data bits 8
   };
 
 
    // Gets added too CDC_Control_FS() in usbd_cdc_if.c / .cpp
    case CDC_SET_LINE_CODING: 
    memcpy( lineCoding, pbuf, sizeof(lineCoding) ); // <-- add this line
    break;
    case CDC_GET_LINE_CODING: 
    memcpy( pbuf, lineCoding, sizeof(lineCoding) ); // <-- add this line
    break;

JensH
Associate III

Hi all,

I hope it's ok to use this question for my problem.

I have nearly the same problem. I have done every adjustment but the connection doesn't work.

For the testing I use an STM32L476 Discovery Board and the STM32Cube FW-L4 V1.15.1 in the STM32CubeIDE.

I haven't installed the ST VCP-Driver on my Win10 Pro system, because I read it's not neccesary.

My Problem ist, that Windows says that my device could not be startet (Code 10) Failure at reveiving the USB-BOS-Descriptor.

I have searched for an answer for two days now, I hope someone could help.

Best regards

Jens