AnsweredAssumed Answered

STM32Cube USB CDC Unknown USB Device Descriptor Request Failed

Question asked by B Zikhali on Mar 24, 2015
Latest reply on Jan 7, 2017 by Sandaker_Palm.He.001
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_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=]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.