2017-08-31 17:52:02 -04:00
Troubleshooting
2017-09-01 14:44:31 -04:00
===============
2017-08-31 17:52:02 -04:00
From time to time, an error occurs when working with CircuitPython. Here are a
variety of errors that can happen, what they mean and how to fix them.
File system issues
2017-09-01 14:44:31 -04:00
------------------
2017-08-31 17:52:02 -04:00
2017-09-01 14:44:31 -04:00
If your host computer starts complaining that your `` CIRCUITPY `` drive is corrupted
2017-08-31 17:52:02 -04:00
or files cannot be overwritten or deleted, then you will have to erase it completely.
2017-09-01 14:44:31 -04:00
When CircuitPython restarts it will create a fresh empty `` CIRCUITPY `` filesystem.
2017-08-31 17:52:02 -04:00
2021-10-29 18:15:48 -04:00
Corruption often happens on Windows when the `` CIRCUITPY `` disk is not safely ejected
2017-08-31 17:52:02 -04:00
before being reset by the button or being disconnected from USB. This can also
2020-12-09 10:52:18 -05:00
happen on Linux and Mac OSX but it's less likely.
2017-08-31 17:52:02 -04:00
2017-11-14 10:58:26 -05:00
.. caution :: To erase and re-create `` CIRCUITPY `` (for example, to correct a corrupted filesystem),
follow one of the procedures below. It's important to note that **any files stored on the**
2021-10-29 18:15:48 -04:00
`` CIRCUITPY `` **drive will be erased. Back up your code if possible before continuing!**
2017-09-01 14:44:31 -04:00
2021-10-29 16:40:51 -04:00
REPL Erase Method
^^^^^^^^^^^^^^^^^
2021-10-29 18:15:48 -04:00
This is the recommended method of erasing your board. If you are having trouble accessing the
`` CIRCUITPY `` drive or the REPL, consider first putting your board into
`safe mode <https://learn.adafruit.com/welcome-to-circuitpython/troubleshooting#safe-mode-3105351-22> `_ .
**To erase any board if you have access to the REPL:**
2021-10-29 16:40:51 -04:00
#. Connect to the CircuitPython REPL using a terminal program.
#. Type `` import storage `` into the REPL.
#. Then, type `` storage.erase_filesystem() `` into the REPL.
#. The `` CIRCUITPY `` drive will be erased and the board will restart with an empty `` CIRCUITPY `` drive.
Erase File Method
^^^^^^^^^^^^^^^^^
2021-10-29 18:15:48 -04:00
**If you do not have access to the REPL, you may still have options to erase your board.**
2017-11-14 10:58:26 -05:00
2021-11-02 13:52:40 -04:00
The `Erase CIRCUITPY Without Access to the REPL <https://learn.adafruit.com/welcome-to-circuitpython/troubleshooting#erase-circuitpy-without-access-to-the-repl-3105309-32> `_
2021-10-29 18:15:48 -04:00
section of the Troubleshooting page in the Welcome to CircuitPython guide covers the non-REPL
erase process for various boards. Visit the guide, find the process that applies to your board,
and follow the instructions to erase your board.
2017-11-14 10:58:26 -05:00
2017-09-01 14:44:31 -04:00
ValueError: Incompatible `` .mpy `` file.
---------------------------------------
2017-08-31 17:52:02 -04:00
2017-09-01 14:44:31 -04:00
This error occurs when importing a module that is stored as a `` mpy `` binary file
(rather than a `` py `` text file) that was generated by a different version of
2020-12-09 10:52:18 -05:00
CircuitPython than the one it's being loaded into. Most versions are compatible
2017-09-01 14:44:31 -04:00
but, rarely they aren't. In particular, the `` mpy `` binary format changed between
2021-05-23 03:51:35 -04:00
CircuitPython versions 1.x and 2.x, 2.x and 3.x, and will change again between 6.x and 7.x.
2017-08-31 17:52:02 -04:00
2021-05-23 03:51:35 -04:00
So, for instance, if you just upgraded to CircuitPython 7.x from 6.x you'll need to download a
2017-09-01 14:44:31 -04:00
newer version of the library that triggered the error on `` import `` . They are
all available in the
2017-08-31 17:52:02 -04:00
`Adafruit bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest> `_
and the `Community bundle <https://github.com/adafruit/CircuitPython_Community_Bundle/releases/latest> `_ .
2021-05-23 03:51:35 -04:00
Make sure to download a version with 7.0.0 or higher in the filename.