最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

esp32 - How to initialize the SD Card on esp32cam OV5640 - Stack Overflow

programmeradmin2浏览0评论

I'm using a esp32 CamPlus OV5640 Rev 1.2.1 (example) and cannot get the SD card to initialise.

These are my details:

  • Using ESP IDF v5.4
  • Formatted a 16Gb SD Card fat32
  • Flashed via USB-C connector
  • Ran the code below (adapted from ESP-IDF example)

The specific error is:

E (6343) sdmmc_req: handle_idle_state_events unhandled: 00001000 00000000
E (10353) sdmmc_periph: sdmmc_host_clock_update_command(200): sdmmc_host_start_command returned 0x107
E (10353) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
E (10353) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).

I've tried:

  • a variety of SD cards and formatted (linux, windows)
  • lower bus speed, etc
  • using the Arduino IDE instead (SD_MMC.begin())
  • custom pins for SDMMC because allow ESP-IDF says pins are fixed, but the schematic has different SD_* pins.

I'm unable to find much detail on this new (2025) board. (Note it is different to the common esp32cam board for which SD card is fine)

Any ideas, success stories or resources would be greatly appreciated!

#include "esp_vfs_fat.h"
#include "sdmmc_cmd.h"
#include "driver/sdmmc_host.h"

static const char *TAG = "example";

#define MOUNT_POINT "/sdcard"

void app_main(void)
{

    esp_err_t ret;

    esp_vfs_fat_sdmmc_mount_config_t mount_config = {
        .format_if_mount_failed = false, // tried true
        .max_files = 3,
        .allocation_unit_size = 4096 // tried 16 * 1024 too
    };
    sdmmc_card_t *card;
    const char mount_point[] = MOUNT_POINT;

    ESP_LOGI(TAG, "Using SDMMC peripheral");

    sdmmc_host_t host = SDMMC_HOST_DEFAULT();
    // host.max_freq_khz = 400; // Tried to lower frequency
    // host.slot = SDMMC_HOST_SLOT_1; // Tried to customize slot

    sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();

    // Set bus width to use:
    slot_config.width = 4; // tried 1 too

    // Tried to customize pins from
    // .jpg
    // slot_config.clk = 31;
    // slot_config.cmd = 30;
    // slot_config.d0 = 32;
    // slot_config.d1 = 33;
    // slot_config.d2 = 28;
    // slot_config.d3 = 29;

    ESP_LOGI(TAG, "Mounting filesystem");
    ret = esp_vfs_fat_sdmmc_mount(mount_point, &host, &slot_config, &mount_config, &card);

    if (ret != ESP_OK)
    {
        if (ret == ESP_FAIL)
        {
            ESP_LOGE(TAG, "Failed to mount filesystem. ");
        }
        else
        {
            ESP_LOGE(TAG, "Failed to initialize the card (%s). ", esp_err_to_name(ret));
            // fails here with
            // E (1343) sdmmc_periph: sdmmc_host_clock_update_command(200): sdmmc_host_start_command returned 0x107
        }
        return;
    }
    ESP_LOGI(TAG, "Filesystem mounted");
   
    sdmmc_card_print_info(stdout, card);   
    esp_vfs_fat_sdcard_unmount(mount_point, card);
   
}
发布评论

评论列表(0)

  1. 暂无评论