mirror of
https://github.com/esphome/esphome.git
synced 2025-07-29 22:56:37 +00:00
[i2c] Disable i2c scan on certain idf versions (#9237)
This commit is contained in:
parent
5010a0f5e7
commit
61b3379f48
@ -1,5 +1,8 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
from esphome import pins
|
from esphome import pins
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
|
from esphome.components import esp32
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_ADDRESS,
|
CONF_ADDRESS,
|
||||||
@ -12,6 +15,8 @@ from esphome.const import (
|
|||||||
CONF_SCL,
|
CONF_SCL,
|
||||||
CONF_SDA,
|
CONF_SDA,
|
||||||
CONF_TIMEOUT,
|
CONF_TIMEOUT,
|
||||||
|
KEY_CORE,
|
||||||
|
KEY_FRAMEWORK_VERSION,
|
||||||
PLATFORM_ESP32,
|
PLATFORM_ESP32,
|
||||||
PLATFORM_ESP8266,
|
PLATFORM_ESP8266,
|
||||||
PLATFORM_RP2040,
|
PLATFORM_RP2040,
|
||||||
@ -19,6 +24,7 @@ from esphome.const import (
|
|||||||
from esphome.core import CORE, coroutine_with_priority
|
from esphome.core import CORE, coroutine_with_priority
|
||||||
import esphome.final_validate as fv
|
import esphome.final_validate as fv
|
||||||
|
|
||||||
|
LOGGER = logging.getLogger(__name__)
|
||||||
CODEOWNERS = ["@esphome/core"]
|
CODEOWNERS = ["@esphome/core"]
|
||||||
i2c_ns = cg.esphome_ns.namespace("i2c")
|
i2c_ns = cg.esphome_ns.namespace("i2c")
|
||||||
I2CBus = i2c_ns.class_("I2CBus")
|
I2CBus = i2c_ns.class_("I2CBus")
|
||||||
@ -40,6 +46,32 @@ def _bus_declare_type(value):
|
|||||||
raise NotImplementedError
|
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(
|
pin_with_input_and_output_support = pins.internal_gpio_pin_number(
|
||||||
{CONF_OUTPUT: True, CONF_INPUT: True}
|
{CONF_OUTPUT: True, CONF_INPUT: True}
|
||||||
)
|
)
|
||||||
@ -65,6 +97,7 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
}
|
}
|
||||||
).extend(cv.COMPONENT_SCHEMA),
|
).extend(cv.COMPONENT_SCHEMA),
|
||||||
cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266, PLATFORM_RP2040]),
|
cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266, PLATFORM_RP2040]),
|
||||||
|
validate_config,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user