File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed
shared-bindings/supervisor Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -139,8 +139,10 @@ Behavior
139
139
possible to fix code that causes nasty crashes by making it available through mass storage after
140
140
the crash. A reset (the button) is needed after it's fixed to get back into normal mode.
141
141
- 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
144
146
using ``supervisor.runtime.safe_mode_reason ``, and take appropriate action. For instance,
145
147
if a hard crash occurred, ``safemode.py `` may do a ``microcontroller.reset() ``
146
148
to automatically restart despite the crash.
Original file line number Diff line number Diff line change @@ -733,7 +733,9 @@ vstr_t *boot_output;
733
733
#if CIRCUITPY_SAFEMODE_PY
734
734
STATIC void __attribute__ ((noinline )) run_safemode_py (safe_mode_t safe_mode ) {
735
735
// 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 ()) {
737
739
return ;
738
740
}
739
741
Original file line number Diff line number Diff line change @@ -137,7 +137,11 @@ MAKE_ENUM_MAP(supervisor_safe_mode_reason) {
137
137
MAKE_ENUM_MAP_ENTRY (safe_mode_reason , USB_TOO_MANY_INTERFACE_NAMES ),
138
138
139
139
//| 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
+ //| """
141
145
//|
142
146
MAKE_ENUM_MAP_ENTRY (safe_mode_reason , USER ),
143
147
You can’t perform that action at this time.
0 commit comments