M5Stack icon indicating copy to clipboard operation
M5Stack copied to clipboard

Cannot figure out how to use the SD card

Open LEOcab opened this issue 6 months ago • 1 comments

Describe the bug

There's no example code for using the SD card anywhere. I think I found the correct function calls via searching the IDF database and github but I'm not 100% sure this is it. It's crashing my system every time I call the mount function. I'm new to IoT so there's a good chance I'm missing something here.

The following output can be observed in the idf.py monitor when trying to mount the card:

I (21744) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (21746) gpio: GPIO[15]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (21755) gpio: GPIO[2]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (21765) gpio: GPIO[4]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (21774) gpio: GPIO[12]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (21784) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (21793) gpio: GPIO[33]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (21803) gpio: GPIO[34]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (21812) gpio: GPIO[35]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (21822) gpio: GPIO[36]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
E (21858) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
E (21859) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).

To reproduce

Using the Cardputer user demo as a base, execute the following code:

sdmmc_host_t host = SDMMC_HOST_DEFAULT();
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();

esp_vfs_fat_sdmmc_mount_config_t mount_config =
{
	.format_if_mount_failed = true,
	.max_files = 5,
	.allocation_unit_size = 32 * 1024
};

sdmmc_card_t* card;
esp_err_t ret = esp_vfs_fat_sdmmc_mount("/", &host, &slot_config, &mount_config, &card);

Expected behavior

Ideally, esp_vfs_fat_sdmmc_mount should return ESP_OK and the FAT partition on the SD card will be mounted at "/".

Screenshots

No response

Environment

  • OS: Cardputer
  • IDE &IDE Version: ESP-IDF 4.4.6
  • Repository Version: latest

Additional context

I'm not sure if I need to specify the pins manually. If so, I have no idea where to check... Again, the SD functionality doesn't seem to be documented

Issue checklist

  • [X] I searched for previous reports in the issue tracker
  • [X] My report contains all necessary details

LEOcab avatar Jan 02 '24 21:01 LEOcab