-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Environment
- Module or chip used: [ESP32-S3-WROOM-1-N8R8]
- IDF version (run
git describe --tags
to find it): v5.0-dev-1867-g5faf116d26 - Build System: [idf.py]
- Compiler version (run
xtensa-esp32-elf-gcc --version
to find it): xtensa-esp32-elf-gcc (crosstool-NG esp-2021r2-patch3) 8.4.0 - Operating System: [macOS]
- Using an IDE?: [Yes (please give details)]: VSCode
- Power Supply: [external 3.3V]
Problem Description
ESP32-S3-WROOM-1-N8R8 module has trouble with microSD cards at 40MHz / 4-line mode. I have tried both an ESP32-S3-DEVKITC-1-N8R8 and an ESP32-S3-WROOM-1-N8R8 module on a printed circuit board.
The PCB is populated with 10KOhm pull-ups on CMD and D0-D3 lines (and I also tried adding an extra pull-up on the CLK line).
The Devkit was tested with just the internal weak pull-ups enabled.
In both cases, and after trying numerous brands, sizes and speed-rated microSD cards, I have found that they can rarely start at 40MHz (SDMMC_FREQ_HIGHSPEED
) mode, and when they do, there are block read errors observed.
Expected Behavior
Expected the microSD card to start in HIGHSPEED mode.
Actual Behavior
Most of the times, the card fails to start in 40MHz mode with the following errors:
E (1037) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
E (1037) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
After resetting, it can sometimes start at 40MHz, but when proceeding to read data, block read errors eventually occur:
E (3340) sdmmc_cmd: sdmmc_read_sectors_dma: sdmmc_send_cmd returned 0x109
E (3340) diskio_sdmmc: sdmmc_read_blocks failed (265)
E (3342) sdmmc_req: handle_idle_state_events unhandled: 00000008 00000000
Starting the cards at 20MHz mode works fine with no errors.
Steps to reproduce
- Setup an ESP32S3-N8R8 module or devkit with the following pin assignments:
const gpio_num_t kSDSCK_Pin = GPIO_NUM_8;
const gpio_num_t kSDCMD_Pin = GPIO_NUM_9;
const gpio_num_t kSDD0_Pin = GPIO_NUM_18;
const gpio_num_t kSDD1_Pin = GPIO_NUM_7;
const gpio_num_t kSDD2_Pin = GPIO_NUM_17;
const gpio_num_t kSDD3_Pin = GPIO_NUM_16;
- Attach 10k pull-up resistors to all lines above except for SCK (CLK)
- Compile and run the example code below
- SD card fails to start at 40MHz, or when it starts, read errors occur
Code to reproduce this issue
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
host.max_freq_khz = SDMMC_FREQ_HIGHSPEED;
sdmmc_slot_config_t slot_config = {
.clk = kSDSCK_Pin,
.cmd = kSDCMD_Pin,
.d0 = kSDD0_Pin,
.d1 = kSDD1_Pin,
.d2 = kSDD2_Pin,
.d3 = kSDD3_Pin,
.d4 = GPIO_NUM_NC,
.d5 = GPIO_NUM_NC,
.d6 = GPIO_NUM_NC,
.d7 = GPIO_NUM_NC,
.cd = SDMMC_SLOT_NO_CD,
.wp = SDMMC_SLOT_NO_WP,
.width = 4,
.flags = SDMMC_SLOT_FLAG_INTERNAL_PULLUP
};
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
.format_if_mount_failed = false,
.max_files = 5,
.allocation_unit_size = 16 * 1024
};
sdmmc_card_t* card;
esp_err_t mountRes = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
sdmmc_card_print_info(stdout, card);
Debug Logs
I (957) gpio: GPIO[8]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (963) gpio: GPIO[9]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (973) gpio: GPIO[18]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (983) gpio: GPIO[7]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (991) gpio: GPIO[17]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (1001) gpio: GPIO[16]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
E (1037) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
E (1037) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
Other items if possible
- sdkconfig file (attach the sdkconfig file from your project folder)
sdkconfig.zip