M5Core2 and SD-Card stack challenge
-
Hello,
I used ESP-IDF v4.4-beta1, Arduino 2.0.2 for and M5Core2-Library ("0.1.0" = newest version, I also checked 0.0.3). The Arduino libraries I got from "https://github.com/espressif/arduino-esp32.git" and the M5Core2 Library I loaded from "https://github.com/m5stack/M5Core2.git".
I can initialize the M5Core2, write text on the screen and connect to wifi. If I activated the SD-Card I got an error: "A stack overflow in task main has been detected."
I looked for the cause and it are these calls:
bool SD_Enabler = true; M5.begin(true, SD_Enabler, true, false, kMBusModeInput); -> SD.begin(TFCARD_CS_PIN, SPI, 40000000); -> if(!sdcard_mount(_pdrv, mountpoint, max_files, format_if_empty)){ -> FRESULT res = f_mount(fs, drv, 1);
The reason for the stack challenge is f_mount.
There are only two parameters for this function:FATFS* fs; char drv[3] = {(char)('0' + pdrv), ':', 0};
The value for drv is "0:" and seemed okay. The parameter fs was initialled some lines one before without an error:
esp_err_t err = esp_vfs_fat_register(path, drv, max_files, &fs); if (err == ESP_ERR_INVALID_STATE) { log_e("esp_vfs_fat_register failed 0x(%x): SD is registered.", err); return false; } else if (err != ESP_OK) { log_e("esp_vfs_fat_register failed 0x(%x)", err); return false; }
I didn't know what happened. Have anyone a good idea?