CubeMx error in usb code generation
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-06-29 2:17 AM
Posted on June 29, 2016 at 11:17
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)
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-06-29 4:40 AM
Posted on June 29, 2016 at 13:40
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.RegardsOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-09-08 7:29 AM
Posted on September 08, 2016 at 16:29
Hi,
This bug is already fixed in the release CubeMX 4.16Regards