Skip to content

Input/output error when SD card connects to Host computer during flush #10779

@justmobilize

Description

@justmobilize

CircuitPython version and board name

Adafruit CircuitPython 10.0.3 on 2025-10-17; FeatherS3 with ESP32S3

Code/REPL

import board
import sdcardio
import storage
import time

def test(sleep=False, flush=False):
  spi = board.SPI()
  cs = board.IO33
  sdcard = sdcardio.SDCard(spi, cs)
  vfs = storage.VfsFat(sdcard)
  storage.mount(vfs, "/sd")
  
  if sleep:
    time.sleep(5)
  
  with open("/sd/test.txt", "w") as f:
    for i in range(200):
      print(i)
      f.write(f"{i}")
      if flush:
        f.flush()

Behavior

Running test(sleep=False, flush=True) will fail on 10.0.3, somewhere after around 50 writes. Roughly the same time, I get a popup about the drive being available. If I don't flush, it doesn't error either.

This doesn't happen on 9.2.x since the drive doesn't show up.

If I have something running and plug it into my laptop to see logs - it will die, because the drive will be detected (so horrible when my laptop goes to sleep and then I wake it up).

Description

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions