bootloader and programming thru the ISP

I had a need when I lost my code recently (I don't switch my system off often, and I usually forget to save the project—I do wish the IDE would save on compile—anyway), I lost quite a few days work but needed to quickly get the code onto another arduino (of same type and revision). I simply loaded up AVRStudio and ripped out the hex file and then loaded it onto the new arduino without incident.

I noted today while looking for something else, this post about using the programmer option thru the arduino ide itself "File > Upload using Programmer" which then got me to thinking, how does this affect the bootloader? Does uploading the hex file directly bypass the bootloader? Does it remove the bootloader? Can you go back and do it through USB later? Is there a reset involved? What are the implications of doing it this way? (I realise it's easier through USB, but I have a special case when I cannot easily get to a buried shield to toggle a switch to give me access back to the serial port (for usb upload). But I can access (fairly easily) the ISP.

For example, I knew I could rip the old hex out and upload it to the new board since they have the same bootloader and pinouts etc, but if the bootloaders are different, does one get copied over the other? Is it a part of the hex file or something else?

since posting I did find:

but I'm still unsure about it.

From the first link, I read where the bootloader section is unlocked, uploaded and locked again, but then is that part of the programming space or not? Do I read this as you can lock of part of the program space?

Does uploading a hex file (using the IDE or other) remove the bootloader that is present?

Yes, uploading an Hex file using the IDE function "upload with a programmer" does erase the bootloader !

However as far as I checked the fuses are left as they were.

Hope this helps.

Cool, so then, doing it the way I have done has just used the bootloader from the other Arduino, which should have been the same anyway. I just confirmed that I can still upload using the USB, so all is good. :slight_smile: