From b0c618ed2755e39a190f6ab87b5e1669919f4ee7 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 30 Apr 2026 13:03:25 -0500 Subject: [PATCH] [bk72xx] Emit USE_BK72XX_CRASH_HANDLER via cg.add_define MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous gate lived only in core/defines.h, which is loaded for static analysis / IDE support but not for actual builds. As a result the wrap symbols (__wrap_bk_trap_udef/pabt/dabt) were preprocessed out of crash_handler.cpp at compile time, leaving the linker without a target for the SDK's wrapped trap calls. Set the define from libretiny/__init__.py (where the platform-specific codegen lives — bk72xx/__init__.py is auto-generated and not the right home). --- esphome/components/libretiny/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esphome/components/libretiny/__init__.py b/esphome/components/libretiny/__init__.py index f47f7017cc..bc3992e3c9 100644 --- a/esphome/components/libretiny/__init__.py +++ b/esphome/components/libretiny/__init__.py @@ -486,6 +486,10 @@ async def component_to_code(config): # a .noinit region before the SDK's own register dump + bk_cpu_shutdown # chain runs. The .noinit region is injected into the generated linker # script by patch_bk72xx_noinit.py so it survives the watchdog reset. + # bk72xx/__init__.py is auto-generated, so the define is set here + # rather than there. (defines.h has the matching #ifdef USE_BK72XX + # block for static analysis / IDE only — it doesn't drive the build.) + cg.add_define("USE_BK72XX_CRASH_HANDLER") for sym in ("bk_trap_udef", "bk_trap_pabt", "bk_trap_dabt"): cg.add_build_flag(f"-Wl,--wrap={sym}") cg.add_platformio_option("extra_scripts", ["pre:patch_bk72xx_noinit.py"])