Question
STM32Cube USB CDC Unknown USB Device Descriptor Request Failed
Posted on March 24, 2015 at 18:38
I have been working on setting up my MCU as a VCP CDC Device using STM32Cube for the past few days. I have studied the STM32Cube USB device library User Manual (UM1734) and have followed the steps outlined in part 7.5.6 which calls on my application to call the function USBD_CDC_Init().
void MX_USB_DEVICE_Init( void ) { /* Init Device Library,Add Supported Class and Start the library*/ USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS); USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC); USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS); USBD_Start(&hUsbDeviceFS); // USBD_CDC_Init called here hUsbDeviceFS.pClass->Init(&hUsbDeviceFS, DEVICE_FS); } I have changed the value of CDC_DATA_HS_MAX_PACKET_SIZE to 256 in usbd_cdc.h as detailed in this [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/USB%20CDC%20Bug%20in%20CubeMX%20firmware&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/AllItems.aspx¤tviews=3282]post to ensure that my device data packet size is 64 bytes. #define CDC_DATA_HS_MAX_PACKET_SIZE 256 /* Endpoint IN & OUT Packet size */ I have also ensured that my heap size is changed to the minimum recommended by ST support in another post on this forum, in my .ld file _Min_Heap_Size = 0x0400; /* required amount of heap */ _Min_Stack_Size = 0x0400; /* required amount of stack */ The problem is if I call the function USBD_CDC_Init() the MCU controller is listed as an UnKnown Device by Windows and stopped. If I comment out the call, my MCU is correctly recognised and configured as a VCP device in both Windows and Linux but all subsequent calls to USBD_CDC_SetTxBuffer will fail (HardFaultHandler is called) because the pClassData field of the USB Device handler is never initialized. I am caught between the devil and the deep blue sea, how do I proceeed? I am using a STM32f302k8 and STM32CubeMX version 4.6.0 with FW version 1.1.1 for STM32F3. #usb #usb #usb #stm32 #stm32 #stm32f4 #usb #discovery #stm32f3