Yun Serial Connection break down

Hello,

i have some issues with my Yun. I used a Sketch with an RFM12b receiver on my UNO. Now I need to write Data down a a SDCard or an SQlite DB and I bought the yun.
If I load the sketch, after a few seconds the COM Ports goes down and i dont have any connection to the yun. The Wifi Connection is working fine. I deactivated the Serial Debug in my sketch cause of the bridge. I am using the console for debugging.
So now i dont know if its an error with the yun. Maybe its broken ?!
If I upload a Sketch without using RFM Lib its working…
Someone have any ideas ?

master_sender.ino (1.42 KB)

Sounds like the library is messing things up. What board did you use before?

What pinout did you use on the Yun? If you have it the same as an Uno it might not work. The pins of the Yun are different and based on the Leonardo.

I found this hookup on google:

Not guaranteed that it works though as it isn't my creation!
(And than it is not even guaranteed, if it where mine :smiley: )

Sutcliffe:
So now i dont know if its an error with the yun. Maybe its broken ?!

It's MUCH more likely that you have an error in your sketch that's crashing the '32U4 processor.

You say you're not using the Serial debug because of the Bridge. Why? They are two separate things. Serial is the communications port that goes directly to the micro USB connector, and is completely independent from the Bridge. Serial1 is the hardware serial port that uses digital pins 0 and 1, and talks to the Linux processor. That is dedicated to the Bridge, so you don't want to use Serial1 when you are using the Bridge.

This is different than the Uno: an Uno has no Serial1, and Serial is the hardware serial port that goes to digital pins 0 and 1. On the Uno, these pins go to a separate chip that implements the USB interface. A side effect of this is that you can't use pins 0 and 1 on an Uno if you are using the USB interface. And with the USB being a separate chip, the USB connection is not affected if the sketch is reset or crashes.

On the Yun, the USB interface is handled directly by the '32U4 processor, there is no independent USB interface chip. This means that the USB interface is independent of digital pins 0 and 1 (those are controlled by Serial1) and it also means that the USB port will go away temporarily if the '32U4 is reset, or permanently if the sketch crashes. That's why I think the sketch is crashing when you say the USB port disappears.

You are using the Console class for your debugging. That's helpful when you cannot use the USB interface, but I've found Console to be not quite as robust as the Serial interface over USB. If I can use the Serial connection, I prefer it over Console.

Im very certain you have a problem in your sketch, and I would bet that it's memory related. When you don't have the RFM library loaded, you have enough memory and things work. But when you have that library as part of your sketch, it uses more memory, you run out and the stack crashes into your data space, and that crashes the '32U4, taking the USB port out with it.

When you verify the sketch, it prints out some memory utilization statistics. Please post three pieces of information:

  • Your complete sketch (please use code tags when posting it)
  • The memory statistics when using the RFM library
  • The memory statistics when not using the RFM library

hey arjan_hes,

yes i used the same picture. I used an uno bevor. I have the same problem even the rfm12b is not connected.

ShapeShifter ,

thx a lot. I think your right. I try to quote some code. I thought its my sketch, but the same error if i use an example sketch from the jeelib libary.. i used the console instead of the Serieal Debug, caus i thought maybe is this the Problem. I heared that the yun crashes in some cases withe the serial...
i will check out the memory an quote a sketch later..

Sutcliffe:
I try to quote some code. I thought its my sketch, but the same error if i use an example sketch from the jeelib libary.

Perhaps you're running into a problem that it's too big? There is a size limit for posts. If pasting the code into the post makes it too big, you can also attach the file to the post. You can't do that in the Quick Reply box at the bottom of the regular page. So, start typing your post there, then click the "Preview" button. That will load a new page, and under the edit box there will now be a link for "Attachments and other options."

I heared that the yun crashes in some cases withe the serial...

I've not heard that, and not experienced it. Perhaps you are thinking about the common issue where the digital pins 0 and 1 (connected to Serial1) cannot be used on the Yun? Those pins are dedicated to talking to the Linux processor - some people try to also use those pins to talk to external hardware, and that's where you run into problems: not because the Yun crashes, but because you end up with hardware signal conflicts.

hey,

now at home i tried again. Same error. I uploaded the sketch in my first post. This is one of my first test. Nothing special, but same problem. The COM Connection breakes down and Windows doesnt recognize the Yun via Com port. I am still able to upload via Wifi…
it seems like it lose the connection with the Line 34 (rf12_initialize(myNodeId, freq, network):wink:

#include <RF12.h>
#include <Ports.h>
#define MSG_SIZE 2
 
// RFM12 stuff
uint8_t payload[MSG_SIZE]; 
const byte network = 100;
const byte myNodeId = 2;
const byte freq = RF12_433MHZ;
const byte RF12_NORMAL_SENDWAIT = 0;
   
void setup() {
  rf12_initialize(myNodeId, freq, network);
  Serial.begin(9600);
  while(!Serial){;} 
  Serial.println("Empfangsbereit...");
}

Thats the first line using the libary…
If i delete this line, i dont lose the COM Port…

i tested another Yun... same Problem... strange very strange.
Can someone try to upload an example Sketch from jeelib ? I have the same error without the rfm12b module...
thought maybe it is a power problem..

I found out, that if i upload a sketch with Console.print instead of Serial.print it works without losing the USB Port.. thats really strange.. I dont know if its reproducible.. IMHO the Yun isnt working stable as the uno..
Had same Errors with other sketches like the Wifistatus. Is there a generally Problem with losing USB Connection after Upload ??

Sutcliffe:
Is there a generally Problem with losing USB Connection after Upload ??

This last statement got me thinking... I've been assuming that the USB serial port is being created by the Yun, and then going away during execution. But based on what you're saying, perhaps you mean that after you upload a sketch over the USB serial port, when you go to open the Serial Monitor in the IDE, it says that port cannot be opened? If that's what you're saying, then it's a different situation.

Be aware that the USB serial port on the Yun has two different modes: application serial, and bootloader serial. They will actually show up as two different COM port numbers, and switch back and forth between them as you upload code.

For example, when I plug in my Yun into a serial port, I get the USB connected sound from my computer, and the serial port shows up as COM90. On the IDE Port menu, I select COM90. When I go to upload a sketch, the Yun gets reset and it enters bootloader mode: my computer plays the USB disconnected sound as the application port COM90 goes away, and then it plays the USB connected sound as the bootloader port appears, which in my case shows up as COM91. The sketch is uploaded, and then the Yun resets again to start running the sketch. I hear the USB disconnected sound as the bootloader COM91 goes away, and the USB connected sound as the application COM90 comes back.

This is all normal operation. But what I've noticed since upgrading my Arduino IDE a while back is that when the application port COM90 comes back, the IDE Port menu has the bootloader's COM91 port selected. The bootloader isn't running anymore (the application is now running) so there is no COM91. The application port COM90 is there, and ready for a connection, but the IDE has become confused and is no longer looking for it.

What I've found is that after uploading a sketch to the Yun, I need to go back into the IDE Port menu and re-select the proper USB port. After that, everything works properly until the next time I upload.

Could that be your actual problem? Perhaps the Yun is working just fine and it's the IDE that's getting confused?

Note that while this two COM port scenario is the same as other Arduino boards that use a '32U4 processor, like the Leonardo, it is different from the other Arduino boards that use a dedicated USB chip like the Uno. The Uno (and similar boards) only ever show up as a single USB port, so this kind of faulty port switching by the IDE cannot happen. While the processor may reset and go in and out of bootloader mode, the USB interface is independent on these boards, and the USB port does not change or go away during an upload operation.

Hey ShapeShifter,

thx for the reply.
I read about the two different COM Ports.
When I Upload my Sketch, then the old COM Port (8) disappears and the sketch uploaded to the YUN.
Switching back after to COM8 isnt posible after Upload, because Windows doesnt recognize the YUN anymore. There is no COM Port in IDE to select.
If u have some Minutes and a clear YUN try this one:

Libary: https://github.com/jcw/jeelib

I tried on two Yun´s… maybe you will see :slight_smile:

Rf12SensorReceive.ino (828 Bytes)

so, dont know why, without Serial.print its working, so i use Console.print… not as good as Serial, but its working.