I hope this isn't a re-post, the search feature did not work well with "sd" as a search term.
I am trying to interface a Sparkfun ESP32 thing with their ESP32 Thing Motion Shield to use SPI SD access.
- https://learn.sparkfun.com/tutorials/es ... okup-guide
- https://learn.sparkfun.com/tutorials/es ... okup-guide
Why SPI SD Access? Well in theid docs they're using an Arduino sketch with the SPI driver included, and writing everything as an arduino sketch, not using IDF.
I am using IDF and my task raises this error (I have CPU set to halt, not to reboot)
Code: Select all
I (2209) main.c: Using SPI peripheral for SD
D (2209) sdspi_host: sdspi_host_init_slot: SPI2 miso=19 mosi=23 sck=18 cs=33 cd=38 wp=-1, dma_ch=1
D (2209) spi: SPI2 use gpio matrix.
V (2219) intr_alloc: esp_intr_alloc_intrstatus (cpu 1): checking args
V (2239) intr_alloc: esp_intr_alloc_intrstatus (cpu 1): Args okay. Resulting flags 0x80E
D (2239) intr_alloc: Connected src 30 to int 3 (cpu 1)
D (2249) spi_hal: eff: 400, limit: 26666k(/2), 0 dummy, -1 delay
D (2269) spi_master: SPI2: New device added to CS0, effective clock: 400kHz
I (2269) gpio: GPIO[33]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (2279) gpio: GPIO[6]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x400e0d20: ffff0700 ffffffff ffffffff
0x400e0d20: uart_rx_intr_handler_default at /home/leehambley/esp/esp-idf/components/driver/uart.c:890
Core 1 register dump:
PC : 0x400e0d25 PS : 0x00060730 A0 : 0x800d6940 A1 : 0x3ffcc720
0x400e0d25: uart_rx_intr_handler_default at /home/leehambley/esp/esp-idf/components/driver/uart.c:894
A2 : 0x00000001 A3 : 0x3ffcc818 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00060023 A8 : 0x800df0fc A9 : 0xffffffff
A10 : 0x00000000 A11 : 0x00000028 A12 : 0x00000027 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000040 SAR : 0x00000007 EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffe
ELF file SHA256: ffffffffffffffffffffffffffffffff0007ffffffffffffffffffffffffffff
Backtrace: 0x400e0d22:0x3ffcc720 0x400d693d:0x3ffcc7a0 0x400d5a57:0x3ffcc7e0 0x40090d55:0x3ffcc870
0x400e0d22: uart_rx_intr_handler_default at /home/leehambley/esp/esp-idf/components/driver/uart.c:894
0x400d693d: esp_vfs_fat_sdmmc_mount at /home/leehambley/esp/esp-idf/components/fatfs/vfs/vfs_fat_sdmmc.c:74
0x400d5a57: init_sd_task at /home/leehambley/esp/hello_world/build/../main/hello_world_main.c:149
0x40090d55: vPortTaskWrapper at /home/leehambley/esp/esp-idf/components/freertos/port.c:143
CPU halted.
Code: Select all
#define SD_SCK_PIN (GPIO_NUM_18)
#define SD_DO_PIN (GPIO_NUM_19)
#define SD_DI_PIN (GPIO_NUM_23)
#define SD_CS_PIN (GPIO_NUM_33)
#define SD_CD_PIN (GPIO_NUM_38)
// ... snip ...
static void init_sd_task(void *args)
{
ESP_LOGI(TAG, "Using SPI peripheral for SD");
sdmmc_host_t host = SDSPI_HOST_DEFAULT();
sdspi_slot_config_t slot_config = SDSPI_SLOT_CONFIG_DEFAULT();
slot_config.gpio_miso = SD_DO_PIN;
slot_config.gpio_mosi = SD_DI_PIN;
slot_config.gpio_sck = SD_SCK_PIN;
slot_config.gpio_cs = SD_CS_PIN;
slot_config.gpio_cd = SD_CD_PIN;
// Options for mounting the filesystem.
// If format_if_mount_failed is set to true, SD card will be partitioned and
// formatted in case when mounting fails.
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
.format_if_mount_failed = false,
.max_files = 5,
.allocation_unit_size = 16 * 1024};
// Use settings defined above to initialize SD card and mount FAT filesystem.
// Note: esp_vfs_fat_sdmmc_mount is an all-in-one convenience function.
// Please check its source code and implement error recovery when developing
// production applications.
sdmmc_card_t *card;
esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
if (ret != ESP_OK)
{
if (ret == ESP_FAIL)
{
ESP_LOGE(TAG, "Failed to mount filesystem. "
"If you want the card to be formatted, set format_if_mount_failed = true.");
}
else
{
ESP_LOGE(TAG, "Failed to initialize the card (%s). "
"Make sure SD card lines have pull-up resistors in place.",
esp_err_to_name(ret));
}
return;
}
for (;;)
{
}
}
// ... snip ...
xTaskCreatePinnedToCore(init_sd_task, "init_sd_card_task", 8196, NULL, 0, NULL, 1);
The Sparkfun docs don't go into enough detail on whether there are any 10k pull-ups on the required pins.
Can anyone offer advice, or debugging help please?