mirror of
https://github.com/esphome/esphome.git
synced 2025-10-18 17:53:47 +01:00
fix build error
This commit is contained in:
@@ -8,6 +8,7 @@ from esphome.const import (
|
|||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
from esphome.components.zephyr import zephyr_add_prj_conf
|
from esphome.components.zephyr import zephyr_add_prj_conf
|
||||||
import esphome.final_validate as fv
|
import esphome.final_validate as fv
|
||||||
|
from esphome.components.nrf52.const import BOOTLOADER_ADAFRUIT
|
||||||
|
|
||||||
dfu_ns = cg.esphome_ns.namespace("dfu")
|
dfu_ns = cg.esphome_ns.namespace("dfu")
|
||||||
DeviceFirmwareUpdate = dfu_ns.class_("DeviceFirmwareUpdate", cg.Component)
|
DeviceFirmwareUpdate = dfu_ns.class_("DeviceFirmwareUpdate", cg.Component)
|
||||||
@@ -31,7 +32,7 @@ def _validate_mcumgr(config):
|
|||||||
fconf = fv.full_config.get()
|
fconf = fv.full_config.get()
|
||||||
try:
|
try:
|
||||||
bootloader = fconf.get_config_for_path(["nrf52", "bootloader"])
|
bootloader = fconf.get_config_for_path(["nrf52", "bootloader"])
|
||||||
if bootloader != "adafruit":
|
if bootloader != BOOTLOADER_ADAFRUIT:
|
||||||
raise cv.Invalid(f"'{bootloader}' bootloader does not support DFU")
|
raise cv.Invalid(f"'{bootloader}' bootloader does not support DFU")
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
@@ -26,11 +26,11 @@ from esphome.components.zephyr.const import (
|
|||||||
ZEPHYR_VARIANT_GENERIC,
|
ZEPHYR_VARIANT_GENERIC,
|
||||||
ZEPHYR_VARIANT_NRF_SDK,
|
ZEPHYR_VARIANT_NRF_SDK,
|
||||||
KEY_ZEPHYR,
|
KEY_ZEPHYR,
|
||||||
|
KEY_BOOTLOADER,
|
||||||
|
BOOTLOADER_MCUBOOT,
|
||||||
)
|
)
|
||||||
from .boards_zephyr import BOARDS_ZEPHYR
|
from .boards_zephyr import BOARDS_ZEPHYR
|
||||||
from .const import (
|
from .const import (
|
||||||
KEY_BOOTLOADER,
|
|
||||||
BOOTLOADER_MCUBOOT,
|
|
||||||
BOOTLOADER_ADAFRUIT,
|
BOOTLOADER_ADAFRUIT,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -130,8 +130,8 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
cv.Optional(KEY_BOOTLOADER): cv.one_of(*BOOTLOADERS, lower=True),
|
cv.Optional(KEY_BOOTLOADER): cv.one_of(*BOOTLOADERS, lower=True),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
set_core_data,
|
|
||||||
_detect_bootloader,
|
_detect_bootloader,
|
||||||
|
set_core_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
from .const import (
|
from .const import BOOTLOADER_ADAFRUIT
|
||||||
BOOTLOADER_ADAFRUIT,
|
from esphome.components.zephyr.const import KEY_BOOTLOADER
|
||||||
KEY_BOOTLOADER,
|
|
||||||
)
|
|
||||||
|
|
||||||
BOARDS_ZEPHYR = {
|
BOARDS_ZEPHYR = {
|
||||||
"adafruit_itsybitsy_nrf52840": {KEY_BOOTLOADER: BOOTLOADER_ADAFRUIT},
|
"adafruit_itsybitsy_nrf52840": {KEY_BOOTLOADER: BOOTLOADER_ADAFRUIT},
|
||||||
|
@@ -1,3 +1 @@
|
|||||||
KEY_BOOTLOADER = "bootloader"
|
|
||||||
BOOTLOADER_MCUBOOT = "mcuboot"
|
|
||||||
BOOTLOADER_ADAFRUIT = "adafruit"
|
BOOTLOADER_ADAFRUIT = "adafruit"
|
||||||
|
@@ -16,6 +16,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
|
||||||
|
from esphome.components.zephyr.const import BOOTLOADER_MCUBOOT
|
||||||
|
|
||||||
CODEOWNERS = ["@esphome/core"]
|
CODEOWNERS = ["@esphome/core"]
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ def _validate_mcumgr(config):
|
|||||||
fconf = fv.full_config.get()
|
fconf = fv.full_config.get()
|
||||||
try:
|
try:
|
||||||
bootloader = fconf.get_config_for_path(["nrf52", "bootloader"])
|
bootloader = fconf.get_config_for_path(["nrf52", "bootloader"])
|
||||||
if bootloader != "mcuboot":
|
if bootloader != BOOTLOADER_MCUBOOT:
|
||||||
raise cv.Invalid(f"'{bootloader}' bootloader does not support OTA")
|
raise cv.Invalid(f"'{bootloader}' bootloader does not support OTA")
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
@@ -15,18 +15,22 @@ from .const import (
|
|||||||
KEY_PRJ_CONF,
|
KEY_PRJ_CONF,
|
||||||
KEY_OVERLAY,
|
KEY_OVERLAY,
|
||||||
zephyr_ns,
|
zephyr_ns,
|
||||||
|
BOOTLOADER_MCUBOOT,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
AUTO_LOAD = ["preferences"]
|
AUTO_LOAD = ["preferences"]
|
||||||
KEY_BOARD = "board"
|
KEY_BOARD = "board"
|
||||||
|
|
||||||
|
KEY_BOOTLOADER = "bootloader"
|
||||||
|
|
||||||
|
|
||||||
def zephyr_set_core_data(config):
|
def zephyr_set_core_data(config):
|
||||||
CORE.data[KEY_ZEPHYR] = {}
|
CORE.data[KEY_ZEPHYR] = {}
|
||||||
CORE.data[KEY_ZEPHYR][KEY_BOARD] = config[CONF_BOARD]
|
CORE.data[KEY_ZEPHYR][KEY_BOARD] = config[CONF_BOARD]
|
||||||
CORE.data[KEY_ZEPHYR][KEY_PRJ_CONF] = {}
|
CORE.data[KEY_ZEPHYR][KEY_PRJ_CONF] = {}
|
||||||
CORE.data[KEY_ZEPHYR][KEY_OVERLAY] = ""
|
CORE.data[KEY_ZEPHYR][KEY_OVERLAY] = ""
|
||||||
|
CORE.data[KEY_ZEPHYR][KEY_BOOTLOADER] = config[KEY_BOOTLOADER]
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
@@ -131,21 +135,22 @@ def zephyr_copy_files():
|
|||||||
CORE.data[KEY_ZEPHYR][KEY_OVERLAY],
|
CORE.data[KEY_ZEPHYR][KEY_OVERLAY],
|
||||||
)
|
)
|
||||||
|
|
||||||
fake_board_manifest = """
|
if CORE.data[KEY_ZEPHYR][KEY_BOOTLOADER] == BOOTLOADER_MCUBOOT:
|
||||||
|
fake_board_manifest = """
|
||||||
{
|
{
|
||||||
"frameworks": [
|
"frameworks": [
|
||||||
"zephyr"
|
"zephyr"
|
||||||
],
|
],
|
||||||
"name": "esphome nrf52",
|
"name": "esphome nrf52",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 248832,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104
|
"maximum_size": 815104
|
||||||
},
|
},
|
||||||
"url": "https://esphome.io/",
|
"url": "https://esphome.io/",
|
||||||
"vendor": "esphome"
|
"vendor": "esphome"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
write_file_if_changed(
|
write_file_if_changed(
|
||||||
CORE.relative_build_path(f"boards/{CORE.data[KEY_ZEPHYR][KEY_BOARD]}.json"),
|
CORE.relative_build_path(f"boards/{CORE.data[KEY_ZEPHYR][KEY_BOARD]}.json"),
|
||||||
fake_board_manifest,
|
fake_board_manifest,
|
||||||
)
|
)
|
||||||
|
@@ -5,5 +5,7 @@ ZEPHYR_VARIANT_NRF_SDK = "nrf-sdk"
|
|||||||
KEY_ZEPHYR = "zephyr"
|
KEY_ZEPHYR = "zephyr"
|
||||||
KEY_PRJ_CONF = "prj_conf"
|
KEY_PRJ_CONF = "prj_conf"
|
||||||
KEY_OVERLAY = "overlay"
|
KEY_OVERLAY = "overlay"
|
||||||
|
KEY_BOOTLOADER = "bootloader"
|
||||||
|
BOOTLOADER_MCUBOOT = "mcuboot"
|
||||||
|
|
||||||
zephyr_ns = cg.esphome_ns.namespace("zephyr")
|
zephyr_ns = cg.esphome_ns.namespace("zephyr")
|
||||||
|
Reference in New Issue
Block a user