Bootloader is overwritten after programming


I'm working on a project in which an Arduino is programmed through infra red. The project is coming along nicely, but after every time a user-made program is loaded, the bootloader is gone. I've tried burning the bootloader in AVR studio with an AVRISP MKii, setting the lock bits to 0x0F, burning it in the Arduino IDE with another arduino. Every time the result is exactly the same, user loads a program and the bootloader is gone, the user program runs fine but loading a new user program is impossible until the bootloader has been burned on it again.

I'm having a hard time figuring this out, any help would be appreciated, I'm for the most part using code from Kraz, the rest is either existing arduino code or made by me.


What are fuse bits set to?

You need bit 0 on high fuse programmed (BOOTRST) to make it jump to the bootloader on reset - otherwise it will run bootloader only when the rest of the flash is empty, so it will be programmable over bootloader once.

You’ll also see similar behavior if the reset trick (where DTR is capacitatively coupled to reset, so opening serial comms resets it) isn’t working for some reason.

How are you loading the program? Is it from the standard File->Upload? Or are you doing it from File->Upload Using Programmer?

If you are doing it from Upload Using Programmer then that will erase the bootloader first and then load the sketch.

Sorry for my late reply! I spend some time in Germany, so I was away from home. I was programming from AVR Studio 6.2, I've found the problem to be wrongly set BOOTRST, as mentioned by DrAzzy, after I fixed that it worked. Thanks, you earned some karma from me!