{"action":"created","issue":{"url":"https://api.github.com/repos/Optiboot/optiboot/issues/97","labels_url":"https://api.github.com/repos/Optiboot/optiboot/issues/97/labels{/name}","comments_url":"https://api.github.com/repos/Optiboot/optiboot/issues/97/comments","events_url":"https://api.github.com/repos/Optiboot/optiboot/issues/97/events","html_url":"https://github.com/Optiboot/optiboot/issues/97","id":61546554,"number":97,"title":"MCUSR is cleared in bootloader","user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Optiboot/optiboot/labels/auto-migrated","name":"auto-migrated","color":"ededed"},{"url":"https://api.github.com/repos/Optiboot/optiboot/labels/Priority-Low","name":"Priority-Low","color":"ededed"},{"url":"https://api.github.com/repos/Optiboot/optiboot/labels/Type-Enhancement","name":"Type-Enhancement","color":"308df5"}],"state":"open","locked":false,"assignee":{"login":"WestfW","id":425027,"avatar_url":"https://avatars.githubusercontent.com/u/425027?v=3","gravatar_id":"","url":"https://api.github.com/users/WestfW","html_url":"https://github.com/WestfW","followers_url":"https://api.github.com/users/WestfW/followers","following_url":"https://api.github.com/users/WestfW/following{/other_user}","gists_url":"https://api.github.com/users/WestfW/gists{/gist_id}","starred_url":"https://api.github.com/users/WestfW/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WestfW/subscriptions","organizations_url":"https://api.github.com/users/WestfW/orgs","repos_url":"https://api.github.com/users/WestfW/repos","events_url":"https://api.github.com/users/WestfW/events{/privacy}","received_events_url":"https://api.github.com/users/WestfW/received_events","type":"User","site_admin":false},"milestone":null,"comments":27,"created_at":"2015-03-14T10:24:06Z","updated_at":"2015-06-02T00:34:20Z","closed_at":null,"body":"```\nI am running optiboot on an ATmega1284P and everything is working perfectly! \nBut I would like to detect when a watchdog timer caused the reset, but due to \nthis line: \nhttps://code.google.com/p/optiboot/source/browse/optiboot/bootloaders/optiboot/o\nptiboot.c#433 it is not possible at the moment, as the MCUSR register is set to \n0 just before the app starts.\n\nWhat is the reason for doing this? Would it be possible for me just to clear \neverything but the WDRF register with no side effects?\n\nThanks a lot for all your work!\n```\n\nOriginal issue reported on code.google.com by `laus...@gmail.com` on 5 Mar 2014 at 9:44"},"comment":{"url":"https://api.github.com/repos/Optiboot/optiboot/issues/comments/107753257","html_url":"https://github.com/Optiboot/optiboot/issues/97#issuecomment-107753257","issue_url":"https://api.github.com/repos/Optiboot/optiboot/issues/97","id":107753257,"user":{"login":"MarkG55","id":12162083,"avatar_url":"https://avatars.githubusercontent.com/u/12162083?v=3","gravatar_id":"","url":"https://api.github.com/users/MarkG55","html_url":"https://github.com/MarkG55","followers_url":"https://api.github.com/users/MarkG55/followers","following_url":"https://api.github.com/users/MarkG55/following{/other_user}","gists_url":"https://api.github.com/users/MarkG55/gists{/gist_id}","starred_url":"https://api.github.com/users/MarkG55/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarkG55/subscriptions","organizations_url":"https://api.github.com/users/MarkG55/orgs","repos_url":"https://api.github.com/users/MarkG55/repos","events_url":"https://api.github.com/users/MarkG55/events{/privacy}","received_events_url":"https://api.github.com/users/MarkG55/received_events","type":"User","site_admin":false},"created_at":"2015-06-02T00:34:20Z","updated_at":"2015-06-02T00:34:20Z","body":"One possible problem with keeping WDRF set is that if the end user code enables the watchdog, but doesn't clear the flag after a reset, an external reset won't run the bootloader.  Resetting it for a second time will however cause the bootloader to run correctly - as long as the board doesn't end up in a constant watchdog reset loop.\r\n\r\nIf a newbie enables the watchdog and doesn't clear WDRF at the start of their code and they don't reprogram the watchdog timer soon enough, the controller will just sit there resetting itself constantly once a watchdog event has occurred and it won't be possible to reflash new code without power cycling the board.\r\n\r\nEven worse, if we keep WDRF set, a newbie could soft brick their device by enabling the watchdog straight away and then not reset the watchdog soon enough - would require the \"hold reset while powering on\" trick as mentioned here:\r\nhttps://github.com/Optiboot/optiboot/issues/140\r\n\r\nWith the sample code here:\r\nhttp://forum.arduino.cc/index.php?topic=150369.msg1129533#msg1129533\r\n\r\nMy original code will always start the bootloader with an external reset, with the change to keep WDRF, it will be harder to recover from - requiring either 2 resets within about 1 second, or the \"hold reset while powering on\" trick."}}