How to burn a bootloader in Flash ?

Hi,

Currently, I burn my firmware from Eclipse IDE (by using an AVR Dragon) with this external tool line:

"$WORKSPACE_LOC"/arduino/hardware/tools/macosx/avr/bin/avrdude -C"$WORKSPACE_LOC"/arduino/hardware/tools/macosx/avr/etc/avrdude.conf -v -v -patmega2560 -cdragon_isp -Pusb -Uflash:w:"$WORKSPACE_LOC"/myproject/Release/myfirmware.hex:i

I would like to burn my bootloader with the same way (by using AVR + external tool line from Eclipse) : what is the good command line to do that ?

And about my firmware, how can I be sure, my boorloader won't be replace by my firmware ?

Thank you very much for your help guys !

It should be approximately:

$WORKSPACE_LOC"/arduino/hardware/tools/macosx/avr/bin/avrdude -C"$WORKSPACE_LOC"/arduino/hardware/tools/macosx/avr/etc/avrdude.conf -v -v -patmega2560 -cdragon_isp -Pusb \
   -e -U lock:w:0x3f:m  \

[tt]-U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U lfuse:w:0xFF:m
-U flash:w:"$WORKSPACE_LOC"/arduino/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex:i
-U lock:w:0x2f:m
[/tt]
That works to "configure, erases&unlock, set fuses, program bootloader, lock."

You can only retain the bootloader by programming WITH the bootloader; the bootloader has the ability to erase/reprogram a single page at a time, but ISP programming requires that you erase the entire chip (including the bootloader) before you can progam anything new. (That's SPI-based ISP. I'm not sure about JTAG.)