USB communications has suddenly failed

I have been programming my Yun via the USB serial port for about a month and had no problems with it at all. Then suddenly, I lost serial communications and can now only program it via the network connection. Also, the communications over the Bridge no longer works.

I loaded Blink which works correctly, but I did notice a difference.

When everything was working, I noticed that Blink used to occupy about 60% of the program storage space. This always seemed a bit high, but I assumed that there was an overhead in there somewhere for being one side of a Yun.

Then, coinciding with the USB failure, Blink occupies only 14%. Somehow, some space has freed up.

So something changed somewhere along the way and I can't think what I did to deserve it.

When I plug the USB cable into the Yun, the USB is recognised for about 10 seconds before disconnecting on its own.

Does anybody have any suggestions as to what the cause might be?

Would someone do me a favour, please. Load blink onto a Yun Rev 2 and tell me what the program size is.

My non working Yun says "Sketch uses 3694 bytes (12%) of program storage space. Maximum is 28672 bytes." and I'm certain it used to be something above 60%.

I just want to eliminate a branch of investigation.

Just a thought - Do you have the correct board/processor type selected in the IDE?

The Yun uses a '32U4 processor, which drives the USB interface directly. Code needs to be included in the firmware image to manage the USB interface. In addition, the hardware serial port that goes to the Linux side via pins 0 and 1 is Serial1 (Serial is routed through the USB port.

Other processors use an external Serial to USB converter. Serial is the hardware port to pins 0 and 1, which is also the USB interface. In addition, Serial1 doesn't exist.

Choosing the wrong processor type would make the sketch smaller, since it doesn't need the USB management code, and would break USB and Bridge communications. (On the other hand, it would probably make anything that uses the Bridge library fail to compile, but it's still worth checking.)

robertics:
Would someone do me a favour, please. Load blink onto a Yun Rev 2 and tell me what the program size is.

Here's what I get when compiling File > Examples > 01.Basics > Blink for Arduino Yun using Arduino AVR Boards 1.6.23:

Sketch uses 4126 bytes (14%) of program storage space. Maximum is 28672 bytes.
Global variables use 149 bytes (5%) of dynamic memory, leaving 2411 bytes for local variables. Maximum is 2560 bytes.

Note that you don't need to actually upload to the board (or even own the board) to get this information, just select the board from the Tools > Board menu and then compile.

You will get different compilation results depending which version of Arduino AVR Boards (and thus which compiler version) you are using. For example, here are the results when using the beta test version of Arduino AVR Boards:

Sketch uses 3952 bytes (13%) of program storage space. Maximum is 28672 bytes.
Global variables use 149 bytes (5%) of dynamic memory, leaving 2411 bytes for local variables. Maximum is 2560 bytes.

but you'd never see such a massive difference as 14% vs 60% caused by changing to a different version of Arduino AVR Boards.

I like your train of thought, ShapeShifter. There was definitely something weird going on with the with the load sizes.

I reinstalled a fresh IDE and things have perked up massively. The comms via the USB seems to be restored as is the Bridge. The only thing that isn't working now is the serial monitor window over the Wifi. It's a big step in the right direction.

I get the same stats as you now, Pert. It's really strange. Thanks for the tip re not having to upload the sketch to get the stats. The reason I wanted someone else to do it was that my setup wasn't doing believable stuff and I wanted a comparison.

It's all looking a bit more stable now and behaving as far as compile size is concerned.

Thank you both for taking the time to reply.

robertics:
The only thing that isn't working now is the serial monitor window over the Wifi.

Sorry if this is obvious, but is your sketch using the Console class when you are testing the Serial Monitor over the network?

  • Serial: communicates with Serial Monitor only over USB, and not the network
  • Console: communicates with Serial Monitor only over the network, and not the USB

Well it is now using the console class and it appears to be working.

It's always worth pointing out the 'obvious' to a newbie like me.

Thanks for your help.