2016-06-29 02:17 AM
i have generate sample usb-cdc code for stm32F103c8 with CubeMx. The real code generate hardfaults in disconnect from usb. This is the Problem in usbd_conf.c:
-------------------------------------/** * @brief static single allocation. * @param size: size of allocated memory * @retval None */
void
*USBD_static_malloc(uint32_t size) {static
uint32_t mem[(sizeof
(USBD_CDC_HandleTypeDef)/4
)+1
];//On 32-bit boundary
return
mem; }/** * @brief Dummy memory free * @param *p pointer to allocated memory address * @retval None */
void
USBD_static_free(void
*p) { free(p); // !!!!!!!!!! error !!!!!!! } --------------------------------------------------- USBD_static_malloc map memory to static a static variable. USBD_static_free call free(void *)! This corrupt the memory from p. (sorry, my english ist not good)2016-06-29 04:40 AM
Hi,
I confirm with STM32CubeMx 4.15.1, it generates a USB code with a call to free() in usbd_conf.c and this can crashes the software when disconnect USB.Regards2016-09-08 07:29 AM
Hi,
This bug is already fixed in the release CubeMX 4.16Regards