microSD card reading

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
User avatar
RobH
Posts: 91
Joined: Fri Mar 23, 2018 3:37 pm
Location: Netherlands
Contact:

Re: microSD card reading

Post by RobH » Fri Aug 28, 2020 11:41 am

jakub st wrote:
Sun Nov 04, 2018 8:05 pm
Hello,
is there any option to use this code for 2GB cards ?
I've got a whole bunch of such SD cards I really want to use in my projects.
I've tried several format options but without success.
After almost 2 years the issue seems still not resolved.
Although 2GB cards may not be popular anymore these days I have a couple of these which are still useful to me and sufficient for my purpose. But all fail with either EIO (line 237 in sdcard.py) or ENODEV (with os.mount()). I tested with the latest version of sdcard.py and a PyBoard 1.1 and 'black-pill' (STM32F411CEU6) with micropython 1.12-675.
No problems with several larger size cards (I have no smaller).

User avatar
RobH
Posts: 91
Joined: Fri Mar 23, 2018 3:37 pm
Location: Netherlands
Contact:

Re: microSD card reading

Post by RobH » Sun Dec 13, 2020 9:06 am

The machine.SDCard class of the ESP32 port (v1.13) works fine, also with 2GB cards.

yukky
Posts: 1
Joined: Tue Dec 21, 2021 7:55 am

Re: microSD card reading

Post by yukky » Tue Dec 21, 2021 8:00 am

Isn't the card version initialized with V2?
I think that most 2GB SD cards are V1 ~ V1.1.

PM-TPI
Posts: 75
Joined: Fri Jun 28, 2019 3:09 pm

Re: microSD card reading

Post by PM-TPI » Sun Apr 03, 2022 6:34 pm

MicroPython v1.18 on 2022-01-17; ESP32 module with ESP32
I have been chasing this issue for THREE DAYS !!!
@yukky post sent a light bulb on...

I have two identical 2GB cards that give me two different errors
Also note that it reports its [SDCard] v2 card not [SDCard] v1 card
ERRORS...

Code: Select all

[SDCard] v2 card
sectors 1935360
Traceback (most recent call last):
  File "main.py", line 11, in <module>
OSError: [Errno 19] ENODEV

[SDCard] v2 card
sectors 1935360
Traceback (most recent call last):
  File "main.py", line 28, in <module>
  File "sdcard.py", line 239, in readblocks
OSError: [Errno 5] EIO
So in sdcard.py I added 2 print() statments and commented out if/elif check for version and forced self.init_card_v1()

Code: Select all

        # CMD8: determine card version
        r = self.cmd(8, 0x01AA, 0x87, 4)
        print('determine card version')
        print(r)
        # if r == _R1_IDLE_STATE:
        #     self.init_card_v2()
        # elif r == (_R1_IDLE_STATE | _R1_ILLEGAL_COMMAND):
        #     self.init_card_v1()
        # else:
        #     raise OSError("couldn't determine SD card version")

        self.init_card_v1()
and now all works correctly....

Code: Select all

determine card version
1
[SDCard] v1 card
sectors 1966080
['System Volume Information']

['sd', 'boot.py', 'main.py', 'mysdcard.py', 'project.pymakr', 'sdcard.py', 'sdtest.py']
MicroPython v1.18 on 2022-01-17; ESP32 module with ESP32
r = self.cmd(8, 0x01AA, 0x87, 4) is returning... 1
These cheap Chinese Takeout cards trying to pass as v2 cards ???
Can 2GB cards be v2 ???
And what action should be tacken so "CMD8: determine card version" works properly ???
I have seen an enormous amount of posts regarding these ERRORs
I am not a seasoned coder... but these SD Card issues have been floating around for far too long!!!
I need this device to work properly with any SD card used.

Post Reply