Skip to content

Forum User reports adafruit_sdcard and esp32spi fail to share an spi bus #5644

Open
@jepler

Description

@jepler

CircuitPython version

"I am on CircuitPython 7, and tried reverting back to 6.3, same results on both."

Code/REPL

# If you have an AirLift Featherwing or ItsyBitsy Airlift:
esp32_cs = DigitalInOut(board.D13)
esp32_ready = DigitalInOut(board.D11)
esp32_reset = DigitalInOut(board.D12)

spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
# spi = board.SPI()
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)

sdcard = sdcardio.SDCard(spi, board.SD_CS)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")

Behavior

['snare.wav', 'hat.wav', 'kick.wav']
Traceback (most recent call last):
File "code.py", line 59, in <module>
File "adafruit_esp32spi/adafruit_esp32spi.py", line 335, in status
File "adafruit_esp32spi/adafruit_esp32spi.py", line 325, in _send_command_get_response
File "adafruit_esp32spi/adafruit_esp32spi.py", line 293, in _wait_response_cmd
File "adafruit_esp32spi/adafruit_esp32spi.py", line 277, in _check_data
RuntimeError: Expected A0 but got 80

Description

Internet lore says that it's possible to share an SPI bus with an SD card and another device, as long as the SD card is initialized first.

User reports that the same error occurs when the SD card is initialized first. However, a full example in this order was not furnished as far as I saw.

If it's not a hardware impossibility, then it seems most likely the problem resides in the sd card code, perhaps failing to do "extra clocks" at the end of a transaction.

The recently added "CMD25" stuff does not seem relevant here, as the SD card is not being written in the example (and the problem is reported before the addition of CMD25).

Additional information

See https://forums.adafruit.com/viewtopic.php?f=60&t=185718

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions