Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to initlialize/mount 32GB and 64GB sdcards (IDFGH-9144) #10542

Closed
3 tasks done
listout opened this issue Jan 13, 2023 · 6 comments
Closed
3 tasks done

Failed to initlialize/mount 32GB and 64GB sdcards (IDFGH-9144) #10542

listout opened this issue Jan 13, 2023 · 6 comments
Assignees
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@listout
Copy link

listout commented Jan 13, 2023

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.0

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

Development Kit.

ESP32-PICO-DevKitM-2

Power Supply used.

USB

What is the expected behavior?

Mount/initialize sd card successfully.

What is the actual behavior?

Cannout mount/initialize SD card. Initialization fails with sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107.

Similar issue to this thread on forum.

Steps to reproduce.

  1. From tag v5.0 build the sdspi example
  2. Correct appt. pins to sdcard module
  3. Observe failure

Debug Logs.

I (30) boot: ESP-IDF v5.0-dirty 2nd stage bootloader
I (30) boot: compile time 23:47:53
I (30) boot: chip revision: v3.0
I (33) boot_comm: chip revision: 3, min. bootloader chip revision: 0
I (40) boot.esp32: SPI Speed      : 40MHz
I (45) boot.esp32: SPI Mode       : DIO
I (49) boot.esp32: SPI Flash Size : 2MB
I (54) boot: Enabling RNG early entropy source...
I (59) boot: Partition Table:
I (63) boot: ## Label            Usage          Type ST Offset   Length
I (70) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (78) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (85) boot:  2 factory          factory app      00 00 00010000 00100000
I (93) boot: End of partition table
I (97) boot_comm: chip revision: 3, min. application chip revision: 0
I (104) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=0c7e4h ( 51172) map
I (131) esp_image: segment 1: paddr=0001c80c vaddr=3ffb0000 size=02800h ( 10240) load
I (135) esp_image: segment 2: paddr=0001f014 vaddr=40080000 size=01004h (  4100) load
I (139) esp_image: segment 3: paddr=00020020 vaddr=400d0020 size=24a08h (150024) map
I (200) esp_image: segment 4: paddr=00044a30 vaddr=40081004 size=0c650h ( 50768) load
I (221) esp_image: segment 5: paddr=00051088 vaddr=50000000 size=00010h (    16) load
I (228) boot: Loaded app from partition at offset 0x10000
I (228) boot: Disabling RNG early entropy source...
I (241) cpu_start: Pro cpu up.
I (241) cpu_start: Starting app cpu, entry point is 0x40081194
0x40081194: call_start_cpu1 at /home/listout/esp/esp-idf-v5.0/components/esp_system/port/cpu_start.c:142

I (0) cpu_start: App cpu up.
I (255) cpu_start: Pro cpu start user code
I (255) cpu_start: cpu freq: 160000000 Hz
I (255) cpu_start: Application information:
I (260) cpu_start: Project name:     sd_card
I (265) cpu_start: App version:      1
I (269) cpu_start: Compile time:     Jan 13 2023 23:56:38
I (275) cpu_start: ELF file SHA256:  bd976416abda1b1c...
I (281) cpu_start: ESP-IDF:          v5.0-dirty
I (287) heap_init: Initializing. RAM available for dynamic allocation:
I (294) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (300) heap_init: At 3FFB3188 len 0002CE78 (179 KiB): DRAM
I (306) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (312) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (319) heap_init: At 4008D654 len 000129AC (74 KiB): IRAM
I (326) spi_flash: detected chip: generic
I (330) spi_flash: flash io: dio
W (334) spi_flash: Detected size(8192k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (348) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (358) example: Initializing SD card
I (358) example: Using SPI peripheral
I (368) example: Mounting filesystem
I (368) gpio: GPIO[20]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (418) sdspi_transaction: cmd=5, R1 response: command not supported
E (1418) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
E (1418) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
I (1418) gpio: GPIO[20]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
E (1428) example: Failed to initialize the card (ESP_ERR_TIMEOUT). Make sure SD card lines have pull-up resistors in place.

More Information.

SD card used was SanDisk Ultra microSDHC UHS-I card of 32 GB, same issue with 64 GB. Adapter was just a generic micro sdcard adapter found on Amazon.

WhatsApp Image 2023-01-13 at 5 05 09 PM

@listout listout added the Type: Bug bugs in IDF label Jan 13, 2023
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jan 13, 2023
@github-actions github-actions bot changed the title Failed to initlialize/mount 32GB and 64GB sdcards Failed to initlialize/mount 32GB and 64GB sdcards (IDFGH-9144) Jan 13, 2023
@igrr
Copy link
Member

igrr commented Jan 13, 2023

@listout Here are a few things you can do to troubleshoot this:

  • Which GPIOs are you using to connect the card?
  • Do any other SD cards work with the same software version and hardware setup?
  • What is the log output if you set the log level to Verbose in menuconfig? (Please don't paste it inline, instead attach as a file or post a link to a gist.)
  • You can check the data exchanged between the ESP and the card using a logic analyzer, check if the card is actually sending the response to the last command.

@listout
Copy link
Author

listout commented Jan 13, 2023

  1. Here are the gpio defs for the dev board I'm using
#define PIN_NUM_MISO 12
#define PIN_NUM_MOSI 13
#define PIN_NUM_CLK 14
#define PIN_NUM_CS 20
  1. Yes. I've other 16GB sdcards that work fine with same code. This the first 64 GB sdcard I'm trying
  2. http://ix.io/4l6H or https://gist.github.com/listout/73d0ce52433b1953b208665b810b0080
  3. Alright, i'll try that

@listout
Copy link
Author

listout commented Jan 14, 2023

Hey @igrr any ideas/clues looking at the logs? I don't have an logic analyzer right now, hence taking a bit time on that part. I've tried mounting the card on my PC, and it works fine.

Also this looks like a recurring issue #6686

@igrr
Copy link
Member

igrr commented Jan 14, 2023

There can be multiple reasons for the issue at this stage of card initialization process, most common ones are:

To figure out which of these is the case we need to know whether

  • the card gives some response, but the driver fails to read it properly
  • or the card doesn't give any response

Usually the easiest way is to check that using a logic analyzer. If you have access to a known-good hardware (like ESP32-WROVER-KIT board), testing the card with that hardware can also provide a clue.

@listout
Copy link
Author

listout commented Jan 21, 2023

@igrr I've managed to get my hands on a Logic Analyzer. I'm not sure how to share the data with you. I'm using salae software where I can either export as csv or save the session. I'm attaching SS and save session for a working vs non-working card. Hope this helps in debugging.

Channel 0 was my MOSI and 1 was MISO

Not working Card SS

Screenshot from 2023-01-21 20-46-12

Working Card SS
Screenshot from 2023-01-21 20-49-00

Saved Sessions: saves.zip

@ilxj
Copy link

ilxj commented Feb 23, 2024

I also encountered the same problem. Any update about this?

@espressif-bot espressif-bot assigned igrr and unassigned pacucha42 Feb 28, 2024
@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: Opened Issue is new Status: Reviewing Issue is being reviewed labels Feb 28, 2024
espressif-bot pushed a commit that referenced this issue Mar 14, 2024
ACMD41 argument is different between SD mode and SPI mode.
In SPI mode, the only non-zero bit may be the HCS bit. Unlike the SD
mode, the bits reflecting the host's OCR should be zero.
Previously, we used to set these bits the same way as for the SD mode.
This has caused certain cards to fail initializing, apparently their
controllers have checked the ACMD41 argument more strictly and refused
to finish initialization, resulting in an error such as

    sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107

(Note that this error may have other causes than the one fixed in
this commit. For example, if the card doesn't have a sufficient and
stable power supply, it may also fail to complete the internal
initialization process, and will never clear the busy flag in R1
response.)

Closes #6686
Closes #10542
espressif-bot pushed a commit that referenced this issue Mar 15, 2024
ACMD41 argument is different between SD mode and SPI mode.
In SPI mode, the only non-zero bit may be the HCS bit. Unlike the SD
mode, the bits reflecting the host's OCR should be zero.
Previously, we used to set these bits the same way as for the SD mode.
This has caused certain cards to fail initializing, apparently their
controllers have checked the ACMD41 argument more strictly and refused
to finish initialization, resulting in an error such as

    sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107

(Note that this error may have other causes than the one fixed in
this commit. For example, if the card doesn't have a sufficient and
stable power supply, it may also fail to complete the internal
initialization process, and will never clear the busy flag in R1
response.)

Closes #6686
Closes #10542
espressif-bot pushed a commit that referenced this issue Mar 16, 2024
ACMD41 argument is different between SD mode and SPI mode.
In SPI mode, the only non-zero bit may be the HCS bit. Unlike the SD
mode, the bits reflecting the host's OCR should be zero.
Previously, we used to set these bits the same way as for the SD mode.
This has caused certain cards to fail initializing, apparently their
controllers have checked the ACMD41 argument more strictly and refused
to finish initialization, resulting in an error such as

    sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107

(Note that this error may have other causes than the one fixed in
this commit. For example, if the card doesn't have a sufficient and
stable power supply, it may also fail to complete the internal
initialization process, and will never clear the busy flag in R1
response.)

Closes #6686
Closes #10542
espressif-bot pushed a commit that referenced this issue Mar 26, 2024
ACMD41 argument is different between SD mode and SPI mode.
In SPI mode, the only non-zero bit may be the HCS bit. Unlike the SD
mode, the bits reflecting the host's OCR should be zero.
Previously, we used to set these bits the same way as for the SD mode.
This has caused certain cards to fail initializing, apparently their
controllers have checked the ACMD41 argument more strictly and refused
to finish initialization, resulting in an error such as

    sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107

(Note that this error may have other causes than the one fixed in
this commit. For example, if the card doesn't have a sufficient and
stable power supply, it may also fail to complete the internal
initialization process, and will never clear the busy flag in R1
response.)

Closes #6686
Closes #10542
DarkZeros pushed a commit to DarkZeros/esp-idf that referenced this issue May 3, 2024
ACMD41 argument is different between SD mode and SPI mode.
In SPI mode, the only non-zero bit may be the HCS bit. Unlike the SD
mode, the bits reflecting the host's OCR should be zero.
Previously, we used to set these bits the same way as for the SD mode.
This has caused certain cards to fail initializing, apparently their
controllers have checked the ACMD41 argument more strictly and refused
to finish initialization, resulting in an error such as

    sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107

(Note that this error may have other causes than the one fixed in
this commit. For example, if the card doesn't have a sufficient and
stable power supply, it may also fail to complete the internal
initialization process, and will never clear the busy flag in R1
response.)

Closes espressif#6686
Closes espressif#10542
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

5 participants