Thank you very much for following up with this. I was actually able to capture the issue over night.
I also tried removing the MicroSD while the electronic is powered and doing a soft reset with esp_restart() which makes the system work again.
This happens immediately before it stops working:
V (1706031) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
D (1706041) httpd-freertos: Sel add listen 50
D (1706051) httpd-freertos: select ret
V (1706051) sdmmc_cmd: sending cmd slot=2 op=17 arg=4246 flags=1c50 data=0x3ffc61d4 blklen=512 datalen=512 timeout=1000
V (1706061) sdspi_host: sdspi_host_start_command: slot=2, CMD17, arg=0x00004246 flags=0x5, data=0x3ffc61d4, data_size=512 crc=0x03
V (1706071) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0x323a2272
V (1706071) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (1706081) sdmmc_cmd: sending cmd slot=2 op=17 arg=4247 flags=1c50 data=0x3ffc61d4 blklen=512 datalen=512 timeout=1000
V (1706101) sdspi_host: sdspi_host_start_command: slot=2, CMD17, arg=0x00004247 flags=0x5, data=0x3ffc61d4, data_size=512 crc=0x0a
V (1706111) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0x656c222c
V (1706121) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
D (1706131) httpd-freertos: Sel add listen 50
D (1706131) httpd-freertos: select ret
V (1706131) sdmmc_cmd: sending cmd slot=2 op=17 arg=4248 flags=1c50 data=0x3ffc61d4 blklen=512 datalen=512 timeout=1000
V (1706141) sdspi_host: sdspi_host_start_command: slot=2, CMD17, arg=0x00004248 flags=0x5, data=0x3ffc61d4, data_size=512 crc=0x7d
V (1706151) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0x6c222c36
V (1706161) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (1706161) sdmmc_cmd: sending cmd slot=2 op=17 arg=4249 flags=1c50 data=0x3ffc61d4 blklen=512 datalen=512 timeout=1000
V (1706181) sdspi_host: sdspi_host_start_command: slot=2, CMD17, arg=0x00004249 flags=0x5, data=0x3ffc61d4, data_size=512 crc=0x74
***ERROR*** A stack overflow in task esphttpd has been detected.
abort() was called at PC 0x40090370 on core 0
Backtrace: 0x4009005f:0x3ffde5d0 0x40090359:0x3ffde5f0 0x40090370:0x3ffde610 0x4008e60d:0x3ffde630 0x4008f204:0x3ffde660 0x4008f1ba:0x3f467b03
Rebooting...
And here is the full next initialization that fails:
E (381) DeviceManager: Mounting MicroSD card
D (391) sdspi_host: sdspi_host_init_slot: SPI3 miso=26 mosi=25 sck=33 cs=32 cd=-1 wp=-1, dma_ch=1
D (401) spi: SPI2 use gpio matrix.
V (401) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (411) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xC0E
D (411) intr_alloc: Connected src 31 to int 13 CMD52, arg=0x80000c08 flags=0x4, data=0x0, data_size=0 crc=0x4f
D (461) spi_master: SPI device changed from 3 to 0
V (461) sdspi_transaction: r1 = 0x75 hw_cmd.r[0]=0xffffffff
D (471) sdspi_transaction: cmd=52, R1 response: command not supported
D (471) sdmmc_cmd: cmd=52, sdmmc_req_run returned 0x106
V (481) sdmmc_io: sdmmc_io_rw_direct: sdmmc_send_cmd returned 0x106
V (491) sdmmc_cmd: sending cmd slot=2 op=0 arg=0 flags=20 data=0x0 blklen=0 datalen=0 timeout=1000
V (491) sdspi_host: sdspi_host_start_command: slot=2, CMD0, arg=0x00000000 flags=0x40, data=0x0, data_size=0 crc=0x4a
V (511) sdspi_host: start_command_default: ignoring response byte
V (511) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0xffffffff
V (521) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (541) sdmmc_cmd: sending cmd slot=2 op=0 arg=0 flags=1c20 data=0x0 blklen=0 datalen=0 timeout=1000
V (541) sdspi_host: sdspi_host_start_command: slot=2, CMD0, arg=0x00000000 flags=0x4, data=0x0, data_size=0 crc=0x4a
V (541) sdspi_transaction: r1 = 0x7b hw_cmd.r[0]=0xffffffff
D (551) sdspi_transaction: cmd=0, R1 response: command CRC error
D (561) sdmmc_cmd: cmd=0, sdmmc_req_run returned 0x109
D (561) sdmmc_init: sdmmc_card_init: sdmmc_send_cmd_go_idle_state returned 0x109
D (571) vfs_fat_sdmmc: sdmmc_card_init failed 0x(109)
I (571) gpio: GPIO[25]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (581) gpio: GPIO[26]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (591) gpio: GPIO[33]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
V (601) intr_alloc: esp_intr_free: Disabling int, killing handler
E (601) DeviceManager: Initializing MicroSD card failed with error: 265
E (611) DeviceConfig: [loadConfig] no config file found
E (611) DeviceConfig: [storeConfig] fopen failed
As the esphttpd task is going into stack overflow multiple times directly related to sdmmc operations the question arises if I have to mutex fopen/fclose/fwrite/fread/ftell/fflush because it is written from a different task.
Thanks,
Paul