lpcware

USB ROM: hard fault when using composite device

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by cneubert on Mon Nov 30 07:44:17 MST 2015
I´m using LPCXpresso 7.9.0, LPC1857 and USB1 as interface.

I can run the MSC RAM and HID Generic examples without problems, but I can´t get both to run in a composite device. I can´t test the example of LPCOpen, because our hardware does only have the USB1 interface to use.

When I try to run my composite device code, the USB ROM code hard faults and because there is no source for this code, I don´t know how to look for the problem.

If I´m right then the code crashes when the host sends a CONFIGURATION REQUEST to my device (I got this from wireshark).

This is my config descriptor:

ALIGNED(4) uint8_t USB_FsConfigDescriptor[] = {
/* Configuration 1 */
USB_CONFIGURATION_DESC_SIZE,/* bLength */
USB_CONFIGURATION_DESCRIPTOR_TYPE,/* bDescriptorType */
WBVAL(/* wTotalLength */
1 * USB_CONFIGURATION_DESC_SIZE     +
USB_INTERFACE_DESC_SIZE             +/* MSC interface */
2 * USB_ENDPOINT_DESC_SIZE          +/* bulk endpoints */
USB_INTERFACE_DESC_SIZE       +
HID_DESC_SIZE                 +
2*USB_ENDPOINT_DESC_SIZE        +
0
),
0x02,/* bNumInterfaces */
0x01,/* bConfigurationValue */
0x00,/* iConfiguration */
USB_CONFIG_SELF_POWERED,/* bmAttributes */
USB_CONFIG_POWER_MA(100),/* bMaxPower */

/* Interface 0, Alternate Setting 0, MSC class interface descriptor */
USB_INTERFACE_DESC_SIZE,/* bLength */
USB_INTERFACE_DESCRIPTOR_TYPE,/* bDescriptorType */
USB_MSC_IF_NUM,/* bInterfaceNumber: Number of Interface */
0x00,/* bAlternateSetting: Alternate setting */
0x02,/* bNumEndpoints: Two endpoints used */
USB_DEVICE_CLASS_STORAGE,/* bInterfaceClass: Communication Interface Class */
MSC_SUBCLASS_SCSI,/* bInterfaceSubClass: Abstract Control Model */
MSC_PROTOCOL_BULK_ONLY,/* bInterfaceProtocol: no protocol used */
0x04,/* iInterface: */

/* Endpoint, EP Bulk In */
USB_ENDPOINT_DESC_SIZE,/* bLength */
USB_ENDPOINT_DESCRIPTOR_TYPE,/* bDescriptorType */
USB_MSC_IN_EP,/* bEndpointAddress */
USB_ENDPOINT_TYPE_BULK,/* bmAttributes */
WBVAL(USB_FS_MAX_BULK_PACKET),/* wMaxPacketSize */
0x00,/* bInterval: ignore for Bulk transfer */
/* Endpoint, EP Bulk Out */
USB_ENDPOINT_DESC_SIZE,/* bLength */
USB_ENDPOINT_DESCRIPTOR_TYPE,/* bDescriptorType */
USB_MSC_OUT_EP,/* bEndpointAddress */
USB_ENDPOINT_TYPE_BULK,/* bmAttributes */
WBVAL(USB_FS_MAX_BULK_PACKET),/* wMaxPacketSize */
0x00,/* bInterval: ignore for Bulk transfer */

/* Interface 1, Alternate Setting 0, HID Class */
USB_INTERFACE_DESC_SIZE,/* bLength */
USB_INTERFACE_DESCRIPTOR_TYPE,/* bDescriptorType */
USB_HID_IF_NUM,/* bInterfaceNumber */
0x00,/* bAlternateSetting */
0x02,/* bNumEndpoints */
USB_DEVICE_CLASS_HUMAN_INTERFACE,/* bInterfaceClass */
HID_SUBCLASS_NONE,/* bInterfaceSubClass */
HID_PROTOCOL_NONE,/* bInterfaceProtocol */
0x05,/* iInterface */
/* HID Class Descriptor */
/* HID_DESC_OFFSET = 0x0012 */
HID_DESC_SIZE,/* bLength */
HID_HID_DESCRIPTOR_TYPE,/* bDescriptorType */
WBVAL(0x0111),/* bcdHID : 1.11*/
0x00,/* bCountryCode */
0x01,/* bNumDescriptors */
HID_REPORT_DESCRIPTOR_TYPE,/* bDescriptorType */
WBVAL(sizeof(HID_ReportDescriptor)),/* wDescriptorLength */
/* Endpoint, HID Interrupt In */
USB_ENDPOINT_DESC_SIZE,/* bLength */
USB_ENDPOINT_DESCRIPTOR_TYPE,/* bDescriptorType */
HID_IN_EP,/* bEndpointAddress */
USB_ENDPOINT_TYPE_INTERRUPT,/* bmAttributes */
WBVAL(0x0004),/* wMaxPacketSize */
0x08,/* 16ms */          /* bInterval */
/* Endpoint, HID Interrupt Out */
USB_ENDPOINT_DESC_SIZE,/* bLength */
USB_ENDPOINT_DESCRIPTOR_TYPE,/* bDescriptorType */
HID_OUT_EP,/* bEndpointAddress */
USB_ENDPOINT_TYPE_INTERRUPT,/* bmAttributes */
WBVAL(0x0004),/* wMaxPacketSize */
0x08,/* 16ms */          /* bInterval */

/* Terminator */
0/* bLength */
};


I have these defines:

#define USB_MSC_IF_NUM          0x00
#define USB_MSC_IN_EP           0x81
#define USB_MSC_OUT_EP          0x01

#define USB_HID_IF_NUM      0x01
#define HID_IN_EP           0x82
#define HID_OUT_EP 0x02

Outcomes