From dd32f7be3c56ad7f9cd8ef0ebfbae740ac3b00af Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Wed, 27 Sep 2023 17:11:19 +0200 Subject: [PATCH] bootapp cleanup --- Firmware/Marlin_main.cpp | 5 ++--- Firmware/bootapp.c | 4 ++-- Firmware/bootapp.h | 3 +-- Firmware/optiboot_xflash.cpp | 2 ++ 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index b38c10c91..f6de4fdd2 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -920,7 +920,7 @@ void update_sec_lang_from_external_flash() } } } - boot_app_flags &= ~BOOT_APP_FLG_USER0; + boot_app_magic = 0; } @@ -4092,8 +4092,7 @@ void process_commands() } else if (code_seen_P(PSTR("RESET"))) { // PRUSA RESET #if defined(XFLASH) && defined(BOOTAPP) - boot_app_magic = BOOT_APP_MAGIC; - boot_app_flags = BOOT_APP_FLG_RUN; + boot_app_magic = 0; #endif //defined(XFLASH) && defined(BOOTAPP) softReset(); } diff --git a/Firmware/bootapp.c b/Firmware/bootapp.c index aafaadde2..f68b5e844 100644 --- a/Firmware/bootapp.c +++ b/Firmware/bootapp.c @@ -24,8 +24,7 @@ void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size) { cli(); boot_app_magic = BOOT_APP_MAGIC; - boot_app_flags |= BOOT_APP_FLG_COPY; - boot_app_flags |= BOOT_APP_FLG_ERASE; + boot_app_flags |= BOOT_APP_FLG_COPY | BOOT_APP_FLG_ERASE; boot_copy_size = (uint16_t)size; boot_src_addr = (uint32_t)rptr; boot_dst_addr = (uint32_t)fptr; @@ -38,6 +37,7 @@ void bootapp_reboot_user0(uint8_t reserved) cli(); boot_app_magic = BOOT_APP_MAGIC; boot_app_flags = BOOT_APP_FLG_USER0; + boot_copy_size = 0; boot_reserved = reserved; // bootapp_print_vars(); softReset(); diff --git a/Firmware/bootapp.h b/Firmware/bootapp.h index 9a77c5abd..5c868386f 100644 --- a/Firmware/bootapp.h +++ b/Firmware/bootapp.h @@ -17,11 +17,10 @@ #define BOOT_APP_FLG_ERASE 0x01 #define BOOT_APP_FLG_COPY 0x02 #define BOOT_APP_FLG_FLASH 0x04 -#define BOOT_APP_FLG_RUN 0x08 #define BOOT_APP_FLG_USER0 0x80 -#define BOOT_APP_MAGIC 0x55aa55aa +#define BOOT_APP_MAGIC 0x55aa55aaUL #if defined(__cplusplus) diff --git a/Firmware/optiboot_xflash.cpp b/Firmware/optiboot_xflash.cpp index 791435b83..2b846cdda 100644 --- a/Firmware/optiboot_xflash.cpp +++ b/Firmware/optiboot_xflash.cpp @@ -161,6 +161,8 @@ uint8_t optiboot_xflash_enter() lcd_clear(); lcd_puts_at_P(0, 1, PSTR(" Upgrading xflash\n Do not disconnect!")); + boot_app_magic = 0; //disable the bootapp if a watchdog reset is going to be used + /* Forever loop: exits by causing WDT reset */ for (;;) { /* get character from UART */