Page 1 of 1

Some microSD card need mount twice to work

Posted: Wed Apr 28, 2021 3:31 am
by shaoziyang
I have try to mount microSD card via SPI in pyboard. Some microSD card works, but some microSD card will cause timeout error.

Code: Select all

>>> sd=sdcard.SDCard(SPI, PIN_CS)
>>> os.mount(sd, '/SD')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sdcard.py", line 239, in readblocks
  File "sdcard.py", line 181, in readinto
OSError: timeout waiting for response
But if try to mount it again, it will works. Just increase _CMD_TIMEOUT value does not solve the problem.

Code: Select all

>>> sd=sdcard.SDCard(SPI, PIN_CS)
>>> os.mount(sd, '/SD')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sdcard.py", line 239, in readblocks
  File "sdcard.py", line 181, in readinto
OSError: timeout waiting for response
>>> os.mount(sd, '/SD')
>>> os.listdir('/SD')
['demo.py']
>>> os.statvfs('/SD')
(32768, 32768, 491264, 491262, 491262, 0, 0, 0, 0, 255)

Re: Some microSD card need mount twice to work

Posted: Sun Apr 24, 2022 5:57 pm
by lolsch
I just made this account to thank you. Have been struggling with different sd cards and modules for a while now and just calling it twice fixed it very reliable.
Thank you so much!