Giter Club home page Giter Club logo

libretiny's Introduction

LibreTiny

(formerly LibreTuya)

GitHub Workflow Status GitHub last commit

Code style: clang-format Code style: black

Discord PlatformIO Registry

RTL8710BN BK7231

PlatformIO development platform for BK7231 and RTL8710 IoT chips.

The main goal of this project is to provide a usable build environment for IoT developers. While also providing vendor SDKs as PlatformIO cores, the project focuses on developing working Arduino-compatible cores for supported families. The cores are inspired by Espressif's official core for ESP32, which should make it easier to port/run existing ESP apps on less-common, unsupported IoT modules.

There's an ESPHome port based on LibreTiny, which supports BK7231 and RTL8710B chips.

Note: this project is work-in-progress.

License

See LICENSE. Project is licensed under MIT License.

Parts of the code may come from third parties, vendor SDKs or other open-source projects. Most of these files are marked with appropriate copyright/author/license notices.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

libretiny's People

Contributors

alufers avatar blakadder avatar cap9qd avatar catalin2402 avatar cossid avatar dbuezas avatar descipher avatar gerardpollorebozado avatar hn avatar humbledeer avatar ianchi avatar ivankravets avatar kolos avatar kuba2k2 avatar mattshepcar avatar mihsu81 avatar protectivedad avatar reedstrm avatar sonic-amiga avatar szupi-ipuzs avatar xmister avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libretiny's Issues

Link error for generic-rtl8710bn-2mb-468k in libretuya-esphome

Hi @kuba2k2,

Trying to compile libretuya-esphome for generic-rtl8710bn-2mb-468k i get a linking error like the ones below:

Linking .pioenvs\plug-ezviz-test\firmware.elf
.pioenvs\plug-ezviz-test\src\esphome\components\libretuya\core.cpp.o: In function `esphome::arch_init()':
C:\Users\Bethayn-Dell\OneDrive - TUI\Documents\GitHub\esphome\libretuya-esphome\.esphome\build\plug-ezviz-test/src/esphome/components/libretuya/core.cpp:22: undefined reference to `LibreTuya::wdtEnable(unsigned long)'
.pioenvs\plug-ezviz-test\src\esphome\components\libretuya\core.cpp.o: In function `esphome::arch_feed_wdt()':
C:\Users\Bethayn-Dell\OneDrive - TUI\Documents\GitHub\esphome\libretuya-esphome\.esphome\build\plug-ezviz-test/src/esphome/components/libretuya/core.cpp:33: undefined reference to `LibreTuya::wdtFeed()'
collect2.exe: error: ld returned 1 exit status

Full compilation log:

python -m esphome compile plug-ezviz-test.yml
←[32mINFO Reading configuration plug-ezviz-test.yml...←[0m
←[32mINFO Generating C++ source...←[0m
←[32mINFO Compiling app...←[0m
************************************************************************************************************************
Obsolete PIO Core v6.0.2 is used (previous was 6.1.4)
Please remove multiple PIO Cores from a system:
https://docs.platformio.org/en/latest/core/installation/troubleshooting.html
************************************************************************************************************************
Processing plug-ezviz-test (board: generic-rtl8710bn-2mb-468k; framework: arduino; platform: libretuya)
------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/libretuya/generic-rtl8710bn-2mb-468k.html
PLATFORM: LibreTuya (0.10.0+sha.b404f9f) > Generic - RTL8710BN (2M/468k)
HARDWARE: RTL8710BN 125MHz, 256KB RAM, 468KB Flash
DEBUG: Current (openocd) External (custom, openocd)
PACKAGES:
 - framework-arduino-api @ 3.0.0-a4cbfc+sha.3a4cbfc
 - framework-realtek-amb1 @ 750.0.0-b0bc+sha.750b0bc
 - library-flashdb@03500fa @ 3500.0.0-fa+sha.03500fa
 - [email protected] @ 2.0.0-amb1+sha.c39c3f5
 - [email protected] @ 6.0.0+sha.8b831c1
 - tool-ltchiptool @ 1.5.2+sha.f7a0850
 - toolchain-gccarmnoneeabi @ 1.50201.0 (5.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ off, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pioenvs\plug-ezviz-test\src\esphome\components\libretuya\core.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\components\libretuya\gpio_arduino.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\components\libretuya\lt_component.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\components\libretuya\preferences.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\components\mdns\mdns_component.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\components\mdns\mdns_esp32_arduino.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\components\mdns\mdns_esp8266.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\components\mdns\mdns_esp_idf.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\components\network\util.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\components\wifi\wifi_component.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\components\wifi\wifi_component_esp32_arduino.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\components\wifi\wifi_component_esp8266.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\components\wifi\wifi_component_esp_idf.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\components\wifi\wifi_component_libretuya.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\core\application.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\core\color.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\core\component.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\core\component_iterator.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\core\controller.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\core\entity_base.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\core\helpers.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\core\log.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\core\scheduler.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\esphome\core\util.cpp.o
Compiling .pioenvs\plug-ezviz-test\src\main.cpp.o
Compiling .pioenvs\plug-ezviz-test\arduino_api\api\Common.cpp.o
Compiling .pioenvs\plug-ezviz-test\arduino_api\api\IPAddress.cpp.o
Compiling .pioenvs\plug-ezviz-test\arduino_api\api\PluggableUSB.cpp.o
Compiling .pioenvs\plug-ezviz-test\arduino_api\api\Print.cpp.o
Compiling .pioenvs\plug-ezviz-test\arduino_api\api\Stream.cpp.o
Compiling .pioenvs\plug-ezviz-test\arduino_api\api\String.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\api\Events.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\api\FS.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\api\SoftwareSerial.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\api\WiFi\WiFi.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\api\WiFi\WiFiAP.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\api\WiFi\WiFiEvents.cpp.o
Archiving .pioenvs\plug-ezviz-test\libarduino_api.a
Compiling .pioenvs\plug-ezviz-test\libretuya_api\api\WiFi\WiFiGeneric.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\api\WiFi\WiFiSTA.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\api\WiFi\WiFiScan.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\common\WMath.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\common\abi.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\common\dtostrf.c.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\common\hooks.c.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\common\itoa.c.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\common\serial_event.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\common\wiring_shift.c.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\core\LibreTuyaAPI.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\core\LibreTuyaClass.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\core\LibreTuyaCompat.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\core\LibreTuyaCustom.c.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\core\lt_logger.c.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\core\main.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\Flash\Flash.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\HTTPClient\HTTPClient.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\HTTPClient\strptime\strptime.c.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\MD5\MD5MbedTLSImpl.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\MD5\MD5PolarSSLImpl.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\NetUtils\IPv6Address.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\NetUtils\lwip\LwIPClient.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\NetUtils\lwip\LwIPRxBuffer.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\NetUtils\lwip\LwIPServer.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\NetUtils\lwip\LwIPUdp.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\NetUtils\ssl\MbedTLSClient.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\StreamString\StreamString.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\Update\Update.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\Update\UpdateUtil.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\WebServer\Parsing.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\WebServer\WebServer.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\WebServer\detail\mimetable.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\WiFiMulti\WiFiMulti.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\base64\base64.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\base64\libb64\cdecode.c.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\base64\libb64\cencode.c.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\cbuf\cbuf.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\mDNS\LwIPmDNS.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\libraries\mDNS\mDNS.cpp.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\port\printf\putchar.c.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\port\printf\puts.c.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\posix\strcasecmp.c.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\posix\strdup.c.o
Compiling .pioenvs\plug-ezviz-test\libretuya_api\posix\time.c.o
Compiling .pioenvs\plug-ezviz-test\uf2ota\uf2ota\uf2binpatch.c.o
Compiling .pioenvs\plug-ezviz-test\uf2ota\uf2ota\uf2ota.c.o
Compiling .pioenvs\plug-ezviz-test\uf2ota\uf2ota\uf2priv.c.o
Compiling .pioenvs\plug-ezviz-test\board_generic-rtl8710bn-2mb-468k\variant.cpp.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_core\cores\arduino\LibreTuyaAPI.cpp.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_core\cores\arduino\SerialClass.cpp.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_core\cores\arduino\Tone.cpp.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_core\cores\arduino\WInterrupts.c.o
Archiving .pioenvs\plug-ezviz-test\libretuya_api.a
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_core\cores\arduino\main.cpp.o
Archiving .pioenvs\plug-ezviz-test\libuf2ota.a
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_core\cores\arduino\sdk_mem.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_core\cores\arduino\sdk_os.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_core\cores\arduino\wiring.c.o
Archiving .pioenvs\plug-ezviz-test\libboard_generic-rtl8710bn-2mb-468k.a
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_core\cores\arduino\wiring_analog.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_core\cores\arduino\wiring_digital.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_core\cores\arduino\wiring_pulse.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_libs\libraries\PowerManagement\PowerManagement.cpp.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_libs\libraries\SoftwareSerial\SoftwareSerial.cpp.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_libs\libraries\WiFi\WiFi.cpp.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_libs\libraries\WiFi\WiFiAP.cpp.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_libs\libraries\WiFi\WiFiEvents.cpp.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_libs\libraries\WiFi\WiFiGeneric.cpp.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_libs\libraries\WiFi\WiFiSTA.cpp.o
Archiving .pioenvs\plug-ezviz-test\libambz_arduino_core.a
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_libs\libraries\WiFi\WiFiScan.cpp.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_libs\libraries\Wire\Wire.cpp.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_port\port\flashdb\fal_flash_ambz_port.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_arduino_port\port\printf\printf.c.o
Compiling .pioenvs\plug-ezviz-test\flashdb03500fa\port\fal\src\fal.c.o
Compiling .pioenvs\plug-ezviz-test\flashdb03500fa\port\fal\src\fal_flash.c.o
Compiling .pioenvs\plug-ezviz-test\flashdb03500fa\port\fal\src\fal_partition.c.o
Compiling .pioenvs\plug-ezviz-test\flashdb03500fa\port\fal\src\fal_rtt.c.o
Compiling .pioenvs\plug-ezviz-test\flashdb03500fa\src\fdb.c.o
Compiling .pioenvs\plug-ezviz-test\flashdb03500fa\src\fdb_file.c.o
Compiling .pioenvs\plug-ezviz-test\flashdb03500fa\src\fdb_kvdb.c.o
Compiling .pioenvs\plug-ezviz-test\flashdb03500fa\src\fdb_tsdb.c.o
Archiving .pioenvs\plug-ezviz-test\libambz_arduino_port.a
Compiling .pioenvs\plug-ezviz-test\flashdb03500fa\src\fdb_utils.c.o
Compiling .pioenvs\plug-ezviz-test\printf6.0.0\src\printf\printf.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\api\lwip_netconf.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\api\wifi\rtw_wpa_supplicant\wpa_supplicant\wifi_eap_config.c.o
Archiving .pioenvs\plug-ezviz-test\libambz_arduino_libs.a
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\api\wifi\rtw_wpa_supplicant\wpa_supplicant\wifi_p2p_config.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\api\wifi\rtw_wpa_supplicant\wpa_supplicant\wifi_wps_config.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\api\wifi\wifi_conf.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\api\wifi\wifi_promisc.c.o
Archiving .pioenvs\plug-ezviz-test\libflashdb03500fa.a
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\api\wifi\wifi_simple_config.c.o
Archiving .pioenvs\plug-ezviz-test\libprintf6.0.0.a
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\api\wifi\wifi_util.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\drivers\wlan\realtek\src\osdep\lwip_intf.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\analogin_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\dma_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\efuse_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\flash_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\gpio_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\gpio_irq_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\i2c_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\i2s_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\nfc_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\pinmap.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\pinmap_common.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\port_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\pwmout_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\rtc_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\serial_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\sleep.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\spi_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\sys_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\timer_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\us_ticker.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\us_ticker_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\wait_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\mbed\targets\hal\rtl8711b\wdt_api.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\network\dhcp\dhcps.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\network\sntp\sntp.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\network\ssl\ssl_ram_map\ssl_ram_map.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\utilities\cJSON.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\common\utilities\xml.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\os\freertos\cmsis_os.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\os\freertos\freertos_service.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\os\freertos\freertos_v8.1.2\Source\croutine.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\os\freertos\freertos_v8.1.2\Source\event_groups.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\os\freertos\freertos_v8.1.2\Source\list.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\os\freertos\freertos_v8.1.2\Source\portable\GCC\ARM_CM4F\port.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\os\freertos\freertos_v8.1.2\Source\portable\MemMang\heap_5.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\os\freertos\freertos_v8.1.2\Source\queue.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\os\freertos\freertos_v8.1.2\Source\tasks.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\os\freertos\freertos_v8.1.2\Source\timers.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\os\os_dep\device_lock.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\os\os_dep\osdep_service.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\soc\realtek\8711b\app\monitor\ram\rtl_trace.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\soc\realtek\8711b\cmsis\device\system_8195a.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\soc\realtek\8711b\fwlib\ram_lib\rtl8710b_dsleepcfg.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\soc\realtek\8711b\fwlib\ram_lib\rtl8710b_dstandbycfg.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\soc\realtek\8711b\fwlib\ram_lib\rtl8710b_intfcfg.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\soc\realtek\8711b\fwlib\ram_lib\rtl8710b_pinmapcfg.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\soc\realtek\8711b\fwlib\ram_lib\rtl8710b_sleepcfg.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\soc\realtek\8711b\fwlib\ram_lib\startup.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_sdk\component\soc\realtek\8711b\misc\rtl8710b_ota.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\port\realtek\freertos\ethernetif.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\port\realtek\freertos\sys_arch.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\api\api_lib.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\api\api_msg.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\api\err.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\api\netbuf.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\api\netdb.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\api\netifapi.c.o
Archiving .pioenvs\plug-ezviz-test\libambz_sdk.a
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\api\sockets.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\api\tcpip.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\apps\mdns\mdns.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\def.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\dns.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\inet_chksum.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\init.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\ip.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\ipv4\autoip.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\ipv4\dhcp.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\ipv4\etharp.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\ipv4\icmp.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\ipv4\igmp.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\ipv4\ip4.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\ipv4\ip4_addr.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\ipv4\ip4_frag.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\mem.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\memp.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\netif.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\pbuf.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\raw.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\stats.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\sys.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\tcp.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\tcp_in.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\tcp_out.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\timeouts.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\core\udp.c.o
Compiling .pioenvs\plug-ezviz-test\lwip2.0.0_amb1\src\netif\ethernet.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\aes.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\aesni.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\arc4.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\asn1parse.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\asn1write.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\base64.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\bignum.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\blowfish.c.o
Archiving .pioenvs\plug-ezviz-test\liblwip2.0.0_amb1
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\camellia.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\ccm.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\certs.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\cipher.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\cipher_wrap.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\cmac.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\ctr_drbg.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\debug.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\des.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\dhm.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\ecdh.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\ecdsa.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\ecjpake.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\ecp.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\ecp_curves.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\entropy.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\entropy_poll.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\error.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\gcm.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\havege.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\hmac_drbg.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\md.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\md2.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\md4.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\md5.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\md_wrap.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\memory_buffer_alloc.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\oid.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\padlock.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\pem.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\pk.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\pk_wrap.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\pkcs11.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\pkcs12.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\pkcs5.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\pkparse.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\pkwrite.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\platform.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\ripemd160.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\rsa.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\sha1.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\sha256.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\sha512.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\ssl_cache.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\ssl_ciphersuites.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\ssl_cli.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\ssl_cookie.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\ssl_srv.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\ssl_ticket.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\threading.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\timing.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\version.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\version_features.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\x509.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\x509_create.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\x509_crl.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\x509_crt.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\x509_csr.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\x509write_crt.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\x509write_csr.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_mbedtls\component\common\network\ssl\mbedtls-2.4.0\library\xtea.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_fixups\app_start_patch.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_fixups\cmsis_ipsr.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_fixups\log_uart.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_fixups\net_sockets.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_fixups\ssl_tls.c.o
Compiling .pioenvs\plug-ezviz-test\ambz_fixups\wifi_mode.c.o
arm-none-eabi-objcopy -I binary -O elf32-littlearm -B arm C:\Users\Bethayn-Dell\.platformio\platforms\libretuya\platform\realtek-ambz\bin\boot_all_77F7.bin .pioenvs\plug-ezviz-test\boot_all.o
Archiving .pioenvs\plug-ezviz-test\libboot_all.a
Archiving .pioenvs\plug-ezviz-test\libambz_mbedtls.a
Archiving .pioenvs\plug-ezviz-test\libambz_fixups.a
Linking .pioenvs\plug-ezviz-test\firmware.elf
.pioenvs\plug-ezviz-test\src\esphome\components\libretuya\core.cpp.o: In function `esphome::arch_init()':
C:\Users\Bethayn-Dell\OneDrive - TUI\Documents\GitHub\esphome\libretuya-esphome\.esphome\build\plug-ezviz-test/src/esphome/components/libretuya/core.cpp:22: undefined reference to `LibreTuya::wdtEnable(unsigned long)'
.pioenvs\plug-ezviz-test\src\esphome\components\libretuya\core.cpp.o: In function `esphome::arch_feed_wdt()':
C:\Users\Bethayn-Dell\OneDrive - TUI\Documents\GitHub\esphome\libretuya-esphome\.esphome\build\plug-ezviz-test/src/esphome/components/libretuya/core.cpp:33: undefined reference to `LibreTuya::wdtFeed()'
collect2.exe: error: ld returned 1 exit status
|-- Image 1: firmware.ota1.elf
Generated file not found: .pioenvs\plug-ezviz-test\firmware.ota1.elf
*** [.pioenvs\plug-ezviz-test\firmware.elf] Error 1
============================================= [FAILED] Took 88.24 seconds =============================================

I've reduced the yml file to the bare minimum but it didn't help:

esphome:
  name: plug-ezviz-test

libretuya:
  board: generic-rtl8710bn-2mb-468k
  framework:
    version: latest

wifi:
  ssid: "xxx"
  password: "xxx"

problem with flashing wr3e

I have curtains motor switch with wr3e and trying to flash it.
When I pull tx2 pin on ground when starting, I see diode on the board doesn't light. I think I switch chip to download board. But I can't connect to tx0 rx0 to flash firmware. I'm sure about hardware wiring. Maybe does it have something special to open port? I tried to pull tx2 permanently and pull about 1 sec at start.
In normal mode I see in logs on rx2 tx2 strings but in incorrect codepage.

Do I need to unsolder chip before flashing it?

unable to update the firmware to CB2S

python -m esphome upload workshop-8.yaml

> INFO Reading configuration workshop-8.yaml...
> Found multiple options, please choose one:
>   [1] /dev/ttyUSB0 (CP2102 USB to UART Bridge Controller - CP2102 USB to UART Bridge Controller)
>   [2] Over The Air (192.168.1.10)
> (number): 1
> **************************************************************************************************************************************************************************
> Obsolete PIO Core v6.0.2 is used (previous was 6.1.4)
> Please remove multiple PIO Cores from a system:
> https://docs.platformio.org/en/latest/core/installation/troubleshooting.html
> **************************************************************************************************************************************************************************
> Processing workshop-8 (board: cb2s; framework: arduino; platform: libretuya)
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> HARDWARE: BK7231N 120MHz, 256KB RAM, 1.03MB Flash
>  - framework-arduino-api @ 3.0.0-a4cbfc+sha.3a4cbfc
>  - framework-beken-bdk @ 0.0.0+sha.c3533e8.sha.c3533e8
>  - library-flashdb@03500fa @ 3500.0.0-fa+sha.03500fa
>  - [email protected] @ 2.1.3-bdk+sha.33191e0
>  - [email protected] @ 6.0.0+sha.8b831c1
>  - tool-bk7231tools @ 1.0.0-eea4c3+sha.1eea4c3
>  - tool-ltchiptool @ 1.5.2+sha.f7a0850
>  - tool-openocd @ 2.1100.211028 (11.0)
> LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
> Dependency Graph
> |-- ESPAsyncWebServer-esphome @ 3.0.0
> |   |-- AsyncTCP-esphome @ 2.0.0
> |-- ArduinoJson @ 6.18.5
> Building UF2 OTA image
> |-- firmware.uf2
> RAM:   [====      ]  35.8% (used 93740 bytes from 262144 bytes)
> Flash: [=======   ]  69.4% (used 751488 bytes from 1083136 bytes)
> Configuring upload protocol...
> AVAILABLE: uart
> CURRENT: upload_protocol = uart
> Looking for upload port...
> Using manually specified: /dev/ttyUSB0
> Uploading firmware.uf2
> |-- esphome 2022.10.0-dev @ 2022-09-16 21:18:48 -> cb2s
> |-- Using UART
> |   |-- Trying to link on /dev/ttyUSB0 @ 460800
> Connected! Chip info: 0x7231c
> |   |-- Writing 803182 bytes to 0x011000
> ERROR: RuntimeError: Failed to unprotect
>  - File "/home/remy/.platformio/packages/tool-bk7231tools/bk7231tools/serial/__init__.py", line 75, in program_flash
> *** [upload] Error 1
> ======================================================================= [FAILED] Took 3.45 seconds =======================================================================

yaml file

esphome:
  name: workshop-8

libretuya:
  board: cb2s
  framework:
    version: latest
  sdk_silent: true
  gpio_recover: true
  loglevel: verbose

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: ""

ota:
  password: ""

web_server:
  port: 80

wifi:
  ssid: "myssid"
  password: "password"

  manual_ip:
    static_ip: 192.168.1.10
    gateway: 192.168.1.1
    subnet: 255.255.255.0

  # Enable fallback hotspot in case wifi connection fails
  ap:
    ssid: "Workshop-8 FH"
    password: "fA30OYwIpBMb"

The upload file is firmware.uf2, shouldn't it be the firmware.bin file?

Manually I am able to upload but unable to access the device
uartprogram .esphome/build/workshop-8/.pioenvs/workshop-8/firmware.bin -d /dev/ttyUSB0 -w -s 0x0 -u

WiFi issues

  • fix AP mode (DHCP issues, wrong IP setting/reading) on ESPHome - fixed in 9495e34
  • enable fast connect (BSSID connect)
  • fix STA connecting if multiple APs with same name are available
  • fix rare STA connection problems (esphome) - "association leave" before fully connecting, and looping few times with these kind of errors - partially fixed in 96c7fdc
  • fix AP mode on ESPHome (Realtek) - partially fixed
  • fix random reboots (Beken) - I guess no longer a concern
  • fix OTA uploading through ESPHome CLI (Beken)
  • -> possibly rewrite ESPHome socket implementation

CB2S Not restoring saved state consistently

Noticed that preferences are not saved consistently.

this->rtc_.save(&this->state);
ESP_LOGD(TAG, "'%s': Sending state %s", this->name_.c_str(), ONOFF(this->state));
this->state_callback_.call(this->state);

On power loss the last state does not always persist.

Device: Aubess MINI with the BL0942.

yaml:

esphome:
  name: relay-x1-2

libretuya:
  board: cb2s
  framework:
    version: latest

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: ""

ota:
  password: ""

wifi:
  ssid: 
  password: 

  # Enable fallback hotspot in case wifi connection fails
  ap:
    ssid: 
    password: 

web_server:
  port: 80

output:
  - platform: gpio
    id: led1
    inverted: True
    pin: D2

# relay output, exposed as switches in Home Assistant
switch:
  - platform: gpio
    pin: D7
    name: Relay-x1-2
    id: relay_x1_2
    on_turn_on:
      - output.turn_on: led1
    on_turn_off:
      - output.turn_off: led1
    restore_mode: RESTORE_DEFAULT_OFF

binary_sensor:
  - platform: gpio
    pin:
      number: D3
      mode: INPUT_PULLUP
    id: button1
    on_press:
      then:
        - switch.toggle: relay_x1_2
  - platform: gpio
    pin:
      number: D6
      mode: INPUT_PULLUP
    id: button2
    on_press:
      then:
        - switch.toggle: relay_x1_2

uart:
  id: uart_bus
  tx_pin: D5
  rx_pin: D4
  baud_rate: 4800
  stop_bits: 1

sensor:
  - platform: bl0942
    uart_id: uart_bus
    voltage:
      name: 'Relay-x1-2 Voltage'
    current:
      name: 'Relay-x1-2 Current'
    power:
      name: 'Relay-x1-2 Power'
      filters:
        multiply: -1
    energy:
      name: 'Relay-x1-2 Energy'
    frequency:
      name: "Relay-x1-2 Frequency"
      accuracy_decimals: 2

    update_interval: 30s

esphome ota

this is what I see when updating esphome in console (esphome upload) through wifi. (wr3e board)
there was 0.9 libretuya version. Will update to 0.10

ROM:[V0.1]
FLASHRATE:4
BOOT TYPE:0 XTAL:40000000
IMG1 DATA[1168:10002000]
IMG1 ENTRY[8000541:100021ef]
IMG1 ENTER
CHIPID[000000ff]
read_mode idx:0, flash_speed idx:0
calibration_result:[1:9:9][5:d] 
calibration_result:[2:13:7][1:d] 
calibration_result:[3:3:3][1:3] 
calibration_ok:[2:13:7] 
FLASH CALIB[NEW OK]
OTA2 ADDR[80d0000]
OTAx SELE[ffffffe0]
OTA2 USE
OTA2 SIGN[35393138:31313738]
IMG2 DATA[0x813c430:3996:0x10005000]
IMG2 SIGN[RTKWin(10005008)]
IMG2 ENTRY[0x10005000:0x80f6061]
System_Init1
RTL8195A[HAL]: Hard Fault Error!!!!
RTL8195A[HAL]: R0 = 0x1003ef5c
RTL8195A[HAL]: R1 = 0x40003400
RTL8195A[HAL]: R2 = 0xff
RTL8195A[HAL]: R3 = 0xca205
RTL8195A[HAL]: R12 = 0x0
RTL8195A[HAL]: LR = 0x80f54f5
RTL8195A[HAL]: PC = 0xca204
RTL8195A[HAL]: PSR = 0x1000200
RTL8195A[HAL]: BFAR = 0xe000ed38
RTL8195A[HAL]: CFSR = 0x0
RTL8195A[HAL]: HFSR = 0x80000000
RTL8195A[HAL]: DFSR = 0x2
RTL8195A[HAL]: AFSR = 0x0
RTL8195A[HAL]: PriMask 0x0
RTL8195A[HAL]: BasePri 0x0
RTL8195A[HAL]: SVC priority: 0x00
RTL8195A[HAL]: PendSVC priority: 0x00
RTL8195A[HAL]: Systick priority: 0x00

Unexpected error with generic-rtl8720cf-2mb-992k board

Hi there,

as stated on https://docs.libretuya.ml/boards/generic-rtl8720cf-2mb-992k/, this board should be supported.

Adopting the ESPHome example from https://docs.libretuya.ml/docs/projects/esphome/ and changing board accordingly results in an error:

$ python -m esphome compile example.yml 
INFO Reading configuration example.yml...
INFO Generating C++ source...
INFO Compiling app...
Processing example (board: generic-rtl8720cf-2mb-992k; framework: arduino; platform: libretuya)
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Error: Traceback (most recent call last):
  File "/home/robert/.local/lib/python3.10/site-packages/platformio/__main__.py", line 102, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/robert/.local/lib/python3.10/site-packages/platformio/cli.py", line 71, in invoke
    return super().invoke(ctx)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/robert/.local/lib/python3.10/site-packages/platformio/run/cli.py", line 144, in cli
    process_env(
  File "/home/robert/.local/lib/python3.10/site-packages/platformio/run/cli.py", line 201, in process_env
    result = {"env": name, "duration": time(), "succeeded": ep.process()}
  File "/home/robert/.local/lib/python3.10/site-packages/platformio/run/processor.py", line 83, in process
    install_project_env_dependencies(
  File "/home/robert/.local/lib/python3.10/site-packages/platformio/package/commands/install.py", line 131, in install_project_env_dependencies
    _install_project_env_platform(project_env, options),
  File "/home/robert/.local/lib/python3.10/site-packages/platformio/package/commands/install.py", line 148, in _install_project_env_platform
    PlatformPackageManager().install(
  File "/home/robert/.local/lib/python3.10/site-packages/platformio/package/manager/platform.py", line 60, in install
    p.configure_project_packages(project_env, project_targets)
  File "/home/robert/.local/lib/python3.10/site-packages/platformio/platform/base.py", line 184, in configure_project_packages
    self.configure_default_packages(options, targets or [])
  File "/home/robert/.platformio/platforms/libretuya/platform.py", line 132, in configure_default_packages
    framework = next(fw for fw in frameworks if framework in fw)
StopIteration

============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  https://docs.platformio.org/page/faq/index.html

* Report this problem to the developers
  https://github.com/platformio/platformio-core/issues

============================================================

Other generic boards, like generic-rtl8710bn-2mb-788k, compile with other errors (out of scope of this issue):

src/esphome/components/libretuya/core.cpp: In function 'void esphome::arch_init()':
src/esphome/components/libretuya/core.cpp:22:6: error: 'class LibreTuya' has no member named 'wdtEnable'
   LT.wdtEnable();
      ^
src/esphome/components/libretuya/core.cpp: In function 'void esphome::arch_feed_wdt()':
src/esphome/components/libretuya/core.cpp:33:41: error: 'class LibreTuya' has no member named 'wdtFeed'
 void IRAM_ATTR HOT arch_feed_wdt() { LT.wdtFeed(); }

Do you have any idea?

I can't access web_server?

when it enters ap mode it delivers the ip class 192.168.4.x and I try to access it through the port http://192.168.4.1:80 and I have also used nmap to test the ports but I don't think so.
The question: is this a bug or the web server system hasn't been implemented yet or I don't know how to configure it?

Thank you in advance for your attention and for sharing the project, congratulations on your project.

AmebaZ - update OTA2 address upon flashing

This is very annoying, especially on Realtek boards. Flashing UF2 writes it to OTA2, and if the address is mismatched (e.g. by compiling for a wrong board - with a different OTA2 partition address), the bootloader boots OTA1 again. And then I spend countless hours trying to figure out why the program doesn't work, before realizing that the changes were never actually booted.

Refactor project structure

While developing LT, one can notice at least a few oddities and nuisances about the project structure:

  • arduino/<family>/cores/arduino/... - weird path
  • WiFi impl is in libraries/WiFi (correct), but common headers are in libretuya/api/WiFi (weird), while other libraries are in libretuya/libraries
    • since WiFi is not really LT's API (does LT even have its own API?), naming the folder api is not good
  • OTA utilities are in LibreTuya class. I think they could be moved to a separate OTA library (same applies to Watchdog)
  • LT class is named LibreTuyaClass.cpp in common core, and LibreTuyaAPI.cpp in family cores
  • libraries should be split between:
    1. common - family-independent/"final" (those not requiring any family code, like Flash, Update)
    2. api- family-specific (common interface but separate impl, optionally with common functions, like WiFi, SoftwareSerial)
    3. ext - LT-independent (those literally copied from ESP32 core or other places, having code not related to LT at all - probably compatible with every Arduino core. Like WiFiMulti, StreamString, HTTPClient, base64...)
  • NetUtils is a bit of a mess - it's mostly WiFi clients/servers, so why not in one of the WiFi folders?
  • Arduino core extensions (classes which are not yet in ArduinoCore-API, like IPv6Address) should have their own directory

Generally, the current structure is forgetting a bit about non-ArduinoCore usage of LT. All code is in arduino/, and it's completely ignored when using bare-SDK builders, leaving the developer with nothing at all. The project could be refactored to separate the port/ directory (C library ports, non-Arduino code, like FlashDB + FAL and printf), as well as the partial POSIX API, the LT logger and LT API, from the Arduino cores. Builders would then need to be adapted, to include that common code in bare-SDK builds. I think LT should be considered a C-only SDK (as in, adding only C-style functions) when used without Arduino. When using Arduino, the developer gets access to classes like OTA.

This refactor should be done together with the one described in TODO (Environment stability). Bumping the major version number is considerable.

  • platform/ - could this be merged with that refactored cores directory in any way?

Use ESPHome port on HASS ESPhome docker container?

I have ESPhome running as a docker container on HassOS via the Hass native addon.
Is there any way to use the libretuya/esphome fork with this installation? I have over 120 ESP devices in my ESPHome dashboard and don't really want to have to move everything to a separate ESPHome installation elsewhere.

Thanks.

Can't compile in osX

It shows:

warning: /Library/Developer/CommandLineTools/usr/bin/ranlib: archive library: .pioenvs/tuya-power-switch/libbk7231n_fixups.a the table of contents is empty (no object file members in the library define global symbols)

workaround

  1. go to ~/.platformio/platforms/libretuya/builder/main.py,
  2. uncomment #RANLIB=prefix + "gcc-ranlib"

Now it works in osX

Publish libretuya-esphome as a standalone Home Assistant add-on

This should make things a lot easier for people who want to get started, so they can simply install it in their HassOS instead of having to tinker with PlatformIO, ESPHome cloning/installing/building and so on.

It should not be complicated, I think you only need to start building and publishing docker images from libretuya-esphome project and then fork https://github.com/esphome/home-assistant-addon renaming the add-on to something like ESPHome Libretuya and pointing to your own docker image.

What do you think?

[esphome] Serial component broken on bk7231n (even if using hardware uart pins)

In bk7231n, any usage of the uart component makes compilation fail due to missing SoftwareSerial.h file.

Workaround:

diff --git a/esphome/components/uart/uart_component_libretuya.cpp b/esphome/components/uart/uart_component_libretuya.cpp
index 21fc3e182a534339fd8efe432172f31f0bcbf790..4f4e3993648c20328deced4e85aed1a7f1482619 100644
--- a/esphome/components/uart/uart_component_libretuya.cpp
+++ b/esphome/components/uart/uart_component_libretuya.cpp
@@ -10,7 +10,7 @@
 #include "esphome/components/logger/logger.h"
 #endif
 
-#include <SoftwareSerial.h>
+//#include <SoftwareSerial.h>
 
 namespace esphome {
 namespace uart {
@@ -73,7 +73,7 @@ void LibreTuyaUARTComponent::setup() {
   }
 #endif
   else {
-    this->serial_ = new SoftwareSerial(rx_pin, tx_pin, rx_inverted || tx_inverted);
+    // this->serial_ = new SoftwareSerial(rx_pin, tx_pin, rx_inverted || tx_inverted);
   }
 
   this->serial_->begin(this->baud_rate_, get_config());
@@ -83,9 +83,7 @@ void LibreTuyaUARTComponent::dump_config() {
   bool is_hardware = this->hardware_idx_ == -1;
   ESP_LOGCONFIG(TAG, "UART Bus:");
   ESP_LOGCONFIG(TAG, "  Type: %s", UART_TYPE[is_hardware]);
-  if (is_hardware) {
-    ESP_LOGCONFIG(TAG, "  Port number: %d", this->hardware_idx_);
-  }
+  ESP_LOGCONFIG(TAG, "  Port number: %d", this->hardware_idx_);
   LOG_PIN("  TX Pin: ", tx_pin_);
   LOG_PIN("  RX Pin: ", rx_pin_);
   if (this->rx_pin_ != nullptr) {

generic-rtl8710bx-4mb-980k - cannot boot or enter flash mode after OTA update

Hi @kuba2k2,

I had removed a binary_sensor from the yaml configuration file but it kept reappearing in the firmware.
So, I decided to erase with ImageTool all 4MB of the SPI flash. I flashed the last firmware.uf2 but it wouldn't boot.
I flashed a 2MB backup of the EZVIZ firmware and after that the firmware.uf2 and all went ok, the device booted up fine,
A couple of minutes later I tried performing an OTA update of a slightly modified yaml config (different pin for the relay) and realised that the device wasn't responding.
This is all I'm getting now over serial, and the device won't enter flashing mode:

<RTL8195A>
ROM:[V0.1]


FLASHRATE:4


<RTL81ù
<RTL8195A>
ROM:[V0.1]


FLASHRATE:4

Did the SPI flash get wiped somehow together with the bootloader?
Is there a way to flash again the SPI flash from the full dumps I have of the original firmware?

The log after the last successful UART flash is below.

[22:03:44]<RTL8195A>ROM:[V0.1]
[22:03:44]FLASHRATE:4
[22:03:44]BOOT TYPE:0 XTAL:40000000
[22:03:44]IMG1 DATA[1128:10002000]
[22:03:44]IMG1 ENTRY[8000521:100021ef]
[22:03:44]IMG1 ENTER
[22:03:44]CHIPID[000000f6]
[22:03:44]read_mode idx:3, flash_speed idx:3
[22:03:44]calibration_result:[1:25:13][1:19]
[22:03:44]calibration_result:[2:25:13][1:19]
[22:03:44]calibration_result:[3:0:0][ff:ff]
[22:03:44]calibration_ok:[1:25:13]
[22:03:44]FLASH CALIB[NEW OK]
[22:03:44]OTA2 ADDR[8100000]
[22:03:44]OTAx SELE[fffffffe]
[22:03:44]OTA2 USE
[22:03:44]OTA2 SIGN[35393138:31313738]
[22:03:44]IMG2 DATA[0x818bbb0:3812:0x10005000]
[22:03:44]IMG2 SIGN[RTKWin(10005008)]
[22:03:44]IMG2 ENTRY[0x10005000:0x81309f1]
[22:03:44]System_Init1
[22:03:44]System_Init2
[22:03:44]I [      0.000] main():54: - LibreTuya v0.10.0+sha.b404f9f.dirty on generic-rtl8710bx-4mb-980k, compiled at Oct  1 2022 21:55:18
[22:03:44]I [      0.000] main():58: - Reset reason: 0
[22:03:44]I [      0.002] open():81: mainTask: Preferences initialized
[22:03:44][I][logger:283]: Log initialized
[22:03:44][C][status_led:014]: Setting up Status LED...
[22:03:44][C][ota:473]: There have been 0 suspected unsuccessful boot attempts.
[22:03:44][D][lt.preferences:104]: Saving 1 preferences to flash...
[22:03:44][V][lt.preferences:115]: sync: key: 233825507, len: 4
[22:03:44][D][lt.preferences:133]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[22:03:44][I][app:029]: Running through setup()...
[22:03:44][V][app:030]: Sorting components by setup priority...
[22:03:44][C][switch.gpio:011]: Setting up GPIO Switch 'PLUG-EZVIZ'...
[22:03:44][D][switch:017]: 'PLUG-EZVIZ' Turning OFF.
[22:03:44][D][switch:037]: 'PLUG-EZVIZ': Sending state OFF→<RTL8195A>ROM:[V0.1]
[22:03:44]FLASHRATE:4
[22:03:44]BOOT TYPE:0 XTAL:40000000
[22:03:44]IMG1 DATA[1128:10002000]
[22:03:44]IMG1 ENTRY[8000521:100021ef]
[22:03:44]IMG1 ENTER
[22:03:44]CHIPID[000000f6]
[22:03:44]read_mode idx:3, flash_speed idx:3
←[31mERROR Serial port closed!←[0m

BL602

Hello,

will you support BL602 chips too in the future ?

Issues using libretuya on BK7231N

Following up on my last post here. Good point about uploading @kuba2k2, I should have mentioned that in my last comment. I can neither flash from pio nor using the manual method.

Both ltchiptool uf2 upload firmware.uf2 uart /dev/ttyACM0 and python -m esphome upload <path to yaml> give the same error:

|-- esphome 2022.10.0-dev @ 2022-10-16 00:33:43 -> generic-bk7231n-qfn32-tuya
|-- Using UART
|   |-- Trying to link on /dev/ttyACM0 @ 460800
|   |-- Writing 919054 bytes to 0x011000
ERROR: RuntimeError: Writing Status Register failed: wrote 0x0000, got 0x0001
 - File "/home/ricclopez/.local/lib/python3.10/site-packages/bk7231tools/serial/cmd_flash.py", line 163, in flash_write_sr

I've only been able to successfully (at least, on paper) flash with command:
python ~/repos/hid_download_py/uartprogram -w firmware.bin -u -s 0x00 -d /dev/ttyACM0
using hid_download_py

Do you think the flashing process is what's preventing it from working? When I use the latter command to restore the stock firmware (which I also backed up with this tool), it does go back to working properly.

PWM output for BK7231N

I have a light bulb with a BK7231N board in it. How can I define PWM outputs in ESPHome for using it for a light component? More precisely which platform should I use for the output?

# ...

light:
  - platform: rgbww
    name: "my_room"
    red: output_component1
    green: output_component2
    blue: output_component3
    cold_white: output_component4
    warm_white: output_component5
    cold_white_color_temperature: 6536 K
    warm_white_color_temperature: 2000 K

output:
  - platform: ???
    id: output_component1
    pin: P6
  #...

RTL8710BN - Stuck at reboot

Everytime I send an OTA update or ask for a reboot from Home Assistant (software "Restart" button), my RTL8710BN based device is stuck.
Here are the logs (level: VERY_VERBOSE):

[I][restart.button:012]: Restarting device...
[I][app:134]: Rebooting safely...
[VV][lt.preferences:064]: fdb_kv_get_blob: key: 233825507, len: 4
[VV][lt.preferences:041]: s_pending_save: key: 233825507, len: 4
[D][lt.preferences:104]: Saving 4 preferences to flash...
[VV][lt.preferences:113]: Checking if FDB data 233825507 has changed
[V][lt.preferences:115]: sync: key: 233825507, len: 4
[VV][lt.preferences:113]: Checking if FDB data 3130601430 has changed
[V][lt.preferences:115]: sync: key: 3130601430, len: 44
[VV][lt.preferences:113]: Checking if FDB data 2162300045 has changed
[V][lt.preferences:115]: sync: key: 2162300045, len: 44
[VV][lt.preferences:113]: Checking if FDB data 3551080420 has changed
[V][lt.preferences:115]: sync: key: 3551080420, len: 1
[D][lt.preferences:133]: Saving 4 preferences to flash: 0 cached, 4 written, 0 failed
[VV][api.service:025]: send_disconnect_request: DisconnectRequest {}
[VV][api.service:025]: send_disconnect_request: DisconnectRequest {}
===== Enter Image 1.5 ====
Img2 Sign: RTKWin, InfaStart @ 0x080f9fbd
System_Init1
System_Init2
I [      0.000] LibreTuya v0.10.0+sha.a79a2d6 on wr3, compiled at Nov 16 2022 14:50:56
[I][logger:283]: Log initialized
[VV][lt.preferences:064]: fdb_kv_get_blob: key: 233825507, len: 4
[C][ota:473]: There have been 0 suspected unsuccessful boot attempts.
[VV][lt.preferences:041]: s_pending_save: key: 233825507, len: 4
[D][lt.preferences:104]: Saving 1 preferences to flash...
[VV][lt.preferences:113]: Checking if FDB data 233825507 has changed
[V][lt.preferences:115]: sync: key: 233825507, len: 4

The device is stuck at this step, so I do a hard reboot (unplug/replug power) and it goes fine:

ROM:[V0.1]
FLASHRATE:4
BOOT TYPE:0 XTAL:40000000
IMG1 DATA[1168:10002000]
IMG1 ENTRY[8000541:100021ef]
IMG1 ENTER
CHIPID[000000ff]
read_mode idx:3, flash_speed idx:0
calibration_result:[1:5:11][9:d]
calibration_result:[2:13:7][1:d]
calibration_result:[3:7:5][1:7]
calibration_ok:[2:13:7]
FLASH CALIB[NEW OK]
OTA2 ADDR[80d0000]
OTAx SELE[ffffffc0]
OTA1 USE
IMG2 DATA[0x80774a0:3672:0x10005000]
IMG2 SIGN[RTKWin(10005008)]
IMG2 ENTRY[0x10005000:0x80314d5]
System_Init1
System_Init2
I [      0.000] LibreTuya v0.10.0+sha.a79a2d6 on wr3, compiled at Nov  8 2022 12:01:09
[I][logger:283]: Log initialized
[VV][lt.preferences:064]: fdb_kv_get_blob: key: 233825507, len: 4
[C][ota:473]: There have been 0 suspected unsuccessful boot attempts.
[VV][lt.preferences:041]: s_pending_save: key: 233825507, len: 4
[D][lt.preferences:104]: Saving 1 preferences to flash...
[VV][lt.preferences:113]: Checking if FDB data 233825507 has changed
[V][lt.preferences:115]: sync: key: 233825507, len: 4
[D][lt.preferences:133]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...

=> Everything goes well after that hard reboot. It happens everytime.

[CB2S] Issue with power readings

hello to everyone, i have a Smart Plug marked Elivco LSPA9, thanks to this website i know that it has a BL0937 power meter connected with pin 34, 7, 6. I already flashed it with libretuya-esphome and i can turn on/off but i can't read the power meter. This is my yml config if someone could help me

esphome:
  name: elivcolspa9cb2s

libretuya:
  board: cb2s
  framework:
    version: dev

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: ""

ota:
  password: ""
  
# Enable web server
web_server:
  port: 80

wifi:
  ssid: ""
  password: ""
  manual_ip:
    static_ip: x.x.x.188
    gateway: x.x.x.1
    subnet: x.x.x.0

  # Enable fallback hotspot in case wifi connection fails
  ap:
    ssid: "Elivcolspa9Cb2SFallbackHotspot"
    password: "IHxBKsc7WQM4"
    
switch:  # the socket relay
  - platform: gpio
    pin: D7
    id: plug_1
    name: 'Plug 1'
    restore_mode: RESTORE_DEFAULT_OFF  # attempt to restore state and default to OFF if not possible to restore

binary_sensor:  # the button
  - platform: gpio
    pin:
      number: D4
      inverted: true
    id: button
    internal: true  # don't expose it to HASS, only use it locally
    on_release:
      then:
        - switch.toggle: plug_1  # toggle the relay

sensor:
  - platform: hlw8012
    model: BL0937  # note that the model must be specified to use special calculation parameters
    voltage_divider: 1600  # adjust it according to the actual resistor values on board
    sel_pin:
      number: D6
      inverted: true  # the logic of BL0937 is opposite from HLW8012
    cf_pin: D1
    cf1_pin: D0
    current:
      name: 'Plug 1 Current'
    voltage:
      name: 'Plug 1 Voltage'
    power:
      name: 'Plug 1 Power'
    energy:
      name: 'Plug 1 Energy'
      # convert it to kWh
      filters:
        - multiply: 0.001
      unit_of_measurement: 'kWh'
      accuracy_decimals: 4
    update_interval: 60s
    change_mode_every: 3

  

[esphome] wizard error

I am getting an error while using the wizard for LibreTuya, while ESP8266 / ESP32 works fine
although manually created config compiles fine

Also please add LibreTuya in this line .. for your custom ESP8266/ESP32 firmware. Yay!

venom@venom-vm:~/Desktop/libretuya-esphome$ python3 -m esphome wizard yourdevice.yml
Hi there!
I'm the wizard of ESPHome :)
And I'm here to help you get started with ESPHome.
In 4 steps I'm going to guide you through creating a basic configuration file for your custom ESP8266/ESP32 firmware. Yay!

============= STEP 1 =============
    _____ ____  _____  ______
   / ____/ __ \|  __ \|  ____|
  | |   | |  | | |__) | |__
  | |   | |  | |  _  /|  __|
  | |___| |__| | | \ \| |____
   \_____\____/|_|  \_\______|

===================================
First up, please choose a name for your node.
It should be a unique name that can be used to identify the device later.
For example, I like calling the node in my living room livingroom.
(name): livingroom
Great! Your node is now called "livingroom".

============= STEP 2 =============
      ______  _____ _____
     |  ____|/ ____|  __ \\
     | |__  | (___ | |__) |
     |  __|  \___ \|  ___/
     | |____ ____) | |
     |______|_____/|_|

===================================

Now I'd like to know what microcontroller you're using so that I can compile firmwares for it.
Are you using an ESP32, ESP8266 or LibreTuya platform? (Choose ESP8266 for Sonoff devices)

Please enter either ESP32, ESP8266 or LibreTuya.

(ESP32/ESP8266/LibreTuya): LibreTuya

Thanks! You've chosen LIBRETUYA as your platform.
Next, I need to know what board you're using.
Please go to https://docs.libretuya.ml/docs/status/supported/ and choose a board.

For example "cb2s".
Options:
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/venom/Desktop/libretuya-esphome/esphome/__main__.py", line 975, in <module>
    sys.exit(main())
  File "/home/venom/Desktop/libretuya-esphome/esphome/__main__.py", line 966, in main
    return run_esphome(sys.argv)
  File "/home/venom/Desktop/libretuya-esphome/esphome/__main__.py", line 931, in run_esphome
    return PRE_CONFIG_ACTIONS[args.command](args)
  File "/home/venom/Desktop/libretuya-esphome/esphome/__main__.py", line 341, in command_wizard
    return wizard.wizard(args.configuration)
  File "/home/venom/Desktop/libretuya-esphome/esphome/wizard.py", line 365, in wizard
    for group in boards.values():
AttributeError: 'list' object has no attribute 'values'

pinscan usage

On my motor switch I have two relays and three touch buttons. I found pins of relays, but I can't find pins of buttons.
I think in theory itis possible to find them, but I don't see anything in pinscan, when I push buttons

[FR] Project Examples for PlatformIO Registry

Hi,

Currently, the platform page in the PlatformIO Registry doesn't contain any quick start projects for developers. Such examples serve both to highlight widespread use cases and to help newcomers to get up and running much more quickly.

Please consider adding a few comprehensive project examples to the PlatformIO Registry.

Useful links:

pinscan

when I choose Read one pin continuously in digital pins and enter for example 3 or D3 of other number, I always see:
Pin D0 state:

ps: I can't get working pinscan over uart. I see board logs only there. I connect through telnet.
After Realtime readout of all pins in digital pins I have to reboot board because it doesn't respond on q key and I don't see any answer there (I'm not sure if I should see anything here not touching any buttons on switch)

Support for RTL8710CM?

Is there support for RTL8710CM yet?
I have a couple of devices (Tapo L920 LED controllers) using this chip and would love to be able to flash them with libretuya/esphome.

LibreTuya ESPHome fails to compile when using `time`

If I put this on my LibreTuya ESPHome device.yaml:

time:
  - platform: sntp
    id: my_time

The compilation fails with:

chrome_ARbduOVVzI

Full logs are:

INFO Reading configuration /config/libretuya-esphome/portao-tuya.yaml...
INFO Detected timezone 'America/Sao_Paulo'
INFO Generating C++ source...
INFO Compiling app...
Processing portao-tuya (board: wr2e; framework: arduino; platform: https://github.com/kuba2k2/libretuya.git)
--------------------------------------------------------------------------------
HARDWARE: RTL8710BN 125MHz, 256KB RAM, 788KB Flash
 - framework-arduino-api @ 3.0.0-a4cbfc+sha.3a4cbfc 
 - framework-realtek-amb1 @ 750.0.0-b0bc+sha.750b0bc 
 - library-flashdb@03500fa @ 3500.0.0-fa+sha.03500fa 
 - [email protected] @ 2.1.3-amb1+sha.5d6edaa 
 - [email protected] @ 6.0.0+sha.8b831c1 
 - tool-ltchiptool @ 2.0.2+sha.7559033 
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- ESPAsyncWebServer-esphome @ 3.0.0
|   |-- AsyncTCP-esphome @ 2.0.0
|-- DNSServer @ 1.1.0
|-- ArduinoJson @ 6.18.5
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/api/api_connection.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/api/api_frame_helper.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/api/api_pb2.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/api/api_pb2_service.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/api/api_server.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/api/list_entities.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/api/proto.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/api/subscribe_state.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/api/user_services.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/binary_sensor/automation.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/binary_sensor/binary_sensor.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/button/button.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/captive_portal/captive_portal.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/factory_reset/button/factory_reset_button.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/json/json_util.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/libretuya/core.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/libretuya/gpio_arduino.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/libretuya/lt_component.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/libretuya/preferences.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/logger/logger.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/md5/md5.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/mdns/mdns_component.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/mdns/mdns_esp32_arduino.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/mdns/mdns_esp8266.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/mdns/mdns_esp_idf.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/mdns/mdns_rp2040.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/network/util.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/ota/ota_backend_arduino_esp32.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/ota/ota_backend_arduino_esp8266.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/ota/ota_backend_arduino_rp2040.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/ota/ota_backend_esp_idf.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/ota/ota_component.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/restart/button/restart_button.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/sensor/automation.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/sensor/filter.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/sensor/sensor.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/socket/bsd_sockets_impl.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/socket/lwip_raw_tcp_impl.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/socket/lwip_sockets_impl.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/socket/socket.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/status/status_binary_sensor.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/text_sensor/filter.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/text_sensor/text_sensor.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/time/real_time_clock.cpp.o
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/uptime/uptime_sensor.cpp.o
src/esphome/components/time/real_time_clock.cpp: In member function 'void esphome::time::RealTimeClock::apply_timezone_()':
src/esphome/components/time/real_time_clock.cpp:51:42: error: 'setenv' was not declared in this scope
   setenv("TZ", this->timezone_.c_str(), 1);
                                          ^
src/esphome/components/time/real_time_clock.cpp:52:9: error: 'tzset' was not declared in this scope
   tzset();
         ^
Compiling /data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/web_server/list_entities.cpp.o
*** [/data/portao-tuya/.pioenvs/portao-tuya/src/esphome/components/time/real_time_clock.cpp.o] Error 1
========================= [FAILED] Took 80.30 seconds =========================

error installing platformio platform

platformio platform uninstall https://github.com/kuba2k2/libretuya

WARNING: This command is deprecated and will be removed in the next releases. 
Please use `pio pkg uninstall` instead.

Error: Could not find the package with 'https://github.com/kuba2k2/libretuya' requirements for your system 'linux_x86_64'
carmelo@carmelo-desktop:~/Desktop/tuya-cloudcutter$ platformio platform install -f https://github.com/kuba2k2/libretuya

WARNING: This command is deprecated and will be removed in the next releases. 
Please use `pio pkg install` instead.

Platform Manager: Installing git+https://github.com/kuba2k2/libretuya
git version 2.34.1
Cloning into '/home/carmelo/.platformio/.cache/tmp/pkg-installing-i8188zqg'...
remote: Enumerating objects: 650, done.
remote: Counting objects: 100% (650/650), done.
remote: Compressing objects: 100% (446/446), done.
remote: Total 650 (delta 188), reused 529 (delta 173), pack-reused 0
Receiving objects: 100% (650/650), 438.17 KiB | 207.00 KiB/s, done.
Resolving deltas: 100% (188/188), done.
Platform Manager: [email protected]+sha.b85f6f8 has been installed!
Installing/updating ltchiptool
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: ltchiptool in /home/carmelo/.local/lib/python3.10/site-packages (1.7.0)
Collecting ltchiptool
  Downloading ltchiptool-2.0.2-py3-none-any.whl (118 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.9/118.9 KB 213.1 kB/s eta 0:00:00
Requirement already satisfied: prettytable<4.0.0,>=3.3.0 in /home/carmelo/.local/lib/python3.10/site-packages (from ltchiptool) (3.5.0)
Requirement already satisfied: click<9.0.0,>=8.1.3 in /home/carmelo/.local/lib/python3.10/site-packages (from ltchiptool) (8.1.3)
Requirement already satisfied: importlib-metadata<5.0.0,>=4.12.0 in /home/carmelo/.local/lib/python3.10/site-packages (from ltchiptool) (4.13.0)
Requirement already satisfied: pycryptodomex<4.0.0,>=3.15.0 in /home/carmelo/.local/lib/python3.10/site-packages (from ltchiptool) (3.16.0)
Requirement already satisfied: colorama<0.5.0,>=0.4.5 in /home/carmelo/.local/lib/python3.10/site-packages (from ltchiptool) (0.4.6)
Collecting bk7231tools<2.0.0,>=1.2.1
  Downloading bk7231tools-1.2.3-py3-none-any.whl (27 kB)
Collecting xmodem<0.5.0,>=0.4.6
  Downloading xmodem-0.4.6.tar.gz (32 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: pyserial<4.0,>=3.5 in /home/carmelo/.local/lib/python3.10/site-packages (from bk7231tools<2.0.0,>=1.2.1->ltchiptool) (3.5)
Requirement already satisfied: zipp>=0.5 in /usr/lib/python3/dist-packages (from importlib-metadata<5.0.0,>=4.12.0->ltchiptool) (1.0.0)
Requirement already satisfied: wcwidth in /home/carmelo/.local/lib/python3.10/site-packages (from prettytable<4.0.0,>=3.3.0->ltchiptool) (0.2.5)
Building wheels for collected packages: xmodem
  Building wheel for xmodem (setup.py) ... done
  Created wheel for xmodem: filename=xmodem-0.4.6-py3-none-any.whl size=34564 sha256=18ed5de0122c8065d5317eb90efbe230352103e469b2e0bbdaf84843659b14e9
  Stored in directory: /home/carmelo/.cache/pip/wheels/19/00/c7/cff2d8b8981235aa42bcd09109a401169f9726df47518ada6b
Successfully built xmodem
Installing collected packages: xmodem, bk7231tools, ltchiptool
  Attempting uninstall: bk7231tools
    Found existing installation: bk7231tools 1.1.5
    Uninstalling bk7231tools-1.1.5:
      Successfully uninstalled bk7231tools-1.1.5
  Attempting uninstall: ltchiptool
    Found existing installation: ltchiptool 1.7.0
    Uninstalling ltchiptool-1.7.0:
      Successfully uninstalled ltchiptool-1.7.0
Successfully installed bk7231tools-1.2.3 ltchiptool-2.0.2 xmodem-0.4.6
Error: Traceback (most recent call last):
  File "/home/carmelo/.local/lib/python3.10/site-packages/platformio/__main__.py", line 102, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "/home/carmelo/.local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/carmelo/.local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/carmelo/.local/lib/python3.10/site-packages/platformio/cli.py", line 71, in invoke
    return super().invoke(ctx)
  File "/home/carmelo/.local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/carmelo/.local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/carmelo/.local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/carmelo/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/carmelo/.local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/carmelo/.local/lib/python3.10/site-packages/platformio/commands/platform.py", line 177, in platform_install
    ctx.invoke(
  File "/home/carmelo/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/carmelo/.local/lib/python3.10/site-packages/platformio/package/commands/install.py", line 65, in package_install_cmd
    install_global_dependencies(options)
  File "/home/carmelo/.local/lib/python3.10/site-packages/platformio/package/commands/install.py", line 77, in install_global_dependencies
    pm.install(
  File "/home/carmelo/.local/lib/python3.10/site-packages/platformio/package/manager/platform.py", line 52, in install
    p = PlatformFactory.new(pkg)
  File "/home/carmelo/.local/lib/python3.10/site-packages/platformio/platform/factory.py", line 78, in new
    cls.load_platform_module(
  File "/home/carmelo/.local/lib/python3.10/site-packages/platformio/platform/factory.py", line 37, in load_platform_module
    return load_python_module("platformio.platform.%s" % name, path)
  File "/home/carmelo/.local/lib/python3.10/site-packages/platformio/compat.py", line 79, in load_python_module
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/carmelo/.platformio/platforms/libretuya/platform.py", line 48, in <module>
    ltchiptool.util.lt_set_path(dirname(__file__))
AttributeError: module 'ltchiptool.util' has no attribute 'lt_set_path'

ubuntu 22 not virtualized! worked before latest update

esphome + tuya causes unresponsive device

Just flashed a BK7321T (WB3S) module with libretuya and it seems to be working, until I add the tuya: module to my esphome yaml, after which the API becomes unresponsive. I can still upload new firmware with esphome, so it's not like it's completely bricked. I guess it's probably boot looping? Can't connect to view logs and can't connect to it in home assistant

Is the TuyaMCU module not supported yet? Serial seems to be working so I figured this would too, but I guess not?

error: 'lwip_inet_ntop' was not declared in this scope

When trying to compile esphome, if "api:" is declared in yaml config file, the following compilation error occures :

src/esphome/components/socket/lwip_sockets_impl.cpp: In function 'std::__cxx11::string esphome::socket::format_sockaddr(const sockaddr_storage&)':

src/esphome/components/socket/lwip_sockets_impl.cpp:16:80: error: 'lwip_inet_ntop' was not declared in this scope

     const char *ret = lwip_inet_ntop(AF_INET, &addr->sin_addr, buf, sizeof(buf));
                                                                                ^
src/esphome/components/socket/lwip_sockets_impl.cpp: In member function 'virtual ssize_t esphome::socket::LwIPSocketImpl::readv(const iovec*, int)':

src/esphome/components/socket/lwip_sockets_impl.cpp:82:99: error: 'lwip_readv' was not declared in this scope

   ssize_t readv(const struct iovec *iov, int iovcnt) override { return lwip_readv(fd_, iov, iovcnt); }
                                                                                                   ^
*** [.pioenvs\yourdevice\src\esphome\components\socket\lwip_sockets_impl.cpp.o] Error 1

After adding
socket: implementation: lwip_tcp

it compiles fine

ESPHome LibreTuya - adding a HLW8012 sensor causes Hard Fault Error

Compiling ESPHome LibreTuya with a HLW8012 sensor causes a Hard Fault Error.

The output of platformio device monitor with rtl_hard_fault_decoder:

platformio device monitor
C:\Users\Bethayn-Dell\.platformio\packages\toolchain-gccarmnoneeabi\bin\arm-none-eabi-addr2line.exe

Please build project in debug configuration to get more details about an exception.
See https://docs.platformio.org/page/projectconf/build_configurations.html


--- Terminal on COM4 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, rtl_hard_fault_decoder, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
ROM:[V0.1]
FLASHRATE:4
BOOT TYPE:0 XTAL:40000000
IMG1 DATA[1128:10002000]
IMG1 ENTRY[8000521:100021ef]
IMG1 ENTER
CHIPID[000000f6]
read_mode idx:3, flash_speed idx:3
calibration_result:[1:25:13][1:19]
calibration_result:[2:25:13][1:19]
calibration_result:[3:0:0][ff:ff]
calibration_ok:[1:25:13]
FLASH CALIB[NEW OK]
OTA2 ADDR[8100000]
OTAx SELE[0]
OTA1 USE
IMG2 DATA[0x80a0870:3868:0x10005000]
IMG2 SIGN[RTKWin(10005008)]
IMG2 ENTRY[0x10005000:0x8042df9]
System_Init1
System_Init2
I [      0.000] main():54: - LibreTuya v0.10.0+sha.8a4392b.dirty on generic-rtl8710bx-4mb-980k, compiled at Nov 18 2022 09:37:58
I [      0.000] main():58: - Reset reason: 0
I [      0.015] open():81: mainTask: Preferences initialized
[I][logger:283]: Log initialized
[C][status_led:014]: Setting up Status LED...
[C][ota:473]: There have been 3 suspected unsuccessful boot attempts.
[D][lt.preferences:104]: Saving 1 preferences to flash...
[V][lt.preferences:115]: sync: key: 233825507, len: 4
[D][lt.preferences:133]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[V][app:030]: Sorting components by setup priority...
[D][binary_sensor:034]: 'Plug EZVIZ Power Button': Sending initial state OFF
[C][switch.gpio:011]: Setting up GPIO Switch 'Plug EZVIZ'...
[D][switch:013]: 'Plug EZVIZ' Turning ON.
[D][switch:037]: 'Plug EZVIZ': Sending state ON
[D][switch:013]: 'Plug EZVIZ' Turning ON.
RTL8195A[HAL]: Hard Fault Error!!!!
RTL8195A[HAL]: R0 = 0x100061c0
RTL8195A[HAL]: R1 = 0x50
RTL8195A[HAL]: R2 = 0xbb8
RTL8195A[HAL]: R3 = 0x55f0
RTL8195A[HAL]: R12 = 0x0
RTL8195A[HAL]: LR = 0x8029ffd
  0x8029ffd in __gnu_cxx::new_allocator<char>::deallocate(char*, unsigned int) at c:/users/bethayn-dell/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/5.2.1/ext/new_allocator.h:110
      (inlined by) std::allocator_traits<std::allocator<char> >::deallocate(std::allocator<char>&, char*, unsigned int) at c:/users/bethayn-dell/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/5.2.1/bits/alloc_traits.h:386
      (inlined by) std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_destroy(unsigned int) at c:/users/bethayn-dell/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/5.2.1/bits/basic_string.h:185
      (inlined by) std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose() at c:/users/bethayn-dell/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/5.2.1/bits/basic_string.h:180
      (inlined by) std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() at c:/users/bethayn-dell/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/5.2.1/bits/basic_string.h:544
      (inlined by) esphome::wifi_info::IPAddressWiFiInfo::unique_id[abi:cxx11]() at src/esphome/components/wifi_info/wifi_info_text_sensor.h:20
      (inlined by) esphome::wifi_info::IPAddressWiFiInfo::dump_config() at src/esphome/components/wifi_info/wifi_info_text_sensor.cpp:9
RTL8195A[HAL]: PC = 0x8038a98
  0x8038a98 in LwIPUDP::write(unsigned char) at C:/Users/Bethayn-Dell/.platformio/platforms/libretuya/arduino/libretuya/libraries/NetUtils/lwip/LwIPUdp.cpp:192
RTL8195A[HAL]: PSR = 0x21000000
RTL8195A[HAL]: BFAR = 0xe000ed38
RTL8195A[HAL]: CFSR = 0x10000
RTL8195A[HAL]: HFSR = 0x40000000
RTL8195A[HAL]: DFSR = 0x0
RTL8195A[HAL]: AFSR = 0x0
RTL8195A[HAL]: PriMask 0x0
RTL8195A[HAL]: BasePri 0x0
RTL8195A[HAL]: SVC priority: 0x00
RTL8195A[HAL]: PendSVC priority: 0xf0
RTL8195A[HAL]: Systick priority: 0xf0

The output of platformio device monitor with rtl_hard_fault_decoder after removing the wifi_info sensor:

platformio device monitor
C:\Users\Bethayn-Dell\.platformio\packages\toolchain-gccarmnoneeabi\bin\arm-none-eabi-addr2line.exe

Please build project in debug configuration to get more details about an exception.
See https://docs.platformio.org/page/projectconf/build_configurations.html


--- Terminal on COM4 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, rtl_hard_fault_decoder, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
ROM:[V0.1]
FLASHRATE:4
BOOT TYPE:0 XTAL:40000000
IMG1 DATA[1128:10002000]
IMG1 ENTRY[8000521:100021ef]
IMG1 ENTER
CHIPID[000000f6]
read_mode idx:3, flash_speed idx:3
calibration_result:[1:25:13][1:19]
calibration_result:[2:25:13][1:19]
calibration_result:[3:0:0][ff:ff]
calibration_ok:[1:25:13]
FLASH CALIB[NEW OK]
OTA2 ADDR[8100000]
OTAx SELE[0]
OTA1 USE
IMG2 DATA[0x80a0870:3868:0x10005000]
IMG2 SIGN[RTKWin(10005008)]
IMG2 ENTRY[0x10005000:0x8042df9]
System_Init1
System_Init2
I [      0.000] main():54: - LibreTuya v0.10.0+sha.8a4392b.dirty on generic-rtl8710bx-4mb-980k, compiled at Nov 18 2022 09:37:58
I [      0.000] main():58: - Reset reason: 0
I [      0.015] open():81: mainTask: Preferences initialized
[I][logger:283]: Log initialized
[C][status_led:014]: Setting up Status LED...
[C][ota:473]: There have been 7 suspected unsuccessful boot attempts.
[D][lt.preferences:104]: Saving 1 preferences to flash...
[V][lt.preferences:115]: sync: key: 233825507, len: 4
[D][lt.preferences:133]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[V][app:030]: Sorting components by setup priority...
[D][binary_sensor:034]: 'Plug EZVIZ Power Button': Sending initial state OFF
[C][switch.gpio:011]: Setting up GPIO Switch 'Plug EZVIZ'...
[D][switch:013]: 'Plug EZVIZ' Turning ON.
[D][switch:037]: 'Plug EZVIZ': Sending state ON
[D][switch:013]: 'Plug EZVIZ' Turning ON.
RTL8195A[HAL]: Hard Fault Error!!!!
RTL8195A[HAL]: R0 = 0x100061c0
RTL8195A[HAL]: R1 = 0x50
RTL8195A[HAL]: R2 = 0xbb8
RTL8195A[HAL]: R3 = 0x55f0
RTL8195A[HAL]: R12 = 0x0
RTL8195A[HAL]: LR = 0x8029ffd
  0x8029ffd in std::_Vector_base<esphome::switch_::Switch*, std::allocator<esphome::switch_::Switch*> >::_Vector_impl::_Vector_impl() at c:/users/bethayn-dell/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/5.2.1/bits/stl_vector.h:87
      (inlined by) std::_Vector_base<esphome::switch_::Switch*, std::allocator<esphome::switch_::Switch*> >::_Vector_base() at c:/users/bethayn-dell/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/5.2.1/bits/stl_vector.h:125
      (inlined by) std::vector<esphome::switch_::Switch*, std::allocator<esphome::switch_::Switch*> >::vector() at c:/users/bethayn-dell/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/5.2.1/bits/stl_vector.h:257
      (inlined by) esphome::Application::Application() at src/esphome/core/application.h:54
      (inlined by) __static_initialization_and_destruction_0 at src/esphome/core/application.cpp:155
      (inlined by) _GLOBAL__sub_I__ZN7esphome11Application19register_component_EPNS_9ComponentE at src/esphome/core/application.cpp:157
RTL8195A[HAL]: PC = 0x8038a98
  0x8038a98 in WiFiClass::softAP(char const*, char const*, int, bool, int) at C:/Users/Bethayn-Dell/.platformio/platforms/libretuya/arduino/realtek-ambz/libraries/WiFi/WiFiAP.cpp:80
RTL8195A[HAL]: PSR = 0x21000000
RTL8195A[HAL]: BFAR = 0xe000ed38
RTL8195A[HAL]: CFSR = 0x10000
RTL8195A[HAL]: HFSR = 0x40000000
RTL8195A[HAL]: DFSR = 0x0
RTL8195A[HAL]: AFSR = 0x0
RTL8195A[HAL]: PriMask 0x0
RTL8195A[HAL]: BasePri 0x0
RTL8195A[HAL]: SVC priority: 0x00
RTL8195A[HAL]: PendSVC priority: 0xf0
RTL8195A[HAL]: Systick priority: 0xf0

The output of platformio device monitor with rtl_hard_fault_decoder after also removing the wifi_signal sensor:

platformio device monitor
C:\Users\Bethayn-Dell\.platformio\packages\toolchain-gccarmnoneeabi\bin\arm-none-eabi-addr2line.exe

Please build project in debug configuration to get more details about an exception.
See https://docs.platformio.org/page/projectconf/build_configurations.html


--- Terminal on COM4 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, rtl_hard_fault_decoder, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
ROM:[V0.1]
FLASHRATE:4
BOOT TYPE:0 XTAL:40000000
IMG1 DATA[1128:10002000]
IMG1 ENTRY[8000521:100021ef]
IMG1 ENTER
CHIPID[000000f6]
read_mode idx:3, flash_speed idx:3
calibration_result:[1:25:13][1:19]
calibration_result:[2:25:13][1:19]
calibration_result:[3:0:0][ff:ff]
calibration_ok:[1:25:13]
FLASH CALIB[NEW OK]
OTA2 ADDR[8100000]
OTAx SELE[0]
OTA1 USE
IMG2 DATA[0x80a0870:3868:0x10005000]
IMG2 SIGN[RTKWin(10005008)]
IMG2 ENTRY[0x10005000:0x8042df9]
System_Init1
System_Init2
I [      0.000] main():54: - LibreTuya v0.10.0+sha.8a4392b.dirty on generic-rtl8710bx-4mb-980k, compiled at Nov 18 2022 09:37:58
I [      0.000] main():58: - Reset reason: 0
I [      0.018] open():81: mainTask: Preferences initialized
[I][logger:283]: Log initialized
[C][status_led:014]: Setting up Status LED...
[C][ota:473]: There have been 6 suspected unsuccessful boot attempts.
[D][lt.preferences:104]: Saving 1 preferences to flash...
[V][lt.preferences:115]: sync: key: 233825507, len: 4
[D][lt.preferences:133]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[V][app:030]: Sorting components by setup priority...
[D][binary_sensor:034]: 'Plug EZVIZ Power Button': Sending initial state OFF
[C][switch.gpio:011]: Setting up GPIO Switch 'Plug EZVIZ'...
[D][switch:013]: 'Plug EZVIZ' Turning ON.
[D][switch:037]: 'Plug EZVIZ': Sending state ON
[D][switch:013]: 'Plug EZVIZ' Turning ON.
RTL8195A[HAL]: Hard Fault Error!!!!
RTL8195A[HAL]: R0 = 0x100061c0
RTL8195A[HAL]: R1 = 0x50
RTL8195A[HAL]: R2 = 0xbb8
RTL8195A[HAL]: R3 = 0x5208
RTL8195A[HAL]: R12 = 0x0
RTL8195A[HAL]: LR = 0x8029ffd
  0x8029ffd in esphome::Component::defer(std::function<void ()>&&) at src/esphome/core/component.cpp:119
RTL8195A[HAL]: PC = 0x8038a98
  0x8038a98 in wifi_indication at C:/Users/Bethayn-Dell/.platformio/platforms/libretuya/arduino/realtek-ambz/libraries/WiFi/WiFiEvents.cpp:89
RTL8195A[HAL]: PSR = 0x21000000
RTL8195A[HAL]: BFAR = 0xe000ed38
RTL8195A[HAL]: CFSR = 0x10000
RTL8195A[HAL]: HFSR = 0x40000000
RTL8195A[HAL]: DFSR = 0x0
RTL8195A[HAL]: AFSR = 0x0
RTL8195A[HAL]: PriMask 0x0
RTL8195A[HAL]: BasePri 0x0
RTL8195A[HAL]: SVC priority: 0x00
RTL8195A[HAL]: PendSVC priority: 0xf0
RTL8195A[HAL]: Systick priority: 0xf0

Below is my config file:

substitutions:
  devicename: plug_ezviz
  friendly_name: Plug EZVIZ
  device_description: EZVIZ TT1 Smart Plug CS-T31-16B-EU 
  current_res: "0.00221"
  voltage_div: "955"

esphome:
  name: plug-ezviz
  platformio_options:
    monitor_speed: 115200
    monitor_filters: rtl_hard_fault_decoder

socket:
  implementation: lwip_tcp

libretuya:
  board: generic-rtl8710bx-4mb-980k
  framework:
    version: latest
  loglevel: verbose
  lt_config:
    LT_LOGGER: 1
    LT_LOGLEVEL: LT_LEVEL_VERBOSE
    LT_LOGGER_TIMESTAMP: 1
    LT_LOGGER_CALLER: 1
    LT_LOGGER_TASK: 1
    LT_LOGGER_COLOR: 1
    LT_LOG_HEAP: 1
  sdk_silent: true
  gpio_recover: true

# Enable logging
logger:
  level: VERBOSE

# Enable Home Assistant API
api:
  reboot_timeout: 1h
  encryption:
    key: xxx

ota:
  password: xxx

web_server:
  port: 80
  auth:
    username: xxx
    password: xxx
  include_internal: true

wifi:
  ssid: "SunnyDay"
  password: "xxx"

  # Enable fallback hotspot in case wifi connection fails
  ap:
    ssid: "${friendly_name} Fallback"
    password: "xxx"

captive_portal:

text_sensor:
  - platform: wifi_info
    ip_address:
      name: ${friendly_name} IP Address
    ssid:
      name: ${friendly_name} Connected SSID
    bssid:
      name: ${friendly_name} Connected BSSID
    mac_address:
      name: ${friendly_name} MAC Wifi Address

button:
  - platform: restart
    name: ${friendly_name} Restart

sensor:
  - platform: wifi_signal
    name: ${friendly_name} Wifi Signal
    update_interval: 60s
    id: ${devicename}_wifi_signal
  - platform: hlw8012
    sel_pin:
      number: D8
      inverted: true
    cf_pin: D11
    cf1_pin: D12
    change_mode_every: 8
    update_interval: 10s
    current:
      name: ${friendly_name} Amperage
      icon: mdi:current-ac
      unit_of_measurement: A
    voltage:
      name: ${friendly_name} Voltage
      icon: mdi:flash-circle
      unit_of_measurement: V
    power:
      id: wattage
      name: ${friendly_name} Wattage
      icon: mdi:flash-outline
      unit_of_measurement: W
    energy:
      name: ${friendly_name} Energy
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}

binary_sensor:
  - platform: gpio
    device_class: power
    pin:
      number: D9
      mode: INPUT_PULLUP
      inverted: true
    name: ${friendly_name} Power Button
    id: ${devicename}_button1
    on_press:
      - switch.toggle: ${devicename}_relay
      - light.toggle: ${devicename}_power_led

switch:
  - platform: restart
    name: "${friendly_name} Restart"
    id: ${devicename}_restart
    internal: true
  - platform: gpio
    name: ${friendly_name}
    pin: D0
    id: ${devicename}_relay
    restore_mode: RESTORE_DEFAULT_OFF
    on_turn_on:
      - light.turn_on: ${devicename}_power_led
    on_turn_off:
      - light.turn_off: ${devicename}_power_led

status_led:
  pin:
    number: D1
    inverted: false

light:
  - id: ${devicename}_power_led
    platform: binary
    name: ${friendly_name} Power LED
    output: ${devicename}_led2
    internal: true

output:
  - id: ${devicename}_led2
    platform: gpio
    pin: D14
    inverted: false

Problem with esphome-libretuya

I didn't find where I could write about esphome, so decide to do it here.
When trying to compile firmware for wr3e, I got error
Compiling .pioenvs/cur/libretuya_api/libraries/Update/uf2ota/uf2binpatch.c.o In file included from /home/bonuzzz/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/sys/time.h:42:0, from /home/bonuzzz/.platformio/platforms/libretuya/arduino/libretuya/libraries/NetUtils/lwip/LwIPClient.cpp:24: /home/bonuzzz/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/sys/_timeval.h:52:8: error: redefinition of 'struct timeval' struct timeval { ^ In file included from /home/bonuzzz/.platformio/platforms/libretuya/arduino/libretuya/libraries/NetUtils/lwip/LwIPClient.cpp:23:0: /home/bonuzzz/.platformio/packages/[email protected]/src/include/lwip/sockets.h:442:8: error: previous definition of 'struct timeval' struct timeval { ^ Compiling .pioenvs/cur/libretuya_api/libraries/Update/uf2ota/uf2ota.c.o In file included from /home/bonuzzz/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/sys/time.h:42:0, from /home/bonuzzz/.platformio/platforms/libretuya/arduino/libretuya/libraries/NetUtils/lwip/LwIPServer.cpp:16: /home/bonuzzz/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/sys/_timeval.h:52:8: error: redefinition of 'struct timeval' struct timeval { ^ In file included from /home/bonuzzz/.platformio/platforms/libretuya/arduino/libretuya/libraries/NetUtils/lwip/LwIPServer.cpp:15:0: /home/bonuzzz/.platformio/packages/[email protected]/src/include/lwip/sockets.h:442:8: error: previous definition of 'struct timeval' struct timeval { ^ Compiling .pioenvs/cur/libretuya_api/libraries/Update/uf2ota/uf2priv.c.o *** [.pioenvs/cur/libretuya_api/libraries/NetUtils/lwip/LwIPServer.cpp.o] Error 1 *** [.pioenvs/cur/libretuya_api/libraries/NetUtils/lwip/LwIPClient.cpp.o] Error 1

I use ubuntu 22.04

unable to compile

python -m esphome compile workshop-8.yaml
give this error

> ERROR Unexpected exception while reading configuration:
> Traceback (most recent call last):
>   File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
>     return _run_code(code, main_globals, None,
>   File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
>     exec(code, run_globals)
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/__main__.py", line 950, in <module>
>     sys.exit(main())
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/__main__.py", line 941, in main
>     return run_esphome(sys.argv)
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/__main__.py", line 919, in run_esphome
>     config = read_config(dict(args.substitution) if args.substitution else {})
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/config.py", line 975, in read_config
>     res = load_config(command_line_substitutions)
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/config.py", line 830, in load_config
>     return _load_config(command_line_substitutions)
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/config.py", line 818, in _load_config
>     result = validate_config(config, command_line_substitutions)
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/config.py", line 745, in validate_config
>     result.run_validation_steps()
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/config.py", line 124, in run_validation_steps
>     task.step.run(self)
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/config.py", line 500, in run
>     validated = schema(self.conf)
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/voluptuous_schema.py", line 34, in __call__
>     res = super().__call__(data)
>   File "/home/remy/.local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
>     return self._compiled([], data)
>   File "/home/remy/.local/lib/python3.10/site-packages/voluptuous/validators.py", line 229, in _run
>     return self._exec(self._compiled, value, path)
>   File "/home/remy/.local/lib/python3.10/site-packages/voluptuous/validators.py", line 353, in _exec
>     v = func(path, v)
>   File "/home/remy/.local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
>     return schema(data)
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/voluptuous_schema.py", line 34, in __call__
>     res = super().__call__(data)
>   File "/home/remy/.local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
>     return self._compiled([], data)
>   File "/home/remy/.local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict
>     return base_validate(path, iteritems(data), out)
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/voluptuous_schema.py", line 118, in validate_mapping
>     not isinstance(key.default, vol.Undefined)
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/config_validation.py", line 1457, in default
>     if CORE.is_esp8266:
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/core/__init__.py", line 593, in is_esp8266
>     return self.target_platform == "esp8266"
>   File "/home/remy/workspace/github.com/esphome_beken/libretuya-esphome/esphome/core/__init__.py", line 589, in target_platform
>     return self.data[KEY_CORE][KEY_TARGET_PLATFORM]
> KeyError: 'target_platform'```

Generic RTL8710BX doesn't start after a reboot

Hi @kuba2k2,

The Generic RTL8710BX (mentioned in my previous support requests) doesn't start after sending a restart command or after an OTA firmware upgrade. https://docs.libretuya.ml/boards/generic-rtl8710bx-4mb-980k/

If I unplug it and plug it again it starts up.

[09:53:04][D][button:013]: 'PLUG-EZVIZ Restart' Pressed.
[09:53:04][I][restart.button:012]: Restarting device...
[09:53:04][I][app:134]: Rebooting safely...
[09:53:04][D][lt.preferences:104]: Saving 1 preferences to flash...
[09:53:04][V][lt.preferences:115]: sync: key: 233825507, len: 4
[09:53:04][D][lt.preferences:133]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
←[32mINFO Disconnected from ESPHome API for plug-ezviz.local←[0m
←[33mWARNING Disconnected from API←[0m
←[33mWARNING Can't connect to ESPHome API for plug-ezviz.local: Error connecting to ('192.168.45.123', 6053): [WinError 121] The semaphore timeout period has expired←[0m
←[32mINFO Trying to reconnect to plug-ezviz.local in the background←[0m
←[32mINFO Successfully connected to plug-ezviz.local←[0m
[09:55:04][V][json:033]: Attempting to allocate 512 bytes for JSON serialization
[09:55:04][V][json:053]: Size after shrink 60 bytes
[09:55:04][V][json:033]: Attempting to allocate 512 bytes for JSON serialization
[09:55:04][V][json:053]: Size after shrink 80 bytes
[09:55:04][V][json:033]: Attempting to allocate 512 bytes for JSON serialization
[09:55:04][V][json:053]: Size after shrink 152 bytes
[09:55:04][V][json:033]: Attempting to allocate 512 bytes for JSON serialization
[09:55:04][V][json:053]: Size after shrink 156 bytes
[09:55:04][V][json:033]: Attempting to allocate 512 bytes for JSON serialization
[09:55:04][V][json:053]: Size after shrink 148 bytes
[09:55:04][V][json:033]: Attempting to allocate 512 bytes for JSON serialization
[09:55:04][V][json:053]: Size after shrink 168 bytes
[09:55:17][V][wifi_lt:276]: Event: Connected ssid='SunnyDay' bssid=FC:EF:03:10:01:01 channel=4, authmode=WPA PSK
[09:58:37][I][ota:109]: Boot seems successful, resetting boot loop counter.
[09:58:37][D][lt.preferences:104]: Saving 1 preferences to flash...
[09:58:37][V][lt.preferences:115]: sync: key: 233825507, len: 4
[09:58:37][D][lt.preferences:133]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed

I found some RTL8710CF devices

I have a bunch of RTL8710CF devices:
image
image

It's probably a variant of the existing RTL chips, but this 8710CF is not called out anywhere explicitly...
Can I try these out somehow?

ESPHome-LibreTuya PWM

Can and how can I use PWM control for the cb2s and others chip?
For esp8266 it is:

  • platform: esp8266_pwm

How to do it in LibreTuya's ESPHome port?

delay notworking

Esphome - Delay

esphome scripts config:

id: script_id
then:
  - delay: 500ms
  ...

Error while compiling

../my-config/devices/../components/sensors/countdown_relay.yaml: In function 'void setup()':
../my-config/devices/../components/sensors/countdown_relay.yaml:584:16: error: 'class esphome::DelayAction<>' has no member named 'set_delay'
In file included from src/esphome.h:103:0,
from src/main.cpp:3:
src/esphome/core/base_automation.h: In instantiation of 'void esphome::DelayAction::play_complex(Ts ...) [with Ts = {}]':
../my-config/devices/../components/sensors/reactive_power.yaml:21:1: required from here
src/esphome/core/base_automation.h:119:5: error: 'class esphome::DelayAction<>' has no member named 'delay_'
this->set_timeout(this->delay_.value(x...), f);
^
*** [.pioenvs/workshop-4/src/main.cpp.o] Error 1

Unable to flash RTL8710BX - Invalid OTA2 address on chip - found 1048576, expected 851968

I'm trying to flash ESPHome LibreTuya on a RTL8710BX (Ezviz T31 https://www.ezviz.com/product/T31/2021), but I'm getting the following error: Invalid OTA2 address on chip - found 1048576, expected 851968.

PS C:\Users\Bethayn-Dell\OneDrive - TUI\Documents\GitHub\esphome\libretuya-esphome> python -m ltchiptool uf2 upload "C:\Users\Bethayn-Dell\OneDrive - TUI\Documents\GitHub\esphome\libretuya-esphome\.esphome\build\plug-ezviz-test1\.pioenvs\plug-ezviz-test1\firmware.uf2" uart COM7
|-- esphome 2022.10.0-dev @ 2022-09-22 15:43:40 -> wr3l
|-- Using UART
|   |-- Connecting to COM7...
ERROR: ValueError: Invalid OTA2 address on chip - found 1048576, expected 851968
 - File "C:\Program Files\Python39\lib\site-packages\ltchiptool\soc\ambz\upload.py", line 36, in upload

If I try to upload it using esphome, I get Permission denied because of blank spaces in the path.

PS C:\Users\Bethayn-Dell\OneDrive - TUI\Documents\GitHub\esphome\libretuya-esphome> python -m esphome upload plug-ezviz-test1.yml
←[32mINFO Reading configuration plug-ezviz-test1.yml...←[0m
Found multiple options, please choose one:
  [1] COM7 (USB-SERIAL CH340 (COM7))
  [2] Over The Air (plug-ezviz-test1.local)
(number): 1
************************************************************************************************************************
Obsolete PIO Core v6.0.2 is used (previous was 6.1.4)
Please remove multiple PIO Cores from a system:
https://docs.platformio.org/en/latest/core/installation/troubleshooting.html
************************************************************************************************************************
Processing plug-ezviz-test1 (board: wr3le; framework: arduino; platform: libretuya)
------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/libretuya/wr3le.html
PLATFORM: LibreTuya (0.10.0+sha.b404f9f) > WR3LE Wi-Fi Module
HARDWARE: RTL8710BX 62MHz, 256KB RAM, 788KB Flash
DEBUG: Current (openocd) External (custom, openocd)
PACKAGES:
 - framework-arduino-api @ 3.0.0-a4cbfc+sha.3a4cbfc
 - framework-realtek-amb1 @ 750.0.0-b0bc+sha.750b0bc
 - library-flashdb@03500fa @ 3500.0.0-fa+sha.03500fa
 - [email protected] @ 2.0.0-amb1+sha.c39c3f5
 - [email protected] @ 6.0.0+sha.8b831c1
 - tool-bk7231tools @ 1.0.0-eea4c3+sha.1eea4c3
 - tool-ltchiptool @ 1.5.2+sha.f7a0850
 - tool-openocd @ 2.1100.211028 (11.0)
 - toolchain-gccarmnoneeabi @ 1.50201.0 (5.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ off, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Building UF2 OTA image
|-- firmware.uf2
Checking size .pioenvs\plug-ezviz-test1\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  20.1% (used 52780 bytes from 262144 bytes)
Flash: [=====     ]  48.7% (used 393164 bytes from 806912 bytes)
Configuring upload protocol...
AVAILABLE: uart
CURRENT: upload_protocol = uart
Looking for upload port...
Using manually specified: COM7
Uploading firmware.uf2
Usage: python -m ltchiptool uf2 upload [OPTIONS] FILE COMMAND [ARGS]...
Try 'python -m ltchiptool uf2 upload -h' for help.

Error: Invalid value for 'FILE': 'C:\Users\Bethayn-Dell\OneDrive': Permission denied
*** [upload] Error 2
============================================== [FAILED] Took 7.57 seconds ==============================================

Since it's not a Tuya device, I've attached a full firmware dump, in case it's needed.
dump_ezviz_new.zip

Also some logs from UART

interface 0 is initialized

interface 1 is initialized



Initializing WIFI ...
<RTL8195A>
ROM:[V0.1]


FLASHRATE:4


BOOT TYPE:0 XTAL:40000000


IMG1 DATA[1128:10002000]


IMG1 ENTRY[8000521:100021ef]


IMG1 ENTER


CHIPID[000000f6]


read_mode idx:3, flash_speed idx:3


calibration_result:[1:25:13][1:19] 


calibration_result:[2:25:13][1:19] 


calibration_result:[3:0:0][ff:ff] 


calibration_ok:[1:25:13] 


FLASH CALIB[NEW OK]


OTA2 ADDR[8100000]


OTAx SELE[fffffffe]


OTA2 USE


OTA2 SIGN[35393138:31313738]


IMG2 DATA[0x817283c:11448:0x10005000]


IMG2 SIGN[RTKWin(10005008)]


IMG2 ENTRY[0x10005000:0x816bfb5]


===== Enter Image 2 ====


System_Init1


OSC8M: 8390004 


boot reason: 0 


System_Init2


#

On RTL8710BX OTA updates start failing after 40-50 successful ones with message: ERROR Error receiving acknowledge Update end: timed out

After a number of 40-50 successful OTA updates, they start failing with error: ERROR Error receiving acknowledge Update end: timed out and continue failing until I flash the device over UART.

INFO Reading configuration /config/libretuya-esphome/plug-ezviz.yaml...
INFO Detected timezone 'Europe/Bucharest'
INFO Generating C++ source...
INFO Compiling app...
Processing plug-ezviz (board: generic-rtl8710bx-4mb-980k; framework: arduino; platform: https://github.com/kuba2k2/libretuya.git)
--------------------------------------------------------------------------------
HARDWARE: RTL8710BX 62MHz, 256KB RAM, 980KB Flash
 - framework-arduino-api @ 3.0.0-a4cbfc+sha.3a4cbfc 
 - framework-realtek-amb1 @ 750.0.0-b0bc+sha.750b0bc 
 - library-flashdb@03500fa @ 3500.0.0-fa+sha.03500fa 
 - [email protected] @ 2.1.3-amb1+sha.5d6edaa 
 - [email protected] @ 6.0.0+sha.8b831c1 
 - tool-ltchiptool @ 2.0.2+sha.7559033 
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- ESPAsyncWebServer-esphome @ 3.0.0
|   |-- AsyncTCP-esphome @ 2.0.0
|-- DNSServer @ 1.1.0
|-- noise-c @ 0.1.4
|   |-- libsodium @ 1.10018.1
|-- ArduinoJson @ 6.18.5
Compiling /data/plug-ezviz/.pioenvs/plug-ezviz/src/main.cpp.o
Linking /data/plug-ezviz/.pioenvs/plug-ezviz/firmware.elf
|-- Image 1: firmware.ota1.elf
|-- Image 2: firmware.ota2.elf
|   |-- image_0x00B000.ota1.bin
|   |   |-- ota1.ram_2.r.bin
|   |   |-- ota1.xip_image2.bin
|   |   |-- ota1.rdp.bin
|   |-- image_0x100000.ota2.bin
|   |   |-- ota2.ram_2.r.bin
|   |   |-- ota2.xip_image2.bin
|   |   |-- ota2.rdp.bin
Building UF2 OTA image
|-- firmware.uf2
RAM:   [==        ]  20.7% (used 54192 bytes from 262144 bytes)
Flash: [======    ]  58.1% (used 583148 bytes from 1003520 bytes)
========================= [SUCCESS] Took 8.77 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of plug-ezviz.local
INFO  -> 192.168.45.123
INFO Uploading /data/plug-ezviz/.pioenvs/plug-ezviz/firmware.uf2 (1167360 bytes)
Uploading: [============================================================] 100% Done...

INFO Waiting for result...

ERROR Error receiving acknowledge Update end: timed out

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.