AnsweredAssumed Answered

CubeMx error in usb code generation

Question asked by liegner.juergen on Jun 29, 2016
Latest reply on Sep 8, 2016 by ForumSTM32.ForumSTM3
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 boundaryreturn 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)

Outcomes