Skip to content

Commit 580ec80

Browse files
committed
Bootloader: double-tap doesn't need anymore to reserve SRAM in the sketch
1 parent 810117c commit 580ec80

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

bootloaders/zero/main.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,26 +106,22 @@ static void check_start_application(void)
106106
}
107107
else
108108
{
109-
switch (BOOT_DOUBLE_TAP_DATA) {
110-
case 0:
111-
/* First tap */
112-
BOOT_DOUBLE_TAP_DATA = DOUBLE_TAP_MAGIC;
113-
114-
for (uint32_t i=0; i<125000; i++) /* 500ms */
115-
/* force compiler to not optimize this... */
116-
__asm__ __volatile__("");
117-
118-
/* Timeout happened, continue boot... */
119-
BOOT_DOUBLE_TAP_DATA = 0;
120-
break;
121-
case DOUBLE_TAP_MAGIC:
109+
if (BOOT_DOUBLE_TAP_DATA == DOUBLE_TAP_MAGIC) {
122110
/* Second tap, stay in bootloader */
123111
BOOT_DOUBLE_TAP_DATA = 0;
124112
return;
125-
default:
126-
/* Fallback... reset counter and continue boot */
127-
BOOT_DOUBLE_TAP_DATA = 0;
128113
}
114+
115+
/* First tap */
116+
BOOT_DOUBLE_TAP_DATA = DOUBLE_TAP_MAGIC;
117+
118+
/* Wait 0.5sec to see if the user tap reset again */
119+
for (uint32_t i=0; i<125000; i++) /* 500ms */
120+
/* force compiler to not optimize this... */
121+
__asm__ __volatile__("");
122+
123+
/* Timeout happened, continue boot... */
124+
BOOT_DOUBLE_TAP_DATA = 0;
129125
}
130126
#endif
131127

bootloaders/zero/samd21_sam_ba.bin

-4 Bytes
Binary file not shown.

variants/arduino_zero/linker_scripts/gcc/flash_with_bootloader.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
MEMORY
2727
{
2828
FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */
29-
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000-0x0004 /* Last 4B used by bootloader */
29+
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
3030
}
3131

3232
/* Linker script to place sections and symbol values. Should be used together

0 commit comments

Comments
 (0)