#sd card debugging

1 messages ยท Page 1 of 1 (latest)

hexed trout
#

starting a thread

#

do an F5 in the Explorer window

tulip vigil
#

Already tried ๐Ÿ˜„

hexed trout
#

what is the label shown for the D: drive (or whatever it is)

tulip vigil
#

CIRCUITPY (E:)

hexed trout
#

but is there an F: drive?

#

sd inside of CIRCUITPY will show placeholder.txt, but there should be a second drive appearing

tulip vigil
#

ohhhh

#

Yes there is the F drive

#

totally overlooked that

#

Cool yes I can see the file content now

hexed trout
#

make sure you do an eject after writing to the drive to ensure that the write has completed

tulip vigil
#

Thanks!

#

Can I only read from it or also write files to it?

hexed trout
#

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.

tulip vigil
#

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

hexed trout
#

hmm, that is not my experience when I tested that. Make sure you are copying to the F: drive, not sd inside E:

tulip vigil
#

Yep trying to copy to F drive

hexed trout
#

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.

tulip vigil
#

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?

hexed trout
#

the CIrcuitPython board doesn't know what time it is unless you set the time, so it starts in 2000

tulip vigil
#

ah ok

hexed trout
#

modulo timezones

hexed trout
#

hope to fix this in the next day or two

tulip vigil
#

๐Ÿ‘

hexed trout
#

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)

tulip vigil
#

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

hexed trout
tulip vigil
#
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

hexed trout
#

is it working? Are you using the PR1059 UF2 I linked to above?

#

10.0.0 will not work

tulip vigil
#

I did copy the UF2 file on the board

#

I'll try a clean install again

hexed trout
#

see what is in boot_out.txt or is printed by the REPL

tulip vigil
#

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

tulip vigil
#

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?