don't enter safemode.py on USER safe mode
This commit is contained in:
parent
0f099cdb31
commit
328585f160
@ -139,8 +139,10 @@ Behavior
|
||||
possible to fix code that causes nasty crashes by making it available through mass storage after
|
||||
the crash. A reset (the button) is needed after it's fixed to get back into normal mode.
|
||||
- Safe mode may be handled programmatically by providing a ``safemode.py``.
|
||||
``safemode.py`` is run if the board has reset due to entering safe mode. USB is not
|
||||
available so nothing can be printed. ``safemode.py`` can determine why the safe mode occurred
|
||||
``safemode.py`` is run if the board has reset due to entering safe mode, unless the safe mode
|
||||
initiated by the user by pressing button(s).
|
||||
USB is not available so nothing can be printed.
|
||||
``safemode.py`` can determine why the safe mode occurred
|
||||
using ``supervisor.runtime.safe_mode_reason``, and take appropriate action. For instance,
|
||||
if a hard crash occurred, ``safemode.py`` may do a ``microcontroller.reset()``
|
||||
to automatically restart despite the crash.
|
||||
|
4
main.c
4
main.c
@ -733,7 +733,9 @@ vstr_t *boot_output;
|
||||
#if CIRCUITPY_SAFEMODE_PY
|
||||
STATIC void __attribute__ ((noinline)) run_safemode_py(safe_mode_t safe_mode) {
|
||||
// Don't run if we aren't in safe mode or we won't be able to find safemode.py.
|
||||
if (safe_mode == SAFE_MODE_NONE || !filesystem_present()) {
|
||||
// Also don't run if it's a user-initiated safemode (pressing button(s) during boot),
|
||||
// since that's deliberate.
|
||||
if (safe_mode == SAFE_MODE_NONE || safe_mode == SAFE_MODE_USER || !filesystem_present()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,11 @@ MAKE_ENUM_MAP(supervisor_safe_mode_reason) {
|
||||
MAKE_ENUM_MAP_ENTRY(safe_mode_reason, USB_TOO_MANY_INTERFACE_NAMES),
|
||||
|
||||
//| USER: object
|
||||
//| """The user pressed one or more buttons to enter safe mode."""
|
||||
//| """The user pressed one or more buttons to enter safe mode.
|
||||
//| This safe mode does **not** cause ``safemode.py`` to be run, since its purpose
|
||||
//| is to prevent all user code from running.
|
||||
//| This allows errors in ``safemode.py`` to be corrected easily.
|
||||
//| """
|
||||
//|
|
||||
MAKE_ENUM_MAP_ENTRY(safe_mode_reason, USER),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user