SPI sdmmc driver 沒有初始 SD card 為 SPI mode

jcc147
Posts: 3
Joined: Wed Feb 10, 2021 4:25 am

SPI sdmmc driver 沒有初始 SD card 為 SPI mode

Postby jcc147 » Fri Feb 12, 2021 7:07 pm

我用了 esp-idf examples 裡的 sd_card_example_main.c 來試一個 sd card breakout 板子

硬體
esp32-wroom-32 開發板
https://www.amazon.com/MELIFE-Developme ... 947&sr=8-3

sd card adapter
https://www.amazon.com/CHENBO-Storage-E ... 022&sr=8-4

連接
ESP32 SD card adpater
D19 ---- MISO
D23 ---- MOSI
D18 -----SCK
D5 ---- CS
VIN (5V+) ----VCC
GND ---- GND

esp_idf version v4.2

sd_card_example_main.c 裡的我把 SPI mode的註解取掉來eable SD card 是SPI mode
#define USE_SPI_MODE

得到的訊息
I (345) example: Using SPI peripheral
I (355) gpio: GPIO[5]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (365) sdspi_transaction: cmd=52, R1 response: command not supported
I (415) sdspi_transaction: cmd=5, R1 response: command not supported
W (425) sdmmc_common: sdmmc_init_csd: SDSC card reports capacity=15949824. Limiting to 8388608.
E (425) sdmmc_sd: sdmmc_check_scr: send_scr returned 0x109
E (425) vfs_fat_sdmmc: sdmmc_card_init failed (0x109).
I (435) gpio: GPIO[5]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
E (445) example: Failed to initialize the card (ESP_ERR_INVALID_CRC). Make sure SD card lines have pull-up resistors in place.

完全一樣的硬體以及連結沒變 用microPython 就可以讀寫 SD card 用SPI mode

比較了 microPython 的drive 和 esp-idf sdmmc drive, 發現microPython driver 有用100KHz SCK 讓sd card進入SPI mode, 而esp-idf sdmmc driver 則沒有這個動作

我不確定這是不是問題所在
如果是 那 esp_idf example 裡的 sd_card_example_main.c 或 esp-idf sdmmc driver本身就有問題

Estevo
Posts: 2
Joined: Wed Jun 16, 2021 1:55 pm

Re: SPI sdmmc driver 沒有初始 SD card 為 SPI mode

Postby Estevo » Tue Nov 16, 2021 6:02 pm

Good morning, did you get any results? I am having the same error.

Who is online

Users browsing this forum: Google [Bot] and 30 guests