SDMMC reads fail in 4-bit (but not writes)
Posted: Fri Sep 03, 2021 10:50 pm
I've got a SparkFun ESP32 Thing (1st gen) on a breadboard wired up to a microSD card using 4-bit SDMMC. It's connected to channel 1: GPIOs 15, 14, 2, 4, 12, 13 connect to CMD, CLK, D0, D1, D2, D3 respectively (with external pull-ups.) I'm using a brand new Samsung 256GB card.
It works fine as long as I restrict it to 1-bit mode, i.e. I change the sdmmc_host_t.flags to SDMMC_HOST_FLAG_1BIT. I'm seeing write speeds of about 2.7MB/sec. But I need more speed!
If I enable 4-bit mode, or just leave the flags at the default value, then _writes_ work fine, and a couple of reads may work, but then a read fails with ESP_ERR_INVALID_CRC (0x109), and after that all reads fail with ESP_ERR_TIMEOUT (0x107).
Any idea what's wrong? It would seem like D2 or D3 are the culprits, since those pins are used in 4-bit but not 1-bit. But writes do work! And I've checked the wiring many times and the connections look fine.
It works fine as long as I restrict it to 1-bit mode, i.e. I change the sdmmc_host_t.flags to SDMMC_HOST_FLAG_1BIT. I'm seeing write speeds of about 2.7MB/sec. But I need more speed!
If I enable 4-bit mode, or just leave the flags at the default value, then _writes_ work fine, and a couple of reads may work, but then a read fails with ESP_ERR_INVALID_CRC (0x109), and after that all reads fail with ESP_ERR_TIMEOUT (0x107).
Code: Select all
E (2243) sdmmc_cmd: sdmmc_read_sectors_dma: sdmmc_send_cmd returned 0x109
** read failed, retrying...
E (3353) sdmmc_req: sdmmc_host_wait_for_event returned 0x107
E (3353) sdmmc_cmd: sdmmc_read_sectors_dma: sdmmc_send_cmd returned 0x107