- hal.cpp: include esphome/core/helpers.h for the HOT macro (millis/delay
use it; without the include the TU fails to compile).
- hal_esp8266.h: drop the redundant arch_get_cpu_cycle_count() bare
declaration that came back via the merge from dev (the inline def
above already declares the function).
Followup #16111 dropped the cross-platform arch_get_cpu_cycle_count()
declaration from hal.h dispatcher and added bare decls to libretiny,
rp2040, host, and zephyr per-platform headers — but missed
hal_esp8266.h. ESP8266 callers (spi.h, uart_component_esp8266.cpp) now
fail clang-tidy with 'use of undeclared identifier'.
The body is still out-of-line in components/esp8266/core.cpp on this
PR; the inline def is added on the chained #16112 PR. Add a bare decl
here for now so #16111 builds in isolation.
The wrapper is a one-liner forwarding to Arduino's ::delayMicroseconds.
Add the forward decl to the existing NOLINTBEGIN block (alongside yield,
delay, micros, millis) and inline the body — same pattern as the other
Arduino-flavored wrappers in this header. Drops the out-of-line copy
from components/libretiny/hal.cpp.
- hal.cpp: include components/libretiny/core.h so the lt_* C API
(lt_wdt_enable, lt_reboot, lt_gpio_recover) and the LT_GPIO_RECOVER
macro are properly declared rather than relying on transitive includes.
core.h pulls <Arduino.h> which is libretiny's umbrella header.
- hal_libretiny.h: preserve the HOT attribute on arch_feed_wdt() — the
out-of-line wrapper had it; the inline now uses __attribute__((hot,
always_inline)) to keep the placement hint consistent with the other
platforms. The arch_restart() noreturn concern is already covered by
the dispatcher hal.h declaration ('void __attribute__((noreturn))
arch_restart();' is visible when the body is parsed).
crash_handler.h is itself guarded by #ifdef USE_ESP32_CRASH_HANDLER, so when
hal.cpp included it before defines.h, the namespace block was empty at parse
time and arch_init()'s USE_ESP32_CRASH_HANDLER branch failed with:
error: 'crash_handler_read_and_clear' is not a member of 'esphome::esp32'
Pull defines.h first so USE_ESP32_CRASH_HANDLER is defined before
crash_handler.h is parsed.
clang-tidy flagged the forward decl in hal_esp8266.h because <user_interface.h>
also declares the function (when included via SDK headers). Both decls are
identical `extern "C"` so the redundancy is harmless; suppress the warning
on the hal_esp8266.h side.
Per-platform follow-up to #15977.
Move out-of-line HAL bodies (delayMicroseconds, arch_init, arch_restart)
from components/libretiny/core.cpp into a new components/libretiny/hal.cpp.
core.cpp is now empty (no extra component bootstrap to keep) — left as a
stub for symmetry.
Inline the trivial one-liners directly in hal_libretiny.h with forward
decls for the LibreTiny C API:
arch_feed_wdt() -> lt_wdt_feed()
arch_get_cpu_cycle_count() -> lt_cpu_get_cycle_count()
arch_get_cpu_freq_hz() -> lt_cpu_get_freq()
arch_init stays out-of-line because of the libretiny::setup_preferences()
call (component-private header) plus the BK72xx priority-raise + GPIO
recovery logic.
delayMicroseconds() also stays out-of-line — Arduino's ::delayMicroseconds
signature is unsigned int and forward-declaring it across the C/C++
boundary in a hot header is fragile.
Both bodies are one-liners:
arch_get_cpu_cycle_count() -> esp_get_cycle_count()
arch_get_cpu_freq_hz() -> F_CPU
Move them inline in core/hal/hal_esp8266.h:
- esp_get_cycle_count() comes from <core_esp8266_features.h> (now
pulled into hal_esp8266.h, small ESP8266-only header).
- F_CPU is a -DF_CPU=80000000L compiler flag from the ESP8266 Arduino
board defs, available without any include.
Drop the cross-platform arch_get_cpu_freq_hz() declaration from the
dispatcher hal.h and add bare decls to hal_esp32.h / hal_libretiny.h /
hal_rp2040.h / hal_host.h / hal_zephyr.h so subsequent per-platform
follow-ups only touch their own platform header.
Per-platform follow-up to #15977, chained on top of #16111.
Move out-of-line HAL bodies (millis() fast accumulator, delay() poll,
arch_restart, arch_get_cpu_cycle_count, arch_get_cpu_freq_hz, plus the
__wrap_millis linker trampoline) from components/esp8266/core.cpp into
a new components/esp8266/hal.cpp. core.cpp keeps only the ESP8266
firmware bootstrap (Tasmota OTA magic bytes, optional GPIO pre-init
via resetPins) — single-purpose files.
arch_init() is empty on ESP8266 so it is now inlined directly in
core/hal/hal_esp8266.h alongside the other already-inlined wrappers
(yield, micros, millis_64, delayMicroseconds, arch_feed_wdt,
progmem_read_*).
The dispatcher hal.h drops the cross-platform arch_init() declaration
since at least one platform (ESP8266) inlines it now; bare declarations
are added to the other per-platform headers (hal_esp32.h, hal_libretiny.h,
hal_rp2040.h, hal_host.h, hal_zephyr.h) so future per-platform PRs only
touch their own file.
The previous commit placed the out-of-line ESP32 HAL bodies under
core/hal/hal_esp32.cpp and gated compilation via FILTER_SOURCE_FILES,
mirroring the wake/wake_<platform>.cpp pattern. Switch to the simpler
components/esp32/hal.cpp location instead:
- A component-internal .cpp only compiles when USE_<PLATFORM> is set,
so no FILTER_SOURCE_FILES entry is needed (revert that addition).
- The file can include the component's private crash_handler.h header
directly without a layering inversion or forward decl, so arch_init()
also moves into hal.cpp now (previously stuck in core.cpp because of
that header dependency).
- A future consolidation PR will move the existing core/wake/wake_*.cpp
files into components/<platform>/wake.cpp the same way and drop their
FILTER_SOURCE_FILES entries.
ci-custom's lint_namespace check is satisfied with an empty
namespace esphome::esp32 {} block at the top of the file — the HAL
functions themselves live in namespace esphome (root) since they are
not part of the esp32 component's API.