cancel
Showing results for 
Search instead for 
Did you mean: 

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

Eich
Associate III
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
18 REPLIES 18
mmed
Associate III

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

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 ?

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?

Actually, a quick fix for me is to remove the call to USBD_LL_StallEP in the function USBD_LL_DataOutStage (file: usbd_core.c), so the relevant code section looks like this:

if (pdev->ep0_state == USBD_EP0_STATUS_OUT)
}
   /*
    * STATUS PHASE completed, update ep0_state to idle
    */
   pdev->ep0_state = USBD_EP0_IDLE;
   //USBD_LL_StallEP(pdev, 0U);
}

Not very elegant, but at least enumeration works now. Transmitting and receiving is also possible, let's see if the removal will cause me any trouble in the future.

blt
Associate II

Commenting out the code in usbd_core.c worked for me. Here are my environment settings for those that might come across this issue in the future:

Windows 10

STM32CubeIDE workspace 1.0.2

STM32h743ZI2 with STM32_fw_h7_v1.5.0

Let me know if there's anything I should include to make it more specific, I went back to change the size of the HS packet back to 512U and it still worked for me. As well as not changing to the data[64U] as some other people have suggested.

I also went back to put the heap stack down to the default 0x200 instead of giving more heap size.

#define CDC_DATA_HS_MAX_PACKET_SIZE                 512U 
 
 
typedef struct
{
  uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U];      /* Force 32bits alignment */
//..
}
USBD_CDC_HandleTypeDef;

One thing I have to remember is that when I use the embedded STM32CubeMX in the IDE to config pins and settings is that the generated code will overwrite the uncommented code, so I have to do a re-uncomment on USBD_LL_StallEP(pdev,0U);

EDIT: some grammar

I would recommend that you copy the USB driver files from the Middleware folder to a new, custom folder and deactivate the Middleware in CubeMX. Include the specific header files yourself and you got yourself a working project with USB HS which still supports CubeMX code generation.

finnstap
Associate II

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
Associate

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;

aurimas123
Associate

In my case it was lack of report descriptor, after generating code with cube do not forget to add report descriptor in user code 0 section, something like this:

 

/** Usb HID report descriptor. */
__ALIGN_BEGIN static uint8_t CUSTOM_HID_ReportDesc_FS[USBD_CUSTOM_HID_REPORT_DESC_SIZE] __ALIGN_END =
{
  /* USER CODE BEGIN 0 */
  	0x05, 0x8c,            /* USAGE_PAGE (ST Page)           */                   
	0x09, 0x01,            /* USAGE (Demo Kit)               */    
	0xa1, 0x01,            /* COLLECTION (Application)       */            
	/* 6 */
	
	/* Led 1 */        
//    0x85, 0x01,            /*     REPORT_ID (1)		     */
	0x09, 0x01,            /*     USAGE (LED 1)	             */
	0x15, 0x00,            /*     LOGICAL_MINIMUM (0)        */          
	0x25, 0x01,            /*     LOGICAL_MAXIMUM (1)        */           
	0x75, 0x08,            /*     REPORT_SIZE (8)            */        
	0x95, USBD_CUSTOMHID_OUTREPORT_BUF_SIZE, //CUSTOM_HID_EPIN_SIZE,            /*     REPORT_COUNT (1)           */       
	0x91, 0x02,            /*     OUTPUT (Data,Var,Abs,Vol)  */

	0x09, 0x05,            /*     USAGE (Push Button)        */      
	0x15, 0x00,            /*     LOGICAL_MINIMUM (0)        */      
	0x25, 0x01,            /*     LOGICAL_MAXIMUM (1)        */      
	0x75, 0x08,            /*     REPORT_SIZE (1)            */ 
	0x95, USBD_CUSTOMHID_OUTREPORT_BUF_SIZE,//CUSTOM_HID_EPOUT_SIZE,            /*     REPORT_COUNT (1)           */   
	0x81, 0x02,            /*     INPUT (Data,Var,Abs,Vol)   */   
  /* USER CODE END 0 */
  0xC0    /*     END_COLLECTION	             */
};