diff options
author | Keith Packard <keithp@keithp.com> | 2015-01-25 19:35:19 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2015-01-25 19:35:19 -0800 |
commit | df881bce8576f091b2d8cb53b8ce8a43aeedecde (patch) | |
tree | 5ee730fc6822f0c5755525212139a709c3a98341 /src/stmf0/ao_interrupt.c | |
parent | 02e1058fa52ee7c867ea6c9031ebb9e21d14889c (diff) |
altos: Add self-flash support for STM32F042 processor
Also moves the usual address for applications out of the way of the
flash loader.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/stmf0/ao_interrupt.c')
-rw-r--r-- | src/stmf0/ao_interrupt.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/stmf0/ao_interrupt.c b/src/stmf0/ao_interrupt.c index 99a88dcb..b6a3147f 100644 --- a/src/stmf0/ao_interrupt.c +++ b/src/stmf0/ao_interrupt.c @@ -20,11 +20,23 @@ #include <string.h> #include <ao_boot.h> +#ifndef IS_FLASH_LOADER +#error Should define IS_FLASH_LOADER +#define IS_FLASH_LOADER 0 +#endif + +#if !IS_FLASH_LOADER +#define RELOCATE_INTERRUPT 1 +#endif + extern void main(void); extern char __stack__; extern char __text_start__, __text_end__; extern char __data_start__, __data_end__; extern char __bss_start__, __bss_end__; +#if RELOCATE_INTERRUPT +extern char __interrupt_rom__, __interrupt_start__, __interrupt_end__; +#endif /* Interrupt functions */ @@ -46,7 +58,7 @@ stm_flash_size(void) { switch (dev_id) { case 0x445: - kbytes = 32; /* assume 32kB until we figure this out */ + kbytes = stm_flash_size_04x.f_size; break; } return (uint32_t) kbytes * 1024; @@ -54,7 +66,6 @@ stm_flash_size(void) { void start(void) { -#if 0 #ifdef AO_BOOT_CHAIN if (ao_boot_check_chain()) { #ifdef AO_BOOT_PIN @@ -62,6 +73,10 @@ void start(void) #endif } #endif +#if RELOCATE_INTERRUPT + memcpy(&__interrupt_start__, &__interrupt_rom__, &__interrupt_end__ - &__interrupt_start__); + stm_syscfg.cfgr1 = (stm_syscfg.cfgr1 & ~(STM_SYSCFG_CFGR1_MEM_MODE_MASK << STM_SYSCFG_CFGR1_MEM_MODE)) | + (STM_SYSCFG_CFGR1_MEM_MODE_SRAM << STM_SYSCFG_CFGR1_MEM_MODE); #endif memcpy(&__data_start__, &__text_end__, &__data_end__ - &__data_start__); memset(&__bss_start__, '\0', &__bss_end__ - &__bss_start__); |