SDMMC Thread safety
Posted: Thu Sep 26, 2019 4:25 pm
I use sd card for recording and storing some important process data.
On core 1, every 200ms, I read one sector (using sdmmc_read_sectors), append 32bytes of new data and save (using sdmmc_write_sectors) the whole sector back.
On core 0 I take care of wifi communication: When user asks for data I read 8 x 64sectors and send it to the user webbrowser.
I do not implement any semaphore on sdmmc driver on my own.
Most of time everything works but from time to time. sdmmc_read_sectors (the one on core 0) results in error 0x107 and
is printed. One moment after that, main loop (core 1) is blocked on reading and saving procedure and watchdog is triggered:
Whats more, watchdog triggering cant fix the problem and there is a dead loop of watchdog triggering on core 0.
Backtrace prints:
Sometimes (not always) there is also printed error:
What can I do for fixing this issue?
On core 1, every 200ms, I read one sector (using sdmmc_read_sectors), append 32bytes of new data and save (using sdmmc_write_sectors) the whole sector back.
On core 0 I take care of wifi communication: When user asks for data I read 8 x 64sectors and send it to the user webbrowser.
I do not implement any semaphore on sdmmc driver on my own.
Most of time everything works but from time to time. sdmmc_read_sectors (the one on core 0) results in error 0x107 and
Code: Select all
sdmmc_req: sdmmc_host_wait_for_event returned 0x107
Code: Select all
[0;31mE (34348) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:[0m
[0;31mE (34348) task_wdt: - IDLE1 (CPU 1)[0m
[0;31mE (34348) task_wdt: Tasks currently running:[0m
[0;31mE (34348) task_wdt: CPU 0: IDLE0[0m
[0;31mE (34348) task_wdt: CPU 1: process_task[0m
[0;31mE (34348) task_wdt: Aborting.[0m
abort() was called at PC 0x400d290f on core 0
Backtrace prints:
Code: Select all
0x4008d06d: invoke_abort at /Users/mtm/Development/esp32/esp-idf/components/esp32/panic.c:157
0x4008d3f9: abort at /Users/mtm/Development/esp32/esp-idf/components/esp32/panic.c:174
0x400d2907: task_wdt_isr at /Users/mtm/Development/esp32/esp-idf/components/esp32/task_wdt.c:174 (discriminator 1)
0x400823e5: _xt_lowint1 at /Users/mtm/Development/esp32/esp-idf/components/freertos/xtensa_vectors.S:1153
0x401255cf: ppRxPkt at ??:?
0x4008a3da: ppTask at ??:?
0x4008ffa5: vPortTaskWrapper at /Users/mtm/Development/esp32/esp-idf/components/freertos/port.c:143
Code: Select all
sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107