tmk / tmk_keyboard

Keyboard firmwares for Atmel AVR and Cortex-M
4k stars 1.71k forks source link

'Start Application' from Atmel DFU bootloader #647

Open tmk opened 4 years ago

tmk commented 4 years ago

Got an issue report from FC660C Alt controller user.

The instructions (https://github.com/tmk/tmk_keyboard/wiki#flash-firmware) say in step #5 to either re-plug the USB cord OR click Start Application in FLIP. I found whenever I pressed Start Application, they keyboard would become non-responsive and I'd have to power cycle it a few times. If I instead just re-plug the USB cord it works as expected.

This issue is related to 'watchdog timer' or USB startup code?

Atmel DFU bootloader document says like below. http://ww1.microchip.com/downloads/en/devicedoc/doc7618.pdf

4.10 Starting the Application The flow described below allows to start the application directly from the bootloader upon a specific command reception. Two options are possible:

• Start the application with an internal hardware reset using watchdog. When the device receives this command the watchdog is enabled and the bootloader enters a waiting loop until the watchdog resets the device.

• Start the application without reset. A jump at the address 0000h is used to start the application without reset.

Important note: The bootloader performs a watchdog reset to generate the “hardware reset” that allows to execute the application section. After a watchdog reset occurs, the AVR watchdog is still running, thus the application should take care to disable watchdog at program start-up (otherwise the application that does not manage the hardware watchdog will run in an infinite reset loop).

tmk commented 3 years ago

We have to put 'wdt_disable()' at beginning of application? Section '.initX' can be used for this purpose, perhaps.