File tree Expand file tree Collapse file tree
shared-bindings/supervisor Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -139,8 +139,10 @@ Behavior
139139 possible to fix code that causes nasty crashes by making it available through mass storage after
140140 the crash. A reset (the button) is needed after it's fixed to get back into normal mode.
141141- Safe mode may be handled programmatically by providing a ``safemode.py ``.
142- ``safemode.py `` is run if the board has reset due to entering safe mode. USB is not
143- available so nothing can be printed. ``safemode.py `` can determine why the safe mode occurred
142+ ``safemode.py `` is run if the board has reset due to entering safe mode, unless the safe mode
143+ initiated by the user by pressing button(s).
144+ USB is not available so nothing can be printed.
145+ ``safemode.py `` can determine why the safe mode occurred
144146 using ``supervisor.runtime.safe_mode_reason ``, and take appropriate action. For instance,
145147 if a hard crash occurred, ``safemode.py `` may do a ``microcontroller.reset() ``
146148 to automatically restart despite the crash.
Original file line number Diff line number Diff line change @@ -733,7 +733,9 @@ vstr_t *boot_output;
733733#if CIRCUITPY_SAFEMODE_PY
734734STATIC void __attribute__ ((noinline )) run_safemode_py (safe_mode_t safe_mode ) {
735735 // Don't run if we aren't in safe mode or we won't be able to find safemode.py.
736- if (safe_mode == SAFE_MODE_NONE || !filesystem_present ()) {
736+ // Also don't run if it's a user-initiated safemode (pressing button(s) during boot),
737+ // since that's deliberate.
738+ if (safe_mode == SAFE_MODE_NONE || safe_mode == SAFE_MODE_USER || !filesystem_present ()) {
737739 return ;
738740 }
739741
Original file line number Diff line number Diff line change @@ -137,7 +137,11 @@ MAKE_ENUM_MAP(supervisor_safe_mode_reason) {
137137 MAKE_ENUM_MAP_ENTRY (safe_mode_reason , USB_TOO_MANY_INTERFACE_NAMES ),
138138
139139//| USER: object
140- //| """The user pressed one or more buttons to enter safe mode."""
140+ //| """The user pressed one or more buttons to enter safe mode.
141+ //| This safe mode does **not** cause ``safemode.py`` to be run, since its purpose
142+ //| is to prevent all user code from running.
143+ //| This allows errors in ``safemode.py`` to be corrected easily.
144+ //| """
141145//|
142146 MAKE_ENUM_MAP_ENTRY (safe_mode_reason , USER ),
143147
You can’t perform that action at this time.
0 commit comments