Jump to content
43oh

[Work-around] Stellaris Launchpad USB Serial example not enumerating correctly


Recommended Posts

Hi there. I'm having trouble getting the usb_dev_serial example to work. It compiles and flashes fine, but when I plug it in with the "Device" port, it doesn't work. The device gives its Device descriptor just fine, but the Configuration descriptor and one of the String descriptors are malformed.

 

Edit: it seems the binary that came with the example works OK. I'll try to figure out what makes the binary I compiled fail enumeration.

 

Edit2: Downloaded the codesourcery toolchain and it compiles the example correctly.

 

These are the last few lines of dmesg:

[151628.214809] usb 2-1.1: new full-speed USB device number 9 using ehci_hcd

[151633.299198] usb 2-1.1: unable to read config index 0 descriptor/start: -110

[151633.299212] usb 2-1.1: chopping to 0 config(s)

[151643.284238] usb 2-1.1: string descriptor 0 read error: -110

[151643.284583] usb 2-1.1: no configuration chosen from 0 choices

This is the Wireshark summary of the USB enumeration:

No. Time Source Destination Protocol Length Info

65 10.616482 host 0.0 USB 64 SET ADDRESS Request

69 10.636189 host 9.0 USB 64 GET DESCRIPTOR Request DEVICE

70 10.636404 9.0 host USB 82 GET DESCRIPTOR Response DEVICE

71 10.636494 host 9.0 USB 64 GET DESCRIPTOR Request CONFIGURATION

150 15.636404 9.0 host USB 64 GET DESCRIPTOR Response CONFIGURATION[Malformed Packet]

152 15.636478 host 9.0 USB 64 GET DESCRIPTOR Request STRING

208 20.636346 9.0 host USB 64 GET DESCRIPTOR Response STRING[Malformed Packet]

210 20.636421 host 9.0 USB 64 GET DESCRIPTOR Request STRING

230 25.636316 9.0 host USB 64 GET DESCRIPTOR Response STRING[Malformed Packet]

And I'm attaching the detailed Wireshark information.

usb_dev_serial.pdf

Link to post
Share on other sites

If you download the full StellarisWare package http://www.ti.com/tool/sw-lm3s you should be easily able to port the usb_dev_mouse example from the EK-LM3S9D90 or EK-LM3S9D92 (for this example they are identical). The primary USB difference between the LM3S9D9x and the LM4F120H5QR is that the LM4F uses muxing on the GPIO / USB pins. The LM3S9D9x had dedicated USB pins. To make the examples work configure the GPIO pin muxing for USB mode near the beginning of your code. Something like the below should get you pretty close.

 

   SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);   // enable the GPIO port so we can configure it
   GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5); // setup the port to be in USB analog mode. Routes incoming signals to on chip USB PHY
   USBStackModeSet(0, USB_MODE_FORCE_DEVICE, 0);  // Tells the USB stack to always be a device. Needed since some Stellaris devices running same software stack can be OTG or Host and this chip doesn't have a VBUS pin.

Link to post
Share on other sites
  • 2 weeks later...

Thanks a lot, that worked perfectly! Also, by looking at the LM3S9D90 example I realized why my code didn't work. I was using code snippets from the mouse API docs, but I forgot to set the USB interrupt handler to USB0DeviceIntHandler.

 

It's just crazy how much attention you have to pay to the *all* of the documentation in order to get it to work.

 

Edit: setting the interrupt handler got me as far as enumerating. I had to increase the stack size from 64 to 160 to make it work completely.

 

Edit2: I uploaded the example files in case anyone's interested

Link to post
Share on other sites

I was able to narrow the problem even further - if I use freshly built libusb-cm4f.a and just replace usbdenum.o in it from the original version, it starts to work. So the problem lies somewhere in the usblib/device/usbdenum.c

 

It seems that GCC emits memcpy call in usbdenum.o which does not happen in any other object file. I tried -fno-builtin and -fno-builtin-memcpy but memcpy call is still emited. 

 

The culprit is the line 2571:

 

sConfDesc = *(tConfigDescriptor *)g_psUSBDevice[0].pEP0Data;

 

which gets optimized to memcpy call.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...