mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-16 12:51:47 +00:00
Fix bootloaders not starting user application if the HWB is grounded during watchdog reset.
This commit is contained in:
parent
4c637c93ba
commit
a09cb7e3d8
@ -103,8 +103,19 @@ void Application_Jump_Check(void)
|
|||||||
if (!(MCUSR & (1 << EXTRF)) || (MagicBootKey == MAGIC_BOOT_KEY))
|
if (!(MCUSR & (1 << EXTRF)) || (MagicBootKey == MAGIC_BOOT_KEY))
|
||||||
JumpToApplication = true;
|
JumpToApplication = true;
|
||||||
|
|
||||||
|
/* Clear reset source */
|
||||||
MCUSR &= ~(1 << EXTRF);
|
MCUSR &= ~(1 << EXTRF);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application;
|
||||||
|
* this can happen in the HWBE fuse is set, and the HBE pin is low during the watchdog reset */
|
||||||
|
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
|
||||||
|
JumpToApplication = true;
|
||||||
|
|
||||||
|
/* Clear reset source */
|
||||||
|
MCUSR &= ~(1 << WDRF);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Don't run the user application if the reset vector is blank (no app loaded) */
|
/* Don't run the user application if the reset vector is blank (no app loaded) */
|
||||||
|
@ -64,9 +64,9 @@
|
|||||||
*
|
*
|
||||||
* The are two behaviours of this bootloader, depending on the device's fuses:
|
* The are two behaviours of this bootloader, depending on the device's fuses:
|
||||||
*
|
*
|
||||||
* <b>If the device's BOOTRST fuse is set</b>, the bootloader will run any time the system is not reset from
|
* <b>If the device's BOOTRST fuse is set</b>, the bootloader will run any time the system is reset from
|
||||||
* the external reset pin, unless no valid user application has been loaded. To initiate the bootloader, the
|
* the external reset pin, unless no valid user application has been loaded. To initiate the bootloader, the
|
||||||
* device's external reset pin should be grounded.
|
* device's external reset pin should be grounded momentarily.
|
||||||
*
|
*
|
||||||
* <b>If the device's BOOTRST fuse is not set</b>, the bootloader will run only if initiated via a software
|
* <b>If the device's BOOTRST fuse is not set</b>, the bootloader will run only if initiated via a software
|
||||||
* jump, or if the \c HWB pin was low during the last device reset (if the \c HWBE fuse is set).
|
* jump, or if the \c HWB pin was low during the last device reset (if the \c HWBE fuse is set).
|
||||||
@ -81,16 +81,6 @@
|
|||||||
* Ground \c IO13 when powering the board to start the bootloader. This assumes the \c HWBE fuse is cleared and the
|
* Ground \c IO13 when powering the board to start the bootloader. This assumes the \c HWBE fuse is cleared and the
|
||||||
* \c BOOTRST fuse is set as the HWBE pin is not user accessible on this board.
|
* \c BOOTRST fuse is set as the HWBE pin is not user accessible on this board.
|
||||||
*
|
*
|
||||||
* For board specific exceptions to the above, see below.
|
|
||||||
*
|
|
||||||
* \subsection SSec_XPLAIN Atmel Xplain Board
|
|
||||||
* Ground the USB AVR JTAG's \c TCK pin to ground when powering on the board to start the bootloader. This assumes the
|
|
||||||
* \c HWBE fuse is cleared and the \c BOOTRST fuse is set as the HWBE pin is not user accessible on this board.
|
|
||||||
*
|
|
||||||
* \subsection SSec_Leonardo Arduino Leonardo Board
|
|
||||||
* Ground \c IO13 when powering the board to start the bootloader. This assumes the \c HWBE fuse is cleared and the
|
|
||||||
* \c BOOTRST fuse is set as the HWBE pin is not user accessible on this board.
|
|
||||||
*
|
|
||||||
* \section Sec_Installation Driver Installation
|
* \section Sec_Installation Driver Installation
|
||||||
*
|
*
|
||||||
* After running this bootloader for the first time on a new computer, you will need to supply the .INF
|
* After running this bootloader for the first time on a new computer, you will need to supply the .INF
|
||||||
@ -214,12 +204,6 @@
|
|||||||
* access.
|
* access.
|
||||||
* See <a href=https://groups.google.com/d/msg/lufa-support/CP9cy2bc8yo/kBqsOu-RBeMJ>here</a> for resolution steps.
|
* See <a href=https://groups.google.com/d/msg/lufa-support/CP9cy2bc8yo/kBqsOu-RBeMJ>here</a> for resolution steps.
|
||||||
*
|
*
|
||||||
* \par After loading an application, it is not run automatically on startup.
|
|
||||||
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
|
|
||||||
* to run automatically when the device is reset. In most cases, the BOOTRST
|
|
||||||
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
|
|
||||||
* when needed.
|
|
||||||
*
|
|
||||||
* \section Sec_Options Project Options
|
* \section Sec_Options Project Options
|
||||||
*
|
*
|
||||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||||
|
@ -139,8 +139,19 @@ void Application_Jump_Check(void)
|
|||||||
if (!(MCUSR & (1 << EXTRF)) || (MagicBootKey == MAGIC_BOOT_KEY))
|
if (!(MCUSR & (1 << EXTRF)) || (MagicBootKey == MAGIC_BOOT_KEY))
|
||||||
JumpToApplication = true;
|
JumpToApplication = true;
|
||||||
|
|
||||||
|
/* Clear reset source */
|
||||||
MCUSR &= ~(1 << EXTRF);
|
MCUSR &= ~(1 << EXTRF);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application;
|
||||||
|
* this can happen in the HWBE fuse is set, and the HBE pin is low during the watchdog reset */
|
||||||
|
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
|
||||||
|
JumpToApplication = true;
|
||||||
|
|
||||||
|
/* Clear reset source */
|
||||||
|
MCUSR &= ~(1 << WDRF);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Don't run the user application if the reset vector is blank (no app loaded) */
|
/* Don't run the user application if the reset vector is blank (no app loaded) */
|
||||||
|
@ -62,9 +62,9 @@
|
|||||||
*
|
*
|
||||||
* The are two behaviours of this bootloader, depending on the device's fuses:
|
* The are two behaviours of this bootloader, depending on the device's fuses:
|
||||||
*
|
*
|
||||||
* <b>If the device's BOOTRST fuse is set</b>, the bootloader will run any time the system is not reset from
|
* <b>If the device's BOOTRST fuse is set</b>, the bootloader will run any time the system is reset from
|
||||||
* the external reset pin, unless no valid user application has been loaded. To initiate the bootloader, the
|
* the external reset pin, unless no valid user application has been loaded. To initiate the bootloader, the
|
||||||
* device's external reset pin should be grounded.
|
* device's external reset pin should be grounded momentarily.
|
||||||
*
|
*
|
||||||
* <b>If the device's BOOTRST fuse is not set</b>, the bootloader will run only if initiated via a software
|
* <b>If the device's BOOTRST fuse is not set</b>, the bootloader will run only if initiated via a software
|
||||||
* jump, or if the \c HWB pin was low during the last device reset (if the \c HWBE fuse is set).
|
* jump, or if the \c HWB pin was low during the last device reset (if the \c HWBE fuse is set).
|
||||||
@ -213,12 +213,6 @@
|
|||||||
* access.
|
* access.
|
||||||
* See <a href=https://groups.google.com/d/msg/lufa-support/CP9cy2bc8yo/kBqsOu-RBeMJ>here</a> for resolution steps.
|
* See <a href=https://groups.google.com/d/msg/lufa-support/CP9cy2bc8yo/kBqsOu-RBeMJ>here</a> for resolution steps.
|
||||||
*
|
*
|
||||||
* \par After loading an application, it is not run automatically on startup.
|
|
||||||
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
|
|
||||||
* to run automatically when the device is reset. In most cases, the BOOTRST
|
|
||||||
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
|
|
||||||
* when needed.
|
|
||||||
*
|
|
||||||
* \section Sec_Options Project Options
|
* \section Sec_Options Project Options
|
||||||
*
|
*
|
||||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||||
|
@ -61,9 +61,9 @@
|
|||||||
*
|
*
|
||||||
* \section Sec_Running Running the Bootloader
|
* \section Sec_Running Running the Bootloader
|
||||||
*
|
*
|
||||||
* This bootloader is designed to be started via the HWB mechanism of the USB AVRs; ground the HWB pin (see device
|
* This bootloader is designed to be started via the \c HWB mechanism of the USB AVRs; ground the \c HWB pin (see device
|
||||||
* datasheet) then momentarily ground /RESET to start the bootloader. This assumes the HWBE fuse is set and the BOOTRST
|
* datasheet) then momentarily ground \c /RESET to start the bootloader. This assumes the \c HWBE fuse is set and the
|
||||||
* fuse is cleared.
|
* \c BOOTRST fuse is cleared.
|
||||||
*
|
*
|
||||||
* \section Sec_Installation Driver Installation
|
* \section Sec_Installation Driver Installation
|
||||||
*
|
*
|
||||||
@ -73,7 +73,7 @@
|
|||||||
* \section Sec_HostApp Host Controller Application
|
* \section Sec_HostApp Host Controller Application
|
||||||
*
|
*
|
||||||
* Due to licensing issues, the supplied bootloader is compatible with the HalfKay bootloader protocol designed
|
* Due to licensing issues, the supplied bootloader is compatible with the HalfKay bootloader protocol designed
|
||||||
* by PJRC, but is non-compatible with the cross-platform loader GUI. A modified version of the open source
|
* by PJRC, but is <b>not compatible with the cross-platform loader GUI</b>. A modified version of the open source
|
||||||
* cross-platform TeensyLoader application is supplied, which can be compiled under most operating systems. The
|
* cross-platform TeensyLoader application is supplied, which can be compiled under most operating systems. The
|
||||||
* command-line loader application should remain compatible with genuine Teensy boards in addition to boards using
|
* command-line loader application should remain compatible with genuine Teensy boards in addition to boards using
|
||||||
* this custom bootloader.
|
* this custom bootloader.
|
||||||
@ -86,9 +86,9 @@
|
|||||||
* \section Sec_KnownIssues Known Issues:
|
* \section Sec_KnownIssues Known Issues:
|
||||||
*
|
*
|
||||||
* \par After loading an application, it is not run automatically on startup.
|
* \par After loading an application, it is not run automatically on startup.
|
||||||
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
|
* Some USB AVR boards ship with the \c BOOTRST fuse set, causing the bootloader
|
||||||
* to run automatically when the device is reset. In most cases, the BOOTRST
|
* to run automatically when the device is reset. This booloader requires the
|
||||||
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
|
* \c BOOTRST be disabled and the HWBE fuse used instead to run the bootloader
|
||||||
* when needed.
|
* when needed.
|
||||||
*
|
*
|
||||||
* \section SSec_Options Project Options
|
* \section SSec_Options Project Options
|
||||||
|
@ -120,8 +120,19 @@ void Application_Jump_Check(void)
|
|||||||
if (!(MCUSR & (1 << EXTRF)) || (MagicBootKey == MAGIC_BOOT_KEY))
|
if (!(MCUSR & (1 << EXTRF)) || (MagicBootKey == MAGIC_BOOT_KEY))
|
||||||
JumpToApplication = true;
|
JumpToApplication = true;
|
||||||
|
|
||||||
|
/* Clear reset source */
|
||||||
MCUSR &= ~(1 << EXTRF);
|
MCUSR &= ~(1 << EXTRF);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application;
|
||||||
|
* this can happen in the HWBE fuse is set, and the HBE pin is low during the watchdog reset */
|
||||||
|
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
|
||||||
|
JumpToApplication = true;
|
||||||
|
|
||||||
|
/* Clear reset source */
|
||||||
|
MCUSR &= ~(1 << WDRF);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Don't run the user application if the reset vector is blank (no app loaded) */
|
/* Don't run the user application if the reset vector is blank (no app loaded) */
|
||||||
|
@ -67,9 +67,9 @@
|
|||||||
*
|
*
|
||||||
* The are two behaviours of this bootloader, depending on the device's fuses:
|
* The are two behaviours of this bootloader, depending on the device's fuses:
|
||||||
*
|
*
|
||||||
* <b>If the device's BOOTRST fuse is set</b>, the bootloader will run any time the system is not reset from
|
* <b>If the device's BOOTRST fuse is set</b>, the bootloader will run any time the system is reset from
|
||||||
* the external reset pin, unless no valid user application has been loaded. To initiate the bootloader, the
|
* the external reset pin, unless no valid user application has been loaded. To initiate the bootloader, the
|
||||||
* device's external reset pin should be grounded.
|
* device's external reset pin should be grounded momentarily.
|
||||||
*
|
*
|
||||||
* <b>If the device's BOOTRST fuse is not set</b>, the bootloader will run only if initiated via a software
|
* <b>If the device's BOOTRST fuse is not set</b>, the bootloader will run only if initiated via a software
|
||||||
* jump, or if the \c HWB pin was low during the last device reset (if the \c HWBE fuse is set).
|
* jump, or if the \c HWB pin was low during the last device reset (if the \c HWBE fuse is set).
|
||||||
@ -206,12 +206,6 @@
|
|||||||
* Mass Storage bootloader, or the file system synced via an appropriate command
|
* Mass Storage bootloader, or the file system synced via an appropriate command
|
||||||
* (such as the OS's normal disk ejection command) before disconnecting the device.
|
* (such as the OS's normal disk ejection command) before disconnecting the device.
|
||||||
*
|
*
|
||||||
* \par After loading an application, it is not run automatically on startup.
|
|
||||||
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
|
|
||||||
* to run automatically when the device is reset. In most cases, the BOOTRST
|
|
||||||
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
|
|
||||||
* when needed.
|
|
||||||
*
|
|
||||||
* \section Sec_Options Project Options
|
* \section Sec_Options Project Options
|
||||||
*
|
*
|
||||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||||
|
@ -152,8 +152,19 @@ void Application_Jump_Check(void)
|
|||||||
if (!(MCUSR & (1 << EXTRF)) || (MagicBootKey == MAGIC_BOOT_KEY))
|
if (!(MCUSR & (1 << EXTRF)) || (MagicBootKey == MAGIC_BOOT_KEY))
|
||||||
JumpToApplication = true;
|
JumpToApplication = true;
|
||||||
|
|
||||||
|
/* Clear reset source */
|
||||||
MCUSR &= ~(1 << EXTRF);
|
MCUSR &= ~(1 << EXTRF);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application;
|
||||||
|
* this can happen in the HWBE fuse is set, and the HBE pin is low during the watchdog reset */
|
||||||
|
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
|
||||||
|
JumpToApplication = true;
|
||||||
|
|
||||||
|
/* Clear reset source */
|
||||||
|
MCUSR &= ~(1 << WDRF);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Don't run the user application if the reset vector is blank (no app loaded) */
|
/* Don't run the user application if the reset vector is blank (no app loaded) */
|
||||||
|
@ -61,9 +61,9 @@
|
|||||||
*
|
*
|
||||||
* The are two behaviours of this bootloader, depending on the device's fuses:
|
* The are two behaviours of this bootloader, depending on the device's fuses:
|
||||||
*
|
*
|
||||||
* <b>If the device's BOOTRST fuse is set</b>, the bootloader will run any time the system is not reset from
|
* <b>If the device's BOOTRST fuse is set</b>, the bootloader will run any time the system is reset from
|
||||||
* the external reset pin, unless no valid user application has been loaded. To initiate the bootloader, the
|
* the external reset pin, unless no valid user application has been loaded. To initiate the bootloader, the
|
||||||
* device's external reset pin should be grounded.
|
* device's external reset pin should be grounded momentarily.
|
||||||
*
|
*
|
||||||
* <b>If the device's BOOTRST fuse is not set</b>, the bootloader will run only if initiated via a software
|
* <b>If the device's BOOTRST fuse is not set</b>, the bootloader will run only if initiated via a software
|
||||||
* jump, or if the \c HWB pin was low during the last device reset (if the \c HWBE fuse is set).
|
* jump, or if the \c HWB pin was low during the last device reset (if the \c HWBE fuse is set).
|
||||||
@ -187,12 +187,6 @@
|
|||||||
* are unable to handle true plain-text printing. For best results, the low
|
* are unable to handle true plain-text printing. For best results, the low
|
||||||
* level \c lpr command should be used to print new firmware to the bootloader.
|
* level \c lpr command should be used to print new firmware to the bootloader.
|
||||||
*
|
*
|
||||||
* \par After loading an application, it is not run automatically on startup.
|
|
||||||
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
|
|
||||||
* to run automatically when the device is reset. In most cases, the BOOTRST
|
|
||||||
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
|
|
||||||
* when needed.
|
|
||||||
*
|
|
||||||
* \section Sec_Options Project Options
|
* \section Sec_Options Project Options
|
||||||
*
|
*
|
||||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||||
|
Loading…
Reference in New Issue
Block a user