We have designed our product putting a 4-line SD card on pins 17-22 of ESP-WROOM-32 (GPIO6-GPIO11).
In previous edition of datasheet (see attachment) there were no mention to avoid those pins for SD card (and in general GPIO).
Now we are going to use the SD card with this code:
Code: Select all
ESP_LOGD(TAG_SD, "Using SDMMC peripheral");
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
host.slot = SDMMC_HOST_SLOT_0;
// This initializes the slot without card detect (CD) and write protect (WP) signals.
// Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
slot_config.gpio_cd = GPIO_NUM_34;
slot_config.width = 4;
// GPIOs 7, 8, 9, 10, 11 should have external 10k pull-ups.
// Internal pull-ups are not sufficient. However, enabling internal pull-ups
// does make a difference some boards, so we do that here.
gpio_set_pull_mode(GPIO_NUM_7, GPIO_PULLUP_ONLY); // D0, needed in 4- and 1-line modes
gpio_set_pull_mode(GPIO_NUM_8, GPIO_PULLUP_ONLY); // D1, needed in 4-line mode only
gpio_set_pull_mode(GPIO_NUM_9, GPIO_PULLUP_ONLY); // D2, needed in 4-line mode only
gpio_set_pull_mode(GPIO_NUM_10, GPIO_PULLUP_ONLY); // D3, needed in 4- and 1-line modes
gpio_set_pull_mode(GPIO_NUM_11, GPIO_PULLUP_ONLY); // CMD, needed in 4- and 1- line modes
gpio_set_pull_mode(GPIO_NUM_34, GPIO_PULLUP_ONLY); // CD
// Options for mounting the filesystem.
// If format_if_mount_failed is set to true, SD card will be partitioned and
// formatted in case when mounting fails.
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
.format_if_mount_failed = false,
.max_files = 5,
.allocation_unit_size = 16 * 1024
};
// Use settings defined above to initialize SD card and mount FAT filesystem.
// Note: esp_vfs_fat_sdmmc_mount is an all-in-one convenience function.
// Please check its source code and implement error recovery when developing
// production applications.
sdmmc_card_t* card;
esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
if (ret != ESP_OK) {
if (ret == ESP_FAIL) {
ESP_LOGD(TAG_SD, "Failed to mount filesystem. "
"If you want the card to be formatted, set format_if_mount_failed = true.");
} else {
ESP_LOGD(TAG_SD, "Failed to initialize the card (%d). "
"Make sure SD card lines have pull-up resistors in place.", ret);
}
}
We have also checked latest datasheet and it says to not use GPIO6 to GPIO11.. How to solve that? If we cannot use those pins is a big trouble.
Thanks.