mirror of
https://github.com/esphome/esphome.git
synced 2026-10-26 07:52:14 +00:00
Compare commits
13
Commits
dev
...
libretiny_1_14_0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
472a723b53 | ||
|
|
4d734478e4 | ||
|
|
440c0d9cb5 | ||
|
|
59e36171f2 | ||
|
|
877fb27a07 | ||
|
|
3b7926776d | ||
|
|
f95bc94f94 | ||
|
|
6f9aa52cd2 | ||
|
|
712e977ce9 | ||
|
|
3e068d7e2e | ||
|
|
5546dc3e40 | ||
|
|
e778e9eaf0 | ||
|
|
d4b745be13 |
No files matched your search
@@ -62,6 +62,13 @@ struct SpiData {
|
||||
|
||||
static SpiData *spi_data = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
|
||||
// BDK 3.0.78 makes REG_WRITE a statement expression that yields the volatile assignment,
|
||||
// a deprecated volatile read under clang
|
||||
static inline void reg_write(uint32_t addr, uint32_t value) {
|
||||
// NOLINTNEXTLINE(performance-no-int-to-ptr) - MMIO register at a fixed address
|
||||
*reinterpret_cast<volatile uint32_t *>(addr) = value;
|
||||
}
|
||||
|
||||
static void set_spi_ctrl_register(uint32_t bit, bool val) {
|
||||
uint32_t value = REG_READ(SPI_CTRL);
|
||||
if (val == 0) {
|
||||
@@ -69,7 +76,7 @@ static void set_spi_ctrl_register(uint32_t bit, bool val) {
|
||||
} else if (val == 1) {
|
||||
value |= bit;
|
||||
}
|
||||
REG_WRITE(SPI_CTRL, value);
|
||||
reg_write(SPI_CTRL, value);
|
||||
}
|
||||
|
||||
#ifdef BEKEN_SPI_IS_N_LIKE
|
||||
@@ -80,7 +87,7 @@ static void set_spi_config_register(uint32_t bit, bool val) {
|
||||
} else if (val == 1) {
|
||||
value |= bit;
|
||||
}
|
||||
REG_WRITE(SPI_CONFIG, value);
|
||||
reg_write(SPI_CONFIG, value);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -136,7 +143,7 @@ static void spi_set_clock(uint32_t max_hz) {
|
||||
param = REG_READ(SPI_CTRL);
|
||||
param &= ~(SPI_CKR_MASK << SPI_CKR_POSI);
|
||||
param |= (div << SPI_CKR_POSI);
|
||||
REG_WRITE(SPI_CTRL, param);
|
||||
reg_write(SPI_CTRL, param);
|
||||
#ifdef BEKEN_SPI_IS_N_LIKE
|
||||
const int divisor = div;
|
||||
#else
|
||||
@@ -229,7 +236,7 @@ void BekenSPILEDStripLightOutput::setup() {
|
||||
value = REG_READ(SPI_CTRL);
|
||||
value &= ~CTRL_NSSMD_3;
|
||||
value |= (1 << 17);
|
||||
REG_WRITE(SPI_CTRL, value);
|
||||
reg_write(SPI_CTRL, value);
|
||||
|
||||
#ifdef BEKEN_SPI_IS_N_LIKE
|
||||
value = GFUNC_MODE_SPI_DMA;
|
||||
@@ -279,7 +286,7 @@ void BekenSPILEDStripLightOutput::setup() {
|
||||
value = REG_READ(SPI_CONFIG);
|
||||
value &= ~(0xFFF << 8);
|
||||
value |= ((dma_buffer_size & 0xFFF) << 8);
|
||||
REG_WRITE(SPI_CONFIG, value);
|
||||
reg_write(SPI_CONFIG, value);
|
||||
#else
|
||||
// T-like variants: No transfer-length register. The SPI controller shifts out
|
||||
// everything the DMA writes into SPI_DAT.
|
||||
|
||||
@@ -21,9 +21,10 @@ public ble_api.h.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import re
|
||||
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import libretiny, wifi
|
||||
from esphome.components import libretiny
|
||||
from esphome.components.libretiny.const import (
|
||||
FAMILY_BK7231N,
|
||||
FAMILY_BK7231Q,
|
||||
@@ -32,14 +33,30 @@ from esphome.components.libretiny.const import (
|
||||
FAMILY_BK7251,
|
||||
)
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ENABLE_ON_BOOT, CONF_ID
|
||||
from esphome.core import EsphomeError
|
||||
from esphome.const import (
|
||||
CONF_ENABLE_ON_BOOT,
|
||||
CONF_ESPHOME,
|
||||
CONF_ID,
|
||||
CONF_PLATFORMIO_OPTIONS,
|
||||
KEY_CORE,
|
||||
KEY_FRAMEWORK_VERSION,
|
||||
)
|
||||
from esphome.core import CORE, EsphomeError
|
||||
import esphome.final_validate as fv
|
||||
from esphome.types import ConfigType
|
||||
|
||||
DEPENDENCIES = ["bk72xx"]
|
||||
CODEOWNERS = ["@Bl00d-B0b"]
|
||||
DOMAIN = "bk72xx_ble"
|
||||
|
||||
BEKEN_BDK_VERSION_OPTION = "custom_versions.beken-bdk"
|
||||
# Older BDKs lay the BLE stack out differently and can crash at boot or erase the
|
||||
# bootloader with BLE compiled in; the libretiny platform builds with this one
|
||||
MIN_BDK_VERSION = (3, 0, 78)
|
||||
# Older LibreTiny releases arm the Beken MCU sleep with wifi power save, which halts
|
||||
# the device once the station stops while BLE runs (libretiny-eu/libretiny#414)
|
||||
MIN_LIBRETINY_VERSION = (1, 14, 0)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
bk72xx_ble_ns = cg.esphome_ns.namespace("bk72xx_ble")
|
||||
@@ -80,20 +97,45 @@ def _unsupported_family_message(family: str) -> str | None:
|
||||
return None
|
||||
|
||||
|
||||
def check_bdk_version(value: str | None) -> None:
|
||||
"""Reject a beken-bdk override older than the release the BLE stack needs."""
|
||||
if value is None:
|
||||
return
|
||||
# LibreTiny appends the value to the package URL as a git ref and only builds
|
||||
# 3.0.x releases; the 2021.06.07 tag is the pre 3.0 SDK
|
||||
match = re.fullmatch(r"v?(\d+)\.(\d+)\.(\d+)", str(value))
|
||||
if match is not None:
|
||||
version = tuple(int(g) for g in match.groups())
|
||||
if version[:2] == MIN_BDK_VERSION[:2] and version >= MIN_BDK_VERSION:
|
||||
return
|
||||
minimum = ".".join(str(part) for part in MIN_BDK_VERSION)
|
||||
raise cv.Invalid(
|
||||
f"bk72xx_ble needs beken-bdk {minimum} or a newer 3.0.x release, not "
|
||||
f"'{value}': with BLE compiled in, an older BDK can crash at boot or erase "
|
||||
"the bootloader"
|
||||
)
|
||||
|
||||
|
||||
def check_libretiny_version(version: cv.Version) -> None:
|
||||
"""Reject a LibreTiny release older than the one whose WiFi sleep is safe with BLE."""
|
||||
if (version.major, version.minor, version.patch) >= MIN_LIBRETINY_VERSION:
|
||||
return
|
||||
minimum = ".".join(str(part) for part in MIN_LIBRETINY_VERSION)
|
||||
raise cv.Invalid(
|
||||
f"bk72xx_ble needs LibreTiny {minimum} or newer, not {version}: older releases "
|
||||
"arm the Beken MCU sleep with wifi power save and the device halts once the "
|
||||
"station stops while BLE runs"
|
||||
)
|
||||
|
||||
|
||||
def _final_validate(config: ConfigType) -> None:
|
||||
# Warn only: a hard error here would break the validate-only CI fixtures,
|
||||
# which run on a BLE 4.2 board. The hard error is raised at codegen.
|
||||
if msg := _unsupported_family_message(libretiny.get_libretiny_family()):
|
||||
_LOGGER.warning("%s (this configuration cannot compile)", msg)
|
||||
# Any wifi power_save_mode other than NONE also arms the Beken SDK's MCU
|
||||
# sleep. With the BLE controller running, that sleep never wakes up once the
|
||||
# station is stopped (adapter restart after failed roams, wifi.disable): the
|
||||
# device is dead until a power cycle (esphome#18592). Keep power save off
|
||||
# until LibreTiny ships the SDK-side fix (libretiny-eu/libretiny#414).
|
||||
wifi.force_power_save_off(
|
||||
"with BLE running, the Beken SDK's MCU sleep halts the device once the "
|
||||
"station is stopped (https://github.com/esphome/esphome/issues/18592)"
|
||||
)
|
||||
options = fv.full_config.get()[CONF_ESPHOME].get(CONF_PLATFORMIO_OPTIONS) or {}
|
||||
check_bdk_version(options.get(BEKEN_BDK_VERSION_OPTION))
|
||||
check_libretiny_version(CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION])
|
||||
|
||||
|
||||
FINAL_VALIDATE_SCHEMA = _final_validate
|
||||
@@ -116,20 +158,6 @@ async def to_code(config: ConfigType) -> None:
|
||||
# so this =1 is the single CFG_SUPPORT_BLE define emitted.
|
||||
cg.add_platformio_option("custom_options.sys_config#h", ["CFG_SUPPORT_BLE=1"])
|
||||
|
||||
# Pin the Beken BDK release the BLE 5.x stack is validated against. The
|
||||
# bundled 3.0.33 has an older BLE header/library layout — and with
|
||||
# CFG_SUPPORT_BLE=1 the SDK runs its BLE init unconditionally during boot
|
||||
# (the reason the libretiny platform sets =0 when BLE is unused), so a
|
||||
# mismatched BDK can crash the device before WiFi comes up regardless of
|
||||
# enable_on_boot. Pinning here makes a plain config build against the
|
||||
# validated BDK without any manual platformio_options.
|
||||
_LOGGER.warning(
|
||||
"bk72xx_ble builds with beken-bdk 3.0.78 instead of the platform's bundled "
|
||||
"default: the default's older BLE layout can crash the device at boot when "
|
||||
"BLE is compiled in"
|
||||
)
|
||||
cg.add_platformio_option("custom_versions.beken-bdk", "3.0.78")
|
||||
|
||||
# The BDK exposes the controller's BLE address as `common_default_bdaddr` on
|
||||
# BK7231N, but NOT on BK7238 (its BLE stack has no such symbol; the address is
|
||||
# derived from the WiFi MAC instead — the BDK's own fallback). Tell the C++
|
||||
|
||||
@@ -40,6 +40,7 @@ from .const import (
|
||||
CONF_UART_PORT,
|
||||
FAMILIES,
|
||||
FAMILY_BK7231N,
|
||||
FAMILY_BK7231T,
|
||||
FAMILY_BK7238,
|
||||
FAMILY_COMPONENT,
|
||||
FAMILY_FRIENDLY,
|
||||
@@ -233,14 +234,14 @@ def _notify_old_style(config):
|
||||
# The dev and latest branches will be at *least* this version, which is what matters.
|
||||
# Use GitHub releases directly to avoid PlatformIO moderation delays.
|
||||
ARDUINO_VERSIONS = {
|
||||
"dev": (cv.Version(1, 13, 0), "https://github.com/libretiny-eu/libretiny.git"),
|
||||
"dev": (cv.Version(1, 14, 0), "https://github.com/libretiny-eu/libretiny.git"),
|
||||
"latest": (
|
||||
cv.Version(1, 13, 0),
|
||||
"https://github.com/libretiny-eu/libretiny.git#v1.13.0",
|
||||
cv.Version(1, 14, 0),
|
||||
"https://github.com/libretiny-eu/libretiny.git#v1.14.0",
|
||||
),
|
||||
"recommended": (
|
||||
cv.Version(1, 13, 0),
|
||||
"https://github.com/libretiny-eu/libretiny.git#v1.13.0",
|
||||
cv.Version(1, 14, 0),
|
||||
"https://github.com/libretiny-eu/libretiny.git#v1.14.0",
|
||||
),
|
||||
}
|
||||
|
||||
@@ -516,6 +517,13 @@ async def component_to_code(config):
|
||||
if config[CONF_FAMILY] == FAMILY_RTL8710B:
|
||||
cg.add_platformio_option("custom_versions.freertos", "8.2.3")
|
||||
|
||||
# LibreTiny bundles BDK 3.0.33 for these two but already builds BK7238 with 3.0.78,
|
||||
# where STA+AP works (esphome#19430), the web server OTA does not trip the watchdog
|
||||
# (esphome#19429) and the no WiFi reboot loop is gone (esphome#18268). A
|
||||
# platformio_options custom_versions.beken-bdk entry in the config still wins.
|
||||
if config[CONF_FAMILY] in (FAMILY_BK7231N, FAMILY_BK7231T):
|
||||
cg.add_platformio_option("custom_versions.beken-bdk", "3.0.78")
|
||||
|
||||
# force using arduino framework
|
||||
cg.add_platformio_option("framework", "arduino")
|
||||
cg.add_build_flag("-DUSE_ARDUINO")
|
||||
@@ -533,8 +541,10 @@ async def component_to_code(config):
|
||||
# it for project source files only. GCC uses the last -O flag.
|
||||
build_src_flags += " -Os"
|
||||
cg.add_platformio_option("build_src_flags", build_src_flags)
|
||||
# Must run before the platform's builder scripts are loaded; see the script.
|
||||
cg.add_platformio_option("extra_scripts", ["pre:scons_dont_inherit.py"])
|
||||
# LibreTiny before 1.14.0 breaks under SCons 4.11 without this script; see the script
|
||||
version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
|
||||
if (version.major, version.minor, version.patch) < (1, 14, 0):
|
||||
cg.add_platformio_option("extra_scripts", ["pre:scons_dont_inherit.py"])
|
||||
cg.add_platformio_option("extra_scripts", ["pre:ccache.py"])
|
||||
# IRAM_ATTR is a no-op on BK72xx (SDK masks FIQ+IRQ around flash ops).
|
||||
# On other families, patch_linker.py routes .sram.text into the right
|
||||
|
||||
@@ -42,11 +42,14 @@ from esphome.components.libretiny.const import (
|
||||
LibreTinyComponent,
|
||||
)
|
||||
from esphome.core import CORE
|
||||
from esphome.cpp_generator import MockObj
|
||||
from esphome.types import ConfigType
|
||||
|
||||
{IMPORTS}
|
||||
|
||||
CODEOWNERS = {CODEOWNERS}
|
||||
AUTO_LOAD = ["libretiny"]
|
||||
DOMAIN = "{COMPONENT_LOWER}"
|
||||
IS_TARGET_PLATFORM = True
|
||||
|
||||
COMPONENT_DATA = LibreTinyComponent(
|
||||
@@ -59,7 +62,7 @@ COMPONENT_DATA = LibreTinyComponent(
|
||||
)
|
||||
|
||||
|
||||
def _set_core_data(config):
|
||||
def _set_core_data(config: ConfigType) -> ConfigType:
|
||||
CORE.data[KEY_LIBRETINY] = {}
|
||||
CORE.data[KEY_LIBRETINY][KEY_COMPONENT_DATA] = COMPONENT_DATA
|
||||
return config
|
||||
@@ -76,12 +79,12 @@ PIN_SCHEMA = {PIN_SCHEMA}
|
||||
CONFIG_SCHEMA.prepend_extra(_set_core_data)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
async def to_code(config: ConfigType) -> MockObj:
|
||||
return await libretiny.component_to_code(config)
|
||||
|
||||
|
||||
@pins.PIN_SCHEMA_REGISTRY.register("{COMPONENT_LOWER}", PIN_SCHEMA)
|
||||
async def pin_to_code(config):
|
||||
async def pin_to_code(config: ConfigType) -> MockObj:
|
||||
return await libretiny.gpio.component_pin_to_code(config)
|
||||
|
||||
|
||||
|
||||
@@ -355,11 +355,12 @@ LN882X_BOARD_PINS = {
|
||||
"WIRE0_SCL_5": 5,
|
||||
"WIRE0_SCL_6": 6,
|
||||
"WIRE0_SCL_7": 9,
|
||||
"WIRE0_SCL_8": 11,
|
||||
"WIRE0_SCL_9": 20,
|
||||
"WIRE0_SCL_10": 21,
|
||||
"WIRE0_SCL_11": 22,
|
||||
"WIRE0_SCL_12": 25,
|
||||
"WIRE0_SCL_8": 10,
|
||||
"WIRE0_SCL_9": 11,
|
||||
"WIRE0_SCL_10": 20,
|
||||
"WIRE0_SCL_11": 21,
|
||||
"WIRE0_SCL_12": 22,
|
||||
"WIRE0_SCL_13": 25,
|
||||
"WIRE0_SDA_0": 0,
|
||||
"WIRE0_SDA_1": 1,
|
||||
"WIRE0_SDA_2": 2,
|
||||
@@ -368,11 +369,12 @@ LN882X_BOARD_PINS = {
|
||||
"WIRE0_SDA_5": 5,
|
||||
"WIRE0_SDA_6": 6,
|
||||
"WIRE0_SDA_7": 9,
|
||||
"WIRE0_SDA_8": 11,
|
||||
"WIRE0_SDA_9": 20,
|
||||
"WIRE0_SDA_10": 21,
|
||||
"WIRE0_SDA_11": 22,
|
||||
"WIRE0_SDA_12": 25,
|
||||
"WIRE0_SDA_8": 10,
|
||||
"WIRE0_SDA_9": 11,
|
||||
"WIRE0_SDA_10": 20,
|
||||
"WIRE0_SDA_11": 21,
|
||||
"WIRE0_SDA_12": 22,
|
||||
"WIRE0_SDA_13": 25,
|
||||
"SERIAL0_RX": 3,
|
||||
"SERIAL0_TX": 2,
|
||||
"SERIAL1_TX": 25,
|
||||
@@ -397,6 +399,7 @@ LN882X_BOARD_PINS = {
|
||||
"PA6": 6,
|
||||
"PA09": 9,
|
||||
"PA9": 9,
|
||||
"PA10": 10,
|
||||
"PA11": 11,
|
||||
"PB04": 20,
|
||||
"PB4": 20,
|
||||
@@ -421,7 +424,8 @@ LN882X_BOARD_PINS = {
|
||||
"D9": 22,
|
||||
"D10": 3,
|
||||
"D11": 2,
|
||||
"D12": 11,
|
||||
"D12": 10,
|
||||
"D13": 11,
|
||||
"A0": 0,
|
||||
"A1": 1,
|
||||
"A2": 4,
|
||||
|
||||
@@ -39,6 +39,10 @@ RTL87XX_BOARDS = {
|
||||
"name": "Generic - RTL8710BN (2M/788k)",
|
||||
"family": FAMILY_RTL8710B,
|
||||
},
|
||||
"generic-rtl8710bx-1mb-468k": {
|
||||
"name": "Generic - RTL8710BX (1M/468k)",
|
||||
"family": FAMILY_RTL8710B,
|
||||
},
|
||||
"generic-rtl8710bx-4mb-980k": {
|
||||
"name": "Generic - RTL8710BX (4M/980k)",
|
||||
"family": FAMILY_RTL8710B,
|
||||
@@ -595,6 +599,103 @@ RTL87XX_BOARD_PINS = {
|
||||
"A0": 19,
|
||||
"A1": 41,
|
||||
},
|
||||
"generic-rtl8710bx-1mb-468k": {
|
||||
"SPI0_CS": 19,
|
||||
"SPI0_FCS": 6,
|
||||
"SPI0_FD0": 9,
|
||||
"SPI0_FD1": 7,
|
||||
"SPI0_FD2": 8,
|
||||
"SPI0_FD3": 11,
|
||||
"SPI0_FSCK": 10,
|
||||
"SPI0_MISO": 22,
|
||||
"SPI0_MOSI": 23,
|
||||
"SPI0_SCK": 18,
|
||||
"SPI1_CS": 19,
|
||||
"SPI1_MISO": 22,
|
||||
"SPI1_MOSI": 23,
|
||||
"SPI1_SCK": 18,
|
||||
"WIRE0_SCL_0": 22,
|
||||
"WIRE0_SCL_1": 29,
|
||||
"WIRE0_SDA_0": 19,
|
||||
"WIRE0_SDA_1": 30,
|
||||
"WIRE1_SCL": 18,
|
||||
"WIRE1_SDA": 23,
|
||||
"SERIAL0_CTS": 19,
|
||||
"SERIAL0_RTS": 22,
|
||||
"SERIAL0_RX": 18,
|
||||
"SERIAL0_TX": 23,
|
||||
"SERIAL2_RX": 29,
|
||||
"SERIAL2_TX": 30,
|
||||
"ADC1": 19,
|
||||
"CS0": 19,
|
||||
"CS1": 19,
|
||||
"CTS0": 19,
|
||||
"FCS": 6,
|
||||
"FD0": 9,
|
||||
"FD1": 7,
|
||||
"FD2": 8,
|
||||
"FD3": 11,
|
||||
"FSCK": 10,
|
||||
"MISO0": 22,
|
||||
"MISO1": 22,
|
||||
"MOSI0": 23,
|
||||
"MOSI1": 23,
|
||||
"PA00": 0,
|
||||
"PA0": 0,
|
||||
"PA05": 5,
|
||||
"PA5": 5,
|
||||
"PA06": 6,
|
||||
"PA6": 6,
|
||||
"PA07": 7,
|
||||
"PA7": 7,
|
||||
"PA08": 8,
|
||||
"PA8": 8,
|
||||
"PA09": 9,
|
||||
"PA9": 9,
|
||||
"PA10": 10,
|
||||
"PA11": 11,
|
||||
"PA12": 12,
|
||||
"PA14": 14,
|
||||
"PA15": 15,
|
||||
"PA18": 18,
|
||||
"PA19": 19,
|
||||
"PA22": 22,
|
||||
"PA23": 23,
|
||||
"PA29": 29,
|
||||
"PA30": 30,
|
||||
"PWM1": 15,
|
||||
"PWM2": 0,
|
||||
"PWM3": 12,
|
||||
"PWM4": 30,
|
||||
"PWM5": 22,
|
||||
"RTS0": 22,
|
||||
"RX0": 18,
|
||||
"RX2": 29,
|
||||
"SCK0": 18,
|
||||
"SCK1": 18,
|
||||
"SCL1": 18,
|
||||
"SDA1": 23,
|
||||
"TX0": 23,
|
||||
"TX2": 30,
|
||||
"D0": 0,
|
||||
"D1": 5,
|
||||
"D2": 6,
|
||||
"D3": 7,
|
||||
"D4": 8,
|
||||
"D5": 9,
|
||||
"D6": 10,
|
||||
"D7": 11,
|
||||
"D8": 12,
|
||||
"D9": 14,
|
||||
"D10": 15,
|
||||
"D11": 18,
|
||||
"D12": 19,
|
||||
"D13": 22,
|
||||
"D14": 23,
|
||||
"D15": 29,
|
||||
"D16": 30,
|
||||
"A0": 19,
|
||||
},
|
||||
"generic-rtl8710bx-4mb-980k": {
|
||||
"SPI0_CS": 19,
|
||||
"SPI0_FCS": 6,
|
||||
|
||||
+5
-2
@@ -239,7 +239,7 @@ build_unflags =
|
||||
; This are common settings for the LibreTiny (all variants) using Arduino.
|
||||
[common:libretiny-arduino]
|
||||
extends = common:arduino
|
||||
platform = https://github.com/libretiny-eu/libretiny.git#v1.13.0
|
||||
platform = https://github.com/libretiny-eu/libretiny.git#v1.14.0
|
||||
framework = arduino
|
||||
lib_compat_mode = soft
|
||||
lib_deps =
|
||||
@@ -260,7 +260,6 @@ build_flags =
|
||||
build_unflags =
|
||||
${common.build_unflags}
|
||||
build_src_flags = -include Arduino.h
|
||||
extra_scripts = pre:esphome/components/libretiny/scons_dont_inherit.py.script
|
||||
|
||||
; This is the common settings for the nRF52 using Zephyr.
|
||||
[common:nrf52-zephyr]
|
||||
@@ -557,6 +556,8 @@ build_flags =
|
||||
-DUSE_LIBRETINY_VARIANT_BK7231N
|
||||
build_unflags =
|
||||
${common.build_unflags}
|
||||
; mirror the libretiny codegen pin: BK7231N and BK7231T build with BDK 3.0.78
|
||||
custom_versions.beken-bdk = 3.0.78
|
||||
|
||||
[env:ln882h-arduino]
|
||||
extends = common:libretiny-arduino
|
||||
@@ -594,6 +595,8 @@ build_unflags =
|
||||
[env:bk72xx-tidy]
|
||||
extends = common:libretiny-arduino
|
||||
board = generic-bk7231n-qfn32-tuya
|
||||
; mirror the libretiny codegen pin: BK7231N and BK7231T build with BDK 3.0.78
|
||||
custom_versions.beken-bdk = 3.0.78
|
||||
build_flags =
|
||||
${common:libretiny-arduino.build_flags}
|
||||
${flags:clangtidy.build_flags}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
esphome:
|
||||
name: bk-bdk-newer
|
||||
platformio_options:
|
||||
custom_versions.beken-bdk: "3.0.80"
|
||||
|
||||
bk72xx:
|
||||
board: generic-bk7231n-qfn32-tuya
|
||||
|
||||
wifi:
|
||||
ssid: test
|
||||
password: testtest
|
||||
|
||||
bk72xx_ble:
|
||||
@@ -0,0 +1,13 @@
|
||||
esphome:
|
||||
name: bk-bdk-too-old
|
||||
platformio_options:
|
||||
custom_versions.beken-bdk: "3.0.33"
|
||||
|
||||
bk72xx:
|
||||
board: generic-bk7231n-qfn32-tuya
|
||||
|
||||
wifi:
|
||||
ssid: test
|
||||
password: testtest
|
||||
|
||||
bk72xx_ble:
|
||||
@@ -0,0 +1,13 @@
|
||||
esphome:
|
||||
name: bk-libretiny-too-old
|
||||
|
||||
bk72xx:
|
||||
board: generic-bk7231n-qfn32-tuya
|
||||
framework:
|
||||
version: 1.13.0
|
||||
|
||||
wifi:
|
||||
ssid: test
|
||||
password: testtest
|
||||
|
||||
bk72xx_ble:
|
||||
@@ -0,0 +1,53 @@
|
||||
"""bk72xx_ble refuses a beken-bdk override outside 3.0.78 and later 3.0.x releases:
|
||||
an older BDK can crash at boot or erase the bootloader with BLE compiled in, and
|
||||
LibreTiny only builds the 3.0 line."""
|
||||
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from esphome.components.bk72xx_ble import check_bdk_version
|
||||
from esphome.config import read_config
|
||||
import esphome.config_validation as cv
|
||||
from esphome.core import CORE
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, "3.0.78", "v3.0.78", "3.0.80"])
|
||||
def test_new_enough_versions_pass(value: str | None) -> None:
|
||||
check_bdk_version(value)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"value",
|
||||
[
|
||||
"3.0.33",
|
||||
"3.0.77",
|
||||
"3.1.0",
|
||||
"4.0.0",
|
||||
"2021.06.07",
|
||||
"main",
|
||||
"https://github.com/x/bdk#3.0.78",
|
||||
],
|
||||
)
|
||||
def test_other_versions_fail(value: str) -> None:
|
||||
with pytest.raises(cv.Invalid, match="3.0.78 or a newer 3.0.x"):
|
||||
check_bdk_version(value)
|
||||
|
||||
|
||||
def test_old_override_fails_validation(
|
||||
component_config_path: Callable[[str], Path],
|
||||
capsys: pytest.CaptureFixture[str],
|
||||
) -> None:
|
||||
CORE.config_path = component_config_path("test_bdk_too_old.yaml")
|
||||
assert read_config({}) is None
|
||||
assert "3.0.78 or a newer 3.0.x" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_newer_override_builds(
|
||||
generate_main: Callable[[str | Path], str],
|
||||
component_config_path: Callable[[str], Path],
|
||||
) -> None:
|
||||
main_cpp = generate_main(component_config_path("test_bdk_newer.yaml"))
|
||||
assert "bk72xx_ble::BK72xxBLE" in main_cpp
|
||||
assert CORE.platformio_options.get("custom_versions.beken-bdk") == "3.0.80"
|
||||
@@ -0,0 +1,32 @@
|
||||
"""bk72xx_ble refuses LibreTiny releases older than 1.14.0: their WiFi sleep arms the
|
||||
Beken MCU sleep, which halts the device once the station stops while BLE runs."""
|
||||
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from esphome.components.bk72xx_ble import check_libretiny_version
|
||||
from esphome.config import read_config
|
||||
import esphome.config_validation as cv
|
||||
from esphome.core import CORE
|
||||
|
||||
|
||||
@pytest.mark.parametrize("version", ["1.14.0", "1.14.1", "1.15.0", "2.0.0"])
|
||||
def test_new_enough_releases_pass(version: str) -> None:
|
||||
check_libretiny_version(cv.Version.parse(version))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("version", ["1.13.0", "1.12.2", "0.0.0"])
|
||||
def test_older_releases_fail(version: str) -> None:
|
||||
with pytest.raises(cv.Invalid, match="1.14.0 or newer"):
|
||||
check_libretiny_version(cv.Version.parse(version))
|
||||
|
||||
|
||||
def test_pinned_old_framework_fails_validation(
|
||||
component_config_path: Callable[[str], Path],
|
||||
capsys: pytest.CaptureFixture[str],
|
||||
) -> None:
|
||||
CORE.config_path = component_config_path("test_libretiny_too_old.yaml")
|
||||
assert read_config({}) is None
|
||||
assert "1.14.0 or newer" in capsys.readouterr().out
|
||||
@@ -1,20 +1,16 @@
|
||||
"""bk72xx_ble keeps WiFi power save off: the Beken SDK's MCU sleep does not
|
||||
wake up once the station is stopped while the BLE controller runs."""
|
||||
"""bk72xx_ble no longer keeps WiFi power save off: LibreTiny 1.14.0 sleeps the radio
|
||||
between DTIM beacons only, so the Beken MCU sleep that halted the chip with BLE running
|
||||
is never armed (libretiny-eu/libretiny#414)."""
|
||||
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def test_power_save_mode_is_not_applied_with_ble(
|
||||
def test_power_save_mode_is_applied_with_ble(
|
||||
generate_main: Callable[[str | Path], str],
|
||||
component_config_path: Callable[[str], Path],
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
main_cpp = generate_main(component_config_path("test_power_save.yaml"))
|
||||
|
||||
assert "bk72xx_ble::BK72xxBLE" in main_cpp
|
||||
assert "set_power_save_mode(" not in main_cpp
|
||||
assert "power_save_mode HIGH is not applied" in caplog.text
|
||||
assert "issues/18592" in caplog.text
|
||||
assert "set_power_save_mode(wifi::WIFI_POWER_SAVE_HIGH)" in main_cpp
|
||||
@@ -0,0 +1,5 @@
|
||||
esphome:
|
||||
name: bdk-bk7231n
|
||||
|
||||
bk72xx:
|
||||
board: generic-bk7231n-qfn32-tuya
|
||||
@@ -0,0 +1,5 @@
|
||||
esphome:
|
||||
name: bdk-bk7231t
|
||||
|
||||
bk72xx:
|
||||
board: generic-bk7231t-qfn32-tuya
|
||||
@@ -0,0 +1,7 @@
|
||||
esphome:
|
||||
name: bdk-override
|
||||
platformio_options:
|
||||
custom_versions.beken-bdk: "3.0.33"
|
||||
|
||||
bk72xx:
|
||||
board: generic-bk7231n-qfn32-tuya
|
||||
@@ -0,0 +1,7 @@
|
||||
esphome:
|
||||
name: bk72xx-lt113
|
||||
|
||||
bk72xx:
|
||||
board: generic-bk7231n-qfn32-tuya
|
||||
framework:
|
||||
version: 1.13.0
|
||||
@@ -0,0 +1,29 @@
|
||||
"""BK7231N and BK7231T build with Beken BDK 3.0.78 by default; a platformio_options
|
||||
entry in the config still picks the version."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from esphome.core import CORE
|
||||
|
||||
|
||||
@pytest.mark.parametrize("config_file", ["bdk_bk7231n.yaml", "bdk_bk7231t.yaml"])
|
||||
def test_bk7231_builds_with_bdk_3_0_78(
|
||||
generate_main: Callable[[str | Path], str],
|
||||
component_config_path: Callable[[str], Path],
|
||||
config_file: str,
|
||||
) -> None:
|
||||
generate_main(component_config_path(config_file))
|
||||
assert CORE.platformio_options.get("custom_versions.beken-bdk") == "3.0.78"
|
||||
|
||||
|
||||
def test_config_platformio_option_wins(
|
||||
generate_main: Callable[[str | Path], str],
|
||||
component_config_path: Callable[[str], Path],
|
||||
) -> None:
|
||||
generate_main(component_config_path("bdk_override.yaml"))
|
||||
assert CORE.platformio_options.get("custom_versions.beken-bdk") == "3.0.33"
|
||||
@@ -0,0 +1,25 @@
|
||||
"""The SCons 4.11 script is only loaded for LibreTiny releases before 1.14.0, which
|
||||
fixed the library queue it patches around (libretiny-eu/libretiny#422)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
from esphome.core import CORE
|
||||
|
||||
|
||||
def test_current_release_skips_the_script(
|
||||
generate_main: Callable[[str | Path], str],
|
||||
component_config_path: Callable[[str], Path],
|
||||
) -> None:
|
||||
generate_main(component_config_path("bk72xx.yaml"))
|
||||
assert "pre:scons_dont_inherit.py" not in CORE.platformio_options["extra_scripts"]
|
||||
|
||||
|
||||
def test_pinned_old_release_loads_the_script(
|
||||
generate_main: Callable[[str | Path], str],
|
||||
component_config_path: Callable[[str], Path],
|
||||
) -> None:
|
||||
generate_main(component_config_path("bk72xx_lt113.yaml"))
|
||||
assert "pre:scons_dont_inherit.py" in CORE.platformio_options["extra_scripts"]
|
||||
@@ -1,5 +1,4 @@
|
||||
# A wifi power_save_mode other than NONE is forced off with a warning while
|
||||
# bk72xx_ble is configured (esphome#18592); this config must still validate.
|
||||
# A wifi power_save_mode other than NONE validates and applies alongside bk72xx_ble
|
||||
packages:
|
||||
bk72xx_ble: !include common.yaml
|
||||
|
||||
|
||||
Reference in new issue
Block a user