micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

Raspberry Pi Pico and SD Card module

Open catietravers33 opened this issue 2 years ago • 1 comments

Hi there,

I've been trying really hard to sort out this error with wiring and looking at other forums but just cannot work it out.

This is the error message I get when using sdcard.py: Traceback (most recent call last): File "", line 19, in File "sdcard.py", line 231, in readblocks OSError: [Errno 5] EIO

And this is the code I am calling it from: import machine import sdcard, uos import time

cs = machine.Pin(13, machine.Pin.OUT)

Intialize SPI peripheral (start with 1 MHz)

spi = machine.SPI(1, baudrate=1000000, polarity=0, phase=0, bits=8, firstbit=machine.SPI.MSB, sck=machine.Pin(14), mosi=machine.Pin(15), miso=machine.Pin(12)) sd = sdcard.SDCard(spi, cs) time.sleep_ms(500) vfs = uos.VfsFat(sd) uos.mount(vfs, "/sd") #uos.mount(sd, '/sd') time.sleep_ms(500) print(uos.listdir('/sd'))

If anyone could help that would be appreciated!

catietravers33 avatar Sep 15 '23 04:09 catietravers33

sdcard resets the SPI baudrate to 1320000 (default) so there's no point doing it in the SPI constructor.

If you want to change it do it here:-

sd = sdcard.SDCard(spi, cs,baudrate=<whatever you want>)

I have set it to 20,000,000 and can read my sandisk ultra sdcard. See my issue #990 posted today.

I never got 25,000,000 to work, but that may just be my sdcard hdw.

BNNorman avatar Mar 25 '25 11:03 BNNorman