This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5728: USB Audio class(UAC1) driver not working on AM572x with linux-4.9.28 kernel

Part Number: AM5728

Tool/software: Linux

Hi,

I have downloaded and built the latest TI Linux kernel(4.9.28) from the following link,

and compiled usb  audio gadget driver with uac1(enabled  CONFIG_GADGET_UAC1  in config file) and copied the modules to target board,

On target board,  inserted usb audio gadget driver as follows,

modprobe libcomposite

modprobe g_audio

dependent usb_f_uac1 module got inserted along with g_audio.

But On Enumeration , getting  STALLED Error on usb analyzer(Ellisys) and set_interface(1,1) failed with error -32(EPIPE) on PC(Linux).

usb 2-1.1: 1:1: usb_set_interface failed (-32)


Note: UAC1, UAC2 works fine on AM572x board with linux 4.4 kernel.

and UAC2 works fine on AM572x board with linux 4.9 kernel.

  • Hi Mukesh,

    Do you see any error in the dmesg in the AM572x side ? If so it would be helpful if you can share the dmesg.
  • Hi Dwarakesh,

    I am not getting any error on AM572x side and neither receiving 'set alt' from PC,

    Getting Error only on PC side. Attached full dmesg log from AM572x.

    The following dmesg logs are displayed while inserting g_audio module,

    [  229.879192] g_audio gadget: Hardware params: access 3, format 2, channels 2, rate 48000
    
    [  229.887360] g_audio gadget: Linux USB Audio Gadget, version: Feb 2, 2012
    
    [  229.895616] g_audio gadget: g_audio ready
    
    [  230.284353] g_audio gadget: high-speed config #1: Linux USB Audio Gadget


    4861.dmesg_29Aug2017.txt

    Let me add some more debug prints in drivers and share you the logs shortly.

  • Hi Dwarkesh,

    Please find attached logs dmesg,usb analyzer log of AM572x and Linux PC for UAC1.

    2055.am572x_dmesg_04sep2017_uac1.txt0763.Linux_PC_dmesg_04Sep2017_uac1.txt

    Set Interface is getting Stalled in PC and not received in gadget(AM572x) side.

    Regards,

    Mukesh kumar

  • Hi Mukesh,

    There is a kernel dump coming in the logs shared related to stall. To debug the issue you can try

    1. Adding logs in dwc3_ep0_interrupt() -> dwc3_ep0_xfer_complete() or dwc3_ep0_xfernotready() -> dwc3_ep0_stall_and_restart(). Basically figure out how/where this function dwc3_ep0_stall_and_restart() is getting called to get a clue.

    2. Or quickly you can enable the trace logs for dwc3 as suggested in the link: https://www.kernel.org/doc/Documentation/driver-api/usb/dwc3.rst  under "Reporting Bugs" section and check the flow. 

    This could give us clue, what is happening. Ideally, we should expect composite_setup() function in drivers/usb/gadget/composite.c to be called in success case from my understanding. 

  • Mukesh,

    Is there any reason you want to use UAC1 instead of UAC2?

    I never tested UAC1. Can you please provide the instruction of your test so that I can look at the issue on my side?

    Never mind. I read your post again, the failure happens during enumeration. I will take a look.

  • Hi Dwarkesh,

    As per the link, I have enabled trace logs for dwc3 and captured log file "trace.txt" but I am not able to capture regdump. Further I started analyzing the log and able to see  dwc3_gadget_ep_set_halt  function(Set Stall) is  getting invoked  for which we need to find the root cause, So start debugging by adding  more logs in the functions suggested by you.

    PFA Attachement of trace logs.

    8765.trace_win.txt 0753.trace_linux.txt

    Regards,

    Mukesh kumar.

  • Hi Bin Liu,

    [Q] Is there any reason you want to use UAC1 instead of UAC2?
    Yes, As part of our project requirement , we need to use UAC1.

    Followed the below procedure for Testing UAC1,
    1) Enabled CONFIG_GADGET_UAC1 in linux kernel configuration(By default it is disabled)
    2) Inserted default gadget driver

    modprobe libcomposite
    
    modprobe g_audio

    (dependent module usb_f_uac1) got inserted.

    3) Connected USB cable to Host Machine(linux, Windows)

    Regards,

    Mukesh kumar

  • Mukesh,

    I am able to reproduce the issue and narrowed down the regression to kernel git commit 2b95c939cb88c3 ("usb: gadget: composite: Test get_alt() presence instead of set_alt()"). Please apply the patch attached below to your 4.9.28 kernel and let me know if it solves the issue for you.

    5165.0001-Revert-usb-gadget-composite-Test-get_alt-presence-in.patch[1].txt

    
        Revert "usb: gadget: composite: Test get_alt() presence instead of set_alt()"
        
        This reverts commit 2b95c939cb88c3182e9dd681d4cf40b70985b8a5.
        
        UAC1 gadget on dwc3 UDC failed in enumeration due to this commit,
    because UAC1 doesn't implement get_alt(). diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index c3c5b87b35b3..84ff8d6d4024 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1694,7 +1694,9 @@ static int fill_ext_prop(struct usb_configuration *c, int interface, u8 *buf) value = min(w_length, (u16) 1); break; - /* function drivers must handle get/set altsetting */ + /* function drivers must handle get/set altsetting; if there's + * no get() method, we know only altsetting zero works. + */ case USB_REQ_SET_INTERFACE: if (ctrl->bRequestType != USB_RECIP_INTERFACE) goto unknown; @@ -1703,13 +1705,7 @@ static int fill_ext_prop(struct usb_configuration *c, int interface, u8 *buf) f = cdev->config->interface[intf]; if (!f) break; - - /* - * If there's no get_alt() method, we know only altsetting zero - * works. There is no need to check if set_alt() is not NULL - * as we check this in usb_add_function(). - */ - if (w_value && !f->get_alt) + if (w_value && !f->set_alt) break; value = f->set_alt(f, w_index, w_value); if (value == USB_GADGET_DELAYED_STATUS) {
  • Hi Bin Liu,

    Thank you, the patch is working fine. Now the enumeration is proper and data is also getting transferred between Host PC and gadget.

     Thank you for your support.

    And Still I have some queries on this,

      • Only Speaker(Playback) devices is getting detected in Windows PC. What about recording device(mic) ?
      •  when I play some song/audio through gadget device in host PC, I am able to see data(192 bytes) are getting transferred from Host PC to gadget through usb analyzer(sniffer)  but how to make sure whether the data is received properly in gadget module. Is there way to test the functionality?.
      • Getting Error "g_audio gadget: Playback error: -32" in  AM572x whenever I play  some audio in host PC. (Attached log).6740.gadget_playback_error.txt

    Regards,

    Mukesh kumar