summaryrefslogtreecommitdiff
path: root/firmware/src/start
diff options
context:
space:
mode:
authorlaforge <laforge@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2006-09-23 14:49:43 +0000
committerlaforge <laforge@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2006-09-23 14:49:43 +0000
commit460ece8365600e1a8fdb124c2f68de6aabf1fa62 (patch)
tree21f3e26aad4886bfa425e377ea859d67ec0a6c83 /firmware/src/start
parentd23fda3be353e64852ae04fd03f1cfc4326fec7f (diff)
- Implement runtime DFU switching and reset-after-update. This means
we can now reflash without any buttons or replugging of the device git-svn-id: https://svn.openpcd.org:2342/trunk@222 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'firmware/src/start')
-rw-r--r--firmware/src/start/Cstartup.S24
1 files changed, 24 insertions, 0 deletions
diff --git a/firmware/src/start/Cstartup.S b/firmware/src/start/Cstartup.S
index a750039..990dbcb 100644
--- a/firmware/src/start/Cstartup.S
+++ b/firmware/src/start/Cstartup.S
@@ -35,8 +35,12 @@
//*- 1.1 01/Apr/05 JPP : save SPSR
//*-----------------------------------------------------------------------------*/
+/* Enable DFU by press of hardware POI_BOOTLDR switch */
#define CONFIG_DFU_SWITCH
+/* Enable DFU by magic value in RAM and software reset */
+#define CONFIG_DFU_MAGIC
+
//#define DEBUG_LL
#ifdef DEBUG_LL
@@ -301,6 +305,12 @@ InitReset:
.EQU I_BIT, 0x80
.EQU F_BIT, 0x40
+
+#define AT91C_RSTC_RSR 0xFFFFFD04
+#define AT91C_RSTC_RSTTYP_SOFTWARE (0x03 << 8)
+#define DFU_STATE_appDETACH 1
+
+
/*------------------------------------------------------------------------------
//*- Setup the stack for each mode
//*-------------------------------*/
@@ -319,6 +329,20 @@ InitReset:
msr CPSR_c, #ARM_MODE_SVC
mov r13, r0 /* Init stack Sup */
+#ifdef CONFIG_DFU_MAGIC
+ ldr r1, =AT91C_RSTC_RSR
+ ldr r2, [r1]
+ #and r2, r2, AT91C_RSTC_RSTTYP
+ tst r2, #AT91C_RSTC_RSTTYP_SOFTWARE
+ beq dfu_magic_end
+
+ ldr r1, =dfu_state
+ ldr r2, [r1]
+ cmp r2, #DFU_STATE_appDETACH
+ beq _reloc_dfu
+dfu_magic_end:
+#endif
+
# Relocate DFU .data.shared section (Copy from ROM to RAM)
LDR R1, =_etext
LDR R2, =_data_shared
personal git repositories of Harald Welte. Your mileage may vary