diff --git a/examples/storage/sd_card/main/sd_card_example_main.c b/examples/storage/sd_card/main/sd_card_example_main.c index e3ff6639ed..29df68ab8b 100644 --- a/examples/storage/sd_card/main/sd_card_example_main.c +++ b/examples/storage/sd_card/main/sd_card_example_main.c @@ -75,7 +75,7 @@ void app_main(void) .max_files = 5, .allocation_unit_size = 16 * 1024 }; - sdmmc_card_t* card; + sdmmc_card_t *card; const char mount_point[] = MOUNT_POINT; ESP_LOGI(TAG, "Initializing SD card"); @@ -103,6 +103,7 @@ void app_main(void) gpio_set_pull_mode(12, GPIO_PULLUP_ONLY); // D2, needed in 4-line mode only gpio_set_pull_mode(13, GPIO_PULLUP_ONLY); // D3, needed in 4- and 1-line modes + ESP_LOGI(TAG, "Mounting filesystem"); ret = esp_vfs_fat_sdmmc_mount(mount_point, &host, &slot_config, &mount_config, &card); #else ESP_LOGI(TAG, "Using SPI peripheral"); @@ -134,13 +135,14 @@ void app_main(void) if (ret != ESP_OK) { if (ret == ESP_FAIL) { ESP_LOGE(TAG, "Failed to mount filesystem. " - "If you want the card to be formatted, set the EXAMPLE_FORMAT_IF_MOUNT_FAILED menuconfig option."); + "If you want the card to be formatted, set the EXAMPLE_FORMAT_IF_MOUNT_FAILED menuconfig option."); } 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)); + "Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret)); } return; } + ESP_LOGI(TAG, "Filesystem mounted"); // Card has been initialized, print its properties sdmmc_card_print_info(stdout, card); @@ -148,7 +150,7 @@ void app_main(void) // Use POSIX and C standard library functions to work with files. // First create a file. ESP_LOGI(TAG, "Opening file"); - FILE* f = fopen(MOUNT_POINT"/hello.txt", "w"); + FILE *f = fopen(MOUNT_POINT"/hello.txt", "w"); if (f == NULL) { ESP_LOGE(TAG, "Failed to open file for writing"); return; @@ -182,7 +184,7 @@ void app_main(void) fgets(line, sizeof(line), f); fclose(f); // strip newline - char* pos = strchr(line, '\n'); + char *pos = strchr(line, '\n'); if (pos) { *pos = '\0'; } diff --git a/examples/storage/sd_card/sd_card_example_test.py b/examples/storage/sd_card/sd_card_example_test.py index 05b04eb6c5..ad1d05ebff 100644 --- a/examples/storage/sd_card/sd_card_example_test.py +++ b/examples/storage/sd_card/sd_card_example_test.py @@ -13,6 +13,9 @@ def test_examples_sd_card(env, extra_data): Utility.console_log('peripheral {} detected'.format(peripheral)) assert peripheral in ('SDMMC', 'SPI') + # Provide enough time for possible SD card formatting + dut.expect('Filesystem mounted', timeout=60) + # These lines are matched separately because of ASCII color codes in the output name = dut.expect(re.compile(r'Name: (\w+)'), timeout=5)[0] _type = dut.expect(re.compile(r'Type: (\S+)'), timeout=5)[0]