Reboot after factory reset

This commit is contained in:
Alex Voinea 2020-08-12 12:46:35 +03:00
parent 6b853a4cc3
commit 5530b99882
No known key found for this signature in database
GPG Key ID: F5034E7CFCF2F973
4 changed files with 18 additions and 16 deletions

View File

@ -226,9 +226,7 @@ void dcode_0()
LOG("D0 - Reset\n"); LOG("D0 - Reset\n");
if (code_seen('B')) //bootloader if (code_seen('B')) //bootloader
{ {
cli(); softReset();
wdt_enable(WDTO_15MS);
while(1);
} }
else //reset else //reset
{ {
@ -252,8 +250,7 @@ void dcode_1()
cli(); cli();
for (int i = 0; i < 8192; i++) for (int i = 0; i < 8192; i++)
eeprom_write_byte((unsigned char*)i, (unsigned char)0xff); eeprom_write_byte((unsigned char*)i, (unsigned char)0xff);
wdt_enable(WDTO_15MS); softReset();
while(1);
} }
/*! /*!
@ -420,8 +417,7 @@ void dcode_5()
boot_dst_addr = (uint32_t)address; boot_dst_addr = (uint32_t)address;
boot_src_addr = (uint32_t)(&data); boot_src_addr = (uint32_t)(&data);
bootapp_print_vars(); bootapp_print_vars();
wdt_enable(WDTO_15MS); softReset();
while(1);
} }
while (count) while (count)
{ {
@ -467,8 +463,7 @@ void dcode_7()
boot_copy_size = (uint16_t)0xc00; boot_copy_size = (uint16_t)0xc00;
boot_src_addr = (uint32_t)0x0003e400; boot_src_addr = (uint32_t)0x0003e400;
boot_dst_addr = (uint32_t)0x0003f400; boot_dst_addr = (uint32_t)0x0003f400;
wdt_enable(WDTO_15MS); softReset();
while(1);
*/ */
} }

View File

@ -512,4 +512,6 @@ void load_filament_final_feed();
void marlin_wait_for_click(); void marlin_wait_for_click();
void raise_z_above(float target, bool plan=true); void raise_z_above(float target, bool plan=true);
void softReset();
#endif #endif

View File

@ -762,6 +762,7 @@ static void factory_reset(char level)
} }
} }
softReset();
break; break;
@ -3813,9 +3814,7 @@ void process_commands()
#if (defined(WATCHDOG) && (MOTHERBOARD == BOARD_EINSY_1_0a)) #if (defined(WATCHDOG) && (MOTHERBOARD == BOARD_EINSY_1_0a))
boot_app_magic = BOOT_APP_MAGIC; boot_app_magic = BOOT_APP_MAGIC;
boot_app_flags = BOOT_APP_FLG_RUN; boot_app_flags = BOOT_APP_FLG_RUN;
wdt_enable(WDTO_15MS); softReset();
cli();
while(1);
#else //WATCHDOG #else //WATCHDOG
asm volatile("jmp 0x3E000"); asm volatile("jmp 0x3E000");
#endif //WATCHDOG #endif //WATCHDOG
@ -11716,6 +11715,12 @@ void disable_force_z()
#endif // TMC2130 #endif // TMC2130
} }
void softReset()
{
cli();
wdt_enable(WDTO_15MS);
while(1);
}
void enable_force_z() void enable_force_z()
{ {

View File

@ -9,6 +9,8 @@
extern FILE _uartout; extern FILE _uartout;
#define uartout (&_uartout) #define uartout (&_uartout)
extern void softReset();
void bootapp_print_vars(void) void bootapp_print_vars(void)
{ {
fprintf_P(uartout, PSTR("boot_src_addr =0x%08lx\n"), boot_src_addr); fprintf_P(uartout, PSTR("boot_src_addr =0x%08lx\n"), boot_src_addr);
@ -39,8 +41,7 @@ void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size)
boot_src_addr = (uint32_t)rptr; boot_src_addr = (uint32_t)rptr;
boot_dst_addr = (uint32_t)fptr; boot_dst_addr = (uint32_t)fptr;
bootapp_print_vars(); bootapp_print_vars();
wdt_enable(WDTO_15MS); softReset();
while(1);
} }
void bootapp_reboot_user0(uint8_t reserved) void bootapp_reboot_user0(uint8_t reserved)
@ -50,6 +51,5 @@ void bootapp_reboot_user0(uint8_t reserved)
boot_app_flags = BOOT_APP_FLG_USER0; boot_app_flags = BOOT_APP_FLG_USER0;
boot_reserved = reserved; boot_reserved = reserved;
bootapp_print_vars(); bootapp_print_vars();
wdt_enable(WDTO_15MS); softReset();
while(1);
} }