Skip to content

eMMC driver #7405

Closed
Closed
@marchingband

Description

@marchingband

Board

ESP32-s3

Device Description

DevKitC-1

Hardware Configuration

I have a custom PCB with eMMC attached as follows

#define EMMC_CLK     GPIO_NUM_16
#define EMMC_CMD    GPIO_NUM_15
#define EMMC_DATA0 GPIO_NUM_4
#define EMMC_DATA1 GPIO_NUM_5
#define EMMC_DATA2 GPIO_NUM_6
#define EMMC_DATA3 GPIO_NUM_7

Version

v2.0.5

IDE Name

Arduino IDE

Operating System

macOS 10.15

Flash frequency

80Mhz

PSRAM enabled

no

Upload speed

115200

Description

In this issue: espressif/esp-idf#8257
It seems there was a patch to esp-idf 4.4 which fixes some issues with the eMMC driver timing.
Has this patch been applied to ESP32-Arduino ?
Thanks!

Sketch

#include "Arduino.h"
#include "FS.h"
#include "driver/sdmmc_types.h"
#include "sd_defines.h"
#include "vfs_api.h"

#include <dirent.h>
#include "esp_vfs_fat.h"
#include "driver/sdmmc_host.h"
#include "driver/sdmmc_defs.h"
#include "sdmmc_cmd.h"
#include "soc/sdmmc_pins.h"
#include "ff.h"
#include "USB.h"

#define EMMC_CLK GPIO_NUM_16
#define EMMC_CMD GPIO_NUM_15
#define EMMC_DATA0 GPIO_NUM_4
#define EMMC_DATA1 GPIO_NUM_5
#define EMMC_DATA2 GPIO_NUM_6
#define EMMC_DATA3 GPIO_NUM_7

sdmmc_card_t *card;
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
  
void init_emmc(){
//    Serial.begin(115200);
   // host.max_freq_khz = SDMMC_FREQ_HIGHSPEED;
   host.max_freq_khz = SDMMC_FREQ_DEFAULT;
//   host.flags = SDMMC_HOST_FLAG_4BIT;
   host.flags = SDMMC_HOST_FLAG_1BIT;
   host.flags &= ~SDMMC_HOST_FLAG_DDR;

   sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
   slot_config.width = 1;
   slot_config.clk = EMMC_CLK;
   slot_config.cmd = EMMC_CMD;
   slot_config.d0 = EMMC_DATA0;
//   slot_config.d1 = EMMC_DATA1;
//   slot_config.d2 = EMMC_DATA2;
//   slot_config.d3 = EMMC_DATA3;

   sdmmc_host_init_slot(SDMMC_HOST_SLOT_1, &slot_config);
   gpio_reset_pin(EMMC_CLK);
   gpio_reset_pin(EMMC_CMD);
   gpio_reset_pin(EMMC_DATA0);
   gpio_reset_pin(EMMC_DATA1);
   gpio_reset_pin(EMMC_DATA2);
   gpio_reset_pin(EMMC_DATA3);
   gpio_pullup_en(EMMC_CLK);
   gpio_pulldown_dis(EMMC_CLK);
   gpio_pullup_en(EMMC_CMD);
   gpio_pulldown_dis(EMMC_CMD);
   gpio_pullup_en(EMMC_DATA0);
   gpio_pulldown_dis(EMMC_DATA0);
   gpio_pullup_en(EMMC_DATA1);
   gpio_pulldown_dis(EMMC_DATA1);
   gpio_pullup_en(EMMC_DATA2);
   gpio_pulldown_dis(EMMC_DATA2);
   gpio_pullup_en(EMMC_DATA3);
   gpio_pulldown_dis(EMMC_DATA3);

//    puts("Initialize HOST and SLOT");

   esp_vfs_fat_sdmmc_mount_config_t mount_config = {
       .format_if_mount_failed = true,
       .max_files = 5,
   };
   
   esp_err_t ret = esp_vfs_fat_sdmmc_mount("/root", &host, &slot_config, &mount_config, &card);
   ESP_ERROR_CHECK(ret);
}

void setup(){
  Serial.begin();
  Serial.setDebugOutput(true);
  USB.begin();
}

int inited = 0;

void loop(){
    Serial.println("run");
    log_i("debug");
    vTaskDelay(1000);
    if(Serial.available()){
        if(inited == 0){
            log_i("init emmc");
            inited = 1;
            init_emmc();
        }
    }
}

Debug Message

ESP_ERROR_CHECK failed: esp_err_t 0x109 (ESP_ERR_INVALID_CRC) at 0x4037a43c

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions