mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	[i2c] Disable i2c scan on certain idf versions (#9237)
This commit is contained in:
		
				
					committed by
					
						 Jesse Hills
						Jesse Hills
					
				
			
			
				
	
			
			
			
						parent
						
							5010a0f5e7
						
					
				
				
					commit
					61b3379f48
				
			| @@ -1,5 +1,8 @@ | ||||
| import logging | ||||
|  | ||||
| from esphome import pins | ||||
| import esphome.codegen as cg | ||||
| from esphome.components import esp32 | ||||
| import esphome.config_validation as cv | ||||
| from esphome.const import ( | ||||
|     CONF_ADDRESS, | ||||
| @@ -12,6 +15,8 @@ from esphome.const import ( | ||||
|     CONF_SCL, | ||||
|     CONF_SDA, | ||||
|     CONF_TIMEOUT, | ||||
|     KEY_CORE, | ||||
|     KEY_FRAMEWORK_VERSION, | ||||
|     PLATFORM_ESP32, | ||||
|     PLATFORM_ESP8266, | ||||
|     PLATFORM_RP2040, | ||||
| @@ -19,6 +24,7 @@ from esphome.const import ( | ||||
| from esphome.core import CORE, coroutine_with_priority | ||||
| import esphome.final_validate as fv | ||||
|  | ||||
| LOGGER = logging.getLogger(__name__) | ||||
| CODEOWNERS = ["@esphome/core"] | ||||
| i2c_ns = cg.esphome_ns.namespace("i2c") | ||||
| I2CBus = i2c_ns.class_("I2CBus") | ||||
| @@ -40,6 +46,32 @@ def _bus_declare_type(value): | ||||
|     raise NotImplementedError | ||||
|  | ||||
|  | ||||
| def validate_config(config): | ||||
|     if ( | ||||
|         config[CONF_SCAN] | ||||
|         and CORE.is_esp32 | ||||
|         and CORE.using_esp_idf | ||||
|         and esp32.get_esp32_variant() | ||||
|         in [ | ||||
|             esp32.const.VARIANT_ESP32C5, | ||||
|             esp32.const.VARIANT_ESP32C6, | ||||
|             esp32.const.VARIANT_ESP32P4, | ||||
|         ] | ||||
|     ): | ||||
|         version: cv.Version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] | ||||
|         if version.major == 5 and ( | ||||
|             (version.minor == 3 and version.patch <= 3) | ||||
|             or (version.minor == 4 and version.patch <= 1) | ||||
|         ): | ||||
|             LOGGER.warning( | ||||
|                 "There is a bug in esp-idf version %s that breaks I2C scan, I2C scan " | ||||
|                 "has been disabled, see https://github.com/esphome/issues/issues/7128", | ||||
|                 str(version), | ||||
|             ) | ||||
|             config[CONF_SCAN] = False | ||||
|     return config | ||||
|  | ||||
|  | ||||
| pin_with_input_and_output_support = pins.internal_gpio_pin_number( | ||||
|     {CONF_OUTPUT: True, CONF_INPUT: True} | ||||
| ) | ||||
| @@ -65,6 +97,7 @@ CONFIG_SCHEMA = cv.All( | ||||
|         } | ||||
|     ).extend(cv.COMPONENT_SCHEMA), | ||||
|     cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266, PLATFORM_RP2040]), | ||||
|     validate_config, | ||||
| ) | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user