Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

Pyportal media is write protected
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Pyportal media is write protected

by cr2n on Wed Mar 17, 2021 11:19 pm

I am making a game for my portable PyPortal (M4 with DigiKey silkscreen) and I want to write a game save to the local disk so that when it is restarted, the user can continue where they left off. I am working in Windows 10, and I am using adafruit-circuitpython-bundle-6.x.

I followed the instructions for writing to the filesystem here, using MU IDE for the REPL commands. Files I created in Notepad++ I dragged and dropped to CIRCUITPY drive.
https://learn.adafruit.com/cpu-temperature-logging-with-circuit-python/writing-to-the-filesystem#.

I did not press a reset button at any time, I just dragged and dropped the boot.py to the PyPortal and also a code.py with the code in that tutorial to write a text file to disk, ejected CIRCUITPY drive from Windows, turned on the PyPortal (I built the portable PyPortal Case with battery), then connected it with USB to find that the tmp.txt file had been written from my code.py file.

Now, however, I am unable to rename the boot.py file to restore write permissions to the PyPortal to continue developing my game,

I get this error in MU editor using the REPL feature:
Code: Select all | TOGGLE FULL SIZE
Jupyter QtConsole 4.3.1
Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

import os
os.chdir('E:')
os.rename("/boot.py","/boot.bak")
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
<ipython-input-3-543624381742> in <module>()
----> 1 os.rename("/boot.py","/boot.bak")

PermissionError: [WinError 19] The media is write protected: '/boot.py' -> '/boot.bak'


The tutorial seemed simple enough but I don't really know the impact of any actions I might take now.
I appreciate any suggestions or if there is a different tutorial I should read or perhaps a different approach such as writing to the SD card, I will gladly accept those ideas too. But first, I need to restore write permissions from USB.

Any suggestions?

cr2n
 
Posts: 24
Joined: Mon Mar 31, 2014 9:41 pm

Re: Pyportal media is write protected

by dastels on Thu Mar 18, 2021 11:04 am

You need to do that in the CircuitPython REPL:
Code: Select all | TOGGLE FULL SIZE
>>> import os
>>> os.listdir("/")
>>> os.rename("/boot.py", "/boot.bak")


Dave

dastels
 
Posts: 6111
Joined: Tue Oct 20, 2015 3:22 pm

Re: Pyportal media is write protected

by cr2n on Thu Mar 18, 2021 3:19 pm

That was it.
My mistake was to have previously changed the MODE in MU to Python3 which then displayed a REPL button, which was the wrong REPL.
I switched Mode to Adfafruit CircuitPython, then the Serial Console button appeared and then I was able to reach CircuitPython REPL.
Thank you for your patience and quick response.

cr2n
 
Posts: 24
Joined: Mon Mar 31, 2014 9:41 pm

Re: Pyportal media is write protected

by dastels on Thu Mar 18, 2021 4:12 pm

I'm glad it worked out!

Dave

dastels
 
Posts: 6111
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.