micropython icon indicating copy to clipboard operation
micropython copied to clipboard

ESP32 Cannot mount SD Card on Wemos LOLIN D32 Pro V2.0.0

Open phuzybuny opened this issue 4 years ago • 1 comments

Firmware:

esp32spiram-20210623-v1.16.bin

Board:

Wemos LOLIN D32 Pro V2.0.0, ESP32-WROVER, ESP32-D0WDQ6 (revision 1)

According the Wemos D32 Pro Schematic and verified using a continuity meter, the SD card pins are as follows:

  • SCK: GPIO18
  • MOSI: GPIO23
  • MISO: GPIO19
  • CS: GPIO4

Trying to mount the SD card but encountering the following error:

>>> import uos, machine
>>> uos.mount(machine.SDCard(slot=2, width=1, sck=18, mosi=23, miso=19, cs=4), '/sd')
E (61965) sdmmc_sd: sdmmc_init_spi_crc: sdmmc_send_cmd_crc_on_off returned 0x106
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: 16

phuzybuny avatar Jul 03 '21 03:07 phuzybuny

Can reproduce on current master using a random no-name ESP32-D0WD board and an even more no-name sdcard adapter module, with the only difference that the return code is 0x107 the first time a new card is inserted, otherwise it's 0x108.

agatti avatar Oct 01 '24 20:10 agatti

I'm not able to reproduce this (also using no-name sdcard adapter, but same pins as reporter). Works with or without spiram enabled.

0x107 is ESP_ERR_TIMEOUT and 0x106 is ESP_ERR_NOT_SUPPORTED.

The comment around the call to sdmmc_send_cmd_crc_on_off in ESP-IDF is:

    /* In SD mode, CRC checks of data transfers are mandatory and performed
     * by the hardware. In SPI mode, CRC16 of data transfers is optional and
     * needs to be enabled.
     */

My first guess is that this is a hardware issue: signal integrity, unstable power to the SD card, or something similar.

If it's not that, my second guess is that maybe there are some SD card controllers which don't support CRC16 at all in SPI mode. (It's not clear from this comment whether "optional" means it's optional for the host to enable it, but mandatory for the card to support it, or if it's optional for the card to support it). If so, this would need to be reproduced and reported as an issue in ESP-IDF as their sdmmc driver expects the card to always enable crc16 mode in SPI mode (see the function sdmmc_init_spi_crc) - card init fails otherwise.

projectgus avatar Feb 11 '25 00:02 projectgus