reset.rst 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. Reset and boot modes
  2. ====================
  3. There are soft resets and hard resets.
  4. - A soft reset simply clears the state of the MicroPython virtual machine,
  5. but leaves hardware peripherals unaffected. To do a soft reset, simply press
  6. **Ctrl+D** on the REPL, or within a script do::
  7. import sys
  8. sys.exit()
  9. - A hard reset is the same as performing a power cycle to the board. In order to
  10. hard reset the WiPy, press the switch on the board or::
  11. import machine
  12. machine.reset()
  13. Safe boot
  14. ---------
  15. If something goes wrong with your WiPy, don't panic! It is almost
  16. impossible for you to break the WiPy by programming the wrong thing.
  17. The first thing to try is to boot in safe mode: this temporarily skips
  18. execution of ``boot.py`` and ``main.py`` and gives default WLAN settings.
  19. If you have problems with the filesystem you can :ref:`format the internal flash
  20. drive <wipy_factory_reset>`.
  21. To boot in safe mode, follow the detailed instructions described :ref:`here <wipy_boot_modes>`.
  22. In safe mode, the ``boot.py`` and ``main.py`` files are not executed, and so
  23. the WiPy boots up with default settings. This means you now have access
  24. to the filesystem, and you can edit ``boot.py`` and ``main.py`` to fix any problems.
  25. Entering safe mode is temporary, and does not make any changes to the
  26. files on the WiPy.
  27. .. _wipy_factory_reset:
  28. Factory reset the filesystem
  29. ----------------------------
  30. If you WiPy's filesystem gets corrupted (very unlikely, but possible), you
  31. can format it very easily by doing::
  32. >>> import os
  33. >>> os.mkfs('/flash')
  34. Resetting the filesystem deletes all files on the internal WiPy storage
  35. (not the SD card), and restores the files ``boot.py`` and ``main.py`` back
  36. to their original state after the next reset.