eternauta3k 0 Posted November 24, 2012 Share Posted November 24, 2012 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 bluehash 1 Quote Link to post Share on other sites
cubeberg 540 Posted November 24, 2012 Share Posted November 24, 2012 Did you try to just program the bin provided in the Stellarisware download? You can use this with the LM Flash Programmer. It worked for me without problems. usb_dev_serial.zip Quote Link to post Share on other sites
eternauta3k 0 Posted November 24, 2012 Author Share Posted November 24, 2012 Yes, the provided binary worked. On a related note, does someone have the example for the Mouse Device library? It's mentioned in the documentation but it's not in the stellaris package. Quote Link to post Share on other sites
dellwoodbu 1 Posted November 26, 2012 Share Posted November 26, 2012 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. BravoV, Rickta59 and bluehash 3 Quote Link to post Share on other sites
eternauta3k 0 Posted December 10, 2012 Author Share Posted December 10, 2012 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 Rickta59 1 Quote Link to post Share on other sites
stick 0 Posted December 17, 2012 Share Posted December 17, 2012 Edit2: I uploaded the example files in case anyone's interested Thanks! I added your example to my git repo - https://github.com/fabhack/SW-EK-LM4F120XL (upstream branch is unchanged stellarisware from .exe installer, master is inteded for small modifications like yours). Quote Link to post Share on other sites
stick 0 Posted December 17, 2012 Share Posted December 17, 2012 Btw, has anyone found the solution for the USB enumeration problem? I don't want to use different toolchain than GCC. :-/ PS: After the full GCC rebuild of Stellarisware, if I revert the usblib/gcc-cm4f/libusb-cm4f.a file, the examples start to work. I'm documenting this at my knowledge base: http://fabhack.com/doc/stellaris/faq Quote Link to post Share on other sites
eternauta3k 0 Posted December 22, 2012 Author Share Posted December 22, 2012 Got everything working with Ubuntu's ARM toolchain Quote Link to post Share on other sites
stick 0 Posted December 23, 2012 Share Posted December 23, 2012 Got everything working with Ubuntu's ARM toolchain So you are using linux-gnueabi instead of none-eabi? I did not know this is possible on Cortex M3/M4 MCUs Quote Link to post Share on other sites
eternauta3k 0 Posted December 23, 2012 Author Share Posted December 23, 2012 Yep. Works fine, although I had to compile newlib instead of using the provided libc/libm. Quote Link to post Share on other sites
stick 0 Posted December 24, 2012 Share Posted December 24, 2012 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. bluehash 1 Quote Link to post Share on other sites
stick 0 Posted December 24, 2012 Share Posted December 24, 2012 I fixed the issue by replacing the mentioned line with a series of assignments. See the commit here. bluehash and eternauta3k 2 Quote Link to post Share on other sites
eternauta3k 0 Posted December 24, 2012 Author Share Posted December 24, 2012 Nice! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.