Leonardo does not show Serial port after application loaded - reset? SOLVED

I have some Leonardo boards, when I load a certain application, it kills the board in that Serial no longer shows and it can not be uploaded to again via USB.

On the Leonardo - Is there a way to either reload the bootloader / reset the board or load a new application using an external usb/serial converter?

I have a FTDI Basic and tried that, but maybe due to the fact that the serial port pins are a secondary serial port, the standard method of loading a script does not seem to work. If it should work using standard pins, I'll try again. If reloading the bootloader clears the application, that may work as well, just not sure how to do that with the Leonardo. If I need an external programmer, then I may get one so I can revive and kill them over and over to see what is the root cause, etc.

Details: Working: When I plug it in, it shows Com port 70 .. then that goes away and port 71 shows and works - can be uploaded to. Broken (after loading application): When I plug it in, it shows Com port 70 .. then that goes away and port 71 does not show.

Thank You

You should be able to load the bootloader through the ICSP header using an external programmer.

I have used these tutorials for the UNO, but you will need to get the correct bootloader for the Leonardo:

Using the Arduino software - http://startingelectronics.com/tutorials/arduino/arduino-uno-burning-bootloader-linux/

Using Atmel Studio - http://startingelectronics.com/tutorials/arduino/arduino-uno-burning-bootloader-avr-studio/

Thanks for the pointers, I'll work on a bootloader solution if there is no way to update the sketch via the serial connection and USB to Serial converter. The bootloader is not the root cause, it is the application. So if I can just reload the Blink sketch for example, it should revive the board.

If this was a standard board, I could just hook to the serial pins and reload the application using the USB FTDI Basic adapter. Are there "pins" for the primary serial / is it possible to load a sketch onto the Leonardo this way?

I found another post that seems to answer my question. http://arduino.cc/forum/index.php?action=printpage;topic=112060.0

Summary: You can't use a FTDI Breakout to upload a sketch to the Leonardo. So if you upload a program that makes the serial connection stop working - you need an external programmer (hopefully) to fix it. I have not tried the external programmer as I don't have one yet.

If I am able to revive the software killed boards I'll post details.

Update: Fixed.

I was able to use ArduinoISP to reload the bootloader using an old MEGA as a programmer. This revived both boards and I was able to reload Blink - they feel new again.

So if anyone has an issue with the Leonardo not showing the serial port after loading a sketch, download ArduinoISP and use as directed. If the only other board, this may help (I didn't have to do that since I had other boards around to use as a programmer, just a FYI). http://petervanhoyweghen.wordpress.com/2012/09/16/arduinoisp-on-the-leonardo/

Root cause found and fixed .. a word of warning about Leonardo and related tip.

The root cause of the problem seemed to be an error in an interrupt or setup, causing the system to keep re-running setup and hence not showing the port.

Since error handling is not enable on the arduino, I used another trick to catch the error and keep the system from going into loop / dea mode. The details below explain the code change.

Create a variable .. byte setupRunTimes = 0;

Then in setup .. add this code before any other code, except Serial.begin(), in void setup():

   if (setupRunTimes>1){

Add this code in the first part of void loop():

  if( setupRunTimes > 1 ){
    Serial.println("error on setup");

Hope that helps someone.