cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Cubemx USB CDC VCP Issue and possible solution.

ralvarezb78
Associate
Posted on April 30, 2016 at 19:10

Hi to all, 

I have STM32F4 Discovery board, CubeMx 4.14 version.

I made an empty project with USB Full Speed VCOM port. And I tested both in Linux and Windows. All compiles OK, but...

 1.- In Linux I was having this error (see kernel messages):

[66654.903832] usb 1-2: new full-speed USB device number 37 using xhci_hcd

[66655.070466] usb 1-2: New USB device found, idVendor=0483, idProduct=5740

[66655.070471] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3

[66655.070473] usb 1-2: Product: STM32 Virtual ComPort

[66655.070476] usb 1-2: Manufacturer: STMicroelectronics

[66655.070477] usb 1-2: SerialNumber: 00000000001A

[66655.071569] usb 1-2: can't set config &sharp1, error -32

[66655.706762] usb 1-2: reset full-speed USB device number 37 using xhci_hcd

First of all, I has made plenty of test, the last line seems not always appear ... 

2.- In windows machine (not virtualmachine) 

I have (with properly installed VCP driver) ''SGS Thomson STM32 Virtual ComPort'' as COM15

If I try to open, hyperterminal repots that it can't open. 

After lot tests, and looking into forums, I saw into this forum this post 

/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/USB%20CDC%20problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&currentviews=118

, so I decided to increase the heap size to 0x0400, and then voila, Linux created /dev/ttyACM0: 

[70374.911527] usb 1-2: new full-speed USB device number 41 using xhci_hcd

[70375.077919] usb 1-2: New USB device found, idVendor=0483, idProduct=5740

[70375.077925] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3

[70375.077928] usb 1-2: Product: STM32 Virtual ComPort

[70375.077931] usb 1-2: Manufacturer: STMicroelectronics

[70375.077933] usb 1-2: SerialNumber: 00000000001A

[70375.115166] cdc_acm 1-2:1.0: ttyACM0: USB ACM device

[70375.115911] usbcore: registered new interface driver cdc_acm

[70375.115913] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

I didn't try in windows yet nor USB transmission. But it seems to fix the issue. 

So my question is? Does anyone experenced this problem and fix it by other ways? 

Thanks.

#stm32f4-cubemx-usb-cdc-vcp-com #cube-usb-fs-device-error--32
4 REPLIES 4
Lori B.
Associate III
Posted on May 02, 2016 at 10:30

I can confirm the same problem on Windows with an STM32F2 too.

rm2399
Associate III
Posted on May 02, 2016 at 11:59

Hi Raul

I had exactly the same problem. For me the heap memory was too small. Cube reserved for USB FS Devices 512 bytes instead of 64 bytes. The bug is in the file usbd_cdc.c (V2.4.2) line 475 and following. So, in the moment, you must reserve >512 bytes heap.

At the service team of ST. Please, in the next cube version, think about on the following modification:

- Defines two HandleTypeDef (usbd_cdc.h in File Line 111 and following)

   USBD_CDC_FS_HandleTypeDef

   USBD_CDC_HS_HandleTypeDef

- Delete in usbd_cdc.c (version 2.4.2) the assignment in line 517

- After line 482 insert:

   pdev-> pClassData = USBD_malloc (sizeof (USBD_CDC_HS_HandleTypeDef));

- After line 497 insert:

   pdev-> pClassData = USBD_malloc (sizeof (USBD_CDC_FS_HandleTypeDef));

- Check the rest of the program if all accesses are properly
ron239955
Associate
Posted on June 30, 2016 at 13:15

Hi -

I am having a similar problem, on an F7 MCU.  Increasing the heap size made no difference.   I've got the 2.4.1 code, it looks like.

Any other thoughts on this?
Walid FTITI_O
Senior II
Posted on June 30, 2016 at 15:23

Hi aaron.ron,

You should disable the Vbus sensing if enabled.

Also check the clock setting and if the USB is getting correctly 48 MHz.

-Hannibal-