NXP MCXA156 USB Driver Bugs - usb_dc_kinetis.c does not broadcast SOF events #88981
Labels
area: USB
Universal Serial Bus
bug
The issue is a bug, or the PR is fixing a bug
priority: low
Low impact/importance bug
While doing some testing with a very simple USB audio configuration, I found issues with the underlying USB driver implementation with MCXA156 but would affect any platform with the same IP.
I am using the the FRDM MCXA156 as a test platform. I also used an nRF52840DK as a secondary test platform to validate my test program.
Bug Description:
This is focused on an USB audio, but I think there is an underlying issue with the USB driver implemenation for MCX A. The USB Audio example just helps show the issue.
Setup:
Project:
yoshi.zip
I modified the microphone_headset example to only have 1 single channel microhone. 16-bit 8KHz. I am generating a known, fixed data pattern for testing.
I am using Audacity to do a test record to valid the data stream.
Issue:
A.
If appears that USB SOF events are not being correctly broadcast on MCXA to the device class handlers.
For a USB microphone, there is data request callback that can be registered. This should align to the SOF.
On MCX A, it never fires. I places a volatile test variable in the handler in never increments when I start a recording.
However, on other platforms (such as the nRF52), this works as expected. the requests variable incremenets. I monitor the variable using the Segger Ozone Debugger.
B.)
To get data moving on MCXA and see what is going on, I created a simple test in the main loop:
This is not the ideal place to do this, but it helps show the issue.
The MCXA156 version will partially work. I can start a recording, see correct data. However, if I stop and restart, the underlying USB driver will lock up.
Note: This code also works fine on my reference platform (nRF52)
I disable optimizations and enabled the thread monitor so I could see the issue.
There is a USB servicing thread for the kinetis_dc driver and I can see it sometimes get locked up here:
It is stuck in the while loop and there is no timeout, etc.
I also see it get stuck here:
The usb audio class handler doesn't handle this error condition (but is the subject of another bug report)
All of the behavior seems related to A. There is nothing that can ever reset the state of the buffer desciptors / ownership if the underlying SOF callbacks aren't working. It isn't even possible to know when to transmit audio as most USB audio implementations from device to host use SOF
I set a breakpoint on audio_dc_sof and it is never called. After searching through usb_dc_kinetis.c, it does not appear that SOF has ever been handled.
This problem is easy to trigger. You just need to start/stop recording a few times.
On the reference platform, the attach code works fine (I can record, start/stop at will and I get the SOF callback
I think solving A will solve B. However, I do think the driver should have some timeouts, etc and never spin indefinitely.
I am working from the main branch of Zephyr. commit hash c2c3f75
The text was updated successfully, but these errors were encountered: