altos: Always start application if boot pin isn't in use
authorKeith Packard <keithp@keithp.com>
Fri, 24 Jan 2020 01:40:30 +0000 (17:40 -0800)
committerKeith Packard <keithp@keithp.com>
Fri, 24 Jan 2020 01:40:30 +0000 (17:40 -0800)
When there's no 'force boot loader' pin, jump to the application
instead of stopping in the boot loader.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_boot.h
src/lpc/ao_boot_pin.c
src/lpc/ao_interrupt.c
src/stm/ao_boot_pin.c
src/stm/ao_interrupt.c
src/stmf0/ao_boot_pin.c
src/stmf0/ao_interrupt.c

index 0977cf657fffc8bbd9b72f2f78e72d72dcba6130..c11aac1ed2462b2e933751ec1afd79931b1a96e8 100644 (file)
@@ -22,7 +22,8 @@
 void
 ao_boot_chain(uint32_t *base);
 
 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) */
 ao_boot_check_pin(void);
 
 /* Return true to switch to application (if present) */
index a51c7f8d45414d59eb9a47b47adeb54714ebefdd..91acbfd492bc29cddc2cbca1cccc0c27c81784db 100644 (file)
 #include <ao_boot.h>
 #include <ao_exti.h>
 
 #include <ao_boot.h>
 #include <ao_exti.h>
 
-void
+int
 ao_boot_check_pin(void)
 {
        uint16_t v;
 
 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);
        /* 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);
        /* 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;
 }
 }
index 8d71f43f2de38c1f0216d17d18d14b02e82e9559..a479ec6d59585835c508e6e2cff7ce8db47e0c13 100644 (file)
@@ -53,8 +53,11 @@ void start(void) {
 #ifdef AO_BOOT_CHAIN
        if (ao_boot_check_chain()) {
 #ifdef AO_BOOT_PIN
 #ifdef AO_BOOT_CHAIN
        if (ao_boot_check_chain()) {
 #ifdef AO_BOOT_PIN
-               ao_boot_check_pin();
+               if (ao_boot_check_pin())
 #endif
 #endif
+               {
+                       ao_boot_chain(AO_BOOT_APPLICATION_BASE);
+               }
        }
 #endif
 #if RELOCATE_INTERRUPT
        }
 #endif
 #if RELOCATE_INTERRUPT
index 4b5dc2ac480341086e4264284b9345d2e5da299c..f21ce1b251ff5931d5609ebb1926b6d2d68966ed 100644 (file)
@@ -20,7 +20,7 @@
 #include <ao_boot.h>
 #include <ao_exti.h>
 
 #include <ao_boot.h>
 #include <ao_exti.h>
 
-void
+int
 ao_boot_check_pin(void)
 {
        uint16_t v;
 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);
        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;
 }
 }
index d8be36670baf608726adfa910b9aa70e4b31d5ed..1d563532b755cf7f1144400803ef0a034536febb 100644 (file)
@@ -77,8 +77,11 @@ void start(void)
 #ifdef AO_BOOT_CHAIN
        if (ao_boot_check_chain()) {
 #ifdef AO_BOOT_PIN
 #ifdef AO_BOOT_CHAIN
        if (ao_boot_check_chain()) {
 #ifdef AO_BOOT_PIN
-               ao_boot_check_pin();
+               if (ao_boot_check_pin())
 #endif
 #endif
+               {
+                       ao_boot_chain(AO_BOOT_APPLICATION_BASE);
+               }
        }
 #endif
        /* Set interrupt vector table offset */
        }
 #endif
        /* Set interrupt vector table offset */
index 4b5dc2ac480341086e4264284b9345d2e5da299c..f21ce1b251ff5931d5609ebb1926b6d2d68966ed 100644 (file)
@@ -20,7 +20,7 @@
 #include <ao_boot.h>
 #include <ao_exti.h>
 
 #include <ao_boot.h>
 #include <ao_exti.h>
 
-void
+int
 ao_boot_check_pin(void)
 {
        uint16_t v;
 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);
        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;
 }
 }
index 0025de47153445bbf6d5df961c54726dab0d4c23..1ee6e720091be2e277fca3b26536fd559caea35d 100644 (file)
@@ -72,8 +72,11 @@ void start(void)
 #if AO_BOOT_CHAIN
        if (ao_boot_check_chain()) {
 #if AO_BOOT_PIN
 #if AO_BOOT_CHAIN
        if (ao_boot_check_chain()) {
 #if AO_BOOT_PIN
-               ao_boot_check_pin();
+               if (ao_boot_check_pin())
 #endif
 #endif
+               {
+                       ao_boot_chain(AO_BOOT_APPLICATION_BASE);
+               }
        }
 #endif
        /* Turn on syscfg */
        }
 #endif
        /* Turn on syscfg */