DFU support for reGNUal upgrade
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
2012-05-29 Niibe Yutaka <gniibe@fsij.org>
|
||||
|
||||
* src/main.c (main) [DFU_SUPPORT]: Kill DFU and install .sys.
|
||||
|
||||
* src/config.h.in (FLASH_PAGE_SIZE): New.
|
||||
* src/configure: Support FLASH_PAGE_SIZE for config.h
|
||||
* boards/*/board.h (FLASH_PAGE_SIZE): Remove.
|
||||
* src/flash.c (FLASH_PAGE_SIZE): Remove.
|
||||
|
||||
* src/sys.c (reset): Don't depend if DFU_SUPPORT or not.
|
||||
(flash_erase_all_and_exec): Rename and change the argument.
|
||||
* src/gnuk.ld.in (__flash_start__): Real flash ROM address,
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#define SET_LED_CONDITION(on) on /* To emit light, call palSetPad */
|
||||
#define GPIO_LED GPIOC_LED
|
||||
#define IOPORT_LED GPIOC
|
||||
#define FLASH_PAGE_SIZE 1024
|
||||
|
||||
/*
|
||||
* Board identifier.
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#define IOPORT_USB GPIOA
|
||||
#define GPIO_LED GPIOB_LED
|
||||
#define IOPORT_LED GPIOB
|
||||
#define FLASH_PAGE_SIZE 1024
|
||||
|
||||
/*
|
||||
* Board identifier.
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#define IOPORT_USB GPIOA
|
||||
#define GPIO_LED GPIOA_LED
|
||||
#define IOPORT_LED GPIOA
|
||||
#define FLASH_PAGE_SIZE 1024
|
||||
|
||||
/*
|
||||
* Board identifier.
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#define IOPORT_USB GPIOC
|
||||
#define GPIO_LED GPIOC_LED
|
||||
#define IOPORT_LED GPIOC
|
||||
#define FLASH_PAGE_SIZE 1024
|
||||
|
||||
/*
|
||||
* Board identifier.
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#define IOPORT_USB GPIOD
|
||||
#define GPIO_LED GPIOD_LED1
|
||||
#define IOPORT_LED GPIOD
|
||||
#define FLASH_PAGE_SIZE 2048
|
||||
|
||||
/*
|
||||
* Board identifier.
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#define IOPORT_USB GPIOA
|
||||
#define GPIO_LED GPIOA_LED1
|
||||
#define IOPORT_LED GPIOA
|
||||
#define FLASH_PAGE_SIZE 1024
|
||||
|
||||
/*
|
||||
* Board identifier.
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#define IOPORT_USB GPIOD
|
||||
#define GPIO_LED GPIOE_LEDR
|
||||
#define IOPORT_LED GPIOE
|
||||
#define FLASH_PAGE_SIZE 2048
|
||||
|
||||
/*
|
||||
* Board identifier.
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#define SET_LED_CONDITION(on) on /* To emit light, call palSetPad */
|
||||
#define GPIO_LED GPIOA_LED
|
||||
#define IOPORT_LED GPIOA
|
||||
#define FLASH_PAGE_SIZE 1024
|
||||
|
||||
/*
|
||||
* Board identifier.
|
||||
|
||||
@@ -6,3 +6,4 @@
|
||||
@PINPAD_DEFINE@
|
||||
@PINPAD_MORE_DEFINE@
|
||||
@CERTDO_DEFINE@
|
||||
#define FLASH_PAGE_SIZE @FLASH_PAGE_SIZE@
|
||||
|
||||
1
src/configure
vendored
1
src/configure
vendored
@@ -238,5 +238,6 @@ sed -e "s/@DEBUG_DEFINE@/$DEBUG_DEFINE/" \
|
||||
-e "s/@PINPAD_DEFINE@/$PINPAD_DEFINE/" \
|
||||
-e "s/@PINPAD_MORE_DEFINE@/$PINPAD_MORE_DEFINE/" \
|
||||
-e "s/@CERTDO_DEFINE@/$CERTDO_DEFINE/" \
|
||||
-e "s/@FLASH_PAGE_SIZE@/$FLASH_PAGE_SIZE/" \
|
||||
< config.h.in > config.h
|
||||
exit 0
|
||||
|
||||
@@ -56,11 +56,6 @@
|
||||
* 1.5-KiB Key store (512-byte (p, q and N) key-store * 3)
|
||||
*/
|
||||
#define FLASH_DATA_POOL_HEADER_SIZE 2
|
||||
#if defined(STM32F10X_HD)
|
||||
#define FLASH_PAGE_SIZE 2048
|
||||
#else
|
||||
#define FLASH_PAGE_SIZE 1024
|
||||
#endif
|
||||
#define FLASH_DATA_POOL_SIZE (FLASH_PAGE_SIZE*2)
|
||||
#define FLASH_KEYSTORE_SIZE (512*3)
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ SECTIONS
|
||||
|
||||
.sys : ALIGN(16) SUBALIGN(16)
|
||||
{
|
||||
_sys = .;
|
||||
KEEP(*(.vectors))
|
||||
sys.o(.text)
|
||||
sys.o(.text.*)
|
||||
|
||||
25
src/main.c
25
src/main.c
@@ -483,8 +483,31 @@ main (int argc, char *argv[])
|
||||
port_disable ();
|
||||
/* Set vector */
|
||||
SCB->VTOR = (uint32_t)&_regnual_start;
|
||||
/* Leave Gnuk */
|
||||
#ifdef DFU_SUPPORT
|
||||
#define FLASH_SYS_START_ADDR 0x08000000
|
||||
#define FLASH_SYS_END_ADDR (0x08000000+0x1000)
|
||||
{
|
||||
extern uint8_t _sys;
|
||||
uint32_t addr;
|
||||
handler *new_vector = (handler *)FLASH_SYS_START_ADDR;
|
||||
void (*func) (void (*)(void)) = (void (*)(void (*)(void)))new_vector[10];
|
||||
|
||||
/* Kill DFU */
|
||||
for (addr = FLASH_SYS_START_ADDR; addr < FLASH_SYS_END_ADDR;
|
||||
addr += FLASH_PAGE_SIZE)
|
||||
flash_erase_page (addr);
|
||||
|
||||
/* copy system service routines */
|
||||
flash_write (FLASH_SYS_START_ADDR, &_sys, 0x1000);
|
||||
|
||||
/* Leave Gnuk to exec reGNUal */
|
||||
(*func) (*((void (**)(void))(&_regnual_start+4)));
|
||||
for (;;);
|
||||
}
|
||||
#else
|
||||
/* Leave Gnuk to exec reGNUal */
|
||||
flash_erase_all_and_exec (*((void (**)(void))(&_regnual_start+4)));
|
||||
#endif
|
||||
|
||||
/* Never reached */
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user