Fix MK2.5 softReset()
This commit is contained in:
parent
4d87f65b68
commit
451f601697
|
|
@ -688,7 +688,24 @@ void failstats_reset_print()
|
||||||
void softReset()
|
void softReset()
|
||||||
{
|
{
|
||||||
cli();
|
cli();
|
||||||
wdt_enable(WDTO_15MS);
|
#ifdef WATCHDOG
|
||||||
|
// If the watchdog support is enabled, use that for resetting. The timeout value is customized
|
||||||
|
// for each board since the miniRambo ships with a bootloader which doesn't properly handle the
|
||||||
|
// WDT. In order to avoid bootlooping, the watchdog is set to a value large enough for the
|
||||||
|
// usual timeout of the bootloader to pass.
|
||||||
|
wdt_enable(WATCHDOG_SOFT_RESET_VALUE);
|
||||||
|
#else
|
||||||
|
#warning WATCHDOG not defined. See the following comment for more details about the implications
|
||||||
|
// In case the watchdog is not enabled, the reset is acomplished by jumping to the bootloader
|
||||||
|
// vector manually. This however is somewhat dangerous since the peripherals don't get reset
|
||||||
|
// by this operation. Considering this is not going to be used in any production firmware,
|
||||||
|
// it can be left as is and just be cautious with it. The only way to accomplish a peripheral
|
||||||
|
// reset is by an external reset, by a watchdog reset or by a power cycle. All of these options
|
||||||
|
// can't be accomplished just from software. One way to minimize the dangers of this is by
|
||||||
|
// setting all dangerous pins to INPUT before jumping to the bootloader, but that still doesn't
|
||||||
|
// reset other peripherals such as UART, timers, INT, PCINT, etc...
|
||||||
|
asm volatile("jmp 0x3E000");
|
||||||
|
#endif
|
||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4273,17 +4290,13 @@ void process_commands()
|
||||||
MMU2::mmu2.Reset(MMU2::MMU2::Software);
|
MMU2::mmu2.Reset(MMU2::MMU2::Software);
|
||||||
}
|
}
|
||||||
else if (code_seen_P(PSTR("RESET"))) { // PRUSA RESET
|
else if (code_seen_P(PSTR("RESET"))) { // PRUSA RESET
|
||||||
#ifdef WATCHDOG
|
|
||||||
#if defined(XFLASH) && defined(BOOTAPP)
|
#if defined(XFLASH) && defined(BOOTAPP)
|
||||||
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;
|
||||||
#endif //defined(XFLASH) && defined(BOOTAPP)
|
#endif //defined(XFLASH) && defined(BOOTAPP)
|
||||||
softReset();
|
softReset();
|
||||||
#elif defined(BOOTAPP) //this is a safety precaution. This is because the new bootloader turns off the heaters, but the old one doesn't. The watchdog should be used most of the time.
|
}
|
||||||
asm volatile("jmp 0x3E000");
|
else if (code_seen_P(PSTR("SN"))) { // PRUSA SN
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (code_seen_P(PSTR("SN"))) { // PRUSA SN
|
|
||||||
char SN[20];
|
char SN[20];
|
||||||
eeprom_read_block(SN, (uint8_t*)EEPROM_PRUSA_SN, 20);
|
eeprom_read_block(SN, (uint8_t*)EEPROM_PRUSA_SN, 20);
|
||||||
if (SN[19])
|
if (SN[19])
|
||||||
|
|
|
||||||
|
|
@ -55,9 +55,7 @@ static void putch(char ch) {
|
||||||
static void verifySpace() {
|
static void verifySpace() {
|
||||||
if (getch() != CRC_EOP) {
|
if (getch() != CRC_EOP) {
|
||||||
putch(STK_FAILED);
|
putch(STK_FAILED);
|
||||||
wdt_enable(WDTO_15MS); // shorten WD timeout
|
softReset();
|
||||||
while (1) // and busy-loop so that WD causes
|
|
||||||
; // a reset and app start.
|
|
||||||
}
|
}
|
||||||
putch(STK_INSYNC);
|
putch(STK_INSYNC);
|
||||||
}
|
}
|
||||||
|
|
@ -300,7 +298,7 @@ uint8_t optiboot_xflash_enter()
|
||||||
}
|
}
|
||||||
else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
|
else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
|
||||||
// Adaboot no-wait mod
|
// Adaboot no-wait mod
|
||||||
wdt_enable(WDTO_15MS);
|
wdt_enable(WATCHDOG_SOFT_RESET_VALUE);
|
||||||
verifySpace();
|
verifySpace();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#define XFLASH // external 256kB flash
|
#define XFLASH // external 256kB flash
|
||||||
#define BOOTAPP // bootloader support
|
#define BOOTAPP // bootloader support
|
||||||
|
#define WATCHDOG_SOFT_RESET_VALUE WDTO_15MS
|
||||||
|
|
||||||
#define XFLASH_PIN_CS 32
|
#define XFLASH_PIN_CS 32
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#define SWI2C_SDA 20 //SDA on P3
|
#define SWI2C_SDA 20 //SDA on P3
|
||||||
#define SWI2C_SCL 84 //PH2 on P3, sensor cable must be rewired
|
#define SWI2C_SCL 84 //PH2 on P3, sensor cable must be rewired
|
||||||
|
|
||||||
|
#define WATCHDOG_SOFT_RESET_VALUE WDTO_2S
|
||||||
|
|
||||||
|
|
||||||
#define X_STEP_PIN 37
|
#define X_STEP_PIN 37
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
#define D_REQUIRE 23 //Z_MAX (white)
|
#define D_REQUIRE 23 //Z_MAX (white)
|
||||||
#endif //MICROMETER_LOGGING
|
#endif //MICROMETER_LOGGING
|
||||||
|
|
||||||
|
#define WATCHDOG_SOFT_RESET_VALUE WDTO_2S
|
||||||
|
|
||||||
|
|
||||||
#define X_STEP_PIN 37
|
#define X_STEP_PIN 37
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue