Skip to content

Commit fc72657

Browse files
committed
Store reset reason in RTC backup register 8
1 parent 5dbff35 commit fc72657

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/main.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,11 @@ int main(void) {
224224
BOOT_LOG_INF("Starting Arduino bootloader");
225225

226226
int magic = RTCGetBKPRegister(RTC_BKP_DR0);
227+
int reset = ResetReason::get();
228+
RTCSetBKPRegister(RTC_BKP_DR8, reset);
227229

228230
// in case we have been reset let's wait 500 ms to see if user is trying to stay in bootloader
229-
if (ResetReason::get() == RESET_REASON_PIN_RESET) {
231+
if (reset == RESET_REASON_PIN_RESET) {
230232
// now that we've been reset let's set magic. resetting with this set will
231233
// flag we need to stay in bootloader.
232234
RTCSetBKPRegister(RTC_BKP_DR0, 0xDF59);

0 commit comments

Comments
 (0)