From: Keith Packard Date: Fri, 24 Jan 2020 01:40:30 +0000 (-0800) Subject: altos: Always start application if boot pin isn't in use X-Git-Tag: altosdroid-1.9.1~3 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=ffbf340c516a7fff7c95b808586f623269fe4338 altos: Always start application if boot pin isn't in use When there's no 'force boot loader' pin, jump to the application instead of stopping in the boot loader. Signed-off-by: Keith Packard --- diff --git a/src/kernel/ao_boot.h b/src/kernel/ao_boot.h index 0977cf65..c11aac1e 100644 --- a/src/kernel/ao_boot.h +++ b/src/kernel/ao_boot.h @@ -22,7 +22,8 @@ void ao_boot_chain(uint32_t *base); -void +/* Return true to switch to application */ +int ao_boot_check_pin(void); /* Return true to switch to application (if present) */ diff --git a/src/lpc/ao_boot_pin.c b/src/lpc/ao_boot_pin.c index a51c7f8d..91acbfd4 100644 --- a/src/lpc/ao_boot_pin.c +++ b/src/lpc/ao_boot_pin.c @@ -20,14 +20,11 @@ #include #include -void +int ao_boot_check_pin(void) { uint16_t v; - /* Enable power interface clock */ -// stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_PWREN); - /* Enable the input pin */ ao_enable_input(AO_BOOT_APPLICATION_GPIO, AO_BOOT_APPLICATION_PIN, AO_BOOT_APPLICATION_MODE); @@ -41,7 +38,5 @@ ao_boot_check_pin(void) /* Reset the chip to turn off the port and the power interface clock */ ao_gpio_set_mode(AO_BOOT_APPLICATION_GPIO, AO_BOOT_APPLICATION_PIN, 0); ao_disable_port(AO_BOOT_APPLICATION_GPIO); -// stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_PWREN); - if (v == AO_BOOT_APPLICATION_VALUE) - ao_boot_chain(AO_BOOT_APPLICATION_BASE); + return v == AO_BOOT_APPLICATION_VALUE; } diff --git a/src/lpc/ao_interrupt.c b/src/lpc/ao_interrupt.c index 8d71f43f..a479ec6d 100644 --- a/src/lpc/ao_interrupt.c +++ b/src/lpc/ao_interrupt.c @@ -53,8 +53,11 @@ void start(void) { #ifdef AO_BOOT_CHAIN if (ao_boot_check_chain()) { #ifdef AO_BOOT_PIN - ao_boot_check_pin(); + if (ao_boot_check_pin()) #endif + { + ao_boot_chain(AO_BOOT_APPLICATION_BASE); + } } #endif #if RELOCATE_INTERRUPT diff --git a/src/stm/ao_boot_pin.c b/src/stm/ao_boot_pin.c index 4b5dc2ac..f21ce1b2 100644 --- a/src/stm/ao_boot_pin.c +++ b/src/stm/ao_boot_pin.c @@ -20,7 +20,7 @@ #include #include -void +int ao_boot_check_pin(void) { uint16_t v; @@ -42,6 +42,5 @@ ao_boot_check_pin(void) ao_gpio_set_mode(&AO_BOOT_APPLICATION_GPIO, AO_BOOT_APPLICATION_PIN, 0); ao_disable_port(&AO_BOOT_APPLICATION_GPIO); stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_PWREN); - if (v == AO_BOOT_APPLICATION_VALUE) - ao_boot_chain(AO_BOOT_APPLICATION_BASE); + return v == AO_BOOT_APPLICATION_VALUE; } diff --git a/src/stm/ao_interrupt.c b/src/stm/ao_interrupt.c index d8be3667..1d563532 100644 --- a/src/stm/ao_interrupt.c +++ b/src/stm/ao_interrupt.c @@ -77,8 +77,11 @@ void start(void) #ifdef AO_BOOT_CHAIN if (ao_boot_check_chain()) { #ifdef AO_BOOT_PIN - ao_boot_check_pin(); + if (ao_boot_check_pin()) #endif + { + ao_boot_chain(AO_BOOT_APPLICATION_BASE); + } } #endif /* Set interrupt vector table offset */ diff --git a/src/stmf0/ao_boot_pin.c b/src/stmf0/ao_boot_pin.c index 4b5dc2ac..f21ce1b2 100644 --- a/src/stmf0/ao_boot_pin.c +++ b/src/stmf0/ao_boot_pin.c @@ -20,7 +20,7 @@ #include #include -void +int ao_boot_check_pin(void) { uint16_t v; @@ -42,6 +42,5 @@ ao_boot_check_pin(void) ao_gpio_set_mode(&AO_BOOT_APPLICATION_GPIO, AO_BOOT_APPLICATION_PIN, 0); ao_disable_port(&AO_BOOT_APPLICATION_GPIO); stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_PWREN); - if (v == AO_BOOT_APPLICATION_VALUE) - ao_boot_chain(AO_BOOT_APPLICATION_BASE); + return v == AO_BOOT_APPLICATION_VALUE; } diff --git a/src/stmf0/ao_interrupt.c b/src/stmf0/ao_interrupt.c index 0025de47..1ee6e720 100644 --- a/src/stmf0/ao_interrupt.c +++ b/src/stmf0/ao_interrupt.c @@ -72,8 +72,11 @@ void start(void) #if AO_BOOT_CHAIN if (ao_boot_check_chain()) { #if AO_BOOT_PIN - ao_boot_check_pin(); + if (ao_boot_check_pin()) #endif + { + ao_boot_chain(AO_BOOT_APPLICATION_BASE); + } } #endif /* Turn on syscfg */