This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

USBRingBufInit() in TivaWare 2.1.1.71 hangs



I have a C++ program that uses the USB library. It works fine if I use the library file from TivaWare 2.1.0.12573. However, after upgrading to TivaWare 2.1.1.71, the program no longer works.


I tracked it down to a call to USBRingBufInit() from within USBBufferInit(). As soon as I try to single step into USBRingBufInit(), the debugger totally hangs. I cannot halt or even exit the debugger. I have to abort the debugger to recover from this state.

I am using IAR EWARM 7.40.3 on a DK-TM4C129X dev kit board. I am using the ICDI as the debugger interface. If I switch back to version 2.1.0.12573 of the USB lib it works fine again (even using the latest driverlib).

Any ideas what might have changed in the latest version that could cause this problem?

Thanks,

Dave

  • BTW, I tried the usb_dev_serial example project for TivaWare 2.1.0.12573, and it ran okay on the board. However, when I tried to change the project option to use the C++ compiler, there were all sorts of compiler errors reported for usb_dev_serial.c (even though the file has some conditional code to handle C++ -- it appears that option was not actually tested).
  • Hello Dave

    We have only tested it with C constructs.

    Regards
    Amit
  • Hi, Amit,

    What about my original question regarding what has changed in the USB library that might cause this problem?

    Thanks,

    Dave
  • Hello Dave,

    The release note for the USB library. I think it is 1.8.2 which may be something that C++ is not handling.

    Regards

    Amit

  • Thanks, Amit. I guess I will have to do a diff on the old and new example code to find out what I need to change.
  • Hello Dave,

    There would be a lot of changes.

    Regards
    Amit
  • It turns out there were not a lot of differences between the old and new example code. The only changes are:

    in usb_serial_structs.h -- remove the const qualifiers for g_sTxBuffer and g_sRxBuffer

    in usb_serial_struct.c -- remove the const qualifiers for g_sTxBuffer and g_sRxBuffer and delete all references to the tx and rx buffer workspaces.

    After doing this, my code was able to execute without hanging.

    However, Window is no longer recognizing USB device. When I plug in the USB cable, Device Manager reports the following:

    " Windows has stopped this device because it has reported problems. (Code 43)

    The USB device returned an invalid USB device descriptor."

    I do not understand why this is happening, since I did not change anything regarding the device descriptor. And there were no changes in the example code regarding the device descriptor.

    Any idea why I should be getting this error?

    Thanks,

    Dave
  • Hello Dave,

    Can you diff the original project that you used in 2.1.0 against the new project files?

    Regards
    Amit
  • Some additional info:

    When I run the example code, if I open Device Manager, select the virtual com port device and look at Details/Device instance path, the value reported is USB\VID_1CBE&PID_0002\12345678.

    But if I run my code, the device shows up as an "Unknown USB device" in Device Manager. When I look at Details/Device instance path, the value reported is USB\VID_0000&PID_0005\5&17CB10DD&0&2.

    What is is that controls what device descriptor info is reported? I don't understand why if the info in my program is the same as that in the example code, that somehow a different descriptor is being sent to the computer?

    And the VID/PID are not even defined in the code, so how do I control what gets sent. Is there a .inf file somewhere that I also need to change to get things to work?
  • Hi, Amit,

    I am not quite sure what it is you are asking about doing a diff on.

    If you mean my custom application, I did do a diff. All the changes are in 2 files, and the changes are as I described in a previous post.

    If you mean the old and new example project, I did a diff on all the files, and the only changes I saw were in the usb_serial_struct.c and .h files.

    If you mean the old and new usb lib source, I did a diff on all the files there as well, and the only changes that I could see related to the serial device stuff was in usblib.h, where a struct definition was changed to removed the workspace buffer.

    From what I can tell, somehow when I run my program a different driver is getting used than when I run the example code, since the VID/PID and serial number info is being reported differently. But I don't see how the connection is made between my code and the driver.
  • Hello Dave,

    OK. Just to get in sync, with the older version of TivaWare your application was working fine and the inf file was detecting your device? In a nutshell all development was good when you decided to move to latest TivaWare to be on the latest version!!!

    If possible could you share your code, so that we can build it with the latest TivaWare to see what is going on.

    Regards
    Amit
  • Hi, Amit,

    Yes, with the older version of TivaWare my app was working fine and the USB device was being detected properly.

    I just tried getting a snapshot of the project from last Friday (before updating things for the new TivaWare) and rebuilding everything. It works fine, so that means there were no hardware issues that suddenly cropped up. I also did another diff on the state of the project's source files between today and last Friday, and the only changes were addressing the new USB lib struct format and using the new TivaWare libraries.

    I looked back in my notes and found that on Tuesday I downloaded and installed the sw-usb-win package so that I could have access to the dfuprog utility. Don't know if that might have messed something up. But the fact that my old code still runs properly today would indicate that this is not the case.

    I am reluctant to share my code, since it contains somewhat proprietary information. If there are other things I can try before resorting to that, I would prefer to do that. But if there is nothing else you can think of for me to try, I guess I am stuck having to share it.

    What mechanism should I use to send you the files?

    Thanks,

    Dave
  • Hello Dave.,

    We can switch over to PM (apologies to the forum but for proprietary code I have no option)

    Regards
    Amit
  • For those who might experience similar problems, I am posting the final solution here.

    When I upgraded to the new TivaWare library I neglected to update the project's include directories to point to the 2.1.1.71 code. So the code was still compiling using the old definitions for the tUSBBuffer struct. That last entry in the struct used to be a pointer to the private workspace, but with the new library the workspace is contained in the struct itself. But the code was still treating the workspace entry as a pointer, and it happened to point into the g_pui8CDCSerDeviceDescriptor array. So when the private workspace got initialized, the descriptor got corrupted.

    After updating the include files I rebuilt stuff, and it all works now.
  • Hi dave,

    This is Saurabh.

    I am having the same problem as you had in this thread.
    I too had an hard fault error while i updated my code from the older library "TivaWare_C_Series-2.0.1.11577" to newer library "TivaWare_C_Series-2.1.4.178"

    I followed your steps in the update in the files usb_serial_stuct.c & usb_serial_stuct.h and got the result as you had it, no hard fault.
    But i too had lost my USB recognition in the windows 7 SP1 and got a reporting that "One of the USB devices attached to this computer has malfunctioned and windows does not recognise it"

    Though you have got a solution later that you have not updated the include paths to your project properties. but during the start in my case my all the includes paths and library was updated correctly.
    Now i do not know how to go with this issue.
    Please suggest .
  • Hi, Saurabh,

    Unfortunately, I am not at all knowledgeable regarding the use of the USB library. I basically hacked up the sample code and got it to work, without really understanding what was going on under the hood. So I cannot suggest any ideas for you to try out. Hopefully someone else on the forum will be able to help you with your issue.

    Regards,

    Dave