Using an ISP Nukes Bootloader - AND Disables USB! (Leonardo)

Playing with my Leonardo that I program with my UNO-as-ISP I discovered a new problem: The uploaded sketch overwrites the bootloader - and makes the USB serial, keyboard, and mouse functions disabled. I can burn the bootloader back of course, but I get the original problem that forced me to use an ISP in the first place.

Is there a way to burn both the bootloader and the hex of the sketch at the same time?

Where's the sourcecode for the bootloader? (to make the serial port stay open longer)

Any way to reintroduce the USB libraries so it works without the bootloader?

It is fairly obvious that overwriting the bootloader will remove any support code that it contained - though I thought that compiling code through the IDE would insert the USB libraries where needed.

Whilst the chip has USB hardware, you still need libraries to support it, so you have to figure out how to include those libraries.

What makes me suspicious is what you might mean by

pentius:
but I get the original problem that forced me to use an ISP in the first place.

That sounds as if you were doing something obviously wrong to start with, and it is equally wrong without the bootloader. Without your code however, we can of course never know what that mistake is. ::slight_smile:

Uploading using ISP does erase the bootloader, but I didn't think it would interfere with sketch-level USB functions.
The sketch has its own set of USB libraries, and isn't dependent on the bootloader being present (AFAIK.)

Where's the sourcecode for the bootloader?

...hardware/arduino/bootloaders/caterina/

As the bootloader works over USB I suspect the USB code is part of the bootloader.

...R

Robin2:
As the bootloader works over USB I suspect the USB code is part of the bootloader.

But in general, at least for other processors, the communications code for a sketch is assembled together with the sketch so that it can function stand-alone. While you could have code assembled to reference "BIOS" functions in the bootloader, this is not supposed to be how the IDE works.