Skip to content

Commit 95b1550

Browse files
committed
save RAM content overridden by bootloader magic
and restore it in case of aborted reboot use RAMEND-1 as suggested by @yyyc514 in PR arduino#2474 of course it's not a real solution but we cannot force everyone to update the bootloader using an external programmer
1 parent b275d9c commit 95b1550

File tree

1 file changed

+2
-1
lines changed
  • hardware/arduino/avr/cores/arduino

1 file changed

+2
-1
lines changed

Diff for: hardware/arduino/avr/cores/arduino/CDC.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ bool CDC_Setup(USBSetup& setup)
9595
// We check DTR state to determine if host port is open (bit 0 of lineState).
9696
if (1200 == _usbLineInfo.dwDTERate && (_usbLineInfo.lineState & 0x01) == 0)
9797
{
98+
*(uint16_t *)(RAMEND-1) = *(uint16_t *)0x0800;
9899
*(uint16_t *)0x0800 = 0x7777;
99100
wdt_enable(WDTO_120MS);
100101
}
@@ -107,7 +108,7 @@ bool CDC_Setup(USBSetup& setup)
107108

108109
wdt_disable();
109110
wdt_reset();
110-
*(uint16_t *)0x0800 = 0x0;
111+
*(uint16_t *)0x0800 = *(uint16_t *)(RAMEND-1);
111112
}
112113
}
113114
return true;

0 commit comments

Comments
 (0)