Xinyuan-LilyGO / T-SIM7600X

124 stars 41 forks source link

Cannot mount SD card #55

Closed Sell24 closed 1 year ago

Sell24 commented 1 year ago

Hardware: LilyGo TTGO T-SIM7600NA ESP32 Platform: Espressif 32 v6.3.1 Board: Esp32dev PlatformIO IDE: 3.2.0 Packages: framework-arduinoespressif32 @ 3.20009.0 (2.0.9)

First let me say, I am not 100% sure this is an issue with this module but I going to ask the question here just in case I either have missed something and someone has got an SD card to work.

I have tried two different manufacturer cards (SanDisk and Lexar) both formatted with FAT32

This is the code I am using to mount the card. Note this init code was extracted from AllFunctions.ino.

// Libraries for SD card
#include <SD.h>
#include <SPI.h>

// Define CS pin for the SD card module
#define SD_MISO     2
#define SD_MOSI     15
#define SD_SCLK     14
#define SD_CS       13

void setup() {
  // Start serial communication for debugging purposes
  Serial.begin(115200);

  // Initialize SD card
  SPI.begin(SD_SCLK, SD_MISO, SD_MOSI, SD_CS);

  if (!SD.begin(SD_CS)) {
    Serial.println("SDCard MOUNT FAIL");
  } else {
    uint32_t cardSize = SD.cardSize() / (1024 * 1024);
    String str = "SDCard Size: " + String(cardSize) + "MB";
    Serial.println(str);
  }

}

void loop() {

}

I have tried setting the SPIClass and Datamode and nothing seems to get these cards to mount.

I have also used the examples in the Arduino IDE and they did not work either.

The error returning is:

16:00:58.069 > [   974][E][sd_diskio.cpp:802] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
16:00:58.569 > [  1474][E][sd_diskio.cpp:126] sdSelectCard(): Select Failed

I have posted comments in this issue https://github.com/espressif/arduino-esp32/issues/7707 as it seems this is an issue with the library but again I am just inquiring just in case my setup is incorrect.

Any help would be appreciated @lewisxhe

lewisxhe commented 1 year ago

Initialize SD card before importing

//Initialize SDCard
    pinMode(SD_MISO, INPUT_PULLUP);
    SPI.begin(SD_SCLK, SD_MISO, SD_MOSI, SD_CS);
    if (!SD.begin(SD_CS)) {
        Serial.println("SDCard MOUNT FAIL"); while (1);
    } else {
        uint32_t cardSize = SD.cardSize() / (1024 * 1024);
        String str = "SDCard Size: " + String(cardSize) + "MB";
        Serial.println(str);
    }
Sell24 commented 1 year ago

@lewisxhe Thank you for your quick response. But adding the pinMode does not seem to work for me. I have tried 3 different SD cards.

lewisxhe commented 1 year ago

When I tried to print this issue, I looked at the SD card and found out that it was not possible. https://github.com/Xinyuan-LilyGO/T-SIM7600X/tree/master/firmware

Sell24 commented 1 year ago

Thanks again for the response. Yes sorry the url text is correct just not the actual url. Here is is again:

https://github.com/espressif/arduino-esp32/issues/7707

I assume that is what you are asking me. Otherwise I am not sure what you are telling me by including the link to the firmware. Do I need to update the firmware?

lewisxhe commented 1 year ago

Sorry, the response was incorrect. Please use the firmware in the link for testing and troubleshoot any issues with the firmware. If it still doesn't work, then the hardware should be damaged

Sell24 commented 1 year ago

Just to let you know I have tried this with two different boards and multiple different SD cards with the same result.

I am still not sure how to use the tool to test and troubleshoot. As far as I can understand all it does is download new firmware. Which I did with the settings from your link. Here is the result.

image

Even after doing this, it still does not work. I can understand one board having an issue but two? The second one is brand new.

lewisxhe commented 1 year ago

After writing, open the monitor to check if SD was detected at the beginning of startup

What is your SD capacity? Each board has been tested before leaving the factory, and it is unlikely that both have problems

Sell24 commented 1 year ago

I did as you asked and I still have the same issue. I have zero experience with the flash tool, so if you could verify the settings I used are correct, I would appreciate it.

The size of the SD is 32GB. They were the only ones I could find. As I mentioned there were reported issues with the SanDisk cards (see link to the issue previously) so I bought Lexar ones, but same issue.

I have a colleague that has two of the same boards (we bought 6 in total so far) and I will ask him to try the code. I am not sure what capacity his SD card is but once we try this, I will get back to you on that as well.

Sell24 commented 1 year ago

Actually I realized that in the latest version of software, this option is on by default.

image

which means that I did not actually download anything the first time. So once it downloaded the code, this is the output I got which still shows a failure. I tried this on the second board which I have barely used.

image

lewisxhe commented 1 year ago

Then there is no need to doubt, it is broken. The circuit of sd is very simple, if you can, you can repair the SD card holder

Sell24 commented 1 year ago

Just so I understand, you believe this is a hardware circuit issue on both boards and not a software issue?

Once I get my colleague to try his boards, I will let you know the results.

lewisxhe commented 1 year ago

Yes, I think so. Looking forward to your test results

Sell24 commented 1 year ago

Hi Lewis,

I had my colleague try his boards and they worked fine. Turns out you were right, it was a hardware issue but with cards and not the boards. I went out and bought a completely new set of SD cards and they worked. I didn't even need pull the pin to high. Standard code worked.

Thanks so much for taking the time again to help me. It is very much appreciated and sorry for the trouble.