"This device cannot start" (code 10)

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
renanAFJ
Posts: 1
Joined: Thu Sep 01, 2016 12:12 am

"This device cannot start" (code 10)

Post by renanAFJ » Thu Sep 01, 2016 12:31 am

"Report Descriptor was not byte aligned" says the general info.
"The passed ACL did not contain the minimum required information." says the "Problem Status" on.

I´m a slightly changed version of the "2 player gamepad" descriptor available on this tutorial:
http://eleccelerator.com/tutorial-about ... scriptors/

My controller is a dual arcade one so each player have 14 buttons, so my descriptor goes like this:

Code: Select all

PROGMEM const char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = 
{
    //Gamepad 1 (34 bytes)
   0x05, 0x01,                 // USAGE_PAGE (Generic Desktop)
    0x09, 0x05,                 // USAGE (Game Pad)
    0xa1, 0x01,                 // COLLECTION (Application)
   0xa1, 0x00,                 //   COLLECTION (Physical)
   0x85, 0x01,               //     RERPOT_ID (1)
    0x05, 0x09,                 //     USAGE_PAGE (Button)
    0x19, 0x01,                 //     USAGE_MINIMUM (Button 1)
    0x29, 0x0e,                 //     USAGE_MAXIMUM (Button 14)
    0x15, 0x00,                 //     LOGICAL_MINIMUM (0)
    0x25, 0x01,                 //     LOGICAL_MAXIMUM (1)
    0x95, 0x0e,                 //    REPORT_COUNT (14)
    0x75, 0x01,                 //    REPORT_SIZE (1)
    0x81, 0x02,                 //    INPUT (Data,Var,Abs)
    0x75, 0x01,                 //    REPORT_SIZE (1)
    0x95, 0x06,                 //    REPORT_COUNT (2)
    0x81, 0x03,                 //    INPUT (Cnst,Var,Abs)
   0xc0,                       //   END_COLLECTION
    0xc0,                       // END_COLLECTION
   //Gamepad 2 (34 bytes)
   0x05, 0x01,                 // USAGE_PAGE (Generic Desktop)
   0x09, 0x05,                 // USAGE (Game Pad)
   0xa1, 0x01,                 // COLLECTION (Application)
   0xa1, 0x00,                 //   COLLECTION (Physical)
   0x85, 0x02,               //     REPORT_ID (2)
   0x05, 0x09,                 //     USAGE_PAGE (Button)
   0x19, 0x01,                 //     USAGE_MINIMUM (Button 1)
   0x29, 0x0e,                 //     USAGE_MAXIMUM (Button 14)
   0x15, 0x00,                 //     LOGICAL_MINIMUM (0)
   0x25, 0x01,                 //     LOGICAL_MAXIMUM (1)
   0x75, 0x01,                 //    REPORT_SIZE (1)
   0x95, 0x0e,                 //    REPORT_COUNT (14)
   0x81, 0x02,                 //    INPUT (Data,Var,Abs)
   0x75, 0x01,                 //    REPORT_SIZE (1)
   0x95, 0x06,                 //    REPORT_COUNT (2)
   0x81, 0x03,                 //    INPUT (Cnst,Var,Abs)
   0xc0,                       //   END_COLLECTION
   0xc0                  // END_COLLECTION
};


My reports goes like this:

Code: Select all

bufferToUse[0] =  1;
bufferToUse[1] =  buttonsPlayer1[0];
bufferToUse[2] =  buttonsPlayer1[1];
bufferToUse[3] =  2;
bufferToUse[4] =  buttonsPlayer2[0];
bufferToUse[5] =  buttonsPlayer2[1];


The reportBuffer DATABUFSIZE is set to 6

Code: Select all

static uchar    reportBuffer[DATABUFSIZE];   


and the usbFunctionSetup goes like this:

Code: Select all

uchar usbFunctionSetup(uchar data[8])
{
   usbRequest_t* usbReq = (usbRequest_t *) data;

    usbMsgPtr = reportBuffer;
    if((usbReq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS)
   {   
      // Class request type
        if(usbReq->bRequest == USBRQ_HID_GET_REPORT)
      { 
         // wValue: ReportType (highbyte), ReportID (lowbyte)
            // We only have one report type, so don't look at wValue
            buildReport(FALSE);
            return sizeof(reportBuffer);
        }
      else if(usbReq->bRequest == USBRQ_HID_GET_IDLE)
      {
            usbMsgPtr = &idleRate;
            return 1;
        }
      else if(usbReq->bRequest == USBRQ_HID_SET_IDLE)
      {
            idleRate = usbReq->wValue.bytes[1];
        }
    }
   else
   {
        // No vendor specific requests implemented
    }
   
   return 0;
}


I´ve used the Boxter project, by Olof Holmgren, as a safe place to start. Any ideas?

BrainSlugs83
Posts: 6
Joined: Sun Mar 20, 2016 4:30 am

Re: "This device cannot start" (code 10)

Post by BrainSlugs83 » Tue Oct 25, 2016 12:58 am

Looks like you have 14 buttons per gamepad -- 14 bits is definitely not byte aligned.

You could add two buttons per gamepad to bring it up to 16 buttons, or you could add 2 bits of padding per gamepad.

For padding, under "0x05, 0x09 // Usage Page (Button)", right after "0x81, 0x02 // (Input, Data, Var, Abs)" you need to account for the two extra bits of data, something like:

Code: Select all

// Padding -- reportBuffer must be byte aligned:
0x75, 0x01,               //   REPORT_SIZE (1)
0x95, 0x02,               //   REPORT_COUNT (2)
0x81, 0x03,               //   INPUT (Constant, Var, Abs)

BrainSlugs83
Posts: 6
Joined: Sun Mar 20, 2016 4:30 am

Re: "This device cannot start" (code 10)

Post by BrainSlugs83 » Tue Oct 25, 2016 7:00 am

Actually, scratch that.

Looking closer at your code I noticed this:

Code: Select all

    0x95, 0x06,                 //    REPORT_COUNT (2)
    0x81, 0x03,                 //    INPUT (Cnst,Var,Abs)


Notice that your comment correctly says "REPORT COUNT 2", but actually the code says 6. You should just fix it to be 2 like the comment says and that should work.

Post Reply