• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » Stellaris® ARM® Microcontrollers » Stellaris® ARM® LM3S Microcontrollers Forum » Problems with USB bootloader (Stellarisware 6734) and USB command verifier test
Share
Stellaris® ARM® Microcontrollers
  • Forum
Options
  • Subscribe via RSS
Helpful Stellaris® LM4F Series Links
  • LM4F Series
  • Stellaris PinMux Utility
  • Stellaris® LM4F120 LaunchPad
  • LM4F MCU Applications
  • LM4F MCU Video
  • ARM Cortex-M4F Whitepaper
  • Stellaris MCU Brochure
  • LM4F232 Eval Kit
  • Problems with USB bootloader (Stellarisware 6734) and USB command verifier test

    Problems with USB bootloader (Stellarisware 6734) and USB command verifier test

    • Nick Wright
      Posted by Nick Wright
      on Dec 30 2010 08:28 AM
      Prodigy100 points

      Hello,

      I am developing a bus-powered product using the LM3S5C31 Firestorm part and am implementing the Luminary bootloader.  It has been working well on Windows 7 but I found some intermittent enumeration issues in XP.  I ran the USB 2.0 command verifier test against the bootloader and I got several failures:

      - BOS (binary object store) descriptor test

      ERROR
      BOS Descriptors not supported in USB 2.0 and before.
      FAIL
      (1.1.20) Devices must respond with a Request Error to GetDescriptor requests that specify an invalid descriptor type.

      The firmware is returning a 0-length IN data packet in response to this descriptor request.  I believe it should stall the control pipe.  The firmware looks like it should issue a stall but it isn't.

      - Descriptors indicate bus powered but GetStatus request indicates self powered

      This was a simple fix.  Two places in in bl_usbfuncs.c (USBBLInit and USBDSetConfiguration) had the code:

      #if USB_BUS_POWERED
              g_sUSBDeviceState.ucStatus |= USB_STATUS_SELF_PWR;
      #else
              g_sUSBDeviceState.ucStatus &= ~USB_STATUS_SELF_PWR;
      #endif

      I modified to this and corrected the problem:

      #if USB_BUS_POWERED
              g_sUSBDeviceState.ucStatus &= ~USB_STATUS_SELF_PWR;
      #else
              g_sUSBDeviceState.ucStatus |= USB_STATUS_SELF_PWR;
      #endif

      - Enumeration tests failing

      The testing ends with 150 enumeration cycles to the device and is failing on the first cycle.  I believe the problem is in the USB reset handling in the firmware.  I can set a breakpoint in the USB interrupt handler and it never gets called, so something appears to be wrong with setting up the USB interrupt.  I'm still digging in to this one, but wanted to report the problems in order to see if there are any known solutions so far.

      Thanks,
      Nick Wright

      USB
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Nick Wright
      Posted by Nick Wright
      on Jan 21 2011 09:41 AM
      Prodigy100 points

      I spent some time and found the fixes for each of these items.

       

      - BOS test failing

      The problem is caused in the USBGetDescriptor() function.  I can compile with different optimization settings and sometimes it works, so that made me think of a race condition.  It is due to calling USBDevEndpoint0DataAck(false) prior to calling USBBLStallEP0().  Both functions set USB_CSRL0_RXRDYC in the CSRL0 register.  I fixed the issue by removing the USBDevEndpoint0DataAck() function at the beginning of USBGetDescriptor() and only calling it in cases where a stall isn't required.

      Also, each call to USBBLStallEP0() in USBGetDescriptor() should be followed by:

      g_sUSBDeviceState.pEP0Data = 0;
      g_sUSBDeviceState.ulEP0DataRemain = 0;

      So that USBDEP0StateTx() doesn't get called at the bottom of the function.

      - Enumeration tests failing

      This is caused by HandleReset() causing a device reset if g_eDFUState is not equal to STATE_DNLOAD_IDLE or STATE_DNLOAD_DYNC.  If the download hasn't started the state is STATE_IDLE, and the device should not be reset.  I added a check for STATE_IDLE to avoid reset and the enumeration test passes.

      Regards,

      Nick Wright

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Aaron Gage
      Posted by Aaron Gage
      on May 06 2011 17:41 PM
      Intellectual470 points

      Nick --

      Thank you very much for posting your solution.  I ran into the same problem when trying to get a Stellaris device tested for Windows device driver signing (WHQL) because the testing lab caught that same noncompliance.  I made the change you describe above (I commented out the unconditional ACK at the top, created a boolean (initially false) to track whether a stall was required, set it to true in a couple of places in the switch statement instead of stalling there, and then after the switch would either send an ACK or a STALL (also clearing the Tx length) depending on the boolean).  This now passes the USB Command Verifier chapter 9 tests.

      I am puzzled at the fact that this is still not fixed in usblib almost five months later -- I just grabbed release 7243 and the same problem is there (an unconditional ACK at the top of USBDGetDescriptor()).  Another bug that I found that affected USB performance under Linux (device would fail to work after being closed and opened in Linux because the "set interface" command would not cause the toggle bit to clear unless the interface had actually changed) has also not been fixed, even though I posted about it here.

      Are there any other bugs in usblib that you know about that I should fix before we start mass-producing anything?

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Nick Wright
      Posted by Nick Wright
      on May 09 2011 07:57 AM
      Prodigy100 points

      I am not aware of anything else.  We decided not to go to production with the current Firestorm parts so I haven't worked with this code in a few months.

      Good luck,

      Nick

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Dave Wilson
      Posted by Dave Wilson
      on May 10 2011 09:12 AM
      Mastermind22830 points

      Thanks for reporting these issues - I was not aware of them prior to reading this post today. I think it's pretty likely that the official command verifier test was not run on the USB boot loader device so I'll add these issues to our tracking system and make sure we run this test soon. Look for a fix in the next-but-one release of StellarisWare.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Stellaris Paul
      Posted by Stellaris Paul
      on May 13 2011 17:21 PM
      Expert8170 points

      Sorry that we missed this post, these are some very useful changes that we will include in our next release.    We have implemented the suggested changes and the boot loader now passes the Chapter 9 test from the USB compliance suite.  

      Aaron, I will get on your other thread to work out what you are seeing with the data toggle.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Aaron Gage
      Posted by Aaron Gage
      on May 13 2011 17:33 PM
      Intellectual470 points

      Paul --

      I am still using an older version of StellarisWare, but it should be easy to find this in newer versions.

      In the USBDSetInterface() function in usbdenum.c, there is a for() loop over the number of interfaces.  Inside of this loop there is a test for the alternate setting, and then a test that looks like this:

                  if(g_sUSBDeviceState.pucAltSetting[ucInterface] !=
                         psInterface->bAlternateSetting)

      That is, it is comparing the current alt setting to the one being requested by the host.  If they match, it does nothing.

      That's the problem.  I think you'll find in my other thread that the USB spec says this should change unconditionally.  That is, if you remove the test and reconfigure the alt setting anyway (which clears the data toggle bit) then all should be well.

      The easiest way to see this is under Linux, and to do this you need to set up a USB transfer that has an odd number of transfers (so the toggle bit on the device is not left in the power-on state).  Open and close the device to repeat this transfer, and on the second attempt it will fail because Linux expects everything on the device to reset and the toggle bits don't agree.  When Linux closes the device it tells it to go back to its default alt setting, but if it was already there, the StellarisWare code would ignore the request.  You can get this to happen elsewhere if you can manually command the device to go back to the setting it is already on after sending an odd number of packets.

      This doesn't seem to affect Windows in the slightest, and I don't think that the USB Chapter 9 tests will hit this either.

      I'm going to be traveling soon so I may not be responsive -- hopefully this will get you what you need.

       

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Stellaris Paul
      Posted by Stellaris Paul
      on May 13 2011 18:10 PM
      Expert8170 points

      Thanks, I will open an issue so that we don't lose this one as well.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use