From 54447a45a0671600a70adf2cc24de29a1f447a49 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Wed, 4 Jun 2014 10:47:55 +0200 Subject: [PATCH] Bootloader now accessible with left OR right trim inwards --- radio/src/loadboot.cpp | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/radio/src/loadboot.cpp b/radio/src/loadboot.cpp index 947b75d05..03f928480 100644 --- a/radio/src/loadboot.cpp +++ b/radio/src/loadboot.cpp @@ -100,30 +100,28 @@ void _bootStart() bwdt_reset(); } - if ((GPIOE->IDR & 0x00000008) == 0) { - if ((GPIOC->IDR & 0x00000002) == 0) { - // Bootloader needed - const uint8_t *src; - uint8_t *dest; - uint32_t size; + if (((GPIOC->IDR & 0x00000002) == 0) || ((GPIOE->IDR & 0x00000008) == 0)) { + // Bootloader needed + const uint8_t *src; + uint8_t *dest; + uint32_t size; - bwdt_reset(); - size = sizeof(BootCode); - src = BootCode; - dest = (uint8_t *) 0x20000000; - - for (; size; size -= 1) { - *dest++ = *src++; - } - // Could check for a valid copy to RAM here - // Go execute bootloader - bwdt_reset(); - - uint32_t address = *(uint32_t *) 0x20000004; - - ((void (*)(void)) (address))(); // Go execute the loaded application + bwdt_reset(); + size = sizeof(BootCode); + src = BootCode; + dest = (uint8_t *) 0x20000000; + for (; size; size -= 1) { + *dest++ = *src++; } + // Could check for a valid copy to RAM here + // Go execute bootloader + bwdt_reset(); + + uint32_t address = *(uint32_t *) 0x20000004; + + ((void (*)(void)) (address))(); // Go execute the loaded application + } // run_application() ;