Closed choopk closed 6 years ago
looking at the pinout for that board: https://github.com/LilyGO/TTGO-LORA32-V2.0
and comparing to an example sketch: https://github.com/espressif/arduino-esp32/blob/master/libraries/SD_MMC/examples/SDMMC_Test/SDMMC_Test.ino
it looks like you need to use the SD_MMC library, give that a try?
Nope does not work
when you say doesn't work, what does happen? there is more than one way that sketch might "not work" we would need to know more about what you are using and what it does. what type of SD card are you using? SDHC? SDXC? how is it formatted etc?
It failed to mount. Im using a micro sd. SDHC formatted to fat32
are you able to turn on extra logging? the SD_MMC library doe have log messages in it to help us work out why it failed if you can turn them on.
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) flash read err, 1000 ets_main.c 371 ets Jun 8 2016 00:22:57
rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 188777542, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:956 load:0x40078000,len:0 load:0x40078000,len:13076 entry 0x40078a58 E (69) sdmmc_req: handle_idle_state_events unhandled: 00000004 00000000 E (70) sdmmc_cmd: sdmmc_card_init: send_op_cond (1) returned 0x107 Card Mount Failed
i was looking more for error messages like this one: "Failed to mount filesystem. If you want the card to be formatted, set format_if_mount_failed = true." or this one: "Failed to initialize the card (%d). Make sure SD card lines have pull-up resistors in place."
those error messages seem to come from the ESP IDF, and not in the arduino libraries.
I have not turn on extra logging. How am i suppose to enable it?
it looks like that menu option is only available on the "ESP Dev Module" board option, but that board can be configured to match the options of other varients.
but if you set the flash mode, size and frequency to match your board, set the logging to a higher level such as debug or verbose and then recompile/upload and post the new output.
Failed to initialize the card (263). Make sure SD card lines have pull-up resistors in place. Card Mount Failed
sorry, not sure i can help you any further. according to schematics there are already 10k pullups fitted to all the SD lines.
I don't know if 10k is the correct value though.
only thing i can suggest trying would be commenting out this line to try running at a slower speed?
Did that still giving the same error message. Thanks for the help though
what about if you change it to a much lower speed? eg SDMMC_FREQ_PROBING (400 instead of 20000 or 40000)
alternatively try changing your begin call to:
begin("/sdcard", true);
still getting the same error.
what about using the normal SD lib, but set up the SPI before passing it in. so this example
with the setup changed from:
void setup(){
Serial.begin(115200);
if(!SD.begin()){
Serial.println("Card Mount Failed");
return;
}
to:
void setup(){
Serial.begin(115200);
SPI.begin(14, 2, 15);
if(!SD.begin(13)){
Serial.println("Card Mount Failed");
return;
}
@JamesGKent yup it worked flawlessly!! Thanks :D!
wow, that was a total shot in the dark...
btw just to clarify from my reading here SD cards can be used in 3 modes, one of which is SPI and the other two are SD specific. on AVRs the SPI mode is normally used because there is hardware built in for it, so it is faster that software emulating either of the other two modes. on the ESP it looks like we have the MMC hardware to use the other two modes natively.
I believe those other two modes (particularly the 4 bit mode) should be faster than SPI, however for you it seems that this didn't work.
when using the SD_MMC lib the 4 bit is the default unless the board definition says only 1 bit mode is available, so the default didn't work, my suggestion of using begin("/sdcard", true);
should have activated 1 bit mode, which also didn't work. so my last suggestion using the normal SD lib is using SPI, but configuring the pins of the SPI interface onto the pins normally used by MMC.
Thanks a bunch for the help and the great follow up explanation.
On Mar 9, 2018 7:35 PM, "James" notifications@github.com wrote:
wow, that was a total shot in the dark... btw just to clarify from my reading here http://elm-chan.org/docs/mmc/mmc_e.html SD cards can be used in 3 modes, one of which is SPI and the other two are SD specific. on AVRs the SPI mode is normally used because there is hardware built in for it, so it is faster that software emulating either of the other two modes. on the ESP it looks like we have the MMC hardware to use the other two modes natively. I believe those other two modes (particularly the 4 bit mode) should be faster than SPI, however for you it seems that this didn't work. when using the SD_MMC lib the 4 bit is the default unless the board definition says only 1 bit mode is available, so the default didn't work, my suggestion of using begin("/sdcard", true); should have activated 1 bit mode, which also didn't work. so my last suggestion using the normal SD lib is using SPI, but configuring the pins of the SPI interface onto the pins normally used by MMC.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/espressif/arduino-esp32/issues/1190#issuecomment-371789139, or mute the thread https://github.com/notifications/unsubscribe-auth/AY0YQvpI25P2GbVNqMXWxSLnEbTqkDBxks5tcmjugaJpZM4SgRRg .
@JamesGKent I shared your finding in the Wiki. Thank you.
@beegee-tokyo would it not be worth trying to add some explanation as to what the setup is doing? personally i still think it would be worth trying to investigate why the MMC library doesn't work, but as i don't have one of these boards i am not able to do so.
@JamesGKent You are right, will add some more info to it. Don't have such a board either, so I cannot test anything.
If i insert a FAT formatted SD card in the card reader slot of my TTGOv2 board, and restart it, it seems trying to boot from SD card:
rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun 8 2016 00:22:57
Any hint how to avoid this and boot from internal flash?
For the record: this exact solution works also for the LilyGO ESP32 TTGO T4 V1.1 board.
You can see this board and the pins used for SD card connection here: https://github.com/LilyGO/ESP32-TTGO-T4
@JamesGKent Thanks a lot!
Have a look at https://github.com/espressif/esp-idf/tree/master/examples/storage/sd_card#note-about-gpio12
After having similar problems I followed the espefuse.py set_flash_voltage 3.3V suggestion and all problems went away.
I think this is a irreversible operation.
@JamesGKent thank you very much! I'm now able to use an SD card on a TTGO LoRa32 V2.1 board. Cheers!
If anyone else runs into this, the problem is that the pins_arduino.h header file has the wrong SPI pins for the TTGOV2 board (it has the V1 pins). You can either manually update your pins_arduion.h file or follow @JamesGKent recommendation in https://github.com/espressif/arduino-esp32/issues/1190#issuecomment-371777387 and manually initialize the SPI library with the correct pins. By default, the SD library will automatically call the SPI library with the pins (incorrectly) defined by the boards header file.
This has been reported in https://github.com/platformio/platform-espressif32/issues/344
Has anyone manage to get the SD card library working with this (https://github.com/LilyGO/TTGO-LORA32-V2.0) board. Or is there any other library that you guys can recommend.