mirror of
https://github.com/esphome/esphome.git
synced 2025-04-06 10:50:28 +01:00
remove not tested things
This commit is contained in:
parent
12230ce4d7
commit
36b2371498
@ -8,7 +8,6 @@ from esphome.const import (
|
||||
PLATFORM_NRF52,
|
||||
CONF_TYPE,
|
||||
CONF_FRAMEWORK,
|
||||
CONF_VARIANT,
|
||||
CONF_PLATFORM_VERSION,
|
||||
)
|
||||
from esphome.core import CORE, coroutine_with_priority
|
||||
@ -18,8 +17,6 @@ from esphome.components.zephyr import (
|
||||
zephyr_to_code,
|
||||
)
|
||||
from esphome.components.zephyr.const import (
|
||||
ZEPHYR_VARIANT_GENERIC,
|
||||
ZEPHYR_VARIANT_NRF_SDK,
|
||||
KEY_ZEPHYR,
|
||||
KEY_BOOTLOADER,
|
||||
BOOTLOADER_MCUBOOT,
|
||||
@ -42,53 +39,6 @@ def set_core_data(config):
|
||||
return config
|
||||
|
||||
|
||||
# https://github.com/platformio/platform-nordicnrf52/releases
|
||||
NORDICNRF52_PLATFORM_VERSION = cv.Version(10, 3, 0)
|
||||
|
||||
|
||||
def _platform_check_versions(value):
|
||||
value = value.copy()
|
||||
value[CONF_PLATFORM_VERSION] = value.get(
|
||||
CONF_PLATFORM_VERSION,
|
||||
_parse_platform_version(str(NORDICNRF52_PLATFORM_VERSION)),
|
||||
)
|
||||
return value
|
||||
|
||||
|
||||
def _parse_platform_version(value):
|
||||
try:
|
||||
# if platform version is a valid version constraint, prefix the default package
|
||||
cv.platformio_version_constraint(value)
|
||||
return f"platformio/nordicnrf52@{value}"
|
||||
except cv.Invalid:
|
||||
return value
|
||||
|
||||
|
||||
PLATFORM_FRAMEWORK_SCHEMA = cv.All(
|
||||
cv.Schema(
|
||||
{
|
||||
cv.Optional(CONF_PLATFORM_VERSION): _parse_platform_version,
|
||||
}
|
||||
),
|
||||
_platform_check_versions,
|
||||
)
|
||||
|
||||
ZEPHYR_VARIANTS = [
|
||||
ZEPHYR_VARIANT_GENERIC,
|
||||
ZEPHYR_VARIANT_NRF_SDK,
|
||||
]
|
||||
|
||||
FRAMEWORK_SCHEMA = cv.All(
|
||||
cv.Schema(
|
||||
{
|
||||
cv.Optional(CONF_VARIANT, default=ZEPHYR_VARIANT_NRF_SDK): cv.one_of(
|
||||
*ZEPHYR_VARIANTS, lower=True
|
||||
),
|
||||
}
|
||||
),
|
||||
_platform_check_versions,
|
||||
)
|
||||
|
||||
BOOTLOADERS = [
|
||||
BOOTLOADER_ADAFRUIT,
|
||||
BOOTLOADER_MCUBOOT,
|
||||
@ -121,7 +71,6 @@ CONFIG_SCHEMA = cv.All(
|
||||
cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_BOARD): cv.string_strict,
|
||||
cv.Optional(CONF_FRAMEWORK, default={}): FRAMEWORK_SCHEMA,
|
||||
cv.Optional(KEY_BOOTLOADER): cv.one_of(*BOOTLOADERS, lower=True),
|
||||
}
|
||||
),
|
||||
@ -136,7 +85,7 @@ async def to_code(config):
|
||||
cg.add_build_flag("-DUSE_NRF52")
|
||||
cg.add_define("ESPHOME_BOARD", config[CONF_BOARD])
|
||||
cg.add_define("ESPHOME_VARIANT", "NRF52")
|
||||
conf = config[CONF_FRAMEWORK]
|
||||
conf = {"platform_version": "platformio/nordicnrf52@10.3.0"}
|
||||
cg.add_platformio_option(CONF_FRAMEWORK, CORE.data[KEY_CORE][KEY_TARGET_FRAMEWORK])
|
||||
cg.add_platformio_option("platform", conf[CONF_PLATFORM_VERSION])
|
||||
|
||||
|
@ -7,13 +7,10 @@ from esphome.helpers import (
|
||||
copy_file_if_changed,
|
||||
)
|
||||
from esphome.const import (
|
||||
CONF_VARIANT,
|
||||
CONF_BOARD,
|
||||
KEY_NAME,
|
||||
)
|
||||
from .const import (
|
||||
ZEPHYR_VARIANT_GENERIC,
|
||||
ZEPHYR_VARIANT_NRF_SDK,
|
||||
KEY_ZEPHYR,
|
||||
KEY_PRJ_CONF,
|
||||
KEY_OVERLAY,
|
||||
@ -80,25 +77,16 @@ def add_extra_script(stage: str, filename: str, path: str):
|
||||
def zephyr_to_code(conf):
|
||||
cg.add(zephyr_ns.setup_preferences())
|
||||
cg.add_build_flag("-DUSE_ZEPHYR")
|
||||
if conf[CONF_VARIANT] == ZEPHYR_VARIANT_GENERIC:
|
||||
cg.add_platformio_option(
|
||||
"platform_packages",
|
||||
[
|
||||
"platformio/framework-zephyr@^2.30500.231204",
|
||||
],
|
||||
)
|
||||
elif conf[CONF_VARIANT] == ZEPHYR_VARIANT_NRF_SDK:
|
||||
cg.add_platformio_option(
|
||||
"platform_packages",
|
||||
[
|
||||
"platformio/framework-zephyr@https://github.com/tomaszduda23/framework-sdk-nrf",
|
||||
"platformio/toolchain-gccarmnoneeabi@https://github.com/tomaszduda23/toolchain-sdk-ng",
|
||||
],
|
||||
)
|
||||
# build is done by west so bypass board checking in platformio
|
||||
cg.add_platformio_option("boards_dir", CORE.relative_build_path("boards"))
|
||||
else:
|
||||
raise NotImplementedError
|
||||
cg.add_platformio_option(
|
||||
"platform_packages",
|
||||
[
|
||||
"platformio/framework-zephyr@https://github.com/tomaszduda23/framework-sdk-nrf",
|
||||
"platformio/toolchain-gccarmnoneeabi@https://github.com/tomaszduda23/toolchain-sdk-ng",
|
||||
],
|
||||
)
|
||||
# build is done by west so bypass board checking in platformio
|
||||
cg.add_platformio_option("boards_dir", CORE.relative_build_path("boards"))
|
||||
|
||||
# c++ support
|
||||
zephyr_add_prj_conf("NEWLIB_LIBC", True)
|
||||
zephyr_add_prj_conf("CONFIG_FPU", True)
|
||||
|
@ -1,8 +1,5 @@
|
||||
import esphome.codegen as cg
|
||||
|
||||
ZEPHYR_VARIANT_GENERIC = "generic"
|
||||
ZEPHYR_VARIANT_NRF_SDK = "nrf-sdk"
|
||||
|
||||
KEY_ZEPHYR = "zephyr"
|
||||
KEY_PRJ_CONF = "prj_conf"
|
||||
KEY_OVERLAY = "overlay"
|
||||
|
@ -8,19 +8,6 @@ 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"
|
||||
@ -72,6 +59,8 @@ 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)
|
||||
@ -93,6 +82,14 @@ 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
|
||||
@ -113,7 +110,7 @@ async def smpmgr_upload(config, host, firmware):
|
||||
|
||||
try:
|
||||
image_state = await asyncio.wait_for(
|
||||
smp_client.request(ImageStatesRead()), timeout=SMPClient.MEDIUM_TIMEOUT
|
||||
smp_client.request(ImageStatesRead()), timeout=2.5
|
||||
)
|
||||
except SMPBadStartDelimiter as e:
|
||||
_LOGGER.error("mcumgr is not supported by device (%s)", e)
|
||||
@ -156,7 +153,7 @@ async def smpmgr_upload(config, host, firmware):
|
||||
_LOGGER.info("Mark image for testing")
|
||||
r = await asyncio.wait_for(
|
||||
smp_client.request(ImageStatesWrite(hash=image_tlv_sha256)),
|
||||
timeout=SMPClient.SHORT_TIMEOUT,
|
||||
timeout=1.0,
|
||||
)
|
||||
|
||||
if error(r):
|
||||
@ -164,9 +161,7 @@ async def smpmgr_upload(config, host, firmware):
|
||||
return 1
|
||||
|
||||
_LOGGER.info("Reset")
|
||||
r = await asyncio.wait_for(
|
||||
smp_client.request(ResetWrite()), timeout=SMPClient.SHORT_TIMEOUT
|
||||
)
|
||||
r = await asyncio.wait_for(smp_client.request(ResetWrite()), timeout=1.0)
|
||||
|
||||
if error(r):
|
||||
_LOGGER.error(r)
|
||||
|
Loading…
x
Reference in New Issue
Block a user