diff options
author | Martino Facchin <m.facchin@arduino.cc> | 2015-07-01 17:00:14 +0200 |
---|---|---|
committer | Cristian Maglie <c.maglie@arduino.cc> | 2015-07-16 13:13:52 +0200 |
commit | 862febf3e28b313b9571605e0ed29cf4e79514af (patch) | |
tree | 7fb4da0c1613aba9f0e72218f457f0ca2c46b504 /cores/arduino/CDC.cpp | |
parent | 47efb352c964a13bf93b6b44c3c763c2320d295e (diff) |
save RAM content overridden by bootloader magic
and restore it in case of aborted reboot
use RAMEND-1 as suggested by @yyyc514 in PR #2474
of course it's not a real solution but we cannot force everyone to update the bootloader using an external programmer
Diffstat (limited to 'cores/arduino/CDC.cpp')
-rw-r--r-- | cores/arduino/CDC.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp index 22f3591..d694a2d 100644 --- a/cores/arduino/CDC.cpp +++ b/cores/arduino/CDC.cpp @@ -95,6 +95,7 @@ bool CDC_Setup(USBSetup& setup) // We check DTR state to determine if host port is open (bit 0 of lineState). if (1200 == _usbLineInfo.dwDTERate && (_usbLineInfo.lineState & 0x01) == 0) { + *(uint16_t *)(RAMEND-1) = *(uint16_t *)0x0800; *(uint16_t *)0x0800 = 0x7777; wdt_enable(WDTO_120MS); } @@ -107,7 +108,7 @@ bool CDC_Setup(USBSetup& setup) wdt_disable(); wdt_reset(); - *(uint16_t *)0x0800 = 0x0; + *(uint16_t *)0x0800 = *(uint16_t *)(RAMEND-1); } } return true; |