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().
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.
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
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.