The subject line sort of says it all, but in case it's not clear, I posit that one of two things must be true:
1. When you compile a sketch for Leonardo, the compiler mixes in the bootloader to create the .hex file for uploading.
2. When you compile a sketch for Leonardo, the resulting .hex file lacks a bootloader, but the target addresses are chosen such that uploading the .hex file doesn't touch the resident bootloader.
If #1 is true, where are the sources for the bootloader? It should turn up in the underlying makefile somewhere, true?
If #2 is true, is there a something that shows the memory layout?
Why am I asking this?
I'm working on a project where an Ubuntu host processor, connected to the Leonardo vis USB, needs to compile and upload a sketch from time to time.
I can program the Leonardo using the Arduino IDE (on my Mac) using the ISP port. When I plug the Leonardo into the Ubuntu host's USB port, I see /dev/ttyACM0 as expected. Then I can compile and download a sketch to the Leonardo using the Ubuntu host's USB port.
But after that, the bootloader seems to be borked, as evidenced by the fact that /dev/ttyACM0 no longer appears. This makes me think that whatever I'm loading into the Leonardo via the USB port either lacks the correct bootloader (#1) or is somehow stepping on the resident bootloader (#2).
So my real question should be:
I want to compile a sketch on an Ubuntu host and load it onto a Leonardo via USB (all without the Arduino IDE, of course). How do I make sure the resulting code in the Leonardo has a good bootloader?