Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast start/MCUSR fix #158

wants to merge 5 commits into from


None yet
3 participants
Copy link

commented Sep 26, 2015


This is a fix for fast start and clearing MCUSR heavily discussed in #140 and #97. It's also related to #111.
Code is almost unmodified by @MarkG55.
I rewrote comments to explain more, and increased initial bootloader timeout from 1s to 2s as requested in few places (it helps during manual/button reset).

matthijskooijman added a commit to 3devo/optiboot that referenced this pull request Sep 23, 2016

Improve reset reason handling
This fixes a few things:
 - When the bootloader runs to completion and is reset by the watchdog,
   this WDRF flag is no longer reported to the application, but cleared.
 - When the bootloader runs, MCUSR is no longer cleared, so its contents
   can be passed to the application.
 - When the EXTRF flag is set, the bootloader now always runs (with the
   exception of when WDRF is also set). This prevents issues when the
   application enables the watchdog and lets it trigger immediately,
   causing a reboot loop that could not always be broken with an
   external reset. This problem still exists, but now the bootloader can
   be forced by keeping reset pressed during poweron (which sets both
   PORF and EXTRF, which now also triggeres the bootloader).

The MCUSR register is still copied into r2 and cleared when the
application is started. In the future, this might no longer be needed
(see Optiboot#97 / Optiboot#158), but for now it stays in.
@@ -504,7 +532,7 @@ int main(void) {

// Set up watchdog to trigger after 1s

This comment has been minimized.

Copy link

njh Mar 6, 2017


Comment is incorrect


This comment has been minimized.

Copy link

commented Jul 24, 2018

Merged manually.

@WestfW WestfW closed this Jul 24, 2018

@majekw majekw deleted the majekw:mcusr55 branch Oct 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.