Skip to content

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

@softhack007

Description

@softhack007

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:

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

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug externala bug in external driver or library

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions