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

Visitor II
Feb 28, 2024 6:47 AM UTC

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	 */
};

 

Explorer
Jan 10, 2026 4:18 AM UTC

Hi, glad to find this. Long time after but it helped.
In my particular case what saved me was to limit to 24 bytes

#define USBD_CUSTOM_HID_REPORT_DESC_SIZE 24U

That definition plus:
__ALIGN_BEGIN static uint8_t CUSTOM_HID_ReportDesc_FS[USBD_CUSTOM_HID_REPORT_DESC_SIZE] __ALIGN_END =
{
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x04, // Usage (Joystick)
0xA1, 0x01, // Collection (Application)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x09, 0x32, // Usage (Z)
0x15, 0x00, // Logical Min (0)
0x26, 0xFF, 0x0F, // Logical Max (4095)
0x75, 0x10, // Report Size (16 bits)
0x95, 0x03, // Report Count (3 ejes)
0x81, 0x02, // Input (Data, Var, Abs)
0xC0 // End Collection
};

Hope it helps anyone else with a similar problem going over the "Code 10" problem connecting through USB to Windows.

Best regards to everyone.