SDIO Interface

chrhsmt
Posts: 1
Joined: Thu May 18, 2017 8:28 pm

Re: SDIO Interface

Postby chrhsmt » Sun May 21, 2017 4:30 pm

I just tried SDIO example (https://github.com/espressif/esp-idf/tr ... ge/sd_card).
1bit mode works, but 4bit mode does not work.

Connections are ok (correctly as https://github.com/espressif/esp-idf/tr ... d#hardware).
My SD card board has no internal pullup register.
I've already done `espefuse.py set_flash_voltage 3.3V` .

error log is below(verbose log).
D (2244) vfs_fat_sdmmc: using pdrv=0
V (2254) sdmmc_cmd: sending cmd slot=1 op=17 arg=0 flags=1c50 data=0x3ffb8ac8 blklen=512 datalen=512
V (2264) sdmmc_req: make_hw_cmd: opcode=17, rexp=1, crc=1
V (2264) sdmmc_req: fill 4 desc=0 rem=0 next=1 last=1 sz=512
V (2274) sdmmc_req: sdmmc_handle_event: evt 00000004 00000000
V (2274) sdmmc_req: process_events: state=SENDING_CMD
V (2284) sdmmc_req: process_events state=SENDING_CMD next_state=SENDIND_DATA
V (2294) sdmmc_req: process_events state=SENDIND_DATA next_state=SENDIND_DATA
V (2294) sdmmc_req: sdmmc_handle_event: evt 00000008 00000002
V (2304) sdmmc_req: process_events: state=SENDIND_DATA
V (2304) sdmmc_req: process_events state=SENDIND_DATA next_state=IDLE
V (2314) sdmmc_req: process_events state=IDLE next_state=IDLE
V (2324) sdmmc_cmd: cmd response 00000900 00000000 00000000 00000000 err=0x0 state=4
V (2324) sdmmc_cmd: sending cmd slot=1 op=13 arg=aaaa0000 flags=1c00 data=0x0 blklen=0 datalen=0
V (2334) sdmmc_req: make_hw_cmd: opcode=13, rexp=1, crc=1
V (2344) sdmmc_req: sdmmc_handle_event: evt 00000004 00000000
V (2354) sdmmc_req: process_events: state=SENDING_CMD
V (2354) sdmmc_req: process_events state=SENDING_CMD next_state=IDLE
V (2364) sdmmc_req: process_events state=IDLE next_state=IDLE
V (2364) sdmmc_cmd: cmd response 00000900 00000000 00000000 00000000 err=0x0 state=4
V (2374) sdmmc_cmd: sending cmd slot=1 op=17 arg=2000 flags=1c50 data=0x3ffb8ac8 blklen=512 datalen=512
V (2384) sdmmc_req: make_hw_cmd: opcode=17, rexp=1, crc=1
V (2394) sdmmc_req: fill 4 desc=0 rem=0 next=1 last=1 sz=512
V (2394) sdmmc_req: sdmmc_handle_event: evt 00000004 00000000
V (2404) sdmmc_req: process_events: state=SENDING_CMD
V (2404) sdmmc_req: process_events state=SENDING_CMD next_state=SENDIND_DATA
V (2414) sdmmc_req: process_events state=SENDIND_DATA next_state=SENDIND_DATA
V (2424) sdmmc_req: sdmmc_handle_event: evt 00000080 00000000
V (2424) sdmmc_req: process_events: state=SENDIND_DATA
D (2434) sdmmc_req: process_data_status: error 0x109 (status=00000080)
V (2434) sdmmc_req: process_events state=SENDIND_DATA next_state=SENDIND_DATA
V (2444) sdmmc_req: sdmmc_handle_event: evt 00000008 00000002
V (2454) sdmmc_req: process_events: state=SENDIND_DATA
V (2454) sdmmc_req: process_events state=SENDIND_DATA next_state=IDLE
V (2464) sdmmc_req: process_events state=IDLE next_state=IDLE
V (2464) sdmmc_cmd: cmd response 00000900 00000000 00000000 00000000 err=0x109 state=4
E (2474) sdmmc_cmd: sdmmc_read_sectors: sdmmc_send_cmd returned 0x109
E (2484) diskio_sdmmc: sdmmc_read_blocks failed (265)
W (2494) vfs_fat_sdmmc: failed to mount card (13)
E (2494) example: Failed to mount filesystem. If you want the card to be formatted, set format_if_mount_failed = true.
Does anybody has clue ?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: SDIO Interface

Postby ESP_igrr » Mon May 22, 2017 1:14 am

Do you have pullup resistors on SD card data lines? Sorry, I don't understand what 'internal pullup registers' means.

User avatar
rudi ;-)
Posts: 1729
Joined: Fri Nov 13, 2015 3:25 pm

Re: SDIO Interface

Postby rudi ;-) » Mon May 22, 2017 6:12 am

chrhsmt wrote:
I just tried SDIO example (https://github.com/espressif/esp-idf/tr ... ge/sd_card).
1bit mode works, but 4bit mode does not work.

Connections are ok (correctly as https://github.com/espressif/esp-idf/tr ... d#hardware).
My SD card board has no internal pullup register.

looks the connection like the second?

You must itself pullup the lines!
pullup the GPIO with Software does not work
You need "hardware resistors on the lines"
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi ;-)
Posts: 1729
Joined: Fri Nov 13, 2015 3:25 pm

Re: SDIO Interface

Postby rudi ;-) » Mon May 22, 2017 7:02 am

chrhsmt wrote:
I just tried SDIO example (https://github.com/espressif/esp-idf/tr ... ge/sd_card).
1bit mode works, but 4bit mode does not work.
only for clarification:
does the 1bit mode that works -look like this?
do you have Pullups in Hardware in the line?
SD_1-BIT.png
SD_1-BIT.png (17.15 KiB) Viewed 13286 times
so you must do the same in 4bit mode with the other lines like posted and named in the demo.
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

chrhsmt
Posts: 1
Joined: Thu May 18, 2017 8:28 pm

Re: SDIO Interface

Postby chrhsmt » Mon May 22, 2017 8:13 am

Do you have pullup resistors on SD card data lines? Sorry, I don't understand what 'internal pullup registers' means
@ESP_igrr "Internal" means "inside" or "on board". My sd card board has no pull up resister by itself.

@rudi
looks the connection like the second?

You must itself pullup the lines!
pullup the GPIO with Software does not work
You need "hardware resistors on the lines"
only for clarification:
does the 1bit mode that works -look like this?
do you have Pullups in Hardware in the line?
Yes. I done hardware pullup the line. not software.
All 6 line is pulled up by 10K ohm register.

And, I am doing this on breadboard. Is it OK ? ( I heared that breadboard is not good for high frequency circuit).

What else should I check ?
What else could be considered as a reason for crc error ?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: SDIO Interface

Postby ESP_igrr » Mon May 22, 2017 9:31 am

In case you are doing this on the breadboard, re-check your connections. The error being reported is 0x109 or ESP_ERR_INVALID_CRC (see esp_err.h), which usually indicates that there is a signal integrity issue. The driver will use 20MHz clock for most of the cards.

If you find that this doesn't work reliably on the breadboard, you can lower the frequency by changing the value of max_freq_khz field in sdmmc_host_t structure passed into sdmmc_card_init function (like this).

temp4eb
Posts: 35
Joined: Tue Jun 06, 2017 8:59 am

Re: SDIO Interface

Postby temp4eb » Tue Jun 06, 2017 11:32 am

Hi sintech,
I tried your method but got the same error:
I (1198) example: Start delay
I (6198) example: Initializing SD card
I (6198) example: Start Pullup
E (6218) sdmmc_cmd: sdmmc_read_sectors: sdmmc_send_cmd returned 0x109
E (6218) diskio_sdmmc: sdmmc_read_blocks failed (265)
W (6218) vfs_fat_sdmmc: failed to mount card (13)
E (6228) example: Failed to mount filesystem. If you want the card to be formatt
ed, set format_if_mount_failed = true.
Name: SD04G
Type: SDHC/SDXC
Speed: default speed
Size: 3747MB
CSD: ver=1, sector_size=512, capacity=7673856 read_bl_len=9
SCR: sd_spec=2, bus_width=5
I (6248) example: Opening file
E (6258) example: Failed to open file for writing
I will try the eFuse way.
sintech wrote:I'm able to run an example in 4-bit mode only after:
1. disconnecting GPIO12 from SD-card shield (with soldered pull-ups) (to not interfere with internal pull-down signaling of LDO voltage)
2. addling 5 second delay at the beginning of my code
3. reconnecting GPIO12 to SD CARD D2 during this delay.

Speaking about LDO voltage. I have measured voltage on bare GPIO12 pin and it is 0V. So according to page 9 of ESP32 datasheet I made an assumption that internal flash on my module is 3.3V. But in sd_card example readme file I found an opposite information "For boards which use 1.8V flash chip, GPIO12 needs to be low at reset.". So what is true?
And please share with us commands how to set efuses for SDIO_TIEH=0 and SDIO_FORCE=1, because (if I understand correctly) this settings are permanent and can't be changed back.

I have also made some benchmarking (using a code from test_sd.c) and here are the results:

Code: Select all

Type: SDHC/SDXC
Speed: default speed
Size: 14991MB
CSD: ver=1, sector_size=512, capacity=30702592 read_bl_len=9
SCR: sd_spec=2, bus_width=5
# 4-bit mode
  sector  | count | size(kB) | wr_time(ms) | wr_speed(MB/s) | rd_time(ms) | rd_speed(MB/s)
        0 |    1  |    0.5   |    22.21    |      0.02      |    0.33s    |     1.49
        0 |    4  |    2.0   |    22.79    |      0.09      |    0.58s    |     3.39
        1 |   16  |    8.0   |    22.87    |      0.34      |    1.17s    |     6.71
       16 |   32  |   16.0   |    27.29    |      0.57      |    2.05s    |     7.63
       48 |   64  |   32.0   |    16.42    |      1.90      |    3.74s    |     8.35
      128 |  128  |   64.0   |     8.69    |      7.19      |    7.10s    |     8.80
     1024 |  256  |   128.0  |    16.18    |      7.72      |    13.88s   |     9.00

# 1-bit mode
  sector  | count | size(kB) | wr_time(ms) | wr_speed(MB/s) | rd_time(ms) | rd_speed(MB/s)
        0 |    1  |    0.5   |    22.91    |      0.02      |    0.48s    |     1.01
        0 |    4  |    2.0   |    26.14    |      0.07      |    1.20s    |     1.62
        1 |   16  |    8.0   |    25.84    |      0.30      |    3.67s    |     2.13
       16 |   32  |   16.0   |    41.25    |      0.38      |    7.00s    |     2.23
       48 |   64  |   32.0   |    25.09    |      1.25      |    13.58s   |     2.30
      128 |  128  |   64.0   |    27.23    |      2.29      |    26.76s   |     2.34
     1024 |  256  |   128.0  |    53.78    |      2.32      |    53.19s   |     2.35

markwj
Posts: 90
Joined: Tue Mar 08, 2016 5:03 am

Re: SDIO Interface

Postby markwj » Thu Oct 19, 2017 1:28 pm

ESP_igrr wrote:Indeed, WiFive is correct. If you have an SPI flash chip connected to the standard pins, there will be a conflict between SDIO master and SPI0 peripheral. If you want to use SDIO master on HS0 slot, you need to move SPI flash chip to a different set of pins (this is possible by programming Efuses).
Is this still a problem with release/v2.1 and master branches? What is the conflict?

My circuit uses external flash, and these fuses:

Code: Select all

Config fuses:
XPD_SDIO_FORCE         Ignore MTDI pin (GPIO12) for VDD_SDIO on reset    = 1 R/W (0x1)
XPD_SDIO_REG           If XPD_SDIO_FORCE, enable VDD_SDIO reg on reset   = 1 R/W (0x1)
XPD_SDIO_TIEH          If XPD_SDIO_FORCE & XPD_SDIO_REG, 1=3.3V 0=1.8V   = 1 R/W (0x1)
SPI_PAD_CONFIG_CLK     Override SD_CLK pad (GPIO6/SPICLK)                = 6 R/W (0x6)
SPI_PAD_CONFIG_Q       Override SD_DATA_0 pad (GPIO7/SPIQ)               = 7 R/W (0x7)
SPI_PAD_CONFIG_D       Override SD_DATA_1 pad (GPIO8/SPID)               = 8 R/W (0x8)
SPI_PAD_CONFIG_HD      Override SD_DATA_2 pad (GPIO9/SPIHD)              = 9 R/W (0x9)
SPI_PAD_CONFIG_CS0     Override SD_CMD pad (GPIO11/SPICS0)               = 22 R/W (0x16)
DISABLE_SDIO_HOST      Disable SDIO host                                 = 0 R/W (0x0)
then SDCARD in SD mode using standard pins. Standard devkit-c style dual transistor logic for BOOT and EN. GPIO2 is tied to GPIO1. Pull-ups as described in the example.

Mostly getting checksum errors, and in general the SD CARD access is unreliable.

Who is online

Users browsing this forum: No registered users and 119 guests