Content-Length: 988756 | pFad | http://github.com/adafruit/circuitpython/commit/d8231f15886ef43cf3a052c50bca49ec6dd150ff

8E Implement safemode.py · adafruit/circuitpython@d8231f1 · GitHub
Skip to content

Commit d8231f1

Browse files
committed
Implement safemode.py
1 parent 795e46c commit d8231f1

File tree

54 files changed

+494
-338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+494
-338
lines changed

README.rst

+11-3
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,24 @@ Behavior
138138
- Adds a safe mode that does not run user code after a hard crash or brown out. This makes it
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.
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
144+
using ``supervisor.runtime.safe_mode_reason``, and take appropriate action. For instance,
145+
if a hard crash occurred, ``safemode.py`` may do a ``microcontroller.reset()``
146+
to automatically restart despite the crash.
147+
If the battery is low, but is being charged, ``safemode.py`` may put the board in deep sleep
148+
for a while. Or it may simply reset, and have ``code.py`` check the voltage and do the sleep.
141149
- RGB status LED indicating CircuitPython state.
142150
- One green flash - code completed without error.
143151
- Two red flashes - code ended due to an exception.
144152
- Three yellow flashes - safe mode. May be due to CircuitPython internal error.
145153
- Re-runs ``code.py`` or other main file after file system writes by a workflow. (Disable with
146154
``supervisor.disable_autoreload()``)
147155
- Autoreload is disabled while the REPL is active.
148-
- Main is one of these: ``code.txt``, ``code.py``, ``main.py``,
149-
``main.txt``
150-
- Boot is one of these: ``boot.py``, ``boot.txt``
156+
- ``code.py`` may also be named``code.txt``, ``main.py``, or ``main.txt``.
157+
- ``boot.py`` may also be named ``boot.txt``.
158+
- ``safemode.py`` may also be named ``safemode.txt``.
151159

152160
API
153161
~~~

locale/circuitpython.pot

+56-55
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ msgid ""
3535
"https://github.com/adafruit/circuitpython/issues\n"
3636
msgstr ""
3737

38+
#: supervisor/shared/safe_mode.c
39+
msgid ""
40+
"\n"
41+
"To exit, reset the board without requesting safe mode."
42+
msgstr ""
43+
3844
#: py/obj.c
3945
msgid " File \"%q\""
4046
msgstr ""
@@ -85,7 +91,7 @@ msgstr ""
8591
#: ports/raspberrypi/common-hal/alarm/__init__.c
8692
#: ports/raspberrypi/common-hal/analogio/AnalogOut.c
8793
#: ports/raspberrypi/common-hal/rtc/RTC.c ports/stm/common-hal/alarm/__init__.c
88-
#: ports/stm/common-hal/rtc/RTC.c
94+
#: ports/stm/common-hal/canio/Listener.c ports/stm/common-hal/rtc/RTC.c
8995
msgid "%q"
9096
msgstr ""
9197

@@ -589,13 +595,6 @@ msgstr ""
589595
msgid "Both RX and TX required for flow control"
590596
msgstr ""
591597

592-
#: ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h
593-
#: ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h
594-
#: ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h
595-
#: ports/atmel-samd/boards/meowmeow/mpconfigboard.h
596-
msgid "Both buttons were pressed at start up.\n"
597-
msgstr ""
598-
599598
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
600599
msgid "Both pins must support hardware interrupts"
601600
msgstr ""
@@ -661,12 +660,6 @@ msgstr ""
661660
msgid "Bus pin %d is already in use"
662661
msgstr ""
663662

664-
#: ports/espressif/boards/m5stack_core_basic/mpconfigboard.h
665-
#: ports/espressif/boards/m5stack_core_fire/mpconfigboard.h
666-
#: ports/espressif/boards/m5stack_stick_c/mpconfigboard.h
667-
msgid "Button A was pressed at start up.\n"
668-
msgstr ""
669-
670663
#: shared-bindings/_bleio/UUID.c
671664
msgid "Byte buffer must be 16 bytes."
672665
msgstr ""
@@ -934,6 +927,10 @@ msgstr ""
934927
msgid "Error in regex"
935928
msgstr ""
936929

930+
#: supervisor/shared/safe_mode.c
931+
msgid "Error in safemode.py."
932+
msgstr ""
933+
937934
#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c
938935
msgid "Error: Failure to bind"
939936
msgstr ""
@@ -1006,10 +1003,6 @@ msgstr ""
10061003
msgid "Failed to write internal flash."
10071004
msgstr ""
10081005

1009-
#: supervisor/shared/safe_mode.c
1010-
msgid "Fatal error."
1011-
msgstr ""
1012-
10131006
#: py/moduerrno.c
10141007
msgid "File exists"
10151008
msgstr ""
@@ -1209,6 +1202,10 @@ msgstr ""
12091202
msgid "Internal watchdog timer expired."
12101203
msgstr ""
12111204

1205+
#: supervisor/shared/safe_mode.c
1206+
msgid "Interrupt error."
1207+
msgstr ""
1208+
12121209
#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c
12131210
msgid "Invalid %q"
12141211
msgstr ""
@@ -1257,10 +1254,6 @@ msgstr ""
12571254
msgid "Invalid format chunk size"
12581255
msgstr ""
12591256

1260-
#: supervisor/shared/safe_mode.c
1261-
msgid "Invalid memory access."
1262-
msgstr ""
1263-
12641257
#: ports/espressif/common-hal/wifi/Radio.c
12651258
msgid "Invalid multicast MAC address"
12661259
msgstr ""
@@ -1549,10 +1542,6 @@ msgstr ""
15491542
msgid "No timer available"
15501543
msgstr ""
15511544

1552-
#: supervisor/shared/safe_mode.c
1553-
msgid "Nordic system firmware failure assertion."
1554-
msgstr ""
1555-
15561545
#: ports/nrf/common-hal/_bleio/__init__.c
15571546
msgid "Nordic system firmware out of memory"
15581547
msgstr ""
@@ -2003,24 +1992,12 @@ msgstr ""
20031992
msgid "Temperature read timed out"
20041993
msgstr ""
20051994

2006-
#: supervisor/shared/safe_mode.c
2007-
msgid "The BOOT button was pressed at start up.\n"
2008-
msgstr ""
2009-
20101995
#: supervisor/shared/safe_mode.c
20111996
msgid ""
20121997
"The CircuitPython heap was corrupted because the stack was too small.\n"
20131998
"Increase the stack size if you know how. If not:"
20141999
msgstr ""
20152000

2016-
#: ports/espressif/boards/adafruit_feather_esp32_v2/mpconfigboard.h
2017-
msgid "The SW38 button was pressed at start up.\n"
2018-
msgstr ""
2019-
2020-
#: ports/espressif/boards/hardkernel_odroid_go/mpconfigboard.h
2021-
msgid "The VOLUME button was pressed at start up.\n"
2022-
msgstr ""
2023-
20242001
#: supervisor/shared/safe_mode.c
20252002
msgid ""
20262003
"The `microcontroller` module was used to boot into safe mode. Press reset to "
@@ -2031,17 +2008,6 @@ msgstr ""
20312008
msgid "The above exception was the direct cause of the following exception:"
20322009
msgstr ""
20332010

2034-
#: ports/espressif/boards/m5stack_atom_echo/mpconfigboard.h
2035-
#: ports/espressif/boards/m5stack_atom_lite/mpconfigboard.h
2036-
#: ports/espressif/boards/m5stack_atom_matrix/mpconfigboard.h
2037-
#: ports/espressif/boards/m5stack_atom_u/mpconfigboard.h
2038-
msgid "The central button was pressed at start up.\n"
2039-
msgstr ""
2040-
2041-
#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h
2042-
msgid "The left button was pressed at start up.\n"
2043-
msgstr ""
2044-
20452011
#: shared-bindings/rgbmatrix/RGBMatrix.c
20462012
msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30"
20472013
msgstr ""
@@ -2069,6 +2035,10 @@ msgstr ""
20692035
msgid "The sample's signedness does not match the mixer's"
20702036
msgstr ""
20712037

2038+
#: supervisor/shared/safe_mode.c
2039+
msgid "Third-party firmware fatal error."
2040+
msgstr ""
2041+
20722042
#: shared-module/imagecapture/ParallelImageCapture.c
20732043
msgid "This microcontroller does not support continuous capture."
20742044
msgstr ""
@@ -2101,10 +2071,6 @@ msgstr ""
21012071
msgid "Timeout is too long: Maximum timeout length is %d seconds"
21022072
msgstr ""
21032073

2104-
#: supervisor/shared/safe_mode.c
2105-
msgid "To exit, please reset the board without requesting safe mode."
2106-
msgstr ""
2107-
21082074
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
21092075
msgid "Too many channels in sample"
21102076
msgstr ""
@@ -2405,9 +2371,44 @@ msgstr ""
24052371
msgid "You are in safe mode because:\n"
24062372
msgstr ""
24072373

2374+
#: ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h
2375+
#: ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h
2376+
#: ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h
2377+
#: ports/atmel-samd/boards/meowmeow/mpconfigboard.h
2378+
msgid "You pressed both buttons at start up."
2379+
msgstr ""
2380+
2381+
#: ports/espressif/boards/m5stack_core_basic/mpconfigboard.h
2382+
#: ports/espressif/boards/m5stack_core_fire/mpconfigboard.h
2383+
#: ports/espressif/boards/m5stack_stick_c/mpconfigboard.h
2384+
msgid "You pressed button A at start up."
2385+
msgstr ""
2386+
24082387
#: supervisor/shared/safe_mode.c
2409-
msgid ""
2410-
"You pressed the reset button during boot. Press again to exit safe mode."
2388+
msgid "You pressed the BOOT button at start up."
2389+
msgstr ""
2390+
2391+
#: ports/espressif/boards/adafruit_feather_esp32_v2/mpconfigboard.h
2392+
msgid "You pressed the SW38 button at start up."
2393+
msgstr ""
2394+
2395+
#: ports/espressif/boards/hardkernel_odroid_go/mpconfigboard.h
2396+
msgid "You pressed the VOLUME button at start up."
2397+
msgstr ""
2398+
2399+
#: ports/espressif/boards/m5stack_atom_echo/mpconfigboard.h
2400+
#: ports/espressif/boards/m5stack_atom_lite/mpconfigboard.h
2401+
#: ports/espressif/boards/m5stack_atom_matrix/mpconfigboard.h
2402+
#: ports/espressif/boards/m5stack_atom_u/mpconfigboard.h
2403+
msgid "You pressed the central button at start up."
2404+
msgstr ""
2405+
2406+
#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h
2407+
msgid "You pressed the left button at start up."
2408+
msgstr ""
2409+
2410+
#: supervisor/shared/safe_mode.c
2411+
msgid "You pressed the reset button during boot."
24112412
msgstr ""
24122413

24132414
#: py/objtype.c

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/adafruit/circuitpython/commit/d8231f15886ef43cf3a052c50bca49ec6dd150ff

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy