From 460ece8365600e1a8fdb124c2f68de6aabf1fa62 Mon Sep 17 00:00:00 2001 From: laforge Date: Sat, 23 Sep 2006 14:49:43 +0000 Subject: - 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 --- firmware/src/start/Cstartup.S | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'firmware/src/start') 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 -- cgit v1.2.3