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.

USB Stack restart

Other Parts Discussed in Thread: TM4C129ENCPDT, EK-TM4C1294XL

I am using a TM4C129ENCPDT processor with tirtos_tivac_2_12_01_33

The USB is interfacing to a Ublox Toby modem.

I am finding that the USB for the PPP port seems to get out of synch with the modem.

By out of synch I mean that I see no responses from the modem for a period of 1 to 2 minutes and then it starts responding but to my earlier messages.

A normal AT port works fine, just the port on which I have had a PPP session active seems to fail.

Doing a reset on the modem itself doesn't resolve the issue.

Doing a reset of my entire board does resolve the issue.

This seems to indicate I either have a hardware or software issue within the USB interface.

Interestingly the working AT port is part of the same device enumeration, only the PPP port behaves strangely.

I was wondering if there is a way of Resetting the USB host stack so it starts from default when I reset the modem.

  • Hello Barry

    How does the USB Host Stack know that modem has been reset? It will only see a disconnect condition.

    Regards
    Amit
  • That's correct Amit.

    I am forcing the USB disconnect by doing a reset signal to the modem.

    I see the USB disconnect and I see the USB reconnect but for some reason the endpoint I am receiving USB data from seems to get out of synch and I get delayed responses from the modem. 

    A hardware reset of the whole board fixes this so I was wondering if there is a way to do a hardware reset on the USB interface and stack at the same time as I do a hardware reset on the modem.  I believe the issue is the modem manufacturers but I need a work around and restarting the USB hardware and stack should give the same conditions as the reset of the whole board.

  • Hello Barry,

    Though it is not an elegant method, but one method would be that on disconnect, the de-intialization of the USB controller is done, followed by a SysCtlPeripheralReset for USB is and then the initialization routine call.

    One possible method would be to handle this with a function call that handles the reset and init and another function to deinit and reset. The first function is called on a SysTick or Periodic handler if the CPU see that a disconnect is issued or on the first POR. The second function is called when a disconnect is issued and this sets up a flag for the periodic handler to call the first function.

    Regards
    Amit
  • Thanks, this will at least do a hardware restart, if not a USB stack.

    Do you have an example de-initialisation sequence?
    or do I simply look at the initialising code and try to reverse order shutdown.

    As I control the reset I can issue reset, wait for USB disconnect, then do what you suggest and not raise the reset till I have reinitialised the hardware. I can also add a USB initialised flag and make sure the USB tick task won't call the stack unless the USB has been reinitialised.

    Anything else you think I should be careful with?
  • Hello Barry,

    No. I do not have a ready to use example to illustrate de-init. The init code files have APIs for de-init functions as well, especially those related to buffer management.

    As for the sequence, it should be wait for USB disconnect, deinit the stack, Reset the USB peripheral, init the stack and wait for connect event in stack (the last would be done when the external device is plugged in)

    Regards
    Amit
  • Hi Barry,
    In lue of resetting the USB stack why not try to find what is causing the de-sync issue. Perhaps interrupt priority could be the culprit in that PPP time slip. My find for random client disconnects occurring USB was from the OTG (EK1294XL Launch-Pad) port not having any electrolytic on VBus pin 1. Added a 47uf 6.3v to VBus and at least the disconnects occur far less frequent or not at all.
  • I have already spent weeks trying to track the cause down, something that's very hard without analysers, particularly when the board is mini pci express and underneath main board so not easy to access for probes and such.

    What I do know is that

    UBLOX Lisa works fine, Sierra Wireless works fine, Cinterion works fine.

    USB itself works fine with the UBLOX Toby until a PPP session fails and I have to restart the modem.

    In fact with the Toby one set of endpoints is working fine but the PPP set is hanging up, once again not indicating a hardware issue or interrupt priority issue.

    This makes me think it is something in the Toby handling of the USB interface.

    We are talking delays of minutes, not seconds or just a few lost bytes.

    I enabled the start up message on UBLOX Toby and this message itself was also delayed by minutes indicating it's not me missing characters or my own buffers having issues.

    I have just sent UBLOX over 1 G of trace captures so they can see what their modem is doing,

    What I am looking at here is a work around in case they cannot fix their issue and I need to use the modem.

  • Hello Barry

    Is there some other signalling from the modem (like a IO change) that is available to indicate a requirement to restart?

    Regards
    Amit
  • Hello Amit

    The only connections to the modem are USB, reset, power down and power.

    I only use reset as a last resort where the modem is no longer responding to me.

    So in this case the IP packets are no longer getting responses over the PPP link and I have been unable to establish a new PPP session.

    Regards

    Barry

  • Hello Barry

    And on detecting a non responding mode, it is not acceptable to reset the TM4C!

    Regards
    Amit
  • Thanks for the reply Amit

    Unfortunately no.  The application is for alarm monitoring and this modem is just one of the communication links.

    There are standards to comply with regards outage periods and availability, so I need to be able to independently recover this link without effecting the other link.

    Also resetting the entire board just to recover this modem would mean that accidental resets of the board would be hard to detect.  Board resets are reported as part of the alarming so getting one or two a day due to network congestion / outages is not good if you multiply across thousands of devices.

    Regards

    Barry

  • Hello Barry

    OK. Thanks for the info. I wanted to explore all possible options. So it seems that reset of the USB and reinit of the stack is the only way.

    Regards
    Amit
  • Thanks for the reply Amit

    I am wondering if anyone else has reported any issue with a USB endpoint buffering the data then sending in a burst?

    The reason I ask this is the UBLOX log file showed they didn't receive any data into their command port until I had sent a number of packets and then they received a burst of garbage followed by the first command I had tried to send.

    I am still trying to get them to look at their end in case they have some sort of flow control issue but have confirmed at my end the packet I wish to send gets all the way through to USBHCDPipeSchedule.  Other endpoints on the same USB device continue to work normally.

    So either USB Endpoint from Tiva is buffering then sending after a while (is this possible) or their end is buffering.

    I do a reset on their module and the problem doesn't go away, I do a reset on my hardware and it goes away.

    This tends to indicate a possible issue in the USB transmit at my end (Tivaware software), though why it only materialises on this particular modem I am not sure.

    I am using tirtos_tivac_2_12_01_33\products\TivaWare_C_Series-2.1.0.12573c

    Any light you can shed on this would be great.

  • I have changed to C:/ti/tirtos_tivac_2_14_00_10/products/TivaWare_C_Series-2.1.1.71b as I noticed it says TI have fixed a number of USB bugs.
    I will run this for a while and see if I have the same issues.
  • Hello Barry

    As per the description you gave in 2 posts back, there was bug fix where on USB not detecting a Disconnect well during a write or read operation. The same was put on the forum as well almost a year back/.

    Regards
    Amit
  • Thanks Amit

    Even with latest libraries I still have had issues.

    I tried looking at host examples on the latest Tivaware but it doesn't seem to include any in the project examples.

    Can you tell me where I can get a USB host example, even just something which sends reasonable sized chunks of data to the connected device, such as audio playback would be useful.

    I want to check that I an doing the sending of data correctly.

    Currently I place into a circular buffer then feed to the USB as much as the endpoint can handle till the circular buffer is empty.

    This is working and as far as I can tell failure is after I feed the USB FIFO, but I want to make 100% certain I am not contributing to any issue by calling from wrong point in my task.

    Regards

    Barry

  • Hello Barry

    USB Host examples are present in TivaWare installation under the path examples/boards/ek-tm4c1294xl and examples/boards/dk-tm4c129x and start with the name usb_host_XXX

    There is a usb_host_audio example as well in DK-TM4C129X folder.

    Regards
    Amit
  • I have looked in those folders

    C:\ti\tirtos_tivac_2_14_00_10\packages\examples\boards\DK_TM4C129X
    only contains DK_TM4C129X.c, DK_TM4C129X.cmd, DK_TM4C129X.icf, DK_TM4C129X.lds and board.h

    The other folders are similar
    C:\ti\tirtos_tivac_2_14_00_10\packages\examples\boards\EK_TM4C1294XL
    C:\ti\tirtos_tivac_2_14_00_10\packages\examples\boards\EK_TM4C129EXL

    There are no USB_HOST_XXX files and none of the files even contain the text USB_HOST
    A search of the entire TIRTOS install C:\ti\tirtos_tivac_2_14_00_10 shows no files with name USB_HOST*.*
  • Found out I need to run tirtos-mak examplesgen DEST="C:/ti/Examples" in order to see the example projects.
    By default they are not in examples directories.
  • However, even this does not generate any USB_HOST files and only has host mouse and host keyboard examples
  • Hi Barry,

    Why not try the USB bulk device project download and modify the transfer endpoint to your selected endpoint. The bulk device project front end is very easy to make a Launch Pad send data to your end point. I modified it into a USBPrintf() and changed the Windows client into a dumb terminal to receive high speed printouts. One thing I ran into was the default ring buffer had to be extend from 64 bytes up to 2048 and had to check the threshold prior to every write cycle keeps a minimum of 256 bytes or simply return. The symptom was buffer over run (USB FIFO locks) in a matter of seconds without adding a threshold check. Best of luck to you!

    software-dl.ti.com/.../index_FDS.html
  • Hello Barry

    I was referring to the TivaWare examples in TivaWare Software installer not in the TI RTOS installation

    Regards
    Amit
  • Hello Amit

    I installed the combined TIRTOS/TIVAWARE package.

    This has no examples under the Tivaware folder.

    Just downloaded the Tivaware package on its own and installed it, the examples are installed.

    Seems to be a short coming on the combined install

    I now have the examples to look at

    Thanks

    Barry

     

     

  • Hello Barry

    I do not think that TI RTOS has all the examples from TivaWare imported into RTOS environment. I do know that USB is being updated in TI RTOS for having a TM4C like structure (though no dates yet)

    Regards
    Amit
  • Thanks Amit

    Do you know of any examples which show how to use USBHCDTerm, this should terminate a USB Host Stack so it can be restarted.

    I went through all the examples and cannot find any which call this.

    I believe I have fund the source of my problem which is that I was checking to see if any data needed to be started to transmit from within the USB interrupt tick call back.  I have changed this to now do the check from another task instead, has run for 3 days so far without issue.  If it makes it past the weekend then will be proven to be the source of my error.

    I would still like to know how to use USBHCDTerm correctly as it would allow my code to do a USB stack start and restart as well as a modem start / restart.

    Regards

    Barry

  • Hello Barry

    No, there is no example though which has the USBHCDTerm, since all examples the Host has to detect the Device disconnect.

    Regards
    Amit