#define FILE_AN_ISSUE translate("\r\nPlease file an issue with the contents of your CIRCUITPY drive at \nhttps://github.com/adafruit/circuitpython/issues\r\n")
voidprint_safe_mode_message(safe_mode_treason){
if(reason==NO_SAFE_MODE){
return;
}
serial_write("\r\n");
// Output a user safe mode string if its set.
// Output a user safe mode string if it's set.
#ifdef BOARD_USER_SAFE_MODE
if(reason==USER_SAFE_MODE){
serial_write_compressed(translate("You requested starting safe mode by "));
serial_write(BOARD_USER_SAFE_MODE_ACTION);
serial_write("\r\n");
serial_write_compressed(translate("To exit, please reset the board without "));
serial_write_compressed(translate("\r\nTo exit, please reset the board without "));
serial_write(BOARD_USER_SAFE_MODE_ACTION);
serial_write("\r\n");
}else
#endif
if(reason==MANUAL_SAFE_MODE){
serial_write_compressed(translate("The reset button was pressed while booting CircuitPython. Press again to exit safe mode.\n"));
}elseif(reason==PROGRAMMATIC_SAFE_MODE){
serial_write_compressed(translate("The `microcontroller` module was used to boot into safe mode. Press reset to exit safe mode.\n"));
}else{
serial_write_compressed(translate("You are running in safe mode which means something unanticipated happened.\n"));
serial_write_compressed(translate("Looks like our core CircuitPython code crashed hard. Whoops!\nPlease file an issue at https://github.com/adafruit/circuitpython/issues\n with the contents of your CIRCUITPY drive and this message:\n"));
if(reason==HARD_CRASH){
serial_write_compressed(translate("Crash into the HardFault_Handler.\n"));
serial_write_compressed(translate("Attempted heap allocation when MicroPython VM not running.\n"));
}
}elseif(reason==BROWNOUT){
serial_write_compressed(translate("The microcontroller's power dipped. Please make sure your power supply provides\nenough power for the whole circuit and press reset (after ejecting CIRCUITPY).\n"));
}elseif(reason==HEAP_OVERWRITTEN){
serial_write_compressed(translate("The CircuitPython heap was corrupted because the stack was too small.\nPlease increase stack size limits and press reset (after ejecting CIRCUITPY).\nIf you didn't change the stack, then file an issue here with the contents of your CIRCUITPY drive:\n"));
serial_write_compressed(translate("CircuitPython is in safe mode because you pressed the reset button during boot. Press again to exit safe mode.\r\n"));
return;
casePROGRAMMATIC_SAFE_MODE:
serial_write_compressed(translate("The `microcontroller` module was used to boot into safe mode. Press reset to exit safe mode.\r\n"));
return;
default:
break;
}
}
serial_write_compressed(translate("You are in safe mode: something unanticipated happened.\r\n"));
switch(reason){
caseBROWNOUT:
serial_write_compressed(translate("The microcontroller's power dipped. Make sure your power supply provides\r\nenough power for the whole circuit and press reset (after ejecting CIRCUITPY).\r\n"));
return;
caseHEAP_OVERWRITTEN:
serial_write_compressed(translate("The CircuitPython heap was corrupted because the stack was too small.\r\nPlease increase the stack size if you know how, or if not:"));