2021-07-21 06:48 AM
I've asynchronous USB Audio 2.0 implementation where speaker with feedback and microphone interfaces are configured.
I have strange problem with audio Feedback and microphone respective interface which are Isochronous-in type.
The issue observation is as per below.
-> While playing audio through speaker interface - the data on speaker out EP is coming without any issue. The feedback EP also shows that it communicates with Host
at the start of session.
However, after certain time - abruptly the feedback endpoint stops sending data to the host, but the speaker EP getting the data from host properly. It leads to
device and Host get out of sync after certain time as host is not getting proper feedback related data.
Wiresharc shows that zero length isochrounos-in packet is being transferred when feedback is polled from host. It seems that either the external PHY or stm usb stack sends zeroed reply - however, there is no error and indication in usb stack when the issue occurs.
-> The same happens with the microphone channel - isochronous-in - transmission starts and recording works fine for few amount of times.
Abruptly it stops generating interrupt for transmitting the data - even though request is queued properly. The stm stack stops sending the isochronous-in data - however, wiresharc shows that zeroed out packet is being transmitted back to host.
Any help here?
2021-07-29 04:17 AM
Hello @Vpada.1 ,
Could you please share your example for further check ?
Thanks in advance.
BeST Regards,
Walid
2021-08-01 11:28 PM
Hi @Walid ZRELLI
Thanks for taking interest and reaching out to help me.
After spending some time and conducing various test, I have further details on it.
I am using X-CUBE-USB library for Audio Class 2.0; Having USB 2.0 and External phy for High speed configuration.
Where audio configuration is set to use speaker_with_feedback and microphone.
When I just use the Microphone EP from PC for recording (nothing is streamed on speaker), it generates very few Iso-in incomplete events (which is handled correctly) and there is no abrupt loss of communications.
However, If I play speaker along with recording - I am having abrupt loss of communications either in feedback or in mic or in both ( iso-in comm is lost).
Hence, The observation is that, iso-in implementation is appropriate and "Just recording with mic only EP" is working appropriately but whenever two iso-in endpoints are active simultaneously the communication is lost abruptly on any of them.
Whenever, the speaker with feedback EP is started - the iso-in incomplete events occurs a lot for feedback EP.
The feedback EP polling rate is set for 8 micro-frames (1 MS) - so out of 8000 Micro-frames in a second - 1000 micro-frames are served appropriately - but stm32 USB core stack generates 7000 iso-in incomplete events which are falsely handled by USB audio 2.0 class driver - which might be causing communication to fail abruptly.
The above speculation is verified by making feedback polling rate to 1 micro-frame - which led to very few iso-in incomplete events. With feedback polling rate to 1micro-frame, there is very few iso-in incomplete events and very rare loss of communication.
However, for polling rate of 1 micro-frame, facing issue with figuring out which EP generated the iso-in incomplete event - the Reference Manual does not provide much help.
I found a forum thread Here which stats that the existing implementation is flawed and need something better in the programming.
With required polling rate as 8 micro-frames, Need to figure out the handling of iso-in incomplete events -
Also need to know why feebdack EP is having 7000 iso-in incomplete events when polling rate is set to 8 micro frames -
Following is code snippet for handling the iso-in incomplete event.
/**
* @brief USBD_AUDIO_IsoINIncomplete
* handle data ISO IN Incomplete event
* @param pdev: device instance
* @param epnum: endpoint index
* @retval status
*/
static uint8_t USBD_AUDIO_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t epnum)
{
USBD_AUDIO_EPTypeDef *ep;
USBD_AUDIO_HandleTypeDef *haudio;
uint16_t current_sof;
haudio = (USBD_AUDIO_HandleTypeDef*) pdev->pClassData;
/* @TODO check if the feedback is responsible of event */
for(int i = 1; i<USBD_AUDIO_MAX_IN_EP; i++)
{
ep = &haudio->ep_in[i];
current_sof = USB_SOF_NUMBER();
if((ep->open)&&
((ep->ep_usage == USBD_AUDIO_FEEDBACK_EP)||(ep->ep_usage == USBD_AUDIO_DATA_EP))
&& IS_ISO_IN_INCOMPLETE_EP(i,current_sof, ep->tx_rx_soffn))
{
epnum = i|0x80;
USB_CLEAR_INCOMPLETE_IN_EP(epnum);
USBD_LL_FlushEP(pdev, epnum);
ep->tx_rx_soffn = USB_SOF_NUMBER();
#if USBD_SUPPORT_AUDIO_OUT_FEEDBACK
if(ep->ep_usage == USBD_AUDIO_FEEDBACK_EP)
{
USBD_LL_Transmit(pdev,
epnum,
ep->ep_description.sync_ep->feedback_data,
ep->max_packet_length);
continue;
}
else
#endif /*USBD_SUPPORT_AUDIO_OUT_FEEDBACK */
if(ep->ep_usage == USBD_AUDIO_DATA_EP)
{
USBD_LL_Transmit(pdev,
epnum,
ep->ep_description.data_ep->buf,
ep->ep_description.data_ep->length);
}
}
}
return 0;
}
2022-03-11 06:46 AM
Have you had any luck with your problem? My USB3343 seems to be doing the exact same thing
2022-05-31 10:57 AM
Had the same problem.
I only have a speaker no microphone.
Mine solution:
In USBD_AUDIO_IsoINIncomplete():
I do not check if the feedback endpoint is the cause of the INIncomplete interrupt.
I do not flush that endpoint (but you can do).
But I always DO (MUST DO) a USBD_LL_Transmit(feedback_data)!
I think the "STM32CubeExpansion_USBAudioStreaming_V1.0.0" *****
2022-05-31 11:30 AM
see for more detail: Isochronous usb feedback problem and even/odd frame (st.com)