mirror of
https://github.com/esphome/esphome.git
synced 2025-04-08 11:50:34 +01:00
rollback zephyr tools
This commit is contained in:
parent
9c8b5ee933
commit
83938e8755
@ -39,17 +39,20 @@ def zephyr_set_core_data(config):
|
||||
PrjConfValueType = Union[bool, str, int]
|
||||
|
||||
|
||||
def zephyr_add_prj_conf(name: str, value: PrjConfValueType):
|
||||
def zephyr_add_prj_conf(name: str, value: PrjConfValueType, required: bool = True):
|
||||
"""Set an zephyr prj conf value."""
|
||||
if not name.startswith("CONFIG_"):
|
||||
name = "CONFIG_" + name
|
||||
if name in CORE.data[KEY_ZEPHYR][KEY_PRJ_CONF]:
|
||||
old_value = CORE.data[KEY_ZEPHYR][KEY_PRJ_CONF][name]
|
||||
if old_value != value:
|
||||
if old_value[0] != value and old_value[1]:
|
||||
raise ValueError(
|
||||
f"{name} already set with value '{old_value}', cannot set again to '{value}'"
|
||||
f"{name} already set with value '{old_value[0]}', cannot set again to '{value}'"
|
||||
)
|
||||
CORE.data[KEY_ZEPHYR][KEY_PRJ_CONF][name] = value
|
||||
if required:
|
||||
CORE.data[KEY_ZEPHYR][KEY_PRJ_CONF][name] = (value, required)
|
||||
else:
|
||||
CORE.data[KEY_ZEPHYR][KEY_PRJ_CONF][name] = (value, required)
|
||||
|
||||
|
||||
def zephyr_add_overlay(content):
|
||||
@ -96,8 +99,7 @@ def zephyr_to_code(conf):
|
||||
zephyr_add_prj_conf("WDT_DISABLE_AT_BOOT", False)
|
||||
# disable console
|
||||
zephyr_add_prj_conf("UART_CONSOLE", False)
|
||||
# TODO disable when no OTA USB CDC
|
||||
# zephyr_add_prj_conf("CONSOLE", False)
|
||||
zephyr_add_prj_conf("CONSOLE", False, False)
|
||||
|
||||
add_extra_script(
|
||||
"pre",
|
||||
@ -143,7 +145,7 @@ def copy_files():
|
||||
want_opts = CORE.data[KEY_ZEPHYR][KEY_PRJ_CONF]
|
||||
contents = (
|
||||
"\n".join(
|
||||
f"{name}={_format_prj_conf_val(value)}"
|
||||
f"{name}={_format_prj_conf_val(value[0])}"
|
||||
for name, value in sorted(want_opts.items())
|
||||
)
|
||||
+ "\n"
|
||||
|
@ -8,6 +8,19 @@ from bleak import BleakScanner, BleakClient
|
||||
from bleak.exc import BleakDeviceNotFoundError, BleakDBusError
|
||||
from esphome.espota2 import ProgressBar
|
||||
|
||||
try:
|
||||
from smpclient.transport.ble import SMPBLETransport
|
||||
from smpclient.transport.serial import SMPSerialTransport
|
||||
from smpclient import SMPClient
|
||||
from smpclient.mcuboot import IMAGE_TLV, ImageInfo, TLVNotFound, MCUBootImageError
|
||||
from smpclient.requests.image_management import ImageStatesRead, ImageStatesWrite
|
||||
from smpclient.requests.os_management import ResetWrite
|
||||
from smpclient.generics import error, success
|
||||
from smp.exceptions import SMPBadStartDelimiter
|
||||
except ModuleNotFoundError:
|
||||
pass
|
||||
|
||||
|
||||
SMP_SERVICE_UUID = "8D53DC1D-1DB7-4CD3-868B-8A527460AA84"
|
||||
NUS_SERVICE_UUID = "6E400001-B5A3-F393-E0A9-E50E24DCCA9E"
|
||||
NUS_TX_CHAR_UUID = "6E400003-B5A3-F393-E0A9-E50E24DCCA9E"
|
||||
@ -59,8 +72,6 @@ async def smpmgr_scan(name):
|
||||
|
||||
def get_image_tlv_sha256(file):
|
||||
_LOGGER.info("Checking image: %s", str(file))
|
||||
from smpclient.mcuboot import MCUBootImageError, ImageInfo, TLVNotFound, IMAGE_TLV
|
||||
|
||||
try:
|
||||
image_info = ImageInfo.load_file(str(file))
|
||||
pprint(image_info.header)
|
||||
@ -82,14 +93,6 @@ async def smpmgr_upload(config, host, firmware):
|
||||
if sys.version_info < (3, 10):
|
||||
_LOGGER.error("BLE OTA requires at least python 3.10")
|
||||
return 1
|
||||
from smpclient.transport.ble import SMPBLETransport
|
||||
from smpclient.transport.serial import SMPSerialTransport
|
||||
from smpclient import SMPClient
|
||||
from smpclient.requests.image_management import ImageStatesRead, ImageStatesWrite
|
||||
from smpclient.requests.os_management import ResetWrite
|
||||
from smpclient.generics import error, success
|
||||
from smp.exceptions import SMPBadStartDelimiter
|
||||
|
||||
image_tlv_sha256 = get_image_tlv_sha256(firmware)
|
||||
if image_tlv_sha256 is None:
|
||||
return 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user