m5stack / M5Core2

M5Core2 Arduino Library
MIT License
262 stars 113 forks source link

[PlatformIO] Factory test on AWS Kit crash on I2C detection. #104

Closed hpsaturn closed 1 year ago

hpsaturn commented 1 year ago

Describe the bug

With the old version of Espressif Arduino Framework, the factory test works fine. (Platform espressif32 @ 3.2.0), but with the last version it fails in the detection of ECCX08 wit this panic:

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:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
M5Core2 initializing...axp: vbus limit off
axp: gpio1 init
axp: gpio2 init
axp: rtc battery charging enabled
axp: esp32 power voltage was set to 3.35v
axp: lcd backlight voltage was set to 2.80v
axp: lcd logic and sdcard voltage preset to 3.3v
axp: vibrator voltage preset to 2v
touch: FT6336 ready (fw id 0x10 rel 1, lib 0x300E)
[  1362][E][sd_diskio.cpp:199] sdCommand(): Card Failed! cmd: 0x00
[  1363][E][sd_diskio.cpp:802] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
[  1666][E][sd_diskio.cpp:199] sdCommand(): Card Failed! cmd: 0x00
E (1662) I2S: i2s_driver_uninstall(2006): I2S port 0 has not installed
OK
[  2137][E][sd_diskio.cpp:199] sdCommand(): Card Failed! cmd: 0x00
[  2138][E][sd_diskio.cpp:802] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
[  2441][E][sd_diskio.cpp:199] sdCommand(): Card Failed! cmd: 0x00
Addr:0x34 - Name:Axp192
Addr:0x38 - Name:CST Touch
Addr:0x68 - Name:IMU6886
Addr:0x51 - Name:BM8563
Addr:0x35 - Name:AT608A
ECCX08 Serial Number = 0123FE0xxxxx201

Guru Meditation Error: Core  1 panic'ed (InstrFetchProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x14141414  PS      : 0x00060e30  A0      : 0x8014f34c  A1      : 0x3ffb2690  
A2      : 0x3ffc4448  A3      : 0x3ffb26f0  A4      : 0x3ffb2760  A5      : 0x00000001  
A6      : 0x14141414  A7      : 0x14141414  A8      : 0x8014f0c0  A9      : 0x0000000a  
A10     : 0x00000001  A11     : 0x0000000a  A12     : 0x3f448208  A13     : 0x3ffc4624  
A14     : 0x3ffc4448  A15     : 0x3ffb26f0  SAR     : 0x00000020  EXCCAUSE: 0x00000014  
EXCVADDR: 0x14141414  LBEG    : 0x4008c0a1  LEND    : 0x4008c0b1  LCOUNT  : 0xffffffff  

Backtrace:0x14141411:0x3ffb26900x4014f349:0x3ffb26f0 0x400d3f5d:0x3ffb2790 0x400d572d:0x3ffb27d0 0x400e52fe:0x3ffb2820 

ELF file SHA256: 0000000000000000

Rebooting...

Backtrace decoded:

/home/avp/sketchbook/pio/m5stack/M5Core2/examples/core2_for_aws/FactoryTest/FactoryTest.ino:464
/home/avp/sketchbook/pio/m5stack/M5Core2/examples/core2_for_aws/FactoryTest/FactoryTest.ino:1946
/home/avp/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:42

To reproduce

For build with PlatformIO you can use my unmerged pull request that I did one year ago:

https://github.com/m5stack/M5Core2/pull/29

But also you can replicate with the package version that I listed above.

Expected behavior

Not core crash.

Screenshots

No response

Environment

Pkg versions:

Resolving esp32dev dependencies...
Platform espressif32 @ 5.1.1 (required: espressif32)
├── framework-arduinoespressif32 @ 3.20004.220825 (required: platformio/framework-arduinoespressif32 @ ~3.20004.0)
├── framework-espidf @ 3.40401.0 (required: platformio/framework-espidf @ ~3.40401.0)
├── tool-cmake @ 3.16.4 (required: platformio/tool-cmake @ ~3.16.0)
├── tool-esptoolpy @ 1.30300.0 (required: platformio/tool-esptoolpy @ ~1.30300.0)
├── tool-mkfatfs @ 2.0.1 (required: platformio/tool-mkfatfs @ ~2.0.0)
├── tool-mklittlefs @ 1.203.210628 (required: platformio/tool-mklittlefs @ ~1.203.0)
├── tool-mkspiffs @ 2.230.0 (required: platformio/tool-mkspiffs @ ~2.230.0)
├── tool-ninja @ 1.7.1 (required: platformio/tool-ninja @ ^1.7.0)
├── toolchain-esp32ulp @ 1.22851.191205 (required: platformio/toolchain-esp32ulp @ ~1.22851.0)
├── toolchain-riscv32-esp @ 8.4.0+2021r2-patch3 (required: espressif/toolchain-riscv32-esp @ 8.4.0+2021r2-patch3)
└── toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3 (required: espressif/toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3)

Libraries
├── FastLED @ 3.5.0 (required: fastled/FastLED @ ^3.4.0)
└── M5Core2 @ 0.1.5+sha.fcd7dfc (required: git+https://github.com/m5stack/M5Core2)

Additional context

No response

Issue checklist

felmue commented 1 year ago

Hello @hpsaturn

I don't know how to fix the detection of the AETCC608A during the I2C scan: I think the issue is that the AETCC608A is in sleep mode and therefore doesn't react to the scan, but that is just a wild guess.

That said I think at least I found the reason for the crash. Function checkAETCC608AInit() is missing a return value. Adding return 0; at the end of this function fixes the crash for me.

Thanks Felix