improve DFU_SUPPORT

This commit is contained in:
NIIBE Yutaka 2012-05-29 09:04:41 +09:00
parent 8d8e67f1ad
commit e2ab8c9183
4 changed files with 22 additions and 17 deletions

View File

@ -1,5 +1,11 @@
2012-05-29 Niibe Yutaka <gniibe@fsij.org>
* 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.

View File

@ -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

View File

@ -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)

View File

@ -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");
}