2023-05-03 06:29 AM
I am using a USB CDC device on an STM32H7A3 CPU. Most of the code is generated by the Cube IDE, and I have added my own callbacks. It works fine when plugged into a native Windows host or a native Linux host. However, it has an issue when running on a Linux guest in a Virtualbox VM (Windows host).
My application sends some output (a "welcome" message) immediately after start-up. My code calls CDC_Transmit_HS(), which succeeds, and then waits for the CDC_TransmitCplt_HS() callback to occur before sending more. That works fine; as soon as I connect to the device using, e.g., Putty, that callback occurs and I can proceed.
However, when I connect using minicom or screen from within a Linux VM, this callback never occurs, and my application hangs. Some USB traffic is working, though, because I can see that there is still more data coming in using the CDC_Receive_HS() function.
I wonder, is there some flush or reset occuring when I connect from the Linux VM? Do I have to implement an additional callback for this to work?
Solved! Go to Solution.
2023-05-03 07:11 AM
Answering my own question, I have figured out that, in the process of moving the device from the host to the guest, CDC_DeInit_HS() was called as the device was detached from the host. Any ongoing transfer is discarded, and the transfer completion callback is not called. So in CDC_DeInit_HS(), I have to implement the handling of data that was "on the fly."
2023-05-03 07:11 AM
Answering my own question, I have figured out that, in the process of moving the device from the host to the guest, CDC_DeInit_HS() was called as the device was detached from the host. Any ongoing transfer is discarded, and the transfer completion callback is not called. So in CDC_DeInit_HS(), I have to implement the handling of data that was "on the fly."