M66 SD Card Worked with AT Cmd, but not with openCPU (example_file.c)

Hi,
I am using Quectel M66 module with the latest firmware (M66FAR02A07BT) and the latest openCPU SDK (M66_OpenCPU_GS3_SDK_V2.5).
I use AT Commands to access SD Card files, it works as expected:

[2022-09-12 10:25:12:733_S:] AT+QFLDS=“SD”
[2022-09-12 10:25:12:811_R:] AT+QFLDS=“SD”
[2022-09-12 10:25:12:811_R:] +QFLDS: 7882117120, 7882145792

[2022-09-12 10:26:15:866_R:] OK
[2022-09-12 10:26:33:648_S:] AT+QFOPEN=“SD:test.txt”,0
[2022-09-12 10:26:33:726_R:] AT+QFOPEN=“SD:test.txt”,0
[2022-09-12 10:26:33:726_R:] +QFOPEN: 17760257

[2022-09-12 10:26:33:726_R:] OK
[2022-09-12 10:27:18:865_S:] AT+QFREAD=17760257
[2022-09-12 10:27:18:943_R:] AT+QFREAD=17760257
[2022-09-12 10:27:18:943_R:] CONNECT 14
[2022-09-12 10:27:18:943_R:] salam DonYa!!!
[2022-09-12 10:27:18:943_R:] OK

[2022-09-12 10:27:44:037_S:] AT+QFOPEN=“SD:test2.txt”,0
[2022-09-12 10:27:44:115_R:] AT+QFOPEN=“SD:test2.txt”,0
[2022-09-12 10:27:44:115_R:] +QFOPEN: 17825793

[2022-09-12 10:27:44:115_R:] OK
[2022-09-12 10:28:01:439_S:] AT+QFREAD=17825793
[2022-09-12 10:28:01:517_R:] AT+QFREAD=17825793
[2022-09-12 10:28:01:517_R:] CONNECT 21
[2022-09-12 10:28:01:517_R:] Some Text in ASCII…
[2022-09-12 10:28:01:517_R:] OK

Then I upload the example_file.c into the module, but it doesn’t work when TEST_FOR_MEMORY_CARD is defined. it tell me that SD Card free space and available space is -35 (as you know it’s equal to QL_RET_ERR_FILEFAILED)

Can somebody tell me what’s the problem? :thinking:

Another thing, when I send AT Commands from uploaded example it’s not working too:

---- Sent message: “AT+QFLDS="SD"\r\n” ----
AT+QFLDS=“SD”

+CME ERROR: 4014

Check whether SD is supported

Both original firmware and openCPU:

---- Sent message: “AT+QFLDS=?\r\n” ----
AT+QFLDS=?
OK

functionality difference is in AT+QFLDS=“SD” etc.

Where did you learn about supporting SD?

for AT Command-ish handling, there is a pdf named “Quectel_GSM_FILE_AT_Commands_Manual_V1.5.pdf” that can be downloaded from official page of M66:
GSM/GPRS M66 | Quectel

for file handling using OpenCPU, there is not much reference but the file named “example_file.c” found in OpenCPU SDK have a acceptable explanation…

I remind it again, when I upload bare metal firmware all the functions works great. with SDK v2.5 (or v2.6), UFS works but SD Card, not (even with send handy commands to core).

Sorry, this problem is beyond my ability, please bring up the problem again or wait for someone else to solve it

Hi,
+CME ERROR: 4014 Indicates a file driver ERROR. Please check whether the SD card can be used normally and whether the file path of the SD card is correct. You are advised to delete the files of the SD card in AT mode and then run the example command in example.file.c in open mode.

No luck.

Yes, 4014 is Driver error but SD Card and it’s wiring is same as when M66 runs original firmware. had you test openCPU SD Card handling before? I Doubt SDK v2.6 not support SD itself :thinking:

Hi,I haven’t tested SD on M66, only UFS, but since this example is open in the SDK, I think there is a high probability that it is supported. Maybe something is wrong. Could you please provide me with your main uART log and example_file.c?

I’m using my hand-made VSCode-enabled SDK v2.5. You can test it from here:
qwerty13/M66_OpenCPU_GS3_SDK_V2.5_VSCode: M66 OpenCPU SDK V2.5 Package with Additional Visual Studio Code Features! (github.com)

log of open mode or AT cmd mode? open mode have no notable log and AT mode’s log writed at the first post.

Hi,
I need to know what instructions did you send to the module through Main UART when testing the SD card in Open mode, and what did the module reply

First, code prints this:

<–OpenCPU: FILE(SD) TEST!–>

<–Ql_FS_GetFreeSpace(storage=2) =-35–>

<–Ql_FS_GetTotalSpace(storage=2)=-35–>

then I try to send AT Commands:

---- Sent message: “at\r\n” ----
at
OK

---- Sent message: “AT+QFLDS="SD"\r\n” ----
AT+QFLDS=“SD”

+CME ERROR: 4014

Can anybody reproduce and solve the problem?

Solved the problem!

In custom_sys_cfg.c:

/************************************************************************/
/* Define the GPIO pin for external watchdog.                           */
/* NOTES:                                                               */
/*     Customer may specify two GPIOs if needed.                        */
/************************************************************************/
static const ST_ExtWatchdogCfg wtdCfg = {
    PINNAME_PCM_OUT,  // Specify a pin which connects to the external watchdog
    PINNAME_END   // Specify another pin for watchdog if needed
};
ST_ExtWatchdogCfg* Ql_WTD_GetWDIPinCfg(void)
{
    return (ST_ExtWatchdogCfg*)(&wtdCfg);
}

PCM_OUT most not be set for external watchdog by default beacuse then it can not be used for SDIO! removed both and it works!