SD card presented via USB should be writable via below, but is still read-only. I thought I tested this 🤦 .
import board
import sdcardio
import storage
import os
cs = board.D10
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"))
except Exception as e:
print("SD mount failed:", e)
while True:
pass