Arduino Forum

Using Arduino => Installation & Troubleshooting => Topic started by: BrotherTheo on Dec 06, 2015, 06:38 pm

Title: 32U4 bootloader getting corrupted
Post by: BrotherTheo on Dec 06, 2015, 06:38 pm
Hi,

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.

Bootloader: Leonardo-prod-firmware-2012-12-10.hex
Fuse Bits:  BOD 4.3V, HWBE, SPIEN, Boot Size 2048, BOOTRST

Any ideas?

--TimR
Title: Re: 32U4 bootloader getting corrupted
Post by: BrotherTheo on Dec 06, 2015, 07:00 pm
Question: should I be setting the BLB lock bits?  What values should I use?

--TImR
Title: Re: 32U4 bootloader getting corrupted
Post by: BrotherTheo on Dec 10, 2015, 11:10 pm
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.

--TimR
Title: Re: 32U4 bootloader getting corrupted
Post by: westfw on Dec 11, 2015, 01:44 am
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.)
Title: Re: 32U4 bootloader getting corrupted
Post by: BrotherTheo on Dec 11, 2015, 11:20 pm
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.

--TimR
Title: Re: 32U4 bootloader getting corrupted
Post by: westfw on Dec 12, 2015, 02:00 am
In general, you can get the fuses from boards.txt for a "similar" board.  For example, Leonardo has:
leonardo.bootloader.low_fuses=0xff
leonardo.bootloader.high_fuses=0xd8
leonardo.bootloader.extended_fuses=0xcb
(I think that matches what you have...)
Sanity check with http://www.engbedded.com/fusecalc (http://www.engbedded.com/fusecalc)