cancel
Showing results for 
Search instead for 
Did you mean: 

USB CDC CubeMX bug in generated code

taraben
Senior
Posted on February 06, 2016 at 22:31

Hello, in the file usbd_cdc_if.c there is this function:

uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len) { uint8_t result = USBD_OK; /* USER CODE BEGIN 7 */ USBD_CDC_SetTxBuffer(hUsbDevice_0, Buf, Len); while(result != USBD_OK); do { result = USBD_CDC_TransmitPacket(hUsbDevice_0); } while(result != USBD_OK); /* USER CODE END 7 */ return result; } those lines:

while(result != USBD_OK);
do {
result = USBD_CDC_TransmitPacket(hUsbDevice_0);
}
while(result != USBD_OK);

don't make many sense and might lead to potential deadlock bcs. the situation is not resolved within timeout. Happyly the function

USBD_CDC_TransmitPacket

always returns USBD_OK. So in this version it will not lead to deadlock. Please provide a more professional solution. Regards, Adib. #usb-cdc-stm32-cubemx
3 REPLIES 3
Denis Krasutski
Associate III
Posted on April 13, 2016 at 15:49

Also actual problem with lost tx-interrupt.

During high-load transfer I can stay in the ''do{}while;'' cycle  infinite time.

About load, big packet data for tx (toSTM32 USB endpoint) and short responce to HOST after receive data

ST support, can you explain where can I lost interrpt?

BR,

Denis Krasutski
Nesrine M_O
Lead II
Posted on April 14, 2016 at 11:20

Hi Denis Krasutski,

usbd_cdc_if.c is a driver for user application, and the code implemented now is just for help so you can modify it or add your own code [in user code section].

For more details, on how you use the STM32Cube USb device library, please refer to

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00108129.pdf?s_searchtype=keyword

user manual. 

Also you can find a full set of running examples within the STM32Cube firmware package (example: STM32Cube_FW_F4_V1.11.0\Projects\STM324x9I_EVAL\Applications\USB_Device\CDC_Standalone)

-Syrine

taraben
Senior
Posted on April 24, 2016 at 12:13

Hello Syrine,

I know that is code intended to be provided by the user in order to implement the profiles.

But this is autogenerated code by CubeMX. Someone configured CubeMx to do so.

I showed that this is suspicious dodgy code.

Please ST clean up this code. Provide code that has a certain quality standard.

Regards, Adib.

--