circuitpython: Corrupted FS when writing to SD Card

executing this code has repeatedly resulted in a corrupted FS with teh current master CP 3.0 It often fails to allocate enough memory, but sometime runs. If it does all seem ok for awhile -then the FS seem to just disappear… I have reproduced this on a feather_m0_express and on a feather_m0_supersized. Both with a featherwing Adalogger attached.

# Initialize and mount SD card of Featherboard adalogger
import board
import busio
import digitalio
import adafruit_pcf8523
import adafruit_sdcard
import storage
import adafruit_dht

# create the SPI bus and a digital output for the microSD card's c\s line
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
cs = digitalio.DigitalInOut(board.D5)


# create the microSD card object and the filesystem object
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)

# mount the microSD card's filesystem into the CircuitPython filesystem
storage.mount(vfs, "/sd")

# Now ready to read and write data from the sd card
with open("/sd/test.txt", "w") as f:
    f.write("Hello world!\r\n")

# open a file and read a line from it with similar code
with open("/sd/test.txt", "r") as f:
    print("Read line from file:")
    print(f.readline())

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 79

Most upvoted comments

@jerryneedell or just clone it fresh: git clone https://github.com/rhooper/circuitpython rh-circuitpython or similar

@jerryneedell

git remote add rhooper git@github.com:rhooper/circuitpython.git
git fetch rhooper
git checkout rhooper/no-space-savings