Cannot install USB host driver after installing i2c Driver in ESP32-S3

DxPian
Posts: 1
Joined: Tue May 21, 2024 1:22 am

Cannot install USB host driver after installing i2c Driver in ESP32-S3

Postby DxPian » Tue May 21, 2024 2:15 am

  1.  
  2. In ESP32-S3, Installing USB host driver fails once I2C driver was installed already.
  3. If I uninstall I2C driver, USB host driver successfully installed.
  4. Bellow is a brief sample code to reproduce the issue.
  5. Error code = 261(ESP_ERR_NOT_FOUND)
  1. void init_i2c(){
  2.     int i2c_master_port = 1;
  3.    
  4.     i2c_config_t conf = {0,};
  5.     conf.mode = I2C_MODE_MASTER;
  6.     conf.sda_io_num = I2C_MASTER_SDA_IO;
  7.     conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
  8.     conf.scl_io_num = I2C_MASTER_SCL_IO;
  9.     conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
  10.     conf.master.clk_speed = 10000;
  11.     i2c_param_config(i2c_master_port, &conf);
  12.     i2c_driver_install(i2c_master_port, conf.mode,
  13.                        I2C_MASTER_RX_BUF_DISABLE,
  14.                        I2C_MASTER_TX_BUF_DISABLE, 0);
  15. }
  16.  
  17. void init_usb(){
  18.     esp_msc_host_config_t msc_host = {
  19.         .base_path = "/usb",
  20.         .host_driver_config = {
  21.             .create_backround_task = true,    
  22.             .task_priority = 5,                
  23.             .stack_size = 4096
  24.         },
  25.         .vfs_fat_mount_config = {
  26.             .format_if_mount_failed = false,  
  27.             .max_files = 3,                    
  28.             .allocation_unit_size = 1024,      
  29.         },
  30.         .host_config = {
  31.             .intr_flags = ESP_INTR_FLAG_LEVEL1,
  32.         }
  33.     }; 
  34.     err = usb_host_install(&config->host_config);  
  35.     if(err != ESP_OK){
  36.         ESP_LOGE(TAG, "Failed to install USB host driver: %d", err);  // err=261(ESP_ERR_NOT_FOUND)
  37.         return err;
  38.     }
  39.     return ESP_OK;
  40. }
  41.  
  42. void app_main(void)
  43. {
  44.     esp_log_level_set("*", ESP_LOG_DEBUG) ;
  45.     ...
  46.     init_i2c();
  47.     init_usb();  // failed here
  48.     ...
  49. }

leonardo.costa
Posts: 6
Joined: Thu Jan 06, 2022 6:21 pm

Re: Cannot install USB host driver after installing i2c Driver in ESP32-S3

Postby leonardo.costa » Fri Jun 07, 2024 9:36 am

Hello,
i had the same problem and i resolved it using ESP_INTER_FLAG_LEVEL2 as shown below:
const usb_host_config_t host_config = {
.intr_flags = ESP_INTR_FLAG_LEVEL2,
};

Leo

Who is online

Users browsing this forum: No registered users and 330 guests