In the Arduino IDE, what exactly happens when you choose the 'upload with programmer' option to program via a AVR programmer instead of the USB cable? Does it upload just your program, or does it include the bootloader too? If i previously uploaded the bootloader will it still be there, or does it get overridden? Does it set the fusebits during this process?
These answers apply to only the general case - I haven't used the Arduino IDE.
- Does it upload just your program or does it include the bootloader too?
Just your program - bootloader will be overwritten unless someone made an effort to relocate where the image will be programmed in flash. The Arduino IDE may do this but if you find that after you used the 'upload with programmer' option you can't talk to the board any other way, then the programer may have wiped out the bootloader.
Generally fusebits are not set during normal programming. You have to specify that option. Again, the Arduino IDE may have its own tricks, but generally you have to explicitly request the fuse bits be programmed.
the usb interface on an arduino gets you at the avr serial port, where you need a bootloader, etc. Using the ISP interface or whatever they call it (I think it is SPI) you can take over the chip and reload the bootloader (might have fuse limitations). I assume that depends on the binary you are loading and where it wants to load.
The bootloader protocol is often referred to some standard protocol (within the avr world), but if you actually look at the bootloader source (quite easy to read and follow) you find that most of the bootloaders barely support that protocol and each incarnation has its own features. I find it easier to just look at the protocol used by the bootloader and not spend much time outside that.
As far as the other programming interfaces the xmega has an interesting interface, pdi which is not hard to use, and there is the spi interface the other smaller avr devices uses. both are documented with the chips themselves.