USB dropping out periodically

29 Apr 2011

Hello All,

I am having issues with the USB connection dropping out periodically on my mbed. I basically have an app running on it printing out over the USB serial interface to a putty session. After some time the printing stops and I no longer have access to the File System of the mbed either. Only way to solve it is a power cycle. My application is not doing anything intense but prints out the USB serial at a regular interval of 5 seconds.

I am running Windows 7 and the serial port is set to 115200 baud.

Seems other have had similar issues but I have not seen a solution.

Thanks, Serge

29 Apr 2011

Andy discusses some of the issues with printf in his notebook article on interrupts. http://mbed.org/users/AjK/notebook/regarding-interrupts-use-and-blocking/

Definitely worth a look if you have not seen it.

29 Apr 2011

Serge,

This is just a WAG (Wild Ass Guess), but you may be having an issue with flow control. The mbed doesn't really support flow control and so it should be turned off in Putty.

Try lowering your speed and configuration to the recommended 9600 8N1.

Harry

30 Apr 2011

Hi Harry,

I will do some testing around your suggestion and see.

Thanks guys, Serge

02 May 2011

OK so I have played with this over the weekend and I still get the same behavior. I have tried reducing baud rate to 57600 and that has not made a difference either I will still try 9600 .... but honestly it should work at rates higher than 9600!

Just to be clear, the app is still clearly running on the mbed which I can see by the LED patterns. I simply loose the serial communication and access to the MBED file system.

A reset is not enough to solve the issue, I have to perform a cold restart of the mbed.

This could very well be a driver issue on the computer side.

UPDATE. I removed the driver in Windows Device Manager in order for it to re-install itself following a "search for new Hardware" scan without cold restarting the mbed but it made no difference, so I am less convinced its on the PC side now...

Thanks, Serge

02 May 2011

How about downloading and trying Teraterm. That'll elimate something else if it hangs in that too.

02 May 2011

OK,

Switched to 9600 but still have the problem, tried Teraterm but it does not seem to accept COM15 ... stops at COM12. Thanks for the suggestions.

Serge

02 May 2011

Serge,

Are you using the local file system at the same time you're using the USB serial interface?

Is it possible for you to try using an actual serial connection in lieu of the USB?

Did you try turning off flow control in putty?

In your original question, you say you are printing. Are you literally printing?

Can you post any of the code?

Harry

02 May 2011

Hello Harry,

I am not using the LocalFileSystem at all in my application.

Basically everything works fine for a while, sometimes several hours sometimes less, outputting data to my terminal program at a rate of a few lines every 5 seconds. Then all of a sudden there is no more output and I have no longer access the the mbed file system on my PC. This happens without any specific actions on my part. I can leave the computer and come back in a few hours and the link is dead.

Flow control is off, I could try and use another serial port instead of the USB one purely as a test but longer term this is not an option.

Sorry I am not able to post the code, I am hoping someone from mbed would chime in since my understanding is that I am not the only one. In a few days I will have a second mbed and will give it a try to see if the same things happens.

I found another version of this Tera Term which seems to work so will try give it a try.

Thanks, Serge

02 May 2011

Can you try it on another PC?

Maybe the problem is in your PC's USB stack?

Harry

03 May 2011

Its really hard without the code. I had a similiar thing in a program. mBed continued running, infact it continued controlling a relay, but my output and other functionality hung. (hanged?!)

It was me.. it was an interrupt doing WAY to much work.

Do you have any interrupts in your code. (methods connected to tickers?)

If you do, I'd pull them and see if it stabilises.

I come from an application programming background.. embedded programming is quite a bit different, and took me quite a while to get my head round. Initially I found it quite easy to hang an mBed in many different ways. I think I remember once storing a value in a char* that wasn't big enough to hold it, and it would sometimes overwrite memory and go splat. (Randomly splat) Looked like a completely innocuous code issue, but wasn't.

If presume if you code a very simple program to loop and output a constant to your PC every 5 secs then that's completely fine ?

03 May 2011

Hi David,

Fair enough, I will write some code which simply outputs the same amount of data at the same rate and see what that does.

Also I would have expected that if it was some sort of interrupt type issue it would go away with a soft reset and not require a cold restart. Also I would have expected a more predictable time for the failure, as it stands it can run for many hours just fine and then I loose comms just like it can run for < 30 min and I loose comms.

I have now been testing on my second mbed which I received this morning and its still running after five hours.

Thanks, Serge

03 May 2011

Me again,

I would also like to add that the blue LED near the USB connector on the mbed continues to blink (at the expected rate) when USB Rx traffic occurs even when the link between the mbed and my PC breaks so I am very confident its not my app crashing or anything.

Fairly confident at the moment that its USB PC hardware or Windows 7 driver related.

Serge

03 May 2011

Out of interest..

I know there were some dodgy leads flying around at one point. could it be something as daft as the lead ?

04 May 2011

Hi David,

Good idea, I will try with a another cable.

Serge

04 May 2011

OK, a little update here.

Based on David's comment I swapped out the USB cable this morning and things have been running fine since then. Roughly 12 hours I am not going to yell victory yet and propose that I leave it another day or two at which point I will probably plug the old cable back in to convince myself 100% that the problem truly lies in the cable.

David, thank again for pointing out the obvious hopefully this turns out to be the solution.

Serge