From 796b1b50006fc77620a4d1ac642371c6bbb697d5 Mon Sep 17 00:00:00 2001 From: Peter Henn Date: Wed, 29 Dec 2021 14:49:37 +0000 Subject: [PATCH] Fix leave Bootloader only in case of valid application code - Check, if reset vector points to an application before leaving the Bootloader after 5 seconds timeout - Bugfix wrong test of reset vector from mainline --- Bootloaders/DFU/BootloaderDFU.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c index f29af3b51..ce76abe29 100644 --- a/Bootloaders/DFU/BootloaderDFU.c +++ b/Bootloaders/DFU/BootloaderDFU.c @@ -237,7 +237,10 @@ int main(void) Delay_MS(1); if (i++ > 5000) { - break; + if (pgm_read_word_near(0) != 0xFFFF) + break; + else + i = 0; } } else @@ -836,7 +839,7 @@ static void ProcessWriteCommand(void) else // Start via jump { /* Set the flag to terminate the bootloader at next opportunity if a valid application has been loaded */ - if (pgm_read_word_near(0) == 0xFFFF) + if (pgm_read_word_near(0) != 0xFFFF) RunBootloader = false; } } -- 2.11.0