circuitpython: SPI SD Cards don't mount both when on the same SPI bus
CircuitPython version
Adafruit CircuitPython 7.2.0 on 2022-17-4; Raspberry Pi Pico with rp2040
Code/REPL
import time
import board, busio, digitalio
import os, storage
from sdcardio import SDCard
spi = busio.SPI(clock=board.GP18, MOSI=board.GP19, MISO=board.GP16)
sdcs1_pin = board.GP6
sdcs2_pin = board.GP7
print("Starting")
sd1 = SDCard(spi, sdcs1_pin)
vfs1 = storage.VfsFat(sd1)
storage.mount(vfs1, "/sd1")
print("SD 1 Mounted")
print(os.listdir("/sd1"))
storage.umount(vfs1)
sd2 = SDCard(spi, sdcs2_pin)
vfs2 = storage.VfsFat(sd2)
storage.mount(vfs2, "/sd2")
print("SD 2 Mounted")
print(os.listdir("/sd2"))
while True:
print("loop")
time.sleep(1)
Behavior
Below is the error from the code. When run, only one of the SPI SD Card modules is recognized. You can change which one is mounted by unplugging the power and swapping in the code the CS pins. A few times, it successfully mounted both SD cards, but I cant reproduce that event anymore.
>>> %Run -c $EDITOR_CONTENT
Starting
SD 1 Mounted
[]
Traceback (most recent call last):
File "<stdin>", line 18, in <module>
OSError: no SD card
Description
-Error with mounting two SPI SD Card modules -MCU is Raspberry Pi Pico
- I have tried following with no change in behavior: -Slowing the baudrate down to 9600 -Changing to 5V power -Adding time.sleep() calls -Flipping CS Pins -Deiniting CS pins -Tested with a regular SD Card and the SPI SD Card flash module and the two mounted correctly.
Additional information
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 21 (3 by maintainers)
@KurtE Been playing around with different processor and SD Cards. And it seems some SD cards will work and some not. I have been using 3 different SD Cards for testing
The 64GB worked without an issue, for the 32GB card had to increase the timeout in the SD lib to 400 from 200 and then it worked. The 8GB had a problem with-didn’t want to work. The Flash SD Card only worked with certain processors. Here I what I found so far:
There is only one set of connections going to the processor board. So don’t think its a wiring problem. Whether its a timing or other issue with the SD Library don’t know yet.
This was discussed and tested at length on Discord. I think it needs someone with two of the Adafruit flash-chip SD Card breakouts to try to replicate. Confirmed that one regular SD Card breakout + one flash-chip SD Card breakout work fine on RP2040 port, but I don’t have two flash-chip breakouts to test.