USB ROM: hard fault when using composite device

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB ROM: hard fault when using composite device

781 Views
lpcware
NXP Employee
NXP Employee
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
Labels (1)
0 Kudos
3 Replies

700 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cneubert on Tue Dec 01 06:35:04 MST 2015
Finally I found the problem, why the ROM code didn´t configure the EPs right. When one inits the USB stack you also have to say how much EPs the USB device supports and first I didn´t change this value and then I set it to high. Now I set it to USB_MAX_EP_NUM and my PCs find a HID and a MSC device :)

Now I will see if everything still works as expected.
0 Kudos

700 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cneubert on Tue Dec 01 05:50:49 MST 2015
Further tests showed me, that the ROM code only accepts EPs 0x01 and 0x81, when I use 0x02 and 0x82 I get a hardfault in the ROM code and with 0x03/83 and 0x04/84 I get an ERR_USBD_BAD_EP_DESC when I call "USBD_API->hid->init".

Can anybody help me?

Is there a better free USB stack available for a LPC1857 I can use?

I also tested the Keil stack and with it I can get one USB device to running, but as I can´t find a compatible example for my mcu I couldn´t test it with a composite device.
0 Kudos

700 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cneubert on Tue Dec 01 03:02:43 MST 2015
I began from start and for this I used the HID example of LPCOpen 2.12. This example is working as long as the EPs are 0x01 and 0x81.

It also does a hardfault if I change the EPs to e.g. 0x02 and 0x82.

So why can´t the ROM code handle this and how can I change the EPs?
0 Kudos