32u4 Bootloader activating during power glitch

SOLVED, set the BOOTRST fuse bit to false and now it restarts as expected from a power glitch. Set HWBE fuse bit to true to still allow manual bootloader activation from reset button.

Original:
Hi all, so I've got a custom pcb running an ATmega32u4, it's a vehicle fan controller with switching voltage regulator and all that.

Running on 16mhz oscillator, reset pin has pullup resistor, HWB has pulldown resistor but I don't notice a change with a pullup or even floating as far as uploading goes.

I programmed the catrina bootloader onto the pcbs via an UNO with Nick Gammon's bootloader sketch so now I can upload code via USB just fine.

PROBLEM, I've noticed a very brief loss of power/bouncing power wire will cause the bootloader to activate which can be rather annoying when it's on vehicle, so I'm curious if there is a way to set the bootloader to only activate over a usb command or by pressing the reset button.

The goal is to market these to customers with the idea that they can update the units at home if new code is ever released, so I'd like to keep USB uploading in tact if possible.

Fuses are set to default settings, and the datasheet is making my head spin so if anyone has pointers on where to start that would be great.

Thanks all!

Signature = 0x1E 0x95 0x87
Processor = ATmega32U4
Flash memory size = 32768 bytes.
LFuse = 0xFF
HFuse = 0xD8
EFuse = 0xCB
Lock byte = 0xEF
Clock calibration = 0x75
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 4096 bytes starting at 7000

(deleted)

spycatcher2k:
Why not just remove the bootloader?

Because I'd like to leave the option for users to update with newer code if possible.

I GOT IT! After doing some digging I laid out all the Fuse Bits and sure enough one of them was for Boot Reset!

I set that bit to false, modified Nicks code to write my new Fuse and it works as expected!

Now when I bounce the power line the sketch just restarts instead of loading into the bootloader, so no more annoying pauses if there is a slight glitch.

Here is my new High Fuse setup, I set BOOTRST to false (1) which fixes my power glitch issue, and EESAVE to true (0) so user settings aren't erased during an ICSP reprogram.

Writing fuses ...
LFuse = 0xFF
HFuse = 0xD1
EFuse = 0xCB
Lock byte = 0xEF
Clock calibration = 0x63
Done.

Hope this helps others out!

Am I the only one who reads this and thinks the solution is to solve your power supply problem?

Ok, so I may have jumped the gun here, it seems the board only enters the bootloader when there is no code on the chip. After the first program the board will never enter the bootloader, not over usb or pressing the reset button. Will have to see if enabling the HWBE bit will help this.

DrAzzy:
Am I the only one who reads this and thinks the solution is to solve your power supply problem?

I guess I should clarify, I'm not 100% sure if the issue is vehicle interference or temporary loss of power, but I think it's the latter. I'm using a spring tension terminal block, and I've got a feeling they are shaking around and occasionally breaking connection. So besides putting in the biggest cap I can to supply power in between those breaks, i'm not sure what i could do to fix that.

Ok, back again with much better news!

Setting the BOOTRST Boot Reset fuse bit to false prevented the power reset bootloader activation, but it basically disabled the bootloader entirely which just changed the problem.

Luckily my board had a Pulldown resistor on the HWB pin, so after setting the HWBE Hardware Boot Enable fuse bit to true, now the bootloader will activate when I press my reset button(tied to !Reset Pin) and it does not activate under temporary power loss. YAY!

Now my design will be more stable while still allowing USB updating. That was a fun learning experience. Thanks for the input everyone.

Writing fuses ...
LFuse = 0xFF
HFuse = 0xD1
EFuse = 0xFB
Lock byte = 0xEF
Clock calibration = 0x63
Done.