Storage API support for small capacity SD cards

user4_esp32
Posts: 21
Joined: Sun Nov 26, 2017 4:48 pm

Storage API support for small capacity SD cards

Postby user4_esp32 » Mon Jan 15, 2018 2:40 pm

Hello,

I am using an ESP-WROOM-32 to test the interface to different SD cards, using the sd_card_example_main.c example from the ESP32 IDF. The interface works with an 8 GB SDHC card, but when I try it with a 128 MB micro SD card and see the following error:

Code: Select all

E (244) sdmmc_cmd: sdmmc_card_init: send_if_cond (1) returned 0x108
E (244) SD_events: Failed to initialize the card (264). Make sure SD card lines have pull-up resistors in place.
Both the SD card adapter and the micro SD card adapter have 10kohm pull-ups soldered on.

Does the Storage API actually support smaller capacity SD cards (below 2 GB)? In the IDF docs (https://esp-idf.readthedocs.io/en/lates ... sdmmc.html), I see:

"Despite the name, only SD (SDSC/SDHC/SDXC) cards are supported at the moment."

Does "SDSC" mean small capacity?

Thanks.

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

Re: Storage API support for small capacity SD cards

Postby ESP_igrr » Mon Jan 15, 2018 3:46 pm

SDSC means "standard capacity", which is a term used in SD specification. 128MB cards are typically SDSC.
SDMMC driver does not have limitations related to card size, and 128MB (and even 64MB) cards were among those which we have tested. However, among SDSC cards we have found quite a few cards which implement parts of SD specification in interesting ways. For some cases, we have added workarounds in SDMMC driver, some we haven't covered.
It would help if you could set log level to Verbose in menuconfig (component config > log output), post the complete log you get with such a card as a gist, and link it here.
Also please mention the version of IDF you are running.

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: Storage API support for small capacity SD cards

Postby loboris » Mon Jan 15, 2018 5:09 pm

I've been using an old Nokia 64 MB sdcard without any problem.

user4_esp32
Posts: 21
Joined: Sun Nov 26, 2017 4:48 pm

Re: Storage API support for small capacity SD cards

Postby user4_esp32 » Thu Jan 25, 2018 1:32 pm

Thanks for the tips ESP_igrr--the verbose output is very helpful.

I am not sure which version of the ESP32 IDF I have, but I cloned it from git on 17 Nov 2017, if that helps, and I have not updated since.

Is there a command line method to check the version?

Here is the verbose output using the sd example:

Code: Select all


I (145) cpu_start: Starting scheduler on PRO CPU.
V (0) intr_alloc: esp_intr_alloc_intrstatus (cpu 1): checking args
V (0) intr_alloc: esp_intr_alloc_intrstatus (cpu 1): Args okay. Resulting flags 0x40E
D (10) intr_alloc: Connected src 25 to int 2 (cpu 1)
I (10) cpu_start: Starting scheduler on APP CPU.
D (195) heap_init: New heap initialised at 0x3ffe0440
D (195) heap_init: New heap initialised at 0x3ffe4350
V (205) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (205) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xE
D (205) intr_alloc: Connected src 16 to int 12 (cpu 0)
I (225) SD_events: Initializing SD card
SD Running on Core: 0
I (235) SD_events: Using SPI peripheral
D (235) sdspi_host: sdspi_host_init_slot: SPI2 miso=13 mosi=27 sck=14 cs=26 cd=-1 wp=-1, dma_ch=1
V (245) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (255) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0x80E
D (255) intr_alloc: Connected src 30 to int 13 (cpu 0)
I (265) gpio: GPIO[26]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
D (275) sdmmc_cmd: sdmmc_card_init
V (275) sdmmc_cmd: sending cmd slot=1 op=0 arg=0 flags=20 data=0x0 blklen=0 datalen=0 timeout=1000
V (285) sdspi_host: sdspi_host_start_command: slot=1, CMD0, arg=0x00000000 flags=0x4, data=0x0, data_size=0 crc=0x4a
V (295) sdspi_transaction: r1 = 0xff hw_cmd.r[0]=0xffffffff
V (305) sdmmc_cmd: cmd response 000000ff 00000000 00000000 00000000 err=0x0 state=0
V (325) sdmmc_cmd: sending cmd slot=1 op=0 arg=0 flags=20 data=0x0 blklen=0 datalen=0 timeout=1000
V (325) sdspi_host: sdspi_host_start_command: slot=1, CMD0, arg=0x00000000 flags=0x4, data=0x0, data_size=0 crc=0x4a
V (325) sdspi_transaction: r1 = 0x01 hw_cmd.r[0]=0xffffffff
V (335) sdmmc_cmd: cmd response 00000001 00000000 00000000 00000000 err=0x0 state=0
V (365) sdmmc_cmd: sending cmd slot=1 op=8 arg=1aa flags=1c30 data=0x0 blklen=0 datalen=0 timeout=1000
V (365) sdspi_host: sdspi_host_start_command: slot=1, CMD8, arg=0x000001aa flags=0x20, data=0x0, data_size=0 crc=0x43
V (365) sdspi_transaction: r1 = 0x01 hw_cmd.r[0]=0xaa010000
V (375) sdmmc_cmd: cmd response 000001aa 00000000 00000000 00000000 err=0x0 state=0
D (385) sdmmc_cmd: SDHC/SDXC card
V (385) sdmmc_cmd: sending cmd slot=1 op=59 arg=1 flags=1c00 data=0x0 blklen=0 datalen=0 timeout=1000
V (395) sdspi_host: sdspi_host_start_command: slot=1, CMD59, arg=0x00000001 flags=0x4, data=0x0, data_size=0 crc=0x41
D (405) sdspi_host: data CRC set=1
V (405) sdspi_transaction: r1 = 0x01 hw_cmd.r[0]=0xffffffff
V (415) sdmmc_cmd: cmd response 00000001 00000000 00000000 00000000 err=0x0 state=0
V (425) sdmmc_cmd: sending cmd slot=1 op=55 arg=0 flags=1c00 data=0x0 blklen=0 datalen=0 timeout=1000
V (435) sdspi_host: sdspi_host_start_command: slot=1, CMD55, arg=0x00000000 flags=0x4, data=0x0, data_size=0 crc=0x32
V (445) sdspi_transaction: r1 = 0x01 hw_cmd.r[0]=0xffffffff
V (445) sdmmc_cmd: cmd response 00000001 00000000 00000000 00000000 err=0x0 state=0
V (455) sdmmc_cmd: sending cmd slot=1 op=41 arg=40ff8000 flags=1030 data=0x0 blklen=0 datalen=0 timeout=1000
V (465) sdspi_host: sdspi_host_start_command: slot=1, CMD41, arg=0x40ff8000 flags=0x4, data=0x0, data_size=0 crc=0x0b
V (475) sdspi_transaction: r1 = 0x01 hw_cmd.r[0]=0xffffffff
V (485) sdmmc_cmd: cmd response 00000001 00000000 00000000 00000000 err=0x0 state=0
V (495) sdmmc_cmd: sending cmd slot=1 op=55 arg=0 flags=1c00 data=0x0 blklen=0 datalen=0 timeout=1000
V (495) sdspi_host: sdspi_host_start_command: slot=1, CMD55, arg=0x00000000 flags=0x4, data=0x0, data_size=0 crc=0x32
V (515) sdspi_transaction: r1 = 0x01 hw_cmd.r[0]=0xffffffff
V (515) sdmmc_cmd: cmd response 00000001 00000000 00000000 00000000 err=0x0 state=0
V (525) sdmmc_cmd: sending cmd slot=1 op=41 arg=40ff8000 flags=1030 data=0x0 blklen=0 datalen=0 timeout=1000
V (535) sdspi_host: sdspi_host_start_command: slot=1, CMD41, arg=0x40ff8000 flags=0x4, data=0x0, data_size=0 crc=0x0b
V (545) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0xffffffff
V (545) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (555) sdmmc_cmd: sending cmd slot=1 op=58 arg=0 flags=1630 data=0x0 blklen=0 datalen=0 timeout=1000
V (565) sdspi_host: sdspi_host_start_command: slot=1, CMD58, arg=0x00000000 flags=0x10, data=0x0, data_size=0 crc=0x7e
V (575) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0x0080ff80
V (585) sdmmc_cmd: cmd response 80ff8000 00000000 00000000 00000000 err=0x0 state=0
D (595) sdmmc_cmd: host_ocr=0x40ff8000 card_ocr=0x80ff8000
D (595) sdmmc_cmd: sdmmc_card_init: host_ocr=40ff8000, card_ocr=80ff8000
V (605) sdmmc_cmd: sending cmd slot=1 op=10 arg=0 flags=50 data=0x3ffb4590 blklen=0 datalen=16 timeout=1000
V (615) sdspi_host: sdspi_host_start_command: slot=1, CMD10, arg=0x00000000 flags=0x5, data=0x3ffb4590, data_size=16 crc=0x0d
V (625) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0x0000feff
V (625) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (635) sdmmc_cmd: sending cmd slot=1 op=9 arg=0 flags=1c50 data=0x3ffb4590 blklen=0 datalen=16 timeout=1000
V (645) sdspi_host: sdspi_host_start_command: slot=1, CMD9, arg=0x00000000 flags=0x5, data=0x3ffb4590, data_size=16 crc=0x57
V (655) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0x7f00feff
V (665) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (675) sdmmc_cmd: sending cmd slot=1 op=16 arg=200 flags=1c00 data=0x0 blklen=0 datalen=0 timeout=1000
V (685) sdspi_host: sdspi_host_start_command: slot=1, CMD16, arg=0x00000200 flags=0x4, data=0x0, data_size=0 crc=0x0a
V (695) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0xffffffff
V (695) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (705) sdmmc_cmd: sending cmd slot=1 op=55 arg=0 flags=1c00 data=0x0 blklen=0 datalen=0 timeout=1000
V (715) sdspi_host: sdspi_host_start_command: slot=1, CMD55, arg=0x00000000 flags=0x4, data=0x0, data_size=0 crc=0x32
V (725) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0xffffffff
V (735) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (735) sdmmc_cmd: sending cmd slot=1 op=51 arg=0 flags=1c50 data=0x3ffb35bc blklen=8 datalen=8 timeout=1000
V (745) sdspi_host: sdspi_host_start_command: slot=1, CMD51, arg=0x00000000 flags=0x5, data=0x3ffb35bc, data_size=8 crc=0x63
V (765) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0xa501feff
V (765) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
D (775) sdmmc_cmd: switching to DS bus mode
D (775) sdspi_host: Setting card clock to 20000 kHz
V (785) sdmmc_cmd: sending cmd slot=1 op=55 arg=0 flags=1c00 data=0x0 blklen=0 datalen=0 timeout=1000
V (795) sdspi_host: sdspi_host_start_command: slot=1, CMD55, arg=0x00000000 flags=0x4, data=0x0, data_size=0 crc=0x32
V (805) sdspi_transaction: r1 = 0xff hw_cmd.r[0]=0xffffffff
V (805) sdmmc_cmd: cmd response 000000ff 00000000 00000000 00000000 err=0x0 state=0
V (815) sdmmc_cmd: sending cmd slot=1 op=51 arg=0 flags=1c50 data=0x3ffb35bc blklen=8 datalen=8 timeout=1000
V (825) sdspi_host: sdspi_host_start_command: slot=1, CMD51, arg=0x00000000 flags=0x5, data=0x3ffb35bc, data_size=8 crc=0x63
V (835) sdspi_transaction: r1 = 0xff hw_cmd.r[0]=0x0000a501
V (845) sdmmc_cmd: cmd response 000000ff 00000000 00000000 00000000 err=0x0 state=0
D (855) vfs_fat_sdmmc: using pdrv=0
V (855) sdmmc_cmd: sending cmd slot=1 op=17 arg=0 flags=1c50 data=0x3ffb680c blklen=512 datalen=512 timeout=1000
V (865) sdspi_host: sdspi_host_start_command: slot=1, CMD17, arg=0x00000000 flags=0x5, data=0x3ffb680c, data_size=512 crc=0x2a
V (875) sdspi_transaction: r1 = 0xff hw_cmd.r[0]=0x00000000
V (885) sdmmc_cmd: cmd response 000000ff 00000000 00000000 00000000 err=0x0 state=0
V (885) sdmmc_cmd: sending cmd slot=1 op=17 arg=c200 flags=1c50 data=0x3ffb680c blklen=512 datalen=512 timeout=1000
V (895) sdspi_host: sdspi_host_start_command: slot=1, CMD17, arg=0x0000c200 flags=0x5, data=0x3ffb680c, data_size=512 crc=0x02
V (915) sdspi_transaction: r1 = 0xff hw_cmd.r[0]=0x4d9000eb
V (915) sdmmc_cmd: cmd response 000000ff 00000000 00000000 00000000 err=0x0 state=0
Name:
Type: SDSC
Speed: default speed
Size: 121MB
CSD: ver=0, sector_size=512, capacity=247808 read_bl_len=9
SCR: sd_spec=1, bus_width=5
I (935) SD_events: Opening file
V (945) vfs_fat: vfs_fat_open: path="/hello.txt", flags=601, mode=1b6
V (945) sdmmc_cmd: sending cmd slot=1 op=17 arg=14000 flags=1c50 data=0x3ffb680c blklen=512 datalen=512 timeout=1000
V (955) sdspi_host: sdspi_host_start_command: slot=1, CMD17, arg=0x00014000 flags=0x5, data=0x3ffb680c, data_size=512 crc=0x68
V (975) sdspi_transaction: r1 = 0xff hw_cmd.r[0]=0x20202020
V (975) sdmmc_cmd: cmd response 000000ff 00000000 00000000 00000000 err=0x0 state=0
V (985) sdmmc_cmd: sending cmd slot=1 op=17 arg=14200 flags=1c50 data=0x3ffb680c blklen=512 datalen=512 timeout=1000
V (995) sdspi_host: sdspi_host_start_command: slot=1, CMD17, arg=0x00014200 flags=0x5, data=0x3ffb680c, data_size=512 crc=0x7e
V (1005) sdspi_transaction: r1 = 0xff hw_cmd.r[0]=0x31313030
V (1015) sdmmc_cmd: cmd response 000000ff 00000000 00000000 00000000 err=0x0 state=0
V (1015) sdmmc_cmd: sending cmd slot=1 op=24 arg=14200 flags=1c10 data=0x3ffb680c blklen=512 datalen=512 timeout=5000
V (1025) sdspi_host: sdspi_host_start_command: slot=1, CMD24, arg=0x00014200 flags=0x7, data=0x3ffb680c, data_size=512 crc=0x63
D (1045) sdspi_host: start_command_write_blocks: invalid R1 response: 0xff
E (1045) sdspi_host: sdspi_host_start_command: cmd=24 error=0x108
D (1055) sdmmc_cmd: sdmmc_req_run returned 0x108
E (1055) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x108
E (1065) diskio_sdmmc: sdmmc_write_blocks failed (264)
D (1075) vfs_fat: vfs_fat_write: fresult=1
V (1075) sdmmc_cmd: sending cmd slot=1 op=24 arg=14200 flags=1c10 data=0x3ffb680c blklen=512 datalen=512 timeout=5000
V (1085) sdspi_host: sdspi_host_start_command: slot=1, CMD24, arg=0x00014200 flags=0x7, data=0x3ffb680c, data_size=512 crc=0x63
D (1095) sdspi_host: start_command_write_blocks: invalid R1 response: 0xff
E (1105) sdspi_host: sdspi_host_start_command: cmd=24 error=0x108
D (1115) sdmmc_cmd: sdmmc_req_run returned 0x108
E (1115) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x108
E (1125) diskio_sdmmc: sdmmc_write_blocks failed (264)
D (1135) vfs_fat: vfs_fat_close: fresult=1
I (1135) SD_events: File written
V (1135) sdmmc_cmd: sending cmd slot=1 op=24 arg=14200 flags=1c10 data=0x3ffb680c blklen=512 datalen=512 timeout=5000
V (1145) sdspi_host: sdspi_host_start_command: slot=1, CMD24, arg=0x00014200 flags=0x7, data=0x3ffb680c, data_size=512 crc=0x63
D (1165) sdspi_host: start_command_write_blocks: invalid R1 response: 0xff
E (1165) sdspi_host: sdspi_host_start_command: cmd=24 error=0x108
D (1175) sdmmc_cmd: sdmmc_req_run returned 0x108
E (1175) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x108
E (1185) diskio_sdmmc: sdmmc_write_blocks failed (264)
D (1195) vfs_fat: vfs_fat_stat: fresult=1
I (1195) SD_events: Renaming file
V (1205) sdmmc_cmd: sending cmd slot=1 op=24 arg=14200 flags=1c10 data=0x3ffb680c blklen=512 datalen=512 timeout=5000
V (1215) sdspi_host: sdspi_host_start_command: slot=1, CMD24, arg=0x00014200 flags=0x7, data=0x3ffb680c, data_size=512 crc=0x63
D (1225) sdspi_host: start_command_write_blocks: invalid R1 response: 0xff
E (1225) sdspi_host: sdspi_host_start_command: cmd=24 error=0x108
D (1235) sdmmc_cmd: sdmmc_req_run returned 0x108
E (1245) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x108
E (1245) diskio_sdmmc: sdmmc_write_blocks failed (264)
D (1255) vfs_fat: vfs_fat_rename: fresult=1
E (1255) SD_events: Rename failed


Who is online

Users browsing this forum: No registered users and 118 guests