I am using the "Export Compiled Binary" option in the Arduino IDE (selecting the Leonardo profile). I can load my binary just fine via AVRDUDESS and the sketch runs successfully.
However...
When I try to burn the other hex file (".with_bootloader.hex") to load the bootloader, the process finishes with no errors. However the sketch does not run, instead the built in LED just slowly flashes every second.
What gives? Doesn't the ".with_bootloader.hex" file contain both the sketch and the bootloader?
The lock bits are set to the value of the bootloader.unlock_bits property in the "erase" action's command that is run during a "Burn Bootloader" operation, prior to the "bootloader" action command:
(note the -Ulock:w:{bootloader.unlock_bits}:m part of the command template)
The lock bits are set to the value of the bootloader.lock_bits "bootloader" action command that is run at the end of a "Burn Bootloader" operation:
(note the -Ulock:w:{bootloader.lock_bits}:m part of the command template)
So the use of the bootloader.unlock_bits property is to define the lock bits configuration the chip should be put in to prepare it to be written with the bootloader binary.
The use of the bootloader.lock_bits property is to define the lock bits configuration the chip should have at the completion of a "Burn Bootloader" operation.
I can confirm that all the fuses are set correctly. I've tried both the Leonardo defaults (as you show from boards.txt) and a reduced set that maintains only the critical fuses (oscillator etc). The behavior is the same.
I did some more reading last night and it would seem that the bootloader does make it on to the board OK. I get both the "breathing" LED effect when programming and the "slow flash" behavior which, I think, indicates the presence of the bootloader but the absence of a valid sketch.
I've been using a USBasp for programming, on a lark I tried an Arduino-as-ISP and got the same results. A second issue is that I cannot further test the bootloader function by uploading a sketch via USB - my board gives only a "device unrecognized" error from windows, unclear if this is related or unrelated to the above problems.
Well that at least is helpful to know - I was really tearing my hair out on the USB-recognition issue too. So sounds like if I can solve this bootloader problem I might hit two birds with one stone.
I might try rolling back the IDE tonight and see if an older version produces any differences in the .with_bootloader.hex binaries. I can't find anything else wrong in my setup, perhaps its in the file itself.