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.

USB String Descriptor not getting recognized

Other Parts Discussed in Thread: CC2540, BLE-STACK

Hello,

I can't figure out an issue with my usb. My String Descriptors are not getting recognized anymore, and are displayed as follows:

$ ioreg -p IOUSB -w0 -l

    +-o 躊̆遮㄰㌲㔴㜶㤸䉁䑃䙅⠀畮汬瀠@14200000  <class AppleUSBDevice, id 0x1000160a6, registered, matched, active, busy 0 (15 ms), retain 21>

        {

          "sessionID" = 748745556024218

          "iManufacturer" = 1

          "bNumConfigurations" = 1

          "idProduct" = 5812

          "bcdDevice" = 256

          "Bus Power Available" = 500

          "USB Address" = 12

          "bMaxPacketSize0" = 32

          "iProduct" = 2

          "iSerialNumber" = 3

          "bDeviceClass" = 0

          "Built-In" = No

          "locationID" = 337641472

          "bDeviceSubClass" = 0

          "bcdUSB" = 512

          "USB Product Name" = 

          "PortNum" = 2

          "non-removable" = "no"

          "IOCFPlugInTypes" = {"9dc7b780-9ec0-11d4-a54f-000a27052861"="IOUSBFamily.kext/Contents/PlugIns/IOUSBLib.bundle"}

          "bDeviceProtocol" = 0

          "IOUserClientClass" = "IOUSBDeviceUserClientV2"

          "IOPowerManagement" = {"DevicePowerState"=0,"CurrentPowerState"=3,"CapabilityFlags"=65536,"MaxPowerState"=4,"DriverPowerState"=3}

          "Device Speed" = 1

          "USB Vendor Name" = 

          "idVendor" = 1105

          "IOGeneralInterest" = "IOCommand is not serializable"

          "USB Serial Number" = 

          "IOClassNameOverride" = "IOUSBDevice"

        }

I left the Device Descriptor and String Descriptors largely unchanged, which makes me question what I should be looking at...

usbDescStart:

deviceDesc:     ; Device descriptor

               DB deviceDescEnd - deviceDesc    ; bLength

               DB DESC_TYPE_DEVICE              ; bDescriptorType

               DW 0200H                         ; bcdUSB (USB 2.0)

               DB 00H                           ; bDeviceClass (given by interface)

               DB 00H                           ; bDeviceSubClass

               DB 00H                           ; bDeviceProtocol

               DB EP0_PACKET_SIZE

               DW 0451H                         ; idVendor (Texas Instruments)

               DW 16B4H                         ; idProduct (CC2540 HID)

               DW 0100H                         ; bcdDevice (v1.0)

               DB 01H                           ; iManufacturer

               DB 02H                           ; iProduct

               DB 03H                           ; iSerialNumber

               DB 01H                           ; bNumConfigurations

deviceDescEnd:

;;-------------------------------------------------------------------------------------------------------

;; String descriptors

string0Desc:    ; Language ID

                DB string0DescEnd - string0Desc ; bLength

                DB DESC_TYPE_STRING             ; bDescriptorType

                DW 0409H                        ; wLangID (English-US)

string0DescEnd:

string1Desc:    ; Manufacturer

                DB string1DescEnd - string1Desc ; bLength

                DB DESC_TYPE_STRING             ; bDescriptorType

                DB 'T', 0                       ; unicode string

                DB 'e', 0

                DB 'x', 0

                DB 'a', 0

                DB 's', 0

                DB ' ', 0

                DB 'I', 0

                DB 'n', 0

                DB 's', 0

                DB 't', 0

                DB 'r', 0

                DB 'u', 0

                DB 'm', 0

                DB 'e', 0

                DB 'n', 0

                DB 't', 0

                DB 's', 0

string1DescEnd:

string2Desc:    ; Product

                DB string2DescEnd - string2Desc ; bLength

                DB DESC_TYPE_STRING             ; bDescriptorType

                DB 'H', 0

                DB 'I', 0

                DB 'D', 0

string2DescEnd:

; To enable multiple HID dongles to connect to a PC,

; program a unique serial number for each dongle.

string3Desc:    ; Serial Number

                DB string3DescEnd - string3Desc

                DB DESC_TYPE_STRING ; bDescriptorType

                DB '1', 0

                DB '1', 0

                DB '0', 0

string3DescEnd:

usbDescEnd:

What should I look at, to find the error?

I have changed usbsrGetDescriptors, but not for the Device Descriptors nor the String Descriptors.

void usbsrGetDescriptor(void)

{

   uint8 n;

   // Which descriptor?

   switch (HI_UINT16(usbSetupHeader.value)) {

   // Device descriptor

   case DESC_TYPE_DEVICE:

      usbSetupData.pBuffer = (uint8 __code*) usbdpGetDeviceDesc();

      usbSetupData.bytesLeft = usbSetupData.pBuffer[DESC_LENGTH_IDX];

      break;

   // Configuration descriptor

   case DESC_TYPE_CONFIG:

       if(inMemoryConfig == NULL) {

        inMemoryConfig = (uint8 __xdata *)getConfigurationDescriptor ();

       }

     /* This is where the magic happens! */

       if(inMemoryConfig == NULL) {

        usbSetupData.pBuffer = (uint8 __code*) usbdpGetConfigurationDesc(0, LO_UINT16(usbSetupHeader.value));

        usbSetupData.bytesLeft = usbSetupData.pBuffer[DESC_CONFIG_LENGTH_LSB_IDX] +

                                 usbSetupData.pBuffer[DESC_CONFIG_LENGTH_MSB_IDX] * 256;

       } else {

         

         usbSetupData.pBuffer = (uint8 __xdata *) inMemoryConfig;

         //printf("mm: %x %x\n", inMemoryConfig[DESC_CONFIG_LENGTH_LSB_IDX],inMemoryConfig[DESC_CONFIG_LENGTH_MSB_IDX]);

         //printf("pB: %x %x\n", usbSetupData.pBuffer[DESC_CONFIG_LENGTH_LSB_IDX],usbSetupData.pBuffer[DESC_CONFIG_LENGTH_MSB_IDX]);

         

         usbSetupData.bytesLeft = usbSetupData.pBuffer[DESC_CONFIG_LENGTH_LSB_IDX] +

                                 usbSetupData.pBuffer[DESC_CONFIG_LENGTH_MSB_IDX] * 256;

       }

       //printf("\n codeAr:");

       //code_printArray(usbSetupData.bytesLeft, (uint8 __code * )usbdpGetConfigurationDesc(0, LO_UINT16(usbSetupHeader.value)));

       //printf("\n myData:");

       //generic_printArray(usbSetupData.bytesLeft, (uint8 __xdata *)inMemoryConfig);

       //printf("\n");

       //printf("cl: %d\n",usbSetupData.bytesLeft);

      break;

   // String descriptor

   case DESC_TYPE_STRING:

      // OPT: Implement language ID

      usbSetupData.pBuffer = (uint8*) usbdpGetStringDesc(LO_UINT16(usbSetupHeader.value));

      usbSetupData.bytesLeft = usbSetupData.pBuffer[DESC_LENGTH_IDX];

      break;

   // Other descriptor type

   default:

     //printf("%d\n", HI_UINT16(usbSetupHeader.value));

      // Perform a table search (on index and value)

      usbSetupData.pBuffer = NULL;

      

      uint8 isDescriptorDefinedInMem = FALSE;

      

      if(inMemDescriptorTable == NULL)

        inMemDescriptorTable = getReportDescriptor();

      if (inMemDescriptorTable != NULL && 

         (inMemDescriptorTable->valueMsb == HI_UINT16(usbSetupHeader.value))

         && (inMemDescriptorTable->valueLsb == LO_UINT16(usbSetupHeader.value))

         && (inMemDescriptorTable->indexMsb == HI_UINT16(usbSetupHeader.index))

         && (inMemDescriptorTable->indexLsb == LO_UINT16(usbSetupHeader.index)) )

      {

        usbSetupData.pBuffer = (uint8 __generic *)inMemDescriptorTable->pDescStart;

        usbSetupData.bytesLeft = inMemDescriptorTable->length;

        isDescriptorDefinedInMem = TRUE;

        //printf("w");

      }

      if(isDescriptorDefinedInMem == FALSE) {

        for (n = 0; n < ((uint16)usbDescriptorMarker.pUsbDescLutEnd - (uint16)usbDescriptorMarker.pUsbDescLut) / sizeof(DESC_LUT_INFO); n++) {

           if ((usbDescriptorMarker.pUsbDescLut[n].valueMsb == HI_UINT16(usbSetupHeader.value))

               && (usbDescriptorMarker.pUsbDescLut[n].valueLsb == LO_UINT16(usbSetupHeader.value))

               && (usbDescriptorMarker.pUsbDescLut[n].indexMsb == HI_UINT16(usbSetupHeader.index))

               && (usbDescriptorMarker.pUsbDescLut[n].indexLsb == LO_UINT16(usbSetupHeader.index)) )

           {

              usbSetupData.pBuffer = usbDescriptorMarker.pUsbDescLut[n].pDescStart;

              usbSetupData.bytesLeft = usbDescriptorMarker.pUsbDescLut[n].length;

           }

        }

      }

      isDescriptorDefinedInMem = FALSE;

   }

   // Stall EP0 if no descriptor was found

   if (usbSetupData.pBuffer == NULL) usbfwData.ep0Status = EP_STALL;

   if (usbfwData.ep0Status != EP_STALL) {

      // Limit the returned descriptor size (the PC wants to know about sizes before

      // polling the complete descriptors)

      if (usbSetupData.bytesLeft > usbSetupHeader.length) {

         usbSetupData.bytesLeft = usbSetupHeader.length;

      }

      usbfwData.ep0Status = EP_TX;

   }

} // usbsrGetDescriptor

  • Hello,

    What is the specific issue you are trying to solve on CC2540 / BLE-Stack v1.4.1? What have you tried and what are the results?

    Best wishes
  • Hello JXS, thank you for answering.

    The problem is with the String Descriptors, they are not correctly interpreted (or sent, for that matter, I don't know) on the host. Sometimes the device name comes up as a String of Japanese or Chinese Characters and sometimes the Device Name, Manufacturer and Serial Number are simply empty, depends on timing I'd guess. So my guess is that the data is not sent correctly, even though other parts of the USB Connection work perfectly.

    Which means the parts that worry me are the following entries:

    "USB Serial Number" = 

    "USB Vendor Name" = 

    "USB Product Name" = 

    Even though all three values are requested by the host (with LO_UINT16(usbSetupHeader.value) being 0,1,2,3 on consecutive requests, with the HI being DESC_TYPE_STRING) are requested by the host, and are being sent by the cc2540. Maybe it's the definition of the String Descriptors? Or the Device Descriptor? Or maybe the transport of the Language ID is wrong?

    Is there some way of getting an error log of USB out of a Windows Machine (or mac)?

  • Hello,
    Did you solve the problem?
    I have the same problem as you - name of joystick displays incorrect in windows.

    Best regards,
    Alexey