Compiling Bootloader and sketch into single .elf file

Is it possible to dump an arduino bootloader, arduino sketch, eeprom, and fuse settings and dump it all to a single .elf file?

I tried to do it via AVR studio 4 but I get a read error on final verify, and I could not change the BLB1 fuse (bootloader section) without getting an ISP error. AVR studio can reads out the the hex, eeprom, fuses and create the .elf file but I get the this report when I try to reupload it:

Getting isp parameter.. SD=0x02 .. OK
Validating ELF input file.. OK!
Reading FLASH input..OK!
Reading EEPROM input..OK!
Reading FUSE input..OK!
Reading LOCKBIT input..OK!
Reading SIGNATURE input..OK!
Entering programming mode.. OK!
Erasing device.. OK!
Reading signature .. 0x1E, 0x95, 0x0F .. OK!

Signature matches selected device .. OK
Programming FLASH .. OK!
Reading FLASH .. OK!
WARNING: FLASH byte address 0x0002 is 0x20 (should be 0x62).. FAILED!
Leaving programming mode.. OK!

Nothing gets uploaded as far as I can see, and the fuse settings does not change.....

Is it at all possible to compile/combine the bootloader and sketch/hex-file into a single .elf file? Or is the BLB1 fuse preventing to read out the bootloader part?

Any help, experience, thoughts or suggestions will be highly appreciated!

Thanks

Jussi

Take the .hex file of your sketch and the .hex file of your bootloader. Open both of them in a text editor. Remove the last line ':00000001FF' in there and just append the bootloader 'text'.

Thanks, I will try that. Sounds easy. I will report back!

Edit: Opened the files in text editor. I am guessing the bootloader has to come first?

I put it at the end of the sketch. But you can give it a try.