Commit 24652228 authored by Damien George's avatar Damien George
Browse files

drivers/sdcard: Allow up to 5 retries to initialise SD card.

Apparently some cards need more than 2 retries.  See issue #1482.
parent 845b5a2a
......@@ -51,10 +51,12 @@ class SDCard:
for i in range(16):
self.spi.send(0xff)
# CMD0: init card; should return R1_IDLE_STATE (allow 2 attempts)
if self.cmd(0, 0, 0x95) != R1_IDLE_STATE:
if self.cmd(0, 0, 0x95) != R1_IDLE_STATE:
raise OSError("no SD card")
# CMD0: init card; should return R1_IDLE_STATE (allow 5 attempts)
for _ in range(5):
if self.cmd(0, 0, 0x95) == R1_IDLE_STATE:
break
else:
raise OSError("no SD card")
# CMD8: determine card version
r = self.cmd(8, 0x01aa, 0x87, 4)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment