Skip to main content
Eich
Associate III
Jul 25, 2013 9:26 AM UTC
Question

STM32F405RG VCP error ''This device cannot start(code 10)''

Posted on July 25, 2013 at 11:26

Hi !

When running the VCP USB Stack (STM32_USB-Host-Device_Lib_V2.1.0) on my STM32F4 i got an error code on my Win7 x64 sytem. ''This device cannot start(code 10)'' I'm using the USB HS Port on PORTB in FS mode. Finally i found a solution for it. The source code of the file usbd_conf.h must be changed in the following way: Old:

/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
#ifdef USE_USB_OTG_HS
#define CDC_DATA_MAX_PACKET_SIZE 512 /* Endpoint IN & OUT Packet size */
#define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */

New

/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
#ifdef USE_USB_OTG_HS
#define CDC_DATA_MAX_PACKET_SIZE 64 /* Endpoint IN & OUT Packet size */
#define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */

This change is only necessary when using the HS USB in FS mode. Regards, Ed #stm32-stm32f4-vcp-otg_hs-usb

19 replies

Nickname12657_O
Associate III
Jul 25, 2013 7:53 PM UTC
Posted on July 25, 2013 at 21:53

Hi Ed,

Much appreciated!  All thanks from STMicro.

Cheers,

STOne-32

2dimka
Visitor II
Dec 28, 2014 7:48 PM UTC
Posted on December 28, 2014 at 20:48

Hi! I have a same problem with VCP. But i can't install driver for built-in virtual com port on ST-LinkV2 (Nucleo board).

I use latest version of ST firmware and drivers, and my OS is Windows XP x64 sp3.

Whether you can help me? thanks.

em3ly
Associate
Nov 9, 2015 10:25 PM UTC
Posted on November 09, 2015 at 23:25

Hi, i had the same problem. Thanks for help me to  fix my problem. I'm using STM32CubeMx and STM32F4 Discovery. In the stm32CubeMx proyect I configure correctly the usb clock (48MHz) and  i'm using usb_otg_fs as device only. The solution  for ''This device cannot start(code 10)'' is almost the same that in your case.

 In the source code of ''usbd_cdc.h''  must be changed 

#define CDC_DATA_HS_MAX_PACKET_SIZE                512  /* Endpoint IN & OUT Packet size */

 to

#define CDC_DATA_HS_MAX_PACKET_SIZE                 64  /* Endpoint IN & OUT Packet size */

I hope  it help somebody

Cevdet
Associate III
Jan 29, 2019 1:21 PM UTC

Yes, it helped, thank you for sharing:)

But I am wondering why ? I don't even use HS... what did changed by this definition?

MHoga
Visitor II
Mar 7, 2019 3:19 PM UTC
typedef struct
{
 uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32bits alignment */
 uint8_t CmdOpCode;
 uint8_t CmdLength;
 uint8_t *RxBuffer;
 uint8_t *TxBuffer;
 uint32_t RxLength;
 uint32_t TxLength;
 
 __IO uint32_t TxState;
 __IO uint32_t RxState;
}
USBD_CDC_HandleTypeDef;

It seems regardless whether you are using FS or HS, CDC_DATA_HS_MAX_PACKET_SIZE is used to define this type, I am just an electronics intern so don't have much experience at the moment but it seems to be issue, as when I replace it with what is below, it seems to also work, if anyone is able to explain to me why, it would be helpful

typedef struct
{
 uint32_t data[64U]; /* REPLACEMENT */
 uint8_t CmdOpCode;
 uint8_t CmdLength;
 uint8_t *RxBuffer;
 uint8_t *TxBuffer;
 uint32_t RxLength;
 uint32_t TxLength;
 
 __IO uint32_t TxState;
 __IO uint32_t RxState;
}
USBD_CDC_HandleTypeDef;

aaron239955_stm1_st
Senior
Nov 13, 2015 11:05 AM UTC
Posted on November 13, 2015 at 12:05

you don't indicate what version of cube or libraries you are using.  I believe if you update to a recent version (1.8.0 or later) of the F4 libraries this problem has been fixed for over a year.  You shouldn't have to do any changes to the usbd_cdc.h file

enjoy

tsuneo
Associate II
Dec 29, 2015 5:31 AM UTC
Posted on December 29, 2014 at 06:31

> But i can't install driver for built-in virtual com port on ST-LinkV2 (Nucleo board).

Install the latest PC driver for ST-LINK/V2-1, first.

STSW-LINK008   ST-LINK/V2-1 USB driver on Windows Vista, 7 and 8

http://www.st.com/web/en/catalog/tools/FM147/SC1887/PF260218

STSW-LINK009   ST-LINK/V2-1 USB driver on Windows XP (including WinUSB coinstallers)

http://www.st.com/web/en/catalog/tools/FM147/SC1887/PF260219

OR

you may need to update ST-LINK/V2-1 firmware on your Nucleo board.

STSW-LINK007   ST-LINK/V2-1 firmware upgrade

http://www.st.com/web/en/catalog/tools/FM147/SC1887/PF260217

Tsuneo

sycinfinity
Associate
May 11, 2016 2:37 AM UTC
Posted on May 11, 2016 at 04:37

Thank you for your commend. 

I spend all day to solve this problem. and I change CDC_DATA_HS_MAX_PACKET_SIZE 512 => 64,

my VCP driver work well.

Sami.Oweis
Associate
Mar 21, 2019 5:19 PM UTC

Thank you Eichel.

I was inspired by ur solution and was able to resolve my issue with a different library version.

Here is for anyone is still have the same issue.

https://community.st.com/s/question/0D50X0000AX88PpSQJ/stm32f4x-stmicroelectronics-virtual-com-port-is-properly-installed-but-cant-start-error-this-device-cannot-start-code-10-win7-64fixed

mmed
Associate III
Mar 26, 2019 9:19 AM UTC

Hi all,

using windows10,

I want to handle STM32F407 Disco via VCP. In the first case, i tried to configure UART but when i connect my USB TTL converter to my PC: it informs me that VCP error ''This device cannot start(code 10)''.

I thought that the probem is related to my USB converter

Then i tried to configure CDC USB:

USB_OTG_FS on mode Device only

activate USB_Device middelware in CDC mode

0690X0000088qxcQAA.png

check the CubeMX file attached for more details

but the problem still exist!===> VCP error ''This device cannot start(code 10)''.

0690X0000088qxSQAQ.png

and here is the define in "usbd_desc.c" file

#define USBD_VID   1155

#define USBD_LANGID_STRING   1033

#define USBD_MANUFACTURER_STRING   "STMicroelectronics"

#define USBD_PID_FS   22336

#define USBD_PRODUCT_STRING_FS   "STM32 Virtual ComPort"

#define USBD_SERIALNUMBER_STRING_FS   "00000000001A"

#define USBD_CONFIGURATION_STRING_FS   "CDC Config"

#define USBD_INTERFACE_STRING_FS   "CDC Interface"

=====> Please how can i handle to fix this issue! if there is a wrong value generated by CubeMX! or a change that should i do in my environement (PID, VID....)

this is a real problem for me that block my project0

Please any solution or workaround for this

many thanks

H W
Associate II
Jul 26, 2019 8:56 AM UTC

Having the same problem under Win 10 with a STM32L476 and Firmware 1.14.0 !

(USB-Sniffer: device answers correctly after DESCRIPTOR Request DEVICE from host. After DESCRIPTOR Request CONFIGURATION the device returns the correct information, but the device status is USBD_STATUS_STALL_PID (0xc0000004 -> 'error 10 device cannot start') and no further communication)

Any help ?

finnstap
Visitor II
Sep 3, 2019 4:39 PM UTC

Hi, I have the same problem with the STM32L496 and firmware 1.14.0, also Win 10. Actually the device managed to enumerate successfully once and I was able to view incoming data with putty. I have no idea, why that happened.. Most of the time, the configuration descriptor is invalid (USBD_STATUS_STALL_PID (0xc0000004)). Were you able to fix this?

finnstap
Visitor II
Feb 4, 2020 7:40 PM UTC

Hey, just a quick follow up, I tested my solution thoroughly and after making sure it has no negative effects on the usb transmission I finally submitted a bug report to github: https://github.com/STMicroelectronics/STM32CubeH7/issues/22

tl;dr the bug is known and will be fixed in the new upcoming USB device lib.

RMa.1
Visitor II
Jun 14, 2020 10:51 AM UTC

Just run into a similar issue with STM32F405xx.

Thanks a lot for the folks here for the hint.

For me the issue is the same as Eich mentioned: Changing CDC_DATA_HS_MAX_PACKET_SIZE from 512U to 64U solve the problem.

I took a look at the issue and found that:

  1. In the usbd_cdc.c, USBD_CDC_Init() is using this value to allocate memory: USBD_malloc(sizeof(USBD_CDC_HandleTypeDef));
  2. the USBD_malloc is by default using malloc of the compiler... which means it takes heap.
  3. I checked my default linker directive and found the heap size is 0x200 (512 bytes)
  4. This is certainly going to cause trouble....and lucky me only run into a USB error not other issues....

If you do not like the solution to change the CDC_DATA_HS_MAX_PACKET_SIZE from 512 to 64 (like me...), you can enlarge the heap size by modifying the link directive file.

In my case, I am using IAR, I changed heap to 8KBytes:

define symbol __ICFEDIT_size_heap__  = 0x2000;