2020-07-30 12:59 AM
USB CDC is not properly recognized by Windows 10.
How to recover :
\Inc\usbd_conf.h
Source code change
/** Alias for memory allocation. */
//#define USBD_malloc malloc
#define USBD_malloc (USBD_CDC_HandleTypeDef *) USBD_static_malloc
/** Alias for memory release. */
//#define USBD_free free
#define USBD_free USBD_static_free
Source code addition
/* Exported functions -------------------------------------------------------*/
void *USBD_static_malloc(uint32_t size);
void USBD_static_free(void *p);
2020-07-30 06:37 AM
Hello @tsuna
I did not understand your request, could you please give more details about the issue.
Best regards,
Nesrine
2020-07-30 06:38 AM
Could you please share your .ioc file to check the issue.
2020-07-30 04:26 PM
I was using STM32CubeMX 5.6.1 STM32Cube_FW_L4_V1.15.1. The project was working fine. After updating to STM32CubeMX 6.0.0 STM32Cube_FW_L4_V1.16.0, Windows10 no longer recognizes USB properly. Device Manager is showing an exclamation mark.
I compared the old USB code with the new USB code to find out what changed and when I rewrite it with the recovery code above, it works fine.
The project and *.IOC design are commercial and cannot be published.
I know how to recover, but it's very annoying because I have to rewrite the generated code every time I generate code in STM32CubeMX.
STM32CubeMX is a great tool for my work. I hope it will be fixed in the next release.
2020-07-31 04:56 PM
The cause close to the core is
1.I am using FreeRTOS,
The memory area allocation process executed in USBD_CDC_Init() hcdc =USBD_malloc(sizeof(USBD_CDC_HandleTypeDef));
2.STM32Cube_FW_L4_V1.15.1 uses task heap.
3.STM32Cube_FW_L4_V1.16.0 uses __heap_base.
Since STM32CubeMX was updated, Heap_Size was insufficient and a problem occurred.
solution
1. Notify the programmer that the location of dynamic memory allocation has changed. Or
2. Notify that the heap capacity is insufficient. Or
3. Generate code by adding sizeof(USBD_CDC_HandleTypeDef) to the default Heap_Size.