Page 1 of 1

esp_spiffs_format() causes btController task stuck

Posted: Wed Sep 22, 2021 2:42 pm
by Air_Hamster
Hello!

I'm using ESP-IDF 4.2 with ESP32-D0WD.

I'm formatting one of my spiffs partitions from a low-priority task with esp_spiffs_format().
During this long operation btController which running on another core, gets stuck.

The backtrace looks like this:

Code: Select all

E (36207) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:                            
E (36207) task_wdt:  - IDLE1 (CPU 1)                                                                                                
E (36207) task_wdt: Tasks currently running:                                                                                        
E (36207) task_wdt: CPU 0: CLI                                                                                                      
E (36207) task_wdt: CPU 1: btController                                                                                             
E (36207) task_wdt: Print CPU 0 (current core) backtrace                                                                            
                                                                                                                                    
                                                                                                                                    
Backtrace:0x400D6A34:0x3FFBE3D0 0x40084BE1:0x3FFBE3F0 0x40082599:0x3FFD9B70 0x4008569B:0x3FFD9B90 0x4008645D:0x3FFD9BB0 0x40086485:0
x3FFD9BD0 0x40090B45:0x3FFD9BF0 0x40086106:0x3FFD9C10 0x4018C684:0x3FFD9C50 0x4012C6E7:0x3FFD9C70 0x4012DF4A:0x3FFD9CA0 0x4012CAE8:0
x3FFD9CD0 0x4012C41E:0x3FFD9CF0 0x400DD7E6:0x3FFD9D40 0x400DBD9F:0x3FFD9D80 0x401281E9:0x3FFD9DC0 0x400DB046:0x3FFD9DE0 0x40092531:0
x3FFD9E10                                                                                                                           
0x400d6a34: task_wdt_isr at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/esp_common/src/task_wdt.c:187       
                                                                                                                                    
0x40084be1: _xt_lowint1 at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/freertos/xtensa/xtensa_vectors.S:1105
                                                                                                                                    
0x40082599: esp_intr_noniram_enable at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/esp32/intr_alloc.c:896   
                                                                                                                                    
0x4008569b: spi_flash_enable_interrupts_caches_and_other_cpu at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/
spi_flash/cache_utils.c:191                                                                                                         
                                                                                                                                    
0x4008645d: cache_enable at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/spi_flash/spi_flash_os_func_app.c:52
                                                                                                                                    
0x40086485: spi1_end at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/spi_flash/spi_flash_os_func_app.c:95    
                                                                                                                                    
0x40090b45: spiflash_end at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/spi_flash/esp_flash_api.c:92        
                                                                                                                                    
0x40086106: esp_flash_erase_region at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/spi_flash/esp_flash_api.c:
369                                                                                                                                 
                                                                                                                                    
0x4018c684: esp_partition_erase_range at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/spi_flash/partition.c:4
22                                                                                                                                  
                                                                                                                                    
0x4012c6e7: spiffs_api_erase at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/spiffs/spiffs_api.c:58          
                                                                                                                                    
0x4012df4a: spiffs_erase_block at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/spiffs/spiffs/src/spiffs_nucle
us.c:236                                                                                                                            
                                                                                                                                    
0x4012cae8: SPIFFS_format at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/spiffs/spiffs/src/spiffs_hydrogen.c
:47                                                                                                                                 
                                                                                                                                    
0x4012c41e: esp_spiffs_format at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/spiffs/esp_spiffs.c:309        
                                                                                                                                    
0x400dd7e6: LogsManager::wipe() at /home/ilia.lutchenko/workspace/project/build/../firmware/logger/logs_files_manager.cpp:45       
                                                                                                                                    
0x400dbd9f: wipe(int, char**) at /home/ilia.lutchenko/workspace/project/build/../firmware/logger/logger.h:57                       
 (inlined by) wipe at /home/ilia.lutchenko/workspace/project/build/../firmware/cli/cmd_system.cpp:592

0x401281e9: esp_console_run at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/console/commands.c:215

0x400db046: CommandLineTask(void*) at /home/ilia.lutchenko/workspace/project/build/../firmware/cli/console.cpp:121

0x40092531: vPortTaskWrapper at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/freertos/xtensa/port.c:143


E (36207) task_wdt: Print CPU 1 backtrace


Backtrace:0x4008215F:0x3FFBE9D0 0x40084BE1:0x3FFBE9F0 0x401BFD64:0x3FFDDC90 0x401C0305:0x3FFDDCB0 0x40092531:0x3FFDDCE0 
0x4008215f: esp_crosscore_isr at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/esp32/crosscore_int.c:80

0x40084be1: _xt_lowint1 at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/freertos/xtensa/xtensa_vectors.S:1105

0x401bfd64: r_rw_schedule at ??:? 

0x401c0305: btdm_controller_task at ??:?

0x40092531: vPortTaskWrapper at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/freertos/xtensa/port.c:143
This WDG continues triggering even when spiffs formatting was finished.
After some number of triggering application crashes with next backtrace:

Code: Select all

Guru Meditation Error: Core  1 panic'ed (Interrupt wdt timeout on CPU1).                                                            
                                                                                                                                    
Core  1 register dump:                                                                                                              
PC      : 0x4008a285  PS      : 0x00060e34  A0      : 0x801bf940  A1      : 0x3ffbe8c0                                              
0x4008a285: r_assert_param at ??:?                                                                                                  
                                                                                                                                    
A2      : 0x00000001  A3      : 0x00000000  A4      : 0x60008048  A5      : 0x00000000                                              
A6      : 0x00000004  A7      : 0x3ffbdc0c  A8      : 0x8008a280  A9      : 0x3ffbe8a0                                              
A10     : 0x00000000  A11     : 0x00000037  A12     : 0x00000014  A13     : 0xffffffff                                              
A14     : 0x00000000  A15     : 0xfffffffc  SAR     : 0x00000004  EXCCAUSE: 0x00000006                                              
EXCVADDR: 0x00000000  LBEG    : 0x4008a1b8  LEND    : 0x4008a1bf  LCOUNT  : 0x00000000                                              
0x4008a1b8: r_assert_param at ??:?                                                                                                  
                                                                                                                                    
0x4008a1bf: r_assert_param at ??:?                                                                                                  
                                                                                                                                    
Core  1 was running in ISR context:                                                                                                 
EPC1    : 0x401f2953  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x4008a285                                              
0x401f2953: uart_hal_write_txfifo at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/soc/src/hal/uart_hal_iram.c
:35                                                                                                                                 
                                                                                                                                    
0x4008a285: r_assert_param at ??:?                                                                                                  
                                                                                                                                    
                                                                                                                                    
Backtrace:0x4008a282:0x3ffbe8c0 0x401bf93d:0x3ffbe8e0 0x40019fb5:0x3ffbe900 0x40046683:0x3ffbe930 0x40047515:0x3ffbe950 0x4008d3b9:0
x3ffbe970 0x4008d00d:0x3ffbe990 0x4008f6f2:0x3ffbe9b0 0x400907e3:0x3ffbe9d0 0x40084be1:0x3ffbe9f0 0x401bfd64:0x3ffddc90 0x401c0305:0
x3ffddcb0 0x40092531:0x3ffddce0                                                                                                     
0x4008a282: r_assert_param at ??:?                                                                                                  
                                                                                                                                    
0x401bf93d: r_platform_reset at ??:?                                                                                                
                                                                                                                                    
0x4008d3b9: r_lld_evt_end at ??:?                                                                                                   
                                                                                                                                    
0x4008d00d: r_lld_evt_end_isr at ??:?                                                                                               
                                                                                                                                    
0x4008f6f2: r_rwble_isr at ??:?                                                                                                     
                                                                                                                                    
0x400907e3: r_rwbtdm_isr_wrapper at intc.c:?                                                                                        
                                                                                                                                    
0x40084be1: _xt_lowint1 at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/freertos/xtensa/xtensa_vectors.S:1105
                                                                                                                                    
0x401bfd64: r_rw_schedule at ??:?                                                                                                   
                                                                                                                                    
0x401c0305: btdm_controller_task at ??:?                                                                                            
                                                                                                                                    
0x40092531: vPortTaskWrapper at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/freertos/xtensa/port.c:143      
                                                                                                                                    
Core  0 register dump:                                                                                                              
PC      : 0x401eef8e  PS      : 0x00060234  A0      : 0x800d6d45  A1      : 0x3ffd4d50                                              
0x401eef8e: esp_pm_impl_waiti at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/esp32/pm_esp32.c:486           
                                                                                                                                    
A2      : 0x00000000  A3      : 0x00000000  A4      : 0x00000014  A5      : 0x000000a5                                              
A6      : 0x000000a5  A7      : 0x00060023  A8      : 0x800d6c86  A9      : 0x3ffd4d20                                              
A10     : 0x00000000  A11     : 0x00000000  A12     : 0x00000014  A13     : 0x000000a5                                              
A14     : 0x000000a5  A15     : 0x00060023  SAR     : 0x00000000  EXCCAUSE: 0x00000006                                              
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000                                              
                                                                                                                                    
Backtrace:0x401eef8b:0x3ffd4d50 0x400d6d42:0x3ffd4d70 0x40092fd1:0x3ffd4d90 0x40092531:0x3ffd4db0                                   
0x401eef8b: esp_pm_impl_waiti at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/esp32/pm_esp32.c:484           
                                                                                                                                    
0x400d6d42: esp_vApplicationIdleHook at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/esp_common/src/freertos_
hooks.c:63

0x40092fd1: prvIdleTask at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/freertos/tasks.c:3386 (discriminator 
1)

0x40092531: vPortTaskWrapper at /home/ilia.lutchenko/workspace/project/build/../esp-idf/components/freertos/xtensa/port.c:143
And looks like this can also happen while using spiffs too long, for example, when listing all files with their size.
Any suggestion how this problem can be solved?
Thanks