We have a custom board with a 32U4. The bootloader keeps getting trashed. I am using an AVRISP II and Studio 4 to program. A verify confirmed the bootloader was corrupted. It is happening during routine Arduino downloads.
Fuse Bits: BOD 4.3V, HWBE, SPIEN, Boot Size 2048, BOOTRST
Question: should I be setting the BLB lock bits? What values should I use?
I tried setting the BLB lock bits but the board has failed again. I have not checked out yet so I don't know if the bootloader is trashed again.
How are you setting the fuses?
Are you sure the bootloader is getting corrupted? Or could it just be non-operational. It is a common problem (if you don't set the fuses right) that the first attempted use of a new bootloader works OK, but it doesn't work the second time you use it. This happens if you fail to set the BOOTRST or BOOTSZ correctly; on a blank arduino the unprogrammed memory at other flash locations is (more or less) no-ops, and you get to the bootloader eventually no matter where RESET takes you. But after you have a sketch in there, it can prevent the bootloader from starting.
(Note that AS4 will NOT program the fuses based on the .hex or .elf file contents, and I don't think the Arduino bootloaders put the fuses into the binaries, anyway.)
I am setting the fuses using AS4 and an AVRISP II. I know the loader got corrupted the first time as I did a verify and the bits did no match. I haven't gotten the hardware back you so I don't know what happened this time. The board and boot loader have been working fine for a while. The code has been growing, so it may be a size related issue. As for the boot fuses, I have BOOTRST on, and BOOTSZ set to 2K. Gleaning the correct fuse settings has been a struggle. Any help would be appreciated.
In general, you can get the fuses from boards.txt for a "similar" board. For example, Leonardo has:
(I think that matches what you have...)
Sanity check with http://www.engbedded.com/fusecalc (http://www.engbedded.com/fusecalc)