-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Legacy driver conflict detection mechanisms are too aggressive. #10786
Comments
Turning off the check will allow both old and new drivers to be mixed in. This could lead to unexpected results that would be hard to debug. Arduino is meant to be used not only by experienced coders but also (mostly) by unexperienced ones. I am very partial to this and generally do not agree to turn the errors off. We do provide our own I2S interface that the libraries can use to interface with the bus. Why not use that instead and stay compatible from now on? |
Sorry, I agree with the argument for moving to the new drivers, and I think it would be great if all open source libraries registered with Arduino Manager were compatible with the new drivers right now. I'm probably not quite clear on what I'm trying to say, so let me explain a bit more.
|
Imho there will be situations you can not "guard" correctly when trying to use new drivers and using libs which are using deprecated drivers and hacking in support for new stuff. |
Yes, I completely agree. Here's another example: #include <Arduino.h>
#include <driver/i2s.h>
void no_use_function(void)
{
i2s_write(I2S_NUM_0, nullptr, 0, nullptr, 0);
}
void setup() {
analogRead(26);
}
void loop() {} This program is forced to abort due to a driver conflict check, and app_main doesn't even start.
I believe that libraries that depend on old drivers and are not updated should be discarded, but not all libraries in the world are stably maintained. In other words, during the transition period, new and old drivers are linked together. |
This is similar to this issue (related to legacy RMT IDF driver):
|
Yes, thanks. Essentially, if check for the presence of the new driver during the init of the legacy driver and abort if mixing is detected, no conflicts will occur. |
This issue lays in ESP32 only and within IDF 5.1 and IDF 5.3 (used by Arduino Core 3.0.x and 3.1.0). Running the same code using ESP32-S2 or ESP32-S3 (or any RISC-V -> C3, C6, H2), it doesn't fail. |
@lovyan03 - I really love your work with your library, but in this case Arduino Framework can't help it. Let us know what would be your suggestion about how Arduino could fix it. |
YES! AGREE!! |
What I didn't anticipate was that there were people who firmly believed that the current conflict checking system was perfect to protect beginners. |
Summary:IDF Legacy Driver for any peripheral is incompatible with the new IDF 5.x same peripheral driver. Arduino 3.x has its API implementation based on IDF 5. Therefore, using Legacy Drivers shall be done exclusively. The issue here presented: ESP32 SoC using IDF Legacy I2S and Arduino ADC in the same code. In order to fix it, the suggestion is to use ADC Legacy IDF calls to read Analog signals, instead of using Arduino Analog Read API. |
Yes, if the new driver is linked, it's okay if the old driver is not available. If you are using only the legacy I2S driver for normal I2S communication on a normal ESP32, the legacy ADC driver should not initialized, which means the code above should be safe to run. In other words, if we try to do an analog read with a legacy I2S driver, it should be aborted during driver initialization. |
It sounds to be the best way to go. |
Board
ESP32 Dev Module
Device Description
Since this is a software issue, the hardware configuration is not particularly important.
Hardware Configuration
Since this is a software issue, the hardware configuration is not particularly important.
Version
v3.0.7
IDE Name
ArduinoIDE
Operating System
Windows11
Flash frequency
40MHz
PSRAM enabled
no
Upload speed
115200
Description
Starting with ESP-IDF v5, new drivers have appeared, including for ADC and I2S, and the previous drivers are now called legacy drivers.
Mixing new and legacy drivers can cause malfunctions, so if you use a legacy driver, an announcement will be displayed strongly recommending that you switch to the new driver.
However, I feel that the conflict detection is overly excessive. I have written some code to reproduce a specific example, so please take a look.
Sketch
1_src.ino
2_base.h
3_no_use_class.cpp
4_use_class.cpp
Debug Message
Other Steps to Reproduce
The important thing here is that although there are derived classes that use the legacy driver, these derived classes are not used at all.
Despite this, the project cannot be started due to a conflict check.
The reason is that the function that checks for conflicts has the
__attribute__((constructor))
assigned, which forces a reboot before app_main.Let me explain a specific situation in which this occurs.
This time, I tried to create a project using a library called ESP8266Audio.
This library contains numerous class definitions, such as the decoder part of the audio codec and the signal output part.
This library also contains a derived class for the signal output part that uses the legacy I2S driver.
I only used the decoder part of this. For the signal output part, I created my own derived class that uses the new I2S driver.
Therefore, I did not use any signal output parts that use the legacy I2S driver.
However, as shown in the example above, it failed to start.
I understand that this is a safety mechanism to prevent mixing of ESP-IDF's legacy driver and the new driver,
and that it is not essentially an issue with ArduinoESP32.
And I also understand that I should advise the ESP8266Audio repository to migrate to the new driver.
(I intend to report this to the ESP-IDF and ESP8266Audio repositories if necessary.)
However, similar problems will likely occur with other products besides ESP8266Audio.
Also, if an abort occurs immediately after startup due to a legacy driver that is not used at runtime, it can be very difficult to identify the cause.
Even if you decode the backtrace, it will be impossible to identify the cause.
Fortunately, it seems that ESP-IDF has recently added a feature to skip conflict checks for legacy drivers.
espressif/esp-idf@c80fa61
I strongly hope that this will be included in the ArduinoESP32 CONFIG.
It should be sufficient to check for conflicts with legacy drivers when initializing the legacy driver.
If a conflict error is output to the log and aborted during initialization, the cause of the problem will also be shown in the backtrace.
I expect that this will be at least more helpful for users than the current situation.
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: