espressif / esp-idf

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

ESP32S2 crashes when running i2cdetect from esp-idf/examples/peripherals/i2c/i2c_tools (IDFGH-6057) #7739

Closed TeXniKK closed 2 years ago

TeXniKK commented 2 years ago

Environment

Problem Description

i2c_tool example crashes on ESP32S2 after running 'i2cdetect' command multiple times

Expected Behavior

i2cdetect command executed without errors and crashes

Actual Behavior

ESP32S2 crashes with Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).

Steps to reproduce

  1. Clone IDF
  2. Copy esp-idf/examples/peripherals/i2c/i2c_tools to i2c_tools
  3. cd ../i2c_tools
  4. idf.py set-target esp32s2
  5. idf.py menuconfig (save with defaults)
  6. idf.py build
  7. idf.py -p /dev/tty.usbserial-0001 flash
  8. Open minicom, reset board
  9. Execute i2cconfig --sda=4 --scl=5 in ESP shell
  10. Execute i2cdetect multiple times (usually 5-10)

// If possible, attach a picture of your setup/wiring here. SDA connected to pin 4, SCL connected to pin 5. Chips on I2C bus: 24LC32AT-I/OT, SHT20, PCF8533-based LCD

Code to reproduce this issue

Just use unmodified i2c_tools example from IDF

Debug Logs

i2c-tools> i2cconfig --sda=4 --scl=5                                                                                                                     
i2c-tools> i2cdetect                                                                                                                                     
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f                                                                                                      
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                                      
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                                      
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                                      
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- --                                                                                                      
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                                      
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                                      
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                                      
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                                      
i2c-tools> i2cdetect
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- -- 
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
i2c-tools> i2cdetect
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- -- 
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
i2c-tools> i2cdetect
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- -- 
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
i2c-tools> i2cdetect
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- -- 
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
i2c-tools> i2cdetect
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- -- 
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
i2c-tools> i2cdetect
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- -- 
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
i2c-tools> i2cdetect
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- -- 
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
i2c-tools> i2cdetect
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- -- 
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
i2c-tools> i2cdetect
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- UU Guru Meditation Error: Core  0 panic'ed (Interrupt wdt timeout on CPU0). 

Core  0 register dump:
PC      : 0x40024f44  PS      : 0x00060034  A0      : 0x40024665  A1      : 0x3ffc0c00  
A2      : 0x00000000  A3      : 0x00000000  A4      : 0x00000004  A5      : 0x400297d4  
A6      : 0x3ffc31f4  A7      : 0x00000000  A8      : 0x80024e2d  A9      : 0x3ffc0bd0  
A10     : 0x00000000  A11     : 0x3ffc0c08  A12     : 0x00000000  A13     : 0x00000000  
A14     : 0x3ffc32a8  A15     : 0x00060021  SAR     : 0x0000001e  EXCCAUSE: 0x00000005  
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x400232e4  
Core  0 was running in ISR context:
EPC1    : 0x40082707  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x40024f44

Backtrace:0x40024f41:0x3ffc0c000x40024662:0x3ffc0c30 0x40029e71:0x3ffccb30 0x400864c7:0x3ffccb70 0x4008c27c:0x3ffccb90 0x4008c35a:0x3ffccbb0 0x4002c009:0x3ffccbe0 

ELF file SHA256: 07e0d24d8331e10b

Rebooting...
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x400234fc
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6100,len:0x12d8
load:0x4004c000,len:0x8f4
load:0x40050000,len:0x2c5c
entry 0x4004c1a8
I (92) cache: Instruction cache         : size 8KB, 4Ways, cache line size 32Byte
I (92) cpu_start: Pro cpu up.
I (104) cpu_start: Pro cpu start user code
I (104) cpu_start: cpu freq: 160000000
I (104) cpu_start: Application information:
I (109) cpu_start: Project name:     i2c_tools
I (114) cpu_start: App version:      1
I (118) cpu_start: Compile time:     Oct 20 2021 12:59:10
I (124) cpu_start: ELF file SHA256:  07e0d24d8331e10b...
I (130) cpu_start: ESP-IDF:          v4.4-dev-3401-gb86fe0c66c
I (137) heap_init: Initializing. RAM available for dynamic allocation:
I (144) heap_init: At 3FF9E02C len 00001FD4 (7 KiB): RTCRAM
I (150) heap_init: At 3FFC29C0 len 00039640 (229 KiB): DRAM
I (156) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM
I (163) spi_flash: detected chip: generic
I (167) spi_flash: flash io: dio
I (172) cpu_start: Starting scheduler on PRO CPU.

 ==============================================================
 |             Steps to Use i2c-tools                         |
 |                                                            |
 |  1. Try 'help', check all supported commands               |
 |  2. Try 'i2cconfig' to configure your I2C bus              |
 |  3. Try 'i2cdetect' to scan devices on the bus             |
 |  4. Try 'i2cget' to get the content of specific register   |
 |  5. Try 'i2cset' to set the value of specific register     |
 |  6. Try 'i2cdump' to dump all the register (Experiment)    |
 |                                                            |
 ==============================================================

Type 'help' to get the list of commands.
Use UP/DOWN arrows to navigate through command history.
Press TAB when typing command name to auto-complete.
i2c-tools> 

Other items if possible

o-marshmallow commented 2 years ago

Hi @TeXniKK ,

Thanks for reporting this, I am going to try reproducing it and check what the issue is.

felmue commented 2 years ago

Hello guys

I am unable to reproduce this issue. I've tried on two ESP32S2 boards (esp32-s2-saola and esp32-s2-kaluga) with three I2C slave devices (DHT12, BMM150 and BMP280) attached. Same GPIOs (4/5). I ran i2cdetect about 50 times on each board - no crash.

Fresh esp-idf clone: v4.4-dev-3540-g4e03a9c34c

@TeXniKK: does it crash for you as well when no I2C slaves are attached?

Thanks Felix

o-marshmallow commented 2 years ago

Hello @felmue ,

Thanks for your feedback, I tried on my side on an ESP32-S2-WROVER and commit b86fe0c66 and I was also unable to reproduce the issue.

I tried about 40 times with a gyro sensor tied on the bus and 50 times without any device but with a logic analyzer to detect whether the generated signals were correct or not. It turned out they were correct.

TeXniKK commented 2 years ago

Hello guys. Thank you for verification. I'll check which exact I2C device allows to reproduce the issue and post details soon.

Alvin1Zhang commented 2 years ago

@TeXniKK Thanks for reporting, would you please help share if any updates for the issue? Thanks.

o-marshmallow commented 2 years ago

Closing this issue for now, feel free to re-open if you still encounter this problem