Skip to content

Commit

Permalink
save RAM content overridden by bootloader magic
Browse files Browse the repository at this point in the history
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
  • Loading branch information
facchinm authored and cmaglie committed Jul 16, 2015
1 parent 5defaea commit 8a45883
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hardware/arduino/avr/cores/arduino/CDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down

1 comment on commit 8a45883

@NicoHood
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not bad! Im impressed. Its not what we intended to do, but pixes the bug a bit better at least.

Can we block after this interrupt the loop? It should still not run until the ram gets stored back.

Please sign in to comment.