MoonModules / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi! MoonModules adds features on top of upstream.
https://mm.kno.wled.ge
European Union Public License 1.2
228 stars 70 forks source link

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

Open softhack007 opened 1 year ago

softhack007 commented 1 year ago

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

--> error messages related to I2C bus.

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 : https://github.com/espressif/esp-idf/issues/8543

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

https://github.com/MoonModules/WLED/blob/a2c707831c4b0730c42a7b9172076bf4bcd50941/wled00/set.cpp#L506-L512

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

Code of Conduct

softhack007 commented 1 year ago

known bugs:

softhack007 commented 1 year ago

Discussion on Userinterface aspects is here: https://github.com/Aircoookie/WLED/issues/2931