Skip to content

Force boards to start in safe mode #990

@dhalbert

Description

@dhalbert

Sometimes bad code in boot.py or code.py can leave the board in a stuck state with no access to CIRCUITPY or the REPL.

Some ways to get out of this state:

  1. Erase SPI flash: we have some .uf2's that do this. Have to build separately for many different boards, and not sure about QSPI support.
  2. Load a special CircuitPython .uf2 that never runs boot.py or code.py. Again, need to build these, but perhaps friendlier to use, and allows repair of the bad files.
  3. Could we detect triple or quadruple reset button push? I think this would require a UF2 bootloader change.
  4. Force board to start in safe mode. Only the CPX currently has this feature: if you hold down both buttons on boot, CircuitPython will go directly to safe mode.

It would be nice to be able to do 4. on regular boards without extra buttons. We could look for a particular set of pins pulled low or high, but there's always the possibility the user has wired the board in such a way that it might trigger that pattern. But we do have "spare" pins on SWDIO and SWCLK.

SWCLK is not suitable, because if it's held low the board goes into "extended reset", and it's pulled up internally during reset. But perhaps we could detect SWDIO being pulled high or low (as opposed to just floating). But we have to be careful not to interfere with debugger access.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions