File tree Expand file tree Collapse file tree 5 files changed +39
-3
lines changed
variants/arduino_zero/linker_scripts/gcc Expand file tree Collapse file tree 5 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,32 @@ static void check_start_application(void)
9797 led_port -> DIRSET .reg = (1 <<30 );
9898 led_port -> OUTCLR .reg = (1 <<30 );
9999
100+ #if defined(BOOT_DOUBLE_TAP_ADDRESS )
101+ if (PM -> RCAUSE .bit .POR )
102+ {
103+ /* On power-on initialize double-tap */
104+ BOOT_DOUBLE_TAP_DATA = 0 ;
105+ }
106+ else
107+ {
108+ if (BOOT_DOUBLE_TAP_DATA == 0 ) {
109+ /* First tap */
110+ BOOT_DOUBLE_TAP_DATA = 1 ;
111+
112+ for (uint32_t i = 0 ; i < 50000 ; i ++ ) /* 200ms */
113+ /* force compiler to not optimize this... */
114+ __asm__ __volatile__("" );
115+
116+ /* Timeout happened, continue boot... */
117+ BOOT_DOUBLE_TAP_DATA = 0 ;
118+ } else {
119+ /* Second tap, stay in bootloader */
120+ BOOT_DOUBLE_TAP_DATA = 0 ;
121+ return ;
122+ }
123+ }
124+ #endif
125+
100126 uint32_t app_start_address ;
101127
102128 /* Load the Reset Handler address of the application */
Original file line number Diff line number Diff line change 3434#define CPU_FREQUENCY 8000000
3535
3636#define APP_START_ADDRESS 0x00002000
37+
38+ /*
39+ * If BOOT_DOUBLE_TAP_ADDRESS is defined the bootloader is started by
40+ * quickly tapping two times on the reset button.
41+ * BOOT_DOUBLE_TAP_ADDRESS must point to a free SRAM cell that must not
42+ * be touched from the loaded application.
43+ */
44+ #define BOOT_DOUBLE_TAP_ADDRESS 0x20007FFC
45+ #define BOOT_DOUBLE_TAP_DATA (*((volatile uint32_t *) BOOT_DOUBLE_TAP_ADDRESS))
46+
3747#define BOOT_LOAD_PIN PIN_PA21 //Pin 7
3848//#define BOOT_LOAD_PIN PIN_PA15 //Pin 5
3949#define BOOT_PIN_MASK (1U << (BOOT_LOAD_PIN & 0x1f))
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ SEARCH_DIR(.)
5050MEMORY
5151{
5252 rom (rx) : ORIGIN = 0x00000000 , LENGTH = 0x00040000
53- ram (rwx) : ORIGIN = 0x20000000 , LENGTH = 0x00008000
53+ ram (rwx) : ORIGIN = 0x20000000 , LENGTH = 0x00008000 - 0x0004 /* 4 bytes used by bootloader to keep data between resets */
5454}
5555
5656/* The stack size used by the application. NOTE: you need to adjust according to your application. */
Original file line number Diff line number Diff line change 2525 */
2626MEMORY
2727{
28- FLASH (rx) : ORIGIN = 0x00000000 +0x2000 , LENGTH = 0x00040000 -0x2000
29- RAM (rwx) : ORIGIN = 0x20000000 , LENGTH = 0x00008000
28+ 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 */
3030}
3131
3232/* Linker script to place sections and symbol values. Should be used together
You can’t perform that action at this time.
0 commit comments