Go Down

Topic: Unable to connect to YUN through COM Port (Read 1 time) previous topic - next topic

gageb

Jan 21, 2020, 08:48 am Last Edit: Jan 21, 2020, 08:49 am by gageb
My arduino YUN was suddenly unrecognized by my computer after running my latest Arduino code. Having worked with arduino before, this had never happened to me. I tested the USB cable and the power. Both were fine. Unplugging and plugging in the device would be recognized by my computer, however, under my device manager the YUN was now shown as an unknown device. I manually installed the driver by going to the driver folder where I installed the arduino IDE. Windows said the installation was sucessful, but the YUN  only shows up briefly when I double click the reset button. The red LED will flash and then it will disappear from my device manager list. I have attached an image showing how it is listed on my device manager. Any suggestions would be greatly appreciated.

pert

The tricky thing about the native USB boards like the Yun is that the USB code that creates the CDC serial port is running on the same microcontroller as your sketch. This means that it's possible for your sketch to kill the serial port. Here's a minimal example of a sketch that does that:
Code: [Select]

// Prevent the Arduino IDE's sketch preprocessor from automatically adding an #include directive for Arduino.h
#if false
#include <Arduino.h>
#endif

// Override the core library's main function:
int main() {
  return 0;
}


In order to upload to the Arduino board, the microcontroller must be reset to activate the bootloader. On the native USB boards, the Arduino IDE triggers that reset at just the right time by opening a serial connection with the board at 1200 baud. The USB code running in the background of your sketch sees that 1200 baud connection as a signal to reset and activate the bootloader so an upload can begin. But if the USB code in the background of the sketch is broken, or not loaded at all, that signal doesn't go through and the bootloader is never activated, so the upload can't happen.

The solution is to manually reset the board at just the right time during the upload:

File > New

Start the upload.

Watch the black console window at the bottom of the Arduino IDE window. When you see something like this:
Code: [Select]
Sketch uses 444 bytes (1%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

press and release the reset button quickly twice.

The upload should now finish successfully.



Now you can try uploading your previous sketch again. If it causes the same problem to occur again, you know there is something in your code that is breaking the USB functionality. It may be a bit of a chore to find the problem, but at least now you know how to recover from the problem.

ShapeShifter

Another way to kill the USB Serial port on a Yun (or any other board with a '32U4 processor) is to have the wrong board type selected when building/uploading a sketch. If you upload code that was built for a different processor, that code won't have the USB support code, and you won't be able to load code through the USB port, even if you hit reset at the right time.

If @pert's reset trick doesn't work, the next thing to try is to load code over the network: either select the Yun's network address from the IDE port menu, or logging into the Yun's web interface and using the upload sketch button.

Go Up