Cannot install USB host driver after installing i2c Driver in ESP32-S3
Posted: Tue May 21, 2024 2:15 am
- In ESP32-S3, Installing USB host driver fails once I2C driver was installed already.
- If I uninstall I2C driver, USB host driver successfully installed.
- Bellow is a brief sample code to reproduce the issue.
- Error code = 261(ESP_ERR_NOT_FOUND)
- void init_i2c(){
- int i2c_master_port = 1;
- i2c_config_t conf = {0,};
- conf.mode = I2C_MODE_MASTER;
- conf.sda_io_num = I2C_MASTER_SDA_IO;
- conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
- conf.scl_io_num = I2C_MASTER_SCL_IO;
- conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
- conf.master.clk_speed = 10000;
- i2c_param_config(i2c_master_port, &conf);
- i2c_driver_install(i2c_master_port, conf.mode,
- I2C_MASTER_RX_BUF_DISABLE,
- I2C_MASTER_TX_BUF_DISABLE, 0);
- }
- void init_usb(){
- esp_msc_host_config_t msc_host = {
- .base_path = "/usb",
- .host_driver_config = {
- .create_backround_task = true,
- .task_priority = 5,
- .stack_size = 4096
- },
- .vfs_fat_mount_config = {
- .format_if_mount_failed = false,
- .max_files = 3,
- .allocation_unit_size = 1024,
- },
- .host_config = {
- .intr_flags = ESP_INTR_FLAG_LEVEL1,
- }
- };
- err = usb_host_install(&config->host_config);
- if(err != ESP_OK){
- ESP_LOGE(TAG, "Failed to install USB host driver: %d", err); // err=261(ESP_ERR_NOT_FOUND)
- return err;
- }
- return ESP_OK;
- }
- void app_main(void)
- {
- esp_log_level_set("*", ESP_LOG_DEBUG) ;
- ...
- init_i2c();
- init_usb(); // failed here
- ...
- }