atomic14 / esp32-tv

ESP32 - Sound and Vision - Video Streaming to the ESP32
158 stars 27 forks source link

Some SD-cards are not recognized #19

Closed joekam54 closed 3 weeks ago

joekam54 commented 6 months ago

Hello, I found out that some SD-cards could not get mounted-are not recognized.

Device Cheap-Yellow-Display.

I have 2 manufact. Sandisk 16 GB , Intenso 4 GB, the Sanisk card works with the player, the Intenso not.

Attached the serial outputs for both. both are class10 card's, The Intenso works with the device with another code flawless.

image serial-intenso.txt serial-sandisk.txt

cgreening commented 6 months ago

I can only suggest is to decrease the clock rate that is used to talk to the SDCard.

Line 72 of SDCard.cpp

  m_host.max_freq_khz = SDMMC_FREQ_52M;

Try changing this to SDMMC_FREQ_26M or even a hard coded very low value like 10000000.

Also, make sure you are power cycling the board completely.

There may be more information when the board first powers up, but currently it will go into a boot loop when the SD Card fails.

cgreening commented 5 months ago

Can you give it a go with the latest firmware - I want to see if there are more logs on startup and this change should prevent the boot loop.

joekam54 commented 5 months ago

cyd-log_new_PF-ini.txt Hi , updated the Platformioini with your changes, --There are more logs nw, but behavior is the same. Log attached

cgreening commented 5 months ago

So, all I can suggest is changing the SPI speed to a lower value and seeing if that fixes it. We're using the IDF code for the SD Card access and if that doesn't work I'm not sure how to fix it.

One way might be to go back to using the Arduino code if that is more reliable.

KevynWithaY commented 5 months ago

I've had success by using 1-bit mode in the sdmmc section of the SDCard class, using the miso, mosi and clk lines only. Card mounts and I can even use higher speed. Just gotta disconnect GPIO2 when you need to flash.

joekam54 commented 5 months ago

I can only suggest is to decrease the clock rate that is used to talk to the SDCard.

Line 72 of SDCard.cpp

  m_host.max_freq_khz = SDMMC_FREQ_52M;

Try changing this to SDMMC_FREQ_26M or even a hard coded very low value like 10000000.

Also, make sure you are power cycling the board completely.

There may be more information when the board first powers up, but currently it will go into a boot loop when the SD Card fails.

Hi, I patched my cde with your last changes and tryed with 26M and it also was not working, but it works with the default m_host.max_freq_khz = SDMMC_FREQ_DEFAULT;

... so this in 20 mhz Funny thing I have tested it with a few different sdcard brand' before the cange it only worked wih the Sandisk Ultra from the Picture.

davidhampgonsalves commented 3 weeks ago

I had the same experience with two of my SD cards (and switching to SDMMC_FREQ_DEFAULT resolved it).

@cgreening Would you be interested in a small PR to change to using SDMMC_FREQ_DEFAULT or do you think it would negatively impact other use cases?

cgreening commented 3 weeks ago

Let's lower it down. I think there's a lot of cards that can't handle the full speed.

Pull request would be much appreciated! Thank you!

davidhampgonsalves commented 3 weeks ago

Thanks @cgreening for the amazing project. https://github.com/atomic14/esp32-tv/pull/23 is ready for review.