encountered an issue while adding HID to UAC1.0

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
xchips
Active Member
Posts: 41
Joined: Wed Jun 22, 2016 8:08 am

encountered an issue while adding HID to UAC1.0

Postby xchips » Thu Apr 12, 2018 1:24 pm

Hi guys,

I added customized HID device into UAC2.0 FW successfully like 2 years ago, It can send/receive 64 byte HID report data to/from XU208 device, all functions work well in UAC2.0, and I quitted XMOS works until now.
Now I come back to XMOS works and I'm trying to add same HID function to UAC1.0 because XMOS 2.0 driver cannot support 24bit format at lower frequencies (<44.1kHz, please correct me if I'm wrong), but I
got a strange error during USB enumeration process:
xrun: Program received signal ET_LOAD_STORE, Memory access exception.
[Switching to tile[0] core[2] (dual issue)]
handle_audio_request (c_mix_out=<value optimized out>) at E:/XMOS_Workspace/module_usb_audio/usb_buffer/decouple.xc:435

435 write_via_xc_ptr(g_aud_to_host_wrptr, datasize);

This was based on UAC2.0 FW, and I just add HID descriptor into UAC1.0 descriptors (BTW, UAC1.0 can work correctly), what I did:
1. Change the NUM_INTERFACES_A1 and CFG_TOTAL_LENGTH_A1 definitions.

Code: Select all

 #ifdef  HID_CONTROLS
    #define INTERFACES_HID        (1)
#else
    #define INTERFACES_HID        (0)
#endif

#define NUM_INTERFACES_A1           (1+INPUT_INTERFACES_A1 + OUTPUT_INTERFACES_A1 + INTERFACES_HID)

#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP)
#define CFG_TOTAL_LENGTH_A1         (18 + AC_TOTAL_LENGTH + (INPUT_INTERFACES_A1 * 61) + (OUTPUT_INTERFACES_A1 * 70) + (INTERFACES_HID*32) )
#else
#define CFG_TOTAL_LENGTH_A1         (18 + AC_TOTAL_LENGTH + (INPUT_INTERFACES_A1 * 61) + (OUTPUT_INTERFACES_A1 * 61) + (INTERFACES_HID*32) )
#endif


2. Add HID descriptors into UAC1.0 descriptors.

Code: Select all

#ifdef HID_CONTROLS
// HID interface descriptor
        9,                                /* 0  bLength : Size of descriptor in Bytes */
        4,                                /* 1  bDescriptorType (Interface: 0x04)*/
        3,                                /* 2  bInterfaceNumber : Number of interface */
        0,                                /* 3  bAlternateSetting : Value used  alternate interfaces using SetInterface Request */
        2,                                /* 4: bNumEndpoints : Number of endpoitns for this interface (excluding 0) */
        3,                                /* 5: bInterfaceClass */
        0,                                /* 6: bInterfaceSubClass - no boot device */
        0,                                /* 7: bInterfaceProtocol*/
        0,                                /* 8  iInterface */
// HID descriptor
        9,                                /* 0  bLength : Size of descriptor in Bytes */
        0x21,                             /* 1  bDescriptorType (HID) */
        0x10,                             /* 2  bcdHID */
        0x01,                             /* 3  bcdHID */
        0,                                /* 4  bCountryCode */
        1,                                /* 5  bNumDescriptors */
        0x22,                             /* 6  bDescriptorType[0] (Report) */
        sizeof(hidReportDescriptor) & 0xff,/* 7  wDescriptorLength[0] */
        sizeof(hidReportDescriptor) >> 8,  /* 8  wDescriptorLength[0] */

/* Endpoint descriptor (IN) */
        0x7,                              /* 0  bLength */
        5,                                /* 1  bDescriptorType */
        ENDPOINT_ADDRESS_IN_HID,          /* 2  bEndpointAddress  */
        3,                                /* 3  bmAttributes (INTERRUPT) */
        64,                               /* 4  wMaxPacketSize */
        0,
        16,                               /* 6  bInterval */
/* Endpoint descriptor (OUT) */
        0x7,                              /* 0  bLength */
        5,                                /* 1  bDescriptorType */
        ENDPOINT_ADDRESS_OUT_HID,         /* 2  bEndpointAddress  */
//      0x03,
        3,                                /* 3  bmAttributes (INTERRUPT) */
        64,                               /* 4  wMaxPacketSize */
        0,
        16,                               /* 6  bInterval */
#endif


I've been aways from XMOS works for a long time, so I kinda don't know how to trace this issue.
My project is based on "sw_usb_audio-[sw]_6.15.2rc1.zip".
Any advice will be appreciated.
xchips
Active Member
Posts: 41
Joined: Wed Jun 22, 2016 8:08 am

Postby xchips » Tue Apr 17, 2018 12:04 pm

Found an issue in endpoint0.xc file, change the HID related codes as followings:

Code: Select all

#ifdef HID_CONTROLS
                        case USB_GET_DESCRIPTOR:

                            /* Check what inteface request is for */
                    #if defined (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS == 1)                    // Added BY Jason on 2018_0416 for UAC10 HID
                            if(sp.wIndex == 3)
                    #else
                            if(sp.wIndex == INTERFACE_NUMBER_HID)
                    #endif
                            {
                                /* High byte of wValue is descriptor type */
                                unsigned descriptorType = sp.wValue & 0xff00;

                                switch (descriptorType)
                                {
                                    case HID_HID:
                                        /* Return HID Descriptor */
                                         result = XUD_DoGetRequest(ep0_out, ep0_in, hidDescriptor,
                                            sizeof(hidDescriptor), sp.wLength);
                                        break;
                                    case HID_REPORT:
                                        /* Return HID report descriptor */
                                        result = XUD_DoGetRequest(ep0_out, ep0_in, hidReportDescriptor,
                                            sizeof(hidReportDescriptor), sp.wLength);
                                    break;
                                }
                            }

                            break;
#endif

Because INTERFACE_NUMBER_HID for UAC10 is not correct, interface number in UAC10 descriptor is 3 on my side.
After this:
1. Host can get correct HID report descriptor, and PC found a new HID device.
2. That error still exists.
I'm now trying to understand the related codes about that error.

Who is online

Users browsing this forum: No registered users and 17 guests