From 772b5f1cb625fba1396a57b47498ef805ae1a9a8 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 1 May 2018 23:36:16 -0700 Subject: altos/stmf0: Change tests for AO_BOOT_CHAIN and AO_BOOT_PIN to #if Were #ifdef, which meant that #define AO_BOOT_PIN 0 didn't work right. Signed-off-by: Keith Packard --- src/stmf0/ao_interrupt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/stmf0/ao_interrupt.c') diff --git a/src/stmf0/ao_interrupt.c b/src/stmf0/ao_interrupt.c index fcd330f1..0d6f6113 100644 --- a/src/stmf0/ao_interrupt.c +++ b/src/stmf0/ao_interrupt.c @@ -69,9 +69,9 @@ stm_flash_size(void) { void start(void) { -#ifdef AO_BOOT_CHAIN +#if AO_BOOT_CHAIN if (ao_boot_check_chain()) { -#ifdef AO_BOOT_PIN +#if AO_BOOT_PIN ao_boot_check_pin(); #endif } -- cgit v1.2.3 From 08e543cd8b761e4cbbfa97404fcd5394f65a0e9e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 1 May 2018 23:44:00 -0700 Subject: altos/stmf0: Set 0x0 mapping to Main Flash for boot loader When DFU finishes loading firmware and jumps to the application, it leaves the mapping of addresses starting at 0x0 set to System flash, which prevents the boot loader from receiving interrupts and requires a power cycle during flash & cal. Signed-off-by: Keith Packard --- src/stmf0/ao_interrupt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/stmf0/ao_interrupt.c') diff --git a/src/stmf0/ao_interrupt.c b/src/stmf0/ao_interrupt.c index 0d6f6113..a67f6f1a 100644 --- a/src/stmf0/ao_interrupt.c +++ b/src/stmf0/ao_interrupt.c @@ -76,13 +76,17 @@ void start(void) #endif } #endif -#if RELOCATE_INTERRUPT /* Turn on syscfg */ stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_SYSCFGCOMPEN); +#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); +#else + /* Switch to Main Flash mode (DFU loader leaves us in System mode) */ + stm_syscfg.cfgr1 = (stm_syscfg.cfgr1 & ~(STM_SYSCFG_CFGR1_MEM_MODE_MASK << STM_SYSCFG_CFGR1_MEM_MODE)) | + (STM_SYSCFG_CFGR1_MEM_MODE_MAIN_FLASH << STM_SYSCFG_CFGR1_MEM_MODE); #endif memcpy(&__data_start__, &__text_end__, &__data_end__ - &__data_start__); memset(&__bss_start__, '\0', &__bss_end__ - &__bss_start__); -- cgit v1.2.3