From e2ab8c91832725c6b0d3a2c57c1cfd2acf11ade8 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 29 May 2012 09:04:41 +0900 Subject: [PATCH] improve DFU_SUPPORT --- ChangeLog | 6 ++++++ polarssl-0.14.0/library/aes.c | 6 +++--- src/gnuk.ld.in | 4 +++- src/sys.c | 23 ++++++++++------------- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 99cd90d..4afe3f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2012-05-29 Niibe Yutaka + * src/sys.c (reset): Don't depend if DFU_SUPPORT or not. + + * polarssl-0.14.0/library/aes.c (FT0, FT1, FT2): Specify sections + in detail, so that addresses won't be affected by compiler. + * src/gnuk.ld.in (.sys): Define sections in detail. + * boards/STBEE_MINI/board.h (SET_USB_CONDITION, GPIO_USB) (IOPORT_USB, SET_LED_CONDITION, GPIO_LED, IOPORT_LED) (FLASH_PAGE_SIZE): New. diff --git a/polarssl-0.14.0/library/aes.c b/polarssl-0.14.0/library/aes.c index 4f87e88..ea4904c 100644 --- a/polarssl-0.14.0/library/aes.c +++ b/polarssl-0.14.0/library/aes.c @@ -172,15 +172,15 @@ static const unsigned char FSb[256] = V(CB,B0,B0,7B), V(FC,54,54,A8), V(D6,BB,BB,6D), V(3A,16,16,2C) #define V(a,b,c,d) 0x##a##b##c##d -static const unsigned long FT0[256] __attribute__((section(".sys"))) = { FT }; +static const unsigned long FT0[256] __attribute__((section(".sys.0"))) = { FT }; #undef V #define V(a,b,c,d) 0x##b##c##d##a -static const unsigned long FT1[256] __attribute__((section(".sys"))) = { FT }; +static const unsigned long FT1[256] __attribute__((section(".sys.1"))) = { FT }; #undef V #define V(a,b,c,d) 0x##c##d##a##b -static const unsigned long FT2[256] __attribute__((section(".sys"))) = { FT }; +static const unsigned long FT2[256] __attribute__((section(".sys.2"))) = { FT }; #undef V #define V(a,b,c,d) 0x##d##a##b##c diff --git a/src/gnuk.ld.in b/src/gnuk.ld.in index 26506cc..b9ff5f9 100644 --- a/src/gnuk.ld.in +++ b/src/gnuk.ld.in @@ -57,7 +57,9 @@ SECTIONS sys.o(.rodata) sys.o(.rodata.*) . = ALIGN(1024); - *(.sys) + *(.sys.0) + *(.sys.1) + *(.sys.2) } > flash0 .text : ALIGN(16) SUBALIGN(16) diff --git a/src/sys.c b/src/sys.c index 92246f2..2e6e98e 100644 --- a/src/sys.c +++ b/src/sys.c @@ -1,4 +1,3 @@ -#include "config.h" #include "ch.h" #include "hal.h" #include "board.h" @@ -252,20 +251,18 @@ nvic_system_reset (void) static void __attribute__ ((naked)) reset (void) { - asm volatile ("cpsid i\n\t" /* Mask all interrupts */ - "mov.w r0, #0xed00\n\t" /* SCR */ + asm volatile ("cpsid i\n\t" /* Mask all interrupts. */ + "mov.w r0, #0xed00\n\t" /* r0 = SCR */ "movt r0, #0xe000\n\t" -#ifdef DFU_SUPPORT - "mov.w r1, #0x4000\n\t" /* 0x08004000 */ - "movt r1, #0x0800\n\t" -#else - "mov.w r1, #0x1000\n\t" /* 0x08001000 */ - "movt r1, #0x0800\n\t" -#endif - "str r1, [r0, #8]\n\t" /* Set SCR->VCR */ + "mov r1, pc\n\t" /* r1 = (PC + 0x1000) & ~0x0fff */ + "mov r2, #0x1000\n\t" + "add r1, r1, r2\n\t" + "sub r2, r2, #1\n\t" + "bic r1, r1, r2\n\t" + "str r1, [r0, #8]\n\t" /* Set SCR->VCR */ "ldr r0, [r1], #4\n\t" - "msr MSP, r0\n\t" /* Main (exception handler) stack */ - "ldr r0, [r1]\n\t" /* Reset handler */ + "msr MSP, r0\n\t" /* Main (exception handler) stack. */ + "ldr r0, [r1]\n\t" /* Reset handler. */ "bx r0\n" : /* no output */ : /* no input */ : "memory"); }