sd card unmounting and remounting not working
Posted: Wed Jul 02, 2025 9:22 pm
Hello everyone,
I've decided to create a webserver that lets you wirelessly upload files to an sd card connected to the ESP board. I need to have a mechanism where the sd card's lines are switched to another device briefly, meaning it won't be connected to the ESP board. I'm testing the code right now, and it works only for the first upload. If I upload another file, the sd card isn't mounted properly.
Here are the logs for that:
The sd card module I'm using has pull-ups already, so I know that is not the problem.
Any help would be appreciated! Attached is my code.
I've decided to create a webserver that lets you wirelessly upload files to an sd card connected to the ESP board. I need to have a mechanism where the sd card's lines are switched to another device briefly, meaning it won't be connected to the ESP board. I'm testing the code right now, and it works only for the first upload. If I upload another file, the sd card isn't mounted properly.
Here are the logs for that:
Code: Select all
Website File Uploader Running...
I (2911) espressif: Starting ESP-NOW responder...
I (2911) ESPNOW: espnow [version: 2.0] init
I (2921) main_task: Returned from app_main()
I (7091) wifi:<ba-add>idx:1 (ifx:0, 94:2a:6f:a6:7c:cb), tid:6, ssn:2, winSize:64
I (8391) espressif: Uploading file: cat.png
I (9391) gpio: GPIO[2]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (9391) gpio: GPIO[35]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (9391) gpio: GPIO[37]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (9401) espressif: Initializing SD card
I (9401) espressif: Using SDMMC peripheral
I (9411) espressif: Mounting filesystem
I (9411) gpio: GPIO[2]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (9421) gpio: GPIO[35]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (9431) gpio: GPIO[37]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (9531) espressif: Filesystem mounted
Name: USDU1
Type: SDHC
Speed: 40.00 MHz (limit: 40.00 MHz)
Size: 60290MB
CSD: ver=2, sector_size=512, capacity=123473920 read_bl_len=9
SSR: bus_width=1
I (11211) espressif: Finished copying to SD File
I (11211) gpio: GPIO[7]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (11211) gpio: GPIO[2]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (11221) gpio: GPIO[35]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (11231) gpio: GPIO[37]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (11241) espressif: Card unmounted
I (16241) espressif: Uploading file: cat.png
I (17241) gpio: GPIO[2]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (17241) gpio: GPIO[35]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (17241) gpio: GPIO[37]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (17251) espressif: Initializing SD card
I (17251) espressif: Using SDMMC peripheral
I (17261) espressif: Mounting filesystem
I (17261) gpio: GPIO[2]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (17271) gpio: GPIO[35]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (17281) gpio: GPIO[37]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
E (17291) vfs_fat_sdmmc: sdmmc_card_init failed (0x105).
I (17291) gpio: GPIO[7]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (17301) gpio: GPIO[2]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (17311) gpio: GPIO[35]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (17321) gpio: GPIO[37]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
E (17331) espressif: Failed to initialize the card (ESP_ERR_NOT_FOUND). Make sure SD card lines have pull-up resistors in place.
I (17341) SD_TEST: Testing SD pin connections and pullup strength
I (17341) gpio: GPIO[2]| InputEn: 1| OutputEn: 1| OpenDrain: 1| Pullup: 0| Pulldown: 0| Intr:0
I (17351) gpio: GPIO[35]| InputEn: 1| OutputEn: 1| OpenDrain: 1| Pullup: 0| Pulldown: 0| Intr:0
I (17361) gpio: GPIO[37]| InputEn: 1| OutputEn: 1| OpenDrain: 1| Pullup: 0| Pulldown: 0| Intr:0
**** PIN recovery time ****
PIN 2 CLK 43 cycles
PIN 35 CMD 45 cycles
PIN 37 D0 44 cycles
**** PIN recovery time with weak pullup ****
PIN 2 CLK 43 cycles
PIN 35 CMD 44 cycles
PIN 37 D0 45 cycles
E (17391) espressif: Failed to open /sdcard/cat.png for writingAny help would be appreciated! Attached is my code.