For example, I tested code:
Config:
Code: Select all
sdmmc_card_t* card;
esp_vfs_fat_sdmmc_mount_config_t mount_config;
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
gpio_set_pull_mode(CMD_SD, GPIO_PULLUP_ONLY); // CMD
gpio_set_pull_mode(DATA0_SD, GPIO_PULLUP_ONLY); // D0
gpio_set_pull_mode(DATA1_SD, GPIO_PULLUP_ONLY); // D1
gpio_set_pull_mode(DATA2_SD, GPIO_PULLUP_ONLY); // D2
gpio_set_pull_mode(DATA3_SD, GPIO_PULLUP_ONLY); // D3
mount_config.format_if_mount_failed = false;
mount_config.max_files = 5;
mount_config.allocation_unit_size = 16*1024;
esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
Code: Select all
uint8_t TestSD (sdmmc_card_t* p_card)
{
FIL f;
FILE* fi;
FRESULT fres;
printf("Opening file\n");
fi = fopen("/sdcard/hello.txt", "w");
if (fi == NULL)
{
printf("Failed to open file for writing\n");
return 1;
}
fclose(fi);
printf("File written\n");
vTaskDelay(100);
printf("Creat file\n");
vTaskDelay(100);
fres = f_open(&f,"/hel.txt", FA_CREATE_ALWAYS | FA_WRITE);
if (fres != FR_OK)
{
printf("Failed to create file for writing\n");
return 1;
}
printf("File created\n");
f_close(&f);
return 0;
}
- Opening file
CORRUPT HEAP: multi_heap.c:432 detected at 0x3ffbe1cc
abort() was called at PC 0x40087c93 on core 0
ELF file SHA256: ef2ab7615c054010f1454fee4f030d283d8866b0a26d20595f00ccf6f4882bf8
Backtrace: 0x40084f29:0x3ffbe000 0x4008529d:0x3ffbe020 0x40087c93:0x3ffbe040 0x40082181:0x3ffbe060 0x400821b1:0x3ffbe080 0x4008ac7d:0x3ffbe0a0 0x4008872f:0x3ffbe0c0 0x40088984:0x3ffbe0e0 0x4008286a:0x3ffbe100 0x40082894:0x3ffbe120 0x400829e1:0x3ffbe150 0x4000be35:0x3ffbe170 |<-CORRUPTED
Rebooting...
else if I use only FatFs functions in code, no work, error message and reboot.
How do I use FatFs functions directly? I need this way of working with SD card.