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

Add support for new I2C driver used in IDF 5.4 #667

Open
2 of 7 tasks
elijahnyp opened this issue Nov 17, 2024 · 0 comments
Open
2 of 7 tasks

Add support for new I2C driver used in IDF 5.4 #667

elijahnyp opened this issue Nov 17, 2024 · 0 comments

Comments

@elijahnyp
Copy link

The issue

with the upcoming release of 5.4 (currently in beta), there is a new I2C driver. The new driver will not co-exist with the old driver (i2c.h vs i2c_master.h). Some libraries, like the esp32-camera library, support and use the new driver when compiled with version 5.4 of the IDF. Without updating to support the new driver, the esp-idf-lib drivers are incapable of co-existing with drivers that do use the new setup.

Which SDK are you using?

esp-idf

Which version of SDK are you using?

v5.4

Which build target have you used?

  • esp32
  • esp32s2
  • esp32s3
  • esp32c2
  • esp8266
  • other

Component causing the issue

i2cdev

Anything in the logs that might be useful for us?

No response

Additional information or context

The issue occurs at runtime due to changes in i2c.c in idf 5.4. If the new driver is linked in, at runtime the old i2c driver aborts execution.

/**
 * @brief This function will be called during start up, to check that this legacy i2c driver is not running along with the new I2C driver
 */
__attribute__((constructor))
static void check_i2c_driver_conflict(void)
{
    // This function was declared as weak here. The new I2C driver has the implementation.
    // So if the new I2C driver is not linked in, then `i2c_acquire_bus_handle()` should be NULL at runtime.
    extern __attribute__((weak)) esp_err_t i2c_acquire_bus_handle(int port_num, void *i2c_new_bus, int mode);
    if ((void *)i2c_acquire_bus_handle != NULL) {
        ESP_EARLY_LOGE(I2C_TAG, "CONFLICT! driver_ng is not allowed to be used with this old driver");
        abort();
    }
    ESP_EARLY_LOGW(I2C_TAG, "This driver is an old driver, please migrate your application code to adapt `driver/i2c_master.h`");
}

Confirmation

  • This report is not a question nor a request for drivers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant