How to persistently save code py file and start it from circuitpython without pc connection - By Andy

Author :  Andy

Hello all!

I just bought Gamebuino META and exploring Python Language with my child. If we save our "" file into Cortex's flash from Mu editor - all works perfectly, program correctly starts and run. But after exit from Circuit Python "" will automatically erase from flash and progam can not be started again without Mu.

Is anybody knows how to save Python program persistently and start it from CircuitPython without a PC connection? I didn't found any docs about this problem.



Author :  Thierry

I just received my Gamebuino and did not had time to try, but there are several file names convetion available.

Did you try with instead of

Author :  jicehel

atm the program have to be named to be executed by Meta but you can copy / paste your code in Notepad and make a save with the name you want (a more meaning name ...)

Author :  Thierry

from circuitpython documentation:

CircuitPython looks for a code file on the board to run. There are four options: code.txt,, main.txt and CircuitPython looks for those files, in that order, and then runs the first one it finds. While we suggest using as your code file, it is important to know that the other options exist. If your program doesn't seem to be updating as you work, make sure you haven't created another code file that's being read instead of the one you're working on.

So in your case, it should already work... 

Author :  Steph

Hi Andy,

Indeed, the content of the CIRCUITPY volume is volatile... I do not believe that it is currently possible to keep its contents after the volume has been unmounted. In addition, the volume can be unmounted suddenly. It is therefore prudent not to work directly on it... unless your code editor can keep your file, even if the volume has been unmounted.

However, if you are on macOS (like me), you can use a handy tool called fswatch to monitor a folder and execute a shell command when an event is detected in the observed folder. fswatch can therefore observe the folder that contains all your Pyhton scripts and, as soon as one of them is modified (saved), copy it to CIRCUITPY with the appropriate name ( or

fswatch is available on GitHub. But you can also install it by using Homebrew:

brew install fswatch

Then, open a Terminal and go to the directory that contains your Python scripts. Then execute the following command:

fswatch -0 . | while read -d "" file; do   \
  if [ ${file: -3} == ".py" ]; then        \
    cp ${file} /Volumes/CIRCUITPY/; \
  fi;                                      \

Each time you modify a Python script in this folder, it will automatically be copied to CIRCUITPY with the name

Author :  Steph

For Linux, you can use the software suite inotify-tools :

apt install inotify-tools

In particular, look at the inotifywait program:

inotifywait simply blocks for inotify events, making it appropriate for use in shell scripts.
Author :  Steph

If you're on Windows... sorry, I can't help you :-(

Author :  Thierry

Wait what ?

python files are not persisted ?

Author :  Thierry

Now that I have my Meta, I was able to test this.

And it is strange: the file is still on the gamebuino, I can see it in my file browser.

It is just not seen by CircuitMetaPython, don't know why.

Author :  olav

Thank you for porting CircuitPython to the META. I have tried v0.0.3 on both Linux and Windows 10. While on Windows I get the CIRCUITPY disk and can store and execute from it, on Linux, Python crashes after pressing "A" with "Error 2 - Hard Fault".

Author :  Sorunome

Currently, with these early versions of CircuitPython to gamebuino, if you exit circuitpython your program does indeed get erased. This means that you will need to copy the file again from your computer after loading CircuitPython again. So it is very good for quick testing and learning! More permanent storage still has to come

Author :  Sorunome

what is your file are you trying to use?

Author :  Andy

Hello All! Big thanx for all answers, folks. 


We using Mu on Windows 7 and all works good). But thanks for very useful way to keep program updated (we plan to buy Rasberry Pi and wrote Python programs on it).


There are four options: code.txt,, main.txt and

Ok, thanks, it also useful we will checks this) 


Currently, with these early versions of CircuitPython to gamebuino, if you exit circuitpython your program does indeed get erased. 

It's sad to hear this(. IMHO it isn't hard to improve - need to allow CircuitPython grab code.txt,, main.txt or from root folder of SD-card).

what is your file are you trying to use?

Just a simple game - cannon fires a bullet, that fly with parabolic path and must hit a target -). My son starts to learn physics on his school and we wants to apply knowledge -)


On Linux V0.0.4 works fine and the file is not persistent on CIRCUITPY :-(.
The REPL works with "screen /dev/ttyACM0 -b 115200"
That rocks !

Author :  Sorunome

as mentioned in this thread, unfortunately this stuff isn't persistent yet