Skip to content
Snippets Groups Projects
Commit 7ddb2667 authored by Martino Facchin's avatar Martino Facchin
Browse files

Avoid erasing the chip if the sketch doesn't contain a bootloader

Use the information retrieved from the linker script in use to simply call a reset without any erase
parent be280ec9
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,13 @@ static void banzai() {
// Disable all interrupts
__disable_irq();
// Avoid erasing the application if APP_START is < than the minimum bootloader size
// This could happen if without_bootloader linker script was chosen
// Minimum bootloader size in SAMD21 family is 512bytes (RM section 22.6.5)
if (APP_START < (0x200 + 4)) {
goto reset;
}
// Erase application
while (!nvmReady())
;
......@@ -52,6 +59,7 @@ static void banzai() {
while (!nvmReady())
;
reset:
// Reset the device
NVIC_SystemReset() ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment