Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C support is buggy on "V4" environments (ESP-IDF 4.4.1 / arduino-esp32 2.0.4) #7

Open
1 task done
softhack007 opened this issue Dec 5, 2022 · 2 comments
Open
1 task done
Labels
bug external a bug in external driver or library bug Something isn't working

Comments

@softhack007
Copy link
Collaborator

softhack007 commented Dec 5, 2022

What happened?

When using one of the MM "V4 max" configs with 4LD, IMU and games usermod, I see a lot of error messages, when no OLED display is connected but everything is properly configured:

Usermods setup ...
temperature usermod initialized.
Starting display.
[   559][W][Wire.cpp:204] begin(): Bus already started in Master Mode.
[  2449][W][Wire.cpp:204] begin(): Bus already started in Master Mode.
[  2449][E][Wire.cpp:378] requestFrom(): i2cWriteReadNonStop returned Error -1
[  2455][E][Wire.cpp:378] requestFrom(): i2cWriteReadNonStop returned Error -1
[  2462][E][Wire.cpp:378] requestFrom(): i2cWriteReadNonStop returned Error -1
[  2469][E][Wire.cpp:378] requestFrom(): i2cWriteReadNonStop returned Error -1
[  2476][E][Wire.cpp:378] requestFrom(): i2cWriteReadNonStop returned Error -1
[  2513][E][Wire.cpp:378] requestFrom(): i2cWriteReadNonStop returned Error -1
[  2513][E][Wire.cpp:378] requestFrom(): i2cWriteReadNonStop returned Error -1
[  2516][E][Wire.cpp:378] requestFrom(): i2cWriteReadNonStop returned Error -1
[  2543][E][Wire.cpp:378] requestFrom(): i2cWriteReadNonStop returned Error -1
[  2543][E][Wire.cpp:378] requestFrom(): i2cWriteReadNonStop returned Error -1
[  2545][E][Wire.cpp:378] requestFrom(): i2cWriteReadNonStop returned Error -1
[  2552][E][Wire.cpp:378] requestFrom(): i2cWriteReadNonStop returned Error -1
[  2560][E][Wire.cpp:378] requestFrom(): i2cWriteReadNonStop returned Error -1
[  2567][E][Wire.cpp:378] requestFrom(): i2cWriteReadNonStop returned Error -1

When changing -any- usermod settings in the UI, similar messages appear

[761760][E][Wire.cpp:126] setPins(): bus already initialized. change pins only when not.
[761760][W][Wire.cpp:204] begin(): Bus already started in Master Mode.

On ESP32-S3, the situation is even worse - ESP32-S3 seems to "lock up" during startup, and it takes several minutes before LEDs show any reaction. This also happens when usermods are "disabled".

To Reproduce Bug

  • edit platformIO.ini and change -D CORE_DEBUG_LEVEL=4 - this is just to have clearer messages
  • build [env:esp32_4MB_V4_max] or [env:esp32_16MB_V4_max]
  • make sure no display, rotary on motion sensor is connected
  • upload and restart the device

--> error messages related to I2C bus.

  • open rotary UM settings, change nothing but click "save"
    --> more I2C errors

Expected Behavior

  1. WLED should work reliable when usermods that use I2C are compiled in, but no devices are connected to the bus.
  2. WLED should no initialize / reconfigure I2C when usermods are disabled.

Install Method

Self-Compiled

What version of WLED?

WLEDMM_0.14.0.9 esp32_16MB_V4_max, build 2212051.

Which microcontroller/board are you seeing the problem on?

ESP32, ESP32-S3, Other

Relevant log/trace output

see above.

Anything else?

This seems like a problem in upstream 0.14, which shows ugly consequences when compiling with platform = espressif32@ ~5.1.1, either for ESP32 (errors), or for ESP32-S3 (device blocked for several minutes).

We need to further investigate this.

Other

1/ Issues on -S3 could be related to this : espressif/esp-idf#8543

2/ looks like the code in set.cpp/cfg.cpp does a very half-hearted job, and always tries to re-init Wire:

WLED/wled00/set.cpp

Lines 506 to 512 in a2c7078

i2c_sda = hw_sda_pin;
i2c_scl = hw_scl_pin;
#ifdef ESP32
Wire.setPins(i2c_sda, i2c_scl); // this will fail if Wire is initilised (Wire.begin() called)
#endif
Wire.begin();
} else {

3/ Wire.end() is available in arduino-esp32, maybe we need a different implementation with #if WIRE_HAS_END

Code of Conduct

  • I agree to follow this project's Code of Conduct
@softhack007 softhack007 added the bug Something isn't working label Dec 5, 2022
@softhack007
Copy link
Collaborator Author

Discussion on Userinterface aspects is here: Aircoookie#2931

@softhack007 softhack007 added the bug external a bug in external driver or library label Dec 20, 2022
softhack007 added a commit that referenced this issue Nov 15, 2023
this is a band-aid fix for random crashes when switching between presets with multiple segments - crossfade disabled.

!! adding type initializers fixed it for me on -S3, however I still see (less frequent) crashes on esp32, due to heap corruption.

It took me hours to get a meaningful stackdump:

assert failed: heap_caps_free heap_caps.c:360 (heap != NULL && "free() target pointer is outside heap areas")

Backtrace: 0x40084ee1:0x3ffb2570 0x4008e341:0x3ffb2590 0x40094709:0x3ffb25b0 0x4008534a:0x3ffb26e0 0x40094739:0x3ffb2700 0x400e9037:0x3ffb2720 0x400e917c:0x3ffb2740 0x400eaeeb:0x3ffb2760 0x40117ec5:0x3ffb27c0 0x401184ea:0x3ffb2800 0x4013509d:0x3ffb2820

  #0  0x40084ee1:0x3ffb2570 in panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:402
  #1  0x4008e341:0x3ffb2590 in esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:128
  #2  0x40094709:0x3ffb25b0 in __assert_func at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/assert.c:85
  #3  0x4008534a:0x3ffb26e0 in heap_caps_free at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c:360
      (inlined by) heap_caps_free at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c:345
  #4  0x40094739:0x3ffb2700 in free at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/heap.c:39
  #5  0x400e9037:0x3ffb2720 in Segment::deallocateData() at wled00/FX_fcn.cpp:189
  #6  0x400e917c:0x3ffb2740 in Segment::resetIfRequired() at wled00/FX_fcn.cpp:206
      (inlined by) Segment::resetIfRequired() at wled00/FX_fcn.cpp:203
  #7  0x400eaeeb:0x3ffb2760 in WS2812FX::service() at wled00/FX_fcn.cpp:1216 (discriminator 2)
  #8  0x40117ec5:0x3ffb27c0 in WLED::loop() at wled00/wled.cpp:115 (discriminator 3)
  #9  0x401184ea:0x3ffb2800 in loop() at C:/src/wled00/wled00.ino:20
  #10 0x4013509d:0x3ffb2820 in loopTask(void*) at C:/Users/user/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:50

ELF file SHA256: 18c20b536f4c6ef4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug external a bug in external driver or library bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant