I have a atmega32u4 from factory with dfu inside. The HWB is pull down, and RESET pin is pull up.
The first USB plug, dfu programmer appears on my Linux box. I upload the firmware without problem. Now, every time I plug my atmega to USB the application runs first, instead of dfu. But, when reset mcu by software, the bootloader code runs.
According to datasheet, default fuses are : BOOTRST = 1 and HWBE = 0. With this fuses and signals, the expected behaviour should be always the first one as the image show.
I don't know why reset by software, the bootloader runs.
Best Answer
After some testings, this is what happend. The startup code is:
*. At startup, check MCUSR. If reset was due to watchdog, clear corresponding flag.
*. Turn off wdt.
*. Configure wdt with desired timeout.
*. Feed the wdt when needed.
Two options are possible to start application with dfu-programmer:
Start application with an internal hardware reset using watchdog.
A jump at address 0x0000 without reset.
Hanging mcu later, if app was launched with option one, the applications boots.
Using option two, by some reason, the bootloader runs this time.