cancel
Showing results for 
Search instead for 
Did you mean: 

CDC + HID data corruption on CDC interface

dan2
Associate II

Hi all,

I managed to build HID + CDC for STM32F072 and STM32L152 and I am experiencing data corruption if I try to run both interfaces at the same time, however it is not happening always. I am testing on windows and linux (ubuntu 16, 18 and raspbian jessie) and experiencing the same issue on all OSes. To access HID i/f I use hidapi library.

Here are few scenarios in my testing.

  1. Host opens HID interface, sends 64 byte data to the device, reads back and compares. If received data is the same as sent continue the test otherwise exit with error code. While HID test is running hosts open CDC i/f and does the same. The host sends test data of variable length (1 byte to 1234 bytes) to device and device loops the same data back to the host (no real serial port involved). Host reads the data and compares. In this scenario all seems OK.
  2. Data corruption occurs in the following scenario:
  3. Hosts open CDC first and run the same test as above. Then host opens HID i/f and the host receives corrupted data from CDC i/f. The corrupted data contain descriptor strings. Seems like EP0 data gets into data EP for CDC. this happens whenever I re-enumerate USB device or try to read manufacturer string, serial no, etc.
  4. My feeling is there might a problem with USB IRQ handler not dealing with multiple requests at the same time. Perhaps someone have seen the same issue before and can help on this. Your help is appreciated.

HAL lib I am using is 1.6.0, 1.8.0. 1.9.0 and all demonstrate the same problem on STM32F0 and STM32L1.

Regards

Daniel

0 REPLIES 0