← index #775Issue #7129
Related · high · value 1.062
QUERY · ISSUE

OSError: timeout waiting for v2 card

openby zhuzhutouopened 2023-12-05updated 2026-03-02

Title: SD Card Initialization Timeout Issue: Lenovo thinkplus platinum Pro 64GB V30 A3 U3

Description:

I'm experiencing an initialization timeout issue with a Lenovo thinkplus platinum Pro 64GB V30 A3 U3 SD card on MicroPython version 1.21.0 on my device. When I attempt to initialize the SD card, I encounter the following error message:

SD card initialization timeout error: Error: Timeout occurred during SD card initialization.

Steps to reproduce:

  1. Insert the Lenovo thinkplus platinum Pro 64GB V30 A3 U3 SD card into the device's SD card slot.
  2. Execute the SD card initialization code in the MicroPython environment.
import os, sdcard, machine


def sdtest():
    spi = machine.SPI(1, baudrate=1000000, sck=machine.Pin(10), mosi=machine.Pin(11), miso=machine.Pin(12))
    spi.init()  # Ensure right baudrate
    sd = sdcard.SDCard(spi, machine.Pin(13, machine.Pin.OUT))  # Compatible with PCB
    vfs = os.VfsFat(sd)
    os.mount(vfs, "/fc")
    print("Filesystem check")
    print(os.listdir("/fc"))

    line = "abcdefghijklmnopqrstuvwxyz\n"
    lines = line * 200  # 5400 chars
    short = "1234567890\n"

    fn = "/fc/rats.txt"
    print()
    print("Multiple block read/write")
    with open(fn, "w") as f:
        n = f.write(lines)
        print(n, "bytes written")
        n = f.write(short)
        print(n, "bytes written")
        n = f.write(lines)
        print(n, "bytes written")

    with open(fn, "r") as f:
        result1 = f.read()
        print(len(result1), "bytes read")

    fn = "/fc/rats1.txt"
    print()
    print("Single block read/write")
    with open(fn, "w") as f:
        n = f.write(short)  # one block
        print(n, "bytes written")

    with open(fn, "r") as f:
        result2 = f.read()
        print(len(result2), "bytes read")

    os.umount("/fc")

    print()
    print("Verifying data read back")
    success = True
    if result1 == "".join((lines, short, lines)):
        print("Large file Pass")
    else:
        print("Large file Fail")
        success = False
    if result2 == short:
        print("Small file Pass")
    else:
        print("Small file Fail")
        success = False
    print()
    print("Tests", "passed" if success else "failed")


sdtest()
The SD card initialization timeout error occurs after executing the above code.
Expected behavior:

I expect the SD card to initialize successfully, allowing me to access files on the SD card.

Attempts made:

I’ve checked the physical connection and confirmed that the SD card is inserted correctly.
I attempted to upgrade MicroPython to the latest version, but the issue still persists.
The memory card is formatted with the FAT32 file system.
I have searched through MicroPython documentation and forums but have not found a similar issue.
Environment:

Device model: Lenovo thinkplus platinum Pro
SD card model: 64GB V30 A3 U3
MicroPython version: 1.21.0
Operating system: (if relevant)
Expected resolution time:

If possible, please address this issue as soon as possible as the SD card is crucial for my project.

Thank you for your kind assistance!
2 comments
mendenm · 2023-12-06

@zhuzhutou Please try the updated SDCard library in my pull request:
https://github.com/micropython/micropython-lib/pull/765
and let me know if it works with this.

kwagyeman · 2026-03-02

This is resolved with the latest sdcard code.

CANDIDATE · ISSUE

Pico: sdcard.py timeout waiting for response

closedby jbeale1opened 2021-04-18updated 2025-02-02
drivers

I was unable to use the https://github.com/micropython/micropython/blob/master/drivers/sdcard/sdcard.py code as-is on my Raspberry Pi Pico, I would get "timeout waiting for response" when accessing my microSD card device, I presume from this part of the code:

        # read until start byte (0xff)
        for i in range(_CMD_TIMEOUT):
            self.spi.readinto(self.tokenbuf, 0xFF)
            if self.tokenbuf[0] == _TOKEN_DATA:
                break
        else:
            self.cs(1)
            raise OSError("timeout waiting for response")

I was able to fix this by simply changing the _CMD_TIMEOUT from 100 to 1000:
_CMD_TIMEOUT = const(1000)

I don't know if the Pico board is faster, or my old SanDisk 8GB is slower than what was tested, but there is an existence proof that more cards will work with a longer timeout. Also, another Pico user with other SanDisk uSD cards reported the same problem, and found the same fix worked for them as well: https://www.raspberrypi.org/forums/viewtopic.php?f=146&t=308819&start=25

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied