Trouble uploading to Leonardo: no upload port found

Sketch uses 3956 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.
Performing 1200-bps touch reset on serial port COM10
Waiting for upload port...
No upload port found, using COM10 as fallback

"C:\Users\neu\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\neu\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega32u4 -cavr109 "-PCOM10" -b57600 -D "-Uflash:w:C:\Users\neu\AppData\Local\Temp\arduino\sketches\F7626B79F4B071961D9AB4BE82167AD5/Blink.ino.hex:i"
avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\neu\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM10
         Using Programmer              : avr109
         Overriding Baud Rate          : 57600
avrdude: ser_open(): can't open device "\\.\COM10": Das System kann die angegebene Datei nicht finden.



avrdude done.  Thank you.

Failed uploading: uploading error: exit status 1

Since today I get the above error when trying to upload any sketch. This specific error was generated with the example Blink sketch, just to keep things simple. Until yesterday the Leonardo would disconnect and reconnect after verifying the sketch but it would still upload successfully. Now it disconnects and stays disconnected, even with leaving the USB cable plugged in.

I have a USBasp programmer with a 6-pin ICSP adapter and using that the sketch uploads successfully, but when I reconnect the regular USB cable the built-in LED stops blinking (it's on steady) and the RX and TX lights blink rapidly - without uploading anything. I also tried burning the bootloader, which is successful, but it makes no difference.

Is the Leonardo broken?

Probably not. Try tapping the reset button twice.

The usual approach is to double-tap the reset button (as mentioned by @Grumpy_Mike) when the IDE reports the memory usage as shown below.

Some background

Part of the sketch that you upload contains the functionality for the board detection and for the reaction on the reset issued by the IDE (last line in above quote). It is possible that the code that you wrote overwrites variables used by those functionalities so your board is either no longer recognised by the OS or does not react on that software reset. This is a bug in your code !

The reset invokes the boot loader. You can observe the behaviour in Windows device manager. Below screenshots are for a SparkFun Pro Micro, the Leonardo behaves the same.

If you upload a sketch using ICSP, you wipe the boot loader so uploads via USB will not be possible. So you need to burn the boot loader if you want to upload over USB.

If your sketch is well behaved (e.g. blink), the board will still show as in the first screenshot but after a reset it will either stay as shown in the first first screenshot or it disappears.

I tried burning the bootloader with the USBasp and immediately connecting to USB and uploading a sketch via the IDE. That worked. Next I would have tried double tapping the reset button but I didn't need to do that. Thanks!

P.S. I had activated the verbose output during upload, that's why memory usage was reported.

That happens anyway. The problem with the compiler memory report is that it can only give figures for memory used as a result of declarations in the code. It can't do anything about allocation of memory by the code running. Like when you allocate memory for a display. This often pushes the allocation over the limit and you start getting weird things happening like variables changing value "by themselves".

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.