espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.6k stars 7.27k forks source link

New I2c driver and ETH driver used together trigger interrupt WDT timeout (IDFGH-12376) #13407

Closed simunma closed 6 months ago

simunma commented 7 months ago

Answers checklist.

IDF version.

5.2.1

Espressif SoC revision.

ESP32 (revision v3.0)

Operating System used.

Linux

How did you build your project?

Eclipse IDE

If you are using Windows, please specify command line type.

None

Development Kit.

Custom Board

Power Supply used.

USB

What is the expected behavior?

To return from esp_eth_driver_install(...) after earlier in code calling i2c_new_master_bus(...) from new i2c api.

What is the actual behavior?

Interrupt wdt timeout during executing esp_eth_driver_install(...) after calling i2c_new_master_bus(...).

Steps to reproduce.

  1. call i2c_new_master_bus(...)
  2. call esp_eth_driver_install(...)
    m_i2c_master_config.clk_source = I2C_CLK_SRC_DEFAULT;
    m_i2c_master_config.i2c_port = I2C_NUM_0;
    m_i2c_master_config.scl_io_num = I2C_SCL_PIN;
    m_i2c_master_config.sda_io_num = I2C_SDA_PIN;
    m_i2c_master_config.glitch_ignore_cnt = 7;
    m_i2c_master_config.flags.enable_internal_pullup = true;
    result = i2c_new_master_bus(&m_i2c_master_config, &m_i2c_naster_bus_handle);

    result = esp_netif_init();
    eth_netif = esp_netif_new(&netif_cfg);

    result = esp_event_loop_create_default();
    emac_config.smi_mdc_gpio_num = BRD_E_ETH_MDC;
    emac_config.smi_mdio_gpio_num = BRD_E_ETH_MDIO;
    mac = esp_eth_mac_new_esp32(&emac_config,&mac_config);

    phy_config.phy_addr = ETH_PHY_ADDRESS;
    phy_config.reset_gpio_num = BRD_E_PHY_RESET;
    phy = esp_eth_phy_new_lan87xx(&phy_config);

    eth_config.mac = mac;
    eth_config.phy = phy;
    eth_config.check_link_period_ms = 2000;
    eth_config.stack_input = NULL;
    eth_config.on_lowlevel_init_done = NULL;
    eth_config.on_lowlevel_deinit_done = NULL;
    result = esp_eth_driver_install(&eth_config, &eth_handle);

Debug Logs.

I (136) cpu_start: Multicore app                                                                                                    
I (136) quad_psram: This chip is ESP32-D0WD                                                                                         
I (137) esp_psram: Found 8MB PSRAM device                                                                                           
I (138) esp_psram: Speed: 80MHz                                                                                                     
I (142) esp_psram: PSRAM initialized, cache is in low/high (2-core) mode.                                                           
W (150) esp_psram: Virtual address not enough for PSRAM, map as much as we can. 4MB is mapped                                       
D (159) cpu_start: Pro cpu up                                                                                                       
D (162) cpu_start: Starting app cpu, entry point is 0x4008128c                                                                      
D (153) cpu_start: App cpu up                                                                                                       
I (682) esp_psram: SPI SRAM memory test OK                                                                                          
D (690) clk: RTC_SLOW_CLK calibration value: 3248806                                                                                
I (695) cpu_start: Pro cpu start user code                                                                                          
I (695) cpu_start: cpu freq: 160000000 Hz                                                                                           
I (695) cpu_start: Application information:                                                                                         
I (700) cpu_start: Project name:     main                                                                                           
I (705) cpu_start: App version:      1                                                                                              
I (709) cpu_start: Compile time:     Mar 18 2024 07:52:36                                                                           
I (715) cpu_start: ELF file SHA256:  aac2077de...                                                                                   
I (721) cpu_start: ESP-IDF:          v5.2.1-dirty                                                                                   
I (726) cpu_start: Min chip rev:     v3.0                                                                                           
I (731) cpu_start: Max chip rev:     v3.99                                                                                          
I (735) cpu_start: Chip rev:         v3.0                                                                                           
D (740) memory_layout: Checking 10 reserved memory ranges:                                                                          
D (746) memory_layout: Reserved memory range 0x3f800000 - 0x3fc00000                                                                
D (752) memory_layout: Reserved memory range 0x3ff82000 - 0x3ff82000                                                                
D (759) memory_layout: Reserved memory range 0x3ffae000 - 0x3ffae6e0                                                                
D (765) memory_layout: Reserved memory range 0x3ffb0000 - 0x3ffb3630                                                                
D (771) memory_layout: Reserved memory range 0x3ffe0000 - 0x3ffe0440                                                                
D (778) memory_layout: Reserved memory range 0x3ffe3f20 - 0x3ffe4350                                                                
D (784) memory_layout: Reserved memory range 0x40070000 - 0x40078000                                                                
D (791) memory_layout: Reserved memory range 0x40078000 - 0x40080000                                                                
D (797) memory_layout: Reserved memory range 0x40080000 - 0x4008ef3c                                                                
D (803) memory_layout: Reserved memory range 0x50001fe8 - 0x50002000                                                                
D (810) memory_layout: Building list of available memory regions:                                                                   
D (816) memory_layout: Available memory region 0x3ffae6e0 - 0x3ffb0000                                                              
D (823) memory_layout: Available memory region 0x3ffb3630 - 0x3ffb8000                                                              
D (829) memory_layout: Available memory region 0x3ffb8000 - 0x3ffc0000                                                              
D (836) memory_layout: Available memory region 0x3ffc0000 - 0x3ffc2000                                                              
D (842) memory_layout: Available memory region 0x3ffc2000 - 0x3ffc4000                                                              
D (849) memory_layout: Available memory region 0x3ffc4000 - 0x3ffc6000                                                              
D (856) memory_layout: Available memory region 0x3ffc6000 - 0x3ffc8000                                                              
D (862) memory_layout: Available memory region 0x3ffc8000 - 0x3ffca000                                                              
D (869) memory_layout: Available memory region 0x3ffca000 - 0x3ffcc000                                                              
D (875) memory_layout: Available memory region 0x3ffcc000 - 0x3ffce000                                                              
D (882) memory_layout: Available memory region 0x3ffce000 - 0x3ffd0000                                                              
D (889) memory_layout: Available memory region 0x3ffd0000 - 0x3ffd2000                                                              
D (895) memory_layout: Available memory region 0x3ffd2000 - 0x3ffd4000                                                              
D (902) memory_layout: Available memory region 0x3ffd4000 - 0x3ffd6000                                                              
D (908) memory_layout: Available memory region 0x3ffd6000 - 0x3ffd8000                                                              
D (915) memory_layout: Available memory region 0x3ffd8000 - 0x3ffda000                                                              
D (922) memory_layout: Available memory region 0x3ffda000 - 0x3ffdc000                                                              
D (928) memory_layout: Available memory region 0x3ffdc000 - 0x3ffde000                                                              
D (935) memory_layout: Available memory region 0x3ffde000 - 0x3ffe0000                                                              
D (941) memory_layout: Available memory region 0x3ffe0440 - 0x3ffe3f20                                                              
D (948) memory_layout: Available memory region 0x3ffe4350 - 0x3ffe8000                                                              
D (955) memory_layout: Available memory region 0x3ffe8000 - 0x3fff0000                                                              
D (961) memory_layout: Available memory region 0x3fff0000 - 0x3fff8000                                                              
D (968) memory_layout: Available memory region 0x3fff8000 - 0x3fffc000                                                              
D (974) memory_layout: Available memory region 0x3fffc000 - 0x40000000                                                              
D (981) memory_layout: Available memory region 0x4008ef3c - 0x40090000                                                              
D (988) memory_layout: Available memory region 0x40090000 - 0x40092000                                                              
D (994) memory_layout: Available memory region 0x40092000 - 0x40094000                                                              
D (1001) memory_layout: Available memory region 0x40094000 - 0x40096000                                                             
D (1007) memory_layout: Available memory region 0x40096000 - 0x40098000                                                             
D (1014) memory_layout: Available memory region 0x40098000 - 0x4009a000                                                             
D (1021) memory_layout: Available memory region 0x4009a000 - 0x4009c000                                                             
D (1028) memory_layout: Available memory region 0x4009c000 - 0x4009e000                                                             
D (1034) memory_layout: Available memory region 0x4009e000 - 0x400a0000                                                             
I (1041) heap_init: Initializing. RAM available for dynamic allocation:                                                             
D (1048) heap_init: New heap initialised at 0x3ffae6e0                                                                              
I (1053) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM                                                                          
D (1060) heap_init: New heap initialised at 0x3ffb3630                                                                              
I (1065) heap_init: At 3FFB3630 len 0002C9D0 (178 KiB): DRAM                                                                        
I (1071) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM                                                                       
I (1078) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM                                                                      
D (1084) heap_init: New heap initialised at 0x4008ef3c                                                                              
I (1089) heap_init: At 4008EF3C len 000110C4 (68 KiB): IRAM                                                                         
I (1096) esp_psram: Adding pool of 4096K of PSRAM memory to heap allocator                                                          
D (1103) intr_alloc: Connected src 46 to int 2 (cpu 0)                                                                              
D (1109) spi_flash: trying chip: issi                                                                                               
D (1112) spi_flash: trying chip: gd                                                                                                 
I (1116) spi_flash: detected chip: gd                                                                                               
I (1120) spi_flash: flash io: dio                                                                                                   
D (1124) cpu_start: calling init function: 0x400daf7c                                                                               
D (1129) cpu_start: calling init function: 0x400876d8                                                                               
D (1134) cpu_start: calling init function: 0x400d21c0                                                                               
D (1139) cpu_start: calling init function: 0x400d50f8 on core: 0                                                                    
D (1146) intr_alloc: Connected src 17 to int 3 (cpu 0)                                                                              
D (1151) cpu_start: calling init function: 0x400fc860 on core: 0                                                                    
D (1157) intr_alloc: Connected src 24 to int 9 (cpu 0)                                                                              
D (1162) app_start: Starting scheduler on CPU0                                                                                      
 (1166) intr_alloc: Connected src 25 to int 2 (cpu 1)                                                                               
D (1166) app_start: Starting scheduler on CPU1                                                                                      
;32mI (1166) main_task: Started on CPU0                                                                                             
D (1176) heap_init: New heap initialised at 0x3ffe0440                                                                              
D (1186) heap_init: New heap initialised at 0x3ffe4350                                                                              
D (1186) intr_alloc: Connected src 16 to int 12 (cpu 0)                                                                             
I (1186) main_task: Calling app_main()                                                                                              
test                                                                                                                                
D (3196) i2c.common: new bus(0) at 0x3ffaffac                                                                                       
I (3196) gpio: GPIO[5]| InputEn: 1| OutputEn: 1| OpenDrain: 1| Pullup: 1| Pulldown: 0| Intr:0                                       
I (3196) gpio: GPIO[4]| InputEn: 1| OutputEn: 1| OpenDrain: 1| Pullup: 1| Pulldown: 0| Intr:0                                       
D (3206) i2c.common: bus clock source frequency: 80000000hz                                                                         
D (3206) intr_alloc: Connected src 49 to int 13 (cpu 0)                                                                             
Guru Meditation Error: Core  0 panic'ed (Interrupt wdt timeout on CPU0).                                                            

Core  0 register dump:                                                                                                              
PC      : 0x4008247a  PS      : 0x00060034  A0      : 0x400845c8  A1      : 0x3ffb0f60                                              
A2      : 0x3ffafff0  A3      : 0x3ffb298c  A4      : 0x3ff53000  A5      : 0x40088afe                                              
A6      : 0x000005a8  A7      : 0x3ffb696c  A8      : 0x80082459  A9      : 0x3ffb0f30                                              
A10     : 0x00000001  A11     : 0xffffffff  A12     : 0x800d464c  A13     : 0x00060023                                              
A14     : 0x3ffaffac  A15     : 0x0000cdcd  SAR     : 0x00000004  EXCCAUSE: 0x00000005                                              
EXCVADDR: 0x00000000  LBEG    : 0x4000c46c  LEND    : 0x4000c477  LCOUNT  : 0x00000000                                              
Core  0 was running in ISR context:                                                                                                 
EPC1    : 0x400d367b  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x4008247a                                              

Backtrace: 0x40082477:0x3ffb0f60 0x400845c5:0x3ffb0f80 0x400fd75a:0x3ffb58b0 0x400d7f36:0x3ffb5900 0x400fe9fb:0x3ffb5930 0x400886d5:
0x3ffb5960                                                                                                                          

Core  1 register dump:                                                                                                              
PC      : 0x40086496  PS      : 0x00060734  A0      : 0x800d3536  A1      : 0x3ffb6500                                              
A2      : 0x00000000  A3      : 0x00000000  A4      : 0x3ffaf740  A5      : 0x3ffaf720                                              
A6      : 0x4008597c  A7      : 0x00000001  A8      : 0x800db562  A9      : 0x3ffb64c0                                              
A10     : 0x00000000  A11     : 0x00000000  A12     : 0x3ffaf720  A13     : 0x3ffaf6f0                                              
A14     : 0x00000001  A15     : 0x3ffafd48  SAR     : 0x00000000  EXCCAUSE: 0x00000005                                              
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000                                              

Backtrace: 0x40086493:0x3ffb6500 0x400d3533:0x3ffb6520 0x400894cd:0x3ffb6540 0x400886d5:0x3ffb6560                                  

ELF file SHA256: aac2077de                                                                                                          

Rebooting...                                                                                                                        
ets Jul 29 2019 12:21:46                                                                                                            

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)                                                                              
configsip: 0, SPIWP:0xee                                                                                                            
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00                                                             
mode:DIO, clock div:1                                                                                                               
load:0x3fff0030,len:5940                                                                                                            
load:0x40078000,len:15112                                                                                                           
load:0x40080400,len:4                                                                                                               
load:0x40080404,len:3492                                                                                                            
entry 0x400805d0                                                                                                                    
I (136) cpu_start: Multicore app                                                                                                    
I (136) quad_psram: This chip is ESP32-D0WD                                                                                         
I (137) esp_psram: Found 8MB PSRAM device                                                                                           
I (138) esp_psram: Speed: 80MHz                                                                                                     
I (142) esp_psram: PSRAM initialized, cache is in low/high (2-core) mode.                                                           
W (150) esp_psram: Virtual address not enough for PSRAM, map as much as we can. 4MB is mapped                                       
D (159) cpu_start: Pro cpu up                                                                                                       
D (162) cpu_start: Starting app cpu, entry point is 0x4008128c                                                                      
D (153) cpu_start: App cpu up                                                                                                       
I (682) esp_psram: SPI SRAM memory test OK                                                                                          
D (690) clk: RTC_SLOW_CLK calibration value: 3247104                                                                                
I (695) cpu_start: Pro cpu start user code                                                                                          
I (695) cpu_start: cpu freq: 160000000 Hz                                                                                           
I (695) cpu_start: Application information:                                                                                         
I (700) cpu_start: Project name:     main                                                                                           
I (705) cpu_start: App version:      1                                                                                              
I (709) cpu_start: Compile time:     Mar 18 2024 07:52:36                                                                           
I (715) cpu_start: ELF file SHA256:  aac2077de...                                                                                   
I (721) cpu_start: ESP-IDF:          v5.2.1-dirty                                                                                   
I (726) cpu_start: Min chip rev:     v3.0                                                                                           
I (731) cpu_start: Max chip rev:     v3.99                                                                                          
I (735) cpu_start: Chip rev:         v3.0                                                                                           
D (740) memory_layout: Checking 10 reserved memory ranges:                                                                          
D (746) memory_layout: Reserved memory range 0x3f800000 - 0x3fc00000                                                                
D (752) memory_layout: Reserved memory range 0x3ff82000 - 0x3ff82000                                                                
D (759) memory_layout: Reserved memory range 0x3ffae000 - 0x3ffae6e0                                                                
D (765) memory_layout: Reserved memory range 0x3ffb0000 - 0x3ffb3630                                                                
D (771) memory_layout: Reserved memory range 0x3ffe0000 - 0x3ffe0440                                                                
D (778) memory_layout: Reserved memory range 0x3ffe3f20 - 0x3ffe4350                                                                
D (784) memory_layout: Reserved memory range 0x40070000 - 0x40078000                                                                
D (791) memory_layout: Reserved memory range 0x40078000 - 0x40080000                                                                
D (797) memory_layout: Reserved memory range 0x40080000 - 0x4008ef3c                                                                
D (803) memory_layout: Reserved memory range 0x50001fe8 - 0x50002000                                                                
D (810) memory_layout: Building list of available memory regions:                                                                   
D (816) memory_layout: Available memory region 0x3ffae6e0 - 0x3ffb0000                                                              
D (823) memory_layout: Available memory region 0x3ffb3630 - 0x3ffb8000                                                              
D (829) memory_layout: Available memory region 0x3ffb8000 - 0x3ffc0000                                                              
D (836) memory_layout: Available memory region 0x3ffc0000 - 0x3ffc2000                                                              
D (842) memory_layout: Available memory region 0x3ffc2000 - 0x3ffc4000                                                              
D (849) memory_layout: Available memory region 0x3ffc4000 - 0x3ffc6000                                                              
D (856) memory_layout: Available memory region 0x3ffc6000 - 0x3ffc8000                                                              
D (862) memory_layout: Available memory region 0x3ffc8000 - 0x3ffca000                                                              
D (869) memory_layout: Available memory region 0x3ffca000 - 0x3ffcc000                                                              
D (875) memory_layout: Available memory region 0x3ffcc000 - 0x3ffce000                                                              
D (882) memory_layout: Available memory region 0x3ffce000 - 0x3ffd0000                                                              
D (889) memory_layout: Available memory region 0x3ffd0000 - 0x3ffd2000                                                              
D (895) memory_layout: Available memory region 0x3ffd2000 - 0x3ffd4000                                                              
D (902) memory_layout: Available memory region 0x3ffd4000 - 0x3ffd6000                                                              
D (908) memory_layout: Available memory region 0x3ffd6000 - 0x3ffd8000                                                              
D (915) memory_layout: Available memory region 0x3ffd8000 - 0x3ffda000                                                              
D (922) memory_layout: Available memory region 0x3ffda000 - 0x3ffdc000                                                              
D (928) memory_layout: Available memory region 0x3ffdc000 - 0x3ffde000                                                              
D (935) memory_layout: Available memory region 0x3ffde000 - 0x3ffe0000                                                              
D (941) memory_layout: Available memory region 0x3ffe0440 - 0x3ffe3f20                                                              
D (948) memory_layout: Available memory region 0x3ffe4350 - 0x3ffe8000                                                              
D (955) memory_layout: Available memory region 0x3ffe8000 - 0x3fff0000                                                              
D (961) memory_layout: Available memory region 0x3fff0000 - 0x3fff8000                                                              
D (968) memory_layout: Available memory region 0x3fff8000 - 0x3fffc000                                                              
D (974) memory_layout: Available memory region 0x3fffc000 - 0x40000000                                                              
D (981) memory_layout: Available memory region 0x4008ef3c - 0x40090000                                                              
D (988) memory_layout: Available memory region 0x40090000 - 0x40092000                                                              
D (994) memory_layout: Available memory region 0x40092000 - 0x40094000                                                              
D (1001) memory_layout: Available memory region 0x40094000 - 0x40096000                                                             
D (1007) memory_layout: Available memory region 0x40096000 - 0x40098000                                                             
D (1014) memory_layout: Available memory region 0x40098000 - 0x4009a000                                                             
D (1021) memory_layout: Available memory region 0x4009a000 - 0x4009c000                                                             
D (1028) memory_layout: Available memory region 0x4009c000 - 0x4009e000                                                             
D (1034) memory_layout: Available memory region 0x4009e000 - 0x400a0000                                                             
I (1041) heap_init: Initializing. RAM available for dynamic allocation:                                                             
D (1048) heap_init: New heap initialised at 0x3ffae6e0                                                                              
I (1053) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM                                                                          
D (1060) heap_init: New heap initialised at 0x3ffb3630                                                                              
I (1065) heap_init: At 3FFB3630 len 0002C9D0 (178 KiB): DRAM                                                                        
I (1071) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM                                                                       
I (1078) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM                                                                      
D (1084) heap_init: New heap initialised at 0x4008ef3c                                                                              
I (1089) heap_init: At 4008EF3C len 000110C4 (68 KiB): IRAM                                                                         
I (1096) esp_psram: Adding pool of 4096K of PSRAM memory to heap allocator                                                          
D (1103) intr_alloc: Connected src 46 to int 2 (cpu 0)                                                                              
D (1109) spi_flash: trying chip: issi                                                                                               
D (1112) spi_flash: trying chip: gd                                                                                                 
I (1116) spi_flash: detected chip: gd                                                                                               
I (1120) spi_flash: flash io: dio                                                                                                   
D (1124) cpu_start: calling init function: 0x400daf7c                                                                               
D (1129) cpu_start: calling init function: 0x400876d8                                                                               
D (1134) cpu_start: calling init function: 0x400d21c0                                                                               
D (1139) cpu_start: calling init function: 0x400d50f8 on core: 0                                                                    
D (1146) intr_alloc: Connected src 17 to int 3 (cpu 0)                                                                              
D (1151) cpu_start: calling init function: 0x400fc860 on core: 0                                                                    
D (1157) intr_alloc: Connected src 24 to int 9 (cpu 0)                                                                              
D (1162) app_start: Starting scheduler on CPU0                                                                                      
 (1166) intr_alloc: Connected src 25 to int 2 (cpu 1)                                                                               
D (1166) app_start: Starting scheduler on CPU1                                                                                      
;32mI (1166) main_task: Started on CPU0                                                                                             
D (1176) heap_init: New heap initialised at 0x3ffe0440                                                                              
D (1186) heap_init: New heap initialised at 0x3ffe4350                                                                              
D (1186) intr_alloc: Connected src 16 to int 12 (cpu 0)                                                                             
I (1186) main_task: Calling app_main()

More Information.

Legacy I2C API works as expected.

mythbuster5 commented 7 months ago

There will be a fix merged soon~

mythbuster5 commented 6 months ago

There is a fix already merged in master. Could you please have a try on master with step you mentioned above. If there is no more issue. I'm going to conclude this topic,~ @simunma

AxelLin commented 6 months ago

There is a fix already merged in master.

@mythbuster5 Could you share the commit of the fix? (So people can check if it is fixed in v5.2 branch).

simunma commented 6 months ago

@mythbuster5 Hi, sorry i was out of office for holidays. I tested it today, and the problem seems to be fixed. The minimal reproducible example and the main project runs as expected using the new API for i2c and ETH driver on current master branch. No more Interrupt wdt timeout.

kostaond commented 6 months ago

@mythbuster5 thanks for I2C driver fix. @simunma thanks for the testing. Closing the issue...