circuitpython: [pygamer] IOError when reading files from SD card

Hi, I just figure out that there is a ‘slight’ difference when reading files from the flash or from the SD card.

Version: master (6/16/2019)

File generation (copied to the flash and to the SD card

time dd if=/dev/urandom of=test.dat bs=1 count=1M

Code:

import sys
import os
import adafruit_sdcard
import board
import busio
import digitalio
import storage

# Connect to the card and mount the filesystem.
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board.SD_CS)
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")
sys.path.append("/sd")
os.chdir("/sd")

buf = bytearray(160*128)
f = open('test.dat', 'rb')
f.readinto(buf)
f.close()

Results on the SD card:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 5] Input/output error

works well from the flash. os.listdir() works, files located on the SD card are shown

Any idea when I can check ? Libraries ?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

So I tested on 3 more micro SD cards:

SD Card class type size Read speed Access time Results
Sandisk 4 SDHC 8 GB 46.8 MB/s 0.53 ms Failed
Team 4 SDHC 8 GB 22.5MB/s 1.48 ms Success
Sandisk ultra 10 SDXC 128 GB 86.2 MB/s 0.45 ms Failed
Sandisk ultra 10 SDHC 8 GB 45.9 MB/s 0.69 ms Failed

Read speed and Access time are measured with gnome-disk Benchmark tool

I did not expect the cheap slow card to be the only one working 😄