#sd card debugging
1 messages ยท Page 1 of 1 (latest)
Already tried ๐
what is the label shown for the D: drive (or whatever it is)
CIRCUITPY (E:)
but is there an F: drive?
sd inside of CIRCUITPY will show placeholder.txt, but there should be a second drive appearing
ohhhh
Yes there is the F drive
totally overlooked that
Cool yes I can see the file content now
make sure you do an eject after writing to the drive to ensure that the write has completed
it should be read/write to Windows 11. The readonly=True allows that. If you omitted that or said readonly=False, it would be readonly to Windows. readonly is from the point of view of CircuitPython.
only one can be read/write at a time unless you did a storage.remount(..., disable_concurrent_write_protection=True), which is unsafe and totally disrecommended.
in the code it shows readonly=True - when I try to copy a file from win11 file browser to the folder it says not possible because the drive is read-only
hmm, that is not my experience when I tested that. Make sure you are copying to the F: drive, not sd inside E:
Yep trying to copy to F drive
I will try this later on Win11. It was working for me on Linux. If the filesystem is corrupted it might appear as readonly, but I think Windows would have complained about that.
OK
I also noticed the file I copied on the SD chip earlier (using a python script) shows the date to be 31.12.1999
Not sure if that is normal or a bug?
the CIrcuitPython board doesn't know what time it is unless you set the time, so it starts in 2000
ah ok
modulo timezones
It turns out there is a bug I need to fix: https://github.com/adafruit/circuitpython/issues/10657
hope to fix this in the next day or two
๐
I think it's fixed by https://github.com/adafruit/circuitpython/pull/10659.
Note that you will need to modify the program slightly: add
import supervisor
and
supervisor.runtime.autoreload = False
to prevent it from auto-reloading every time you write to the SD card. Here is my test program (note it has a different cs pin than yours, so change it back if you use this)
hmm I don't think it's working for me. It seems to be stuck somehow.
I added a "start" print at the beginning but I don't see it in the console.
import sdcardio
import storage
import os
import time
import supervisor
supervisor.runtime.autoreload = False
print("start")
time.sleep(5)
cs = board.D5
READONLY=False
try:
sdcard = sdcardio.SDCard(board.SPI(), cs, baudrate=24_000_000)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd", readonly=READONLY)
print(f"SD card mounted readonly={READONLY} at /sd")
print("Contents:", os.listdir("/sd"))
try:
with open("/sd/test.txt", "w") as f:
pass
print("/sd is writable from Python")
except:
print("/sd is readonly from Python")
try:
with open("/test.txt", "w") as f:
pass
print("CIRCUITPY is writable from Python")
except:
print("CIRCUITPY is readonly from Python")
except Exception as e:
print("SD mount failed:", e)
while True:
pass```
adding or deleting files with the filebrowser also not possible
Can only read
OK the "start" print I got to work now after removing the code and later adding it again
code.py output:
start
SD card mounted readonly=False at /sd
Contents: ['so', 'test.txt']
/sd is writable from Python
CIRCUITPY is readonly from Python```
But adding files still not possible
set READONLY=True in the program above, which will make it readonly to Python and read/write to the host computer. Sorry, I set that flag so I could flip back and forth easily and left it the wrong way for you.
import sdcardio
import storage
import os
import time
import supervisor
import sys
print(sys.implementation)
supervisor.runtime.autoreload = False
print("start")
time.sleep(5)
cs = board.D5
READONLY=True
try:
sdcard = sdcardio.SDCard(board.SPI(), cs, baudrate=24_000_000)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd", readonly=READONLY)
print(f"SD card mounted readonly={READONLY} at /sd")
print("Contents:", os.listdir("/sd"))
try:
with open("/sd/test.txt", "w") as f:
pass
print("/sd is writable from Python")
except:
print("/sd is readonly from Python")
try:
with open("/test.txt", "w") as f:
pass
print("CIRCUITPY is writable from Python")
except:
print("CIRCUITPY is readonly from Python")
import sys
print(sys.implementation)
except Exception as e:
print("SD mount failed:", e)
while True:
pass```
```SD card mounted readonly=True at /sd
Contents: ['so', 'test.txt']
/sd is readonly from Python
CIRCUITPY is readonly from Python
(name='circuitpython', version=(10, 0, 0, ''), _machine='Adafruit Feather RP2040 Prop-Maker with rp2040', _mpy=774, _build='adafruit_feather_rp2040_prop_maker')```
This is what I have right now
see what is in boot_out.txt or is printed by the REPL
OK with the clean install now it seems to work. I was able to copy a file to it. Thanks!
will do some speed test to see how much faster it is
Another related question - is it possible to install the new UF2 file to an already existing circuitpython drive? (Or do I need to reset it with the buttons?)
Reason I ask is that I installed a couple already in an enclosure where the reset buttons are not accessible - would be a bit of a pain to disassemble it all.
Or is there some workaround I could do?