From 5b500e4e34ecae3d5aaa61604f8a45326150b022 Mon Sep 17 00:00:00 2001 From: Mike Nix Date: Fri, 22 Nov 2019 09:37:12 +0800 Subject: [PATCH] Move eboot_command_clear to after firmware copy. (#6823) The eboot command was cleared from the rtc mem before the firmware copy making it possible for a power failure during an OTA update to brick the esp until the firmware was loaded via USB because of a partial firmware copy that would never be restarted. Moving the eboot_command_clear to after the copy ensures that any partial copy is restarted at next power on. --- bootloaders/eboot/eboot.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bootloaders/eboot/eboot.c b/bootloaders/eboot/eboot.c index 69bc692e9..a640f9130 100644 --- a/bootloaders/eboot/eboot.c +++ b/bootloaders/eboot/eboot.c @@ -128,13 +128,14 @@ int copy_raw(const uint32_t src_addr, void main() { int res = 9; + bool clear_cmd = false; struct eboot_command cmd; print_version(0); if (eboot_command_read(&cmd) == 0) { // valid command was passed via RTC_MEM - eboot_command_clear(); + clear_cmd = true; ets_putc('@'); } else { // no valid command found @@ -155,6 +156,10 @@ void main() } } + if (clear_cmd) { + eboot_command_clear(); + } + if (cmd.action == ACTION_LOAD_APP) { ets_putc('l'); ets_putc('d'); ets_putc('\n'); res = load_app_from_flash_raw(cmd.args[0]);