Commit Graph
14785 Commits
Author SHA1 Message Date
J. Nick Koston 7812a437aa Merge branch 'followup/hal-esp8266' into followup/hal-libretiny 2026-04-29 07:24:37 -05:00
J. Nick Koston cd43002779 Merge branch 'followup/hal-esp32' into followup/hal-esp8266 2026-04-29 07:24:35 -05:00
J. Nick Koston 9dc28556d7 [esp8266] Add bare arch_get_cpu_cycle_count() decl in hal_esp8266.h
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.
2026-04-29 07:24:24 -05:00
J. Nick Koston 9c5d1a7fed [libretiny] Inline delayMicroseconds() in hal_libretiny.h
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.
2026-04-29 07:17:37 -05:00
J. Nick Koston cbd54e47eb [libretiny] Address Copilot review on #16113
- 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).
2026-04-29 07:03:56 -05:00
J. Nick Koston 3ea715b8e4 Merge branch 'followup/hal-esp8266' into followup/hal-libretiny 2026-04-29 06:51:21 -05:00
J. Nick Koston f95e7678ad Merge branch 'followup/hal-esp32' into followup/hal-esp8266 2026-04-29 06:51:19 -05:00
J. Nick Koston 4edac4d89e Merge branch 'inline-micros-esp32' into followup/hal-esp32
Brings in the system_soft_wdt_feed NOLINT fix (4e517b422d) for ESP8266
clang-tidy redundant-declaration.
2026-04-29 06:51:05 -05:00
J. Nick Koston 4009c498d9 [esp32] Fix hal.cpp include order: defines.h before crash_handler.h
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.
2026-04-29 06:50:59 -05:00
J. Nick Koston 4e517b422d [esp8266] NOLINT redundant-declaration on system_soft_wdt_feed forward decl
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.
2026-04-29 06:08:04 -05:00
J. Nick Koston 1ce6364892 [libretiny] Move HAL bodies into components/libretiny/hal.cpp + inline trivial dispatches
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.
2026-04-29 06:01:11 -05:00
J. Nick Koston bb76ee76ec [esp8266] Inline arch_get_cpu_cycle_count() and arch_get_cpu_freq_hz()
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.
2026-04-29 05:59:38 -05:00
J. Nick Koston c0e2d443f0 [esp8266] Move HAL bodies into components/esp8266/hal.cpp + inline arch_init()
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.
2026-04-29 05:56:42 -05:00
J. Nick Koston 174a0b7631 [esp32] Use components/esp32/hal.cpp instead of core/hal/hal_esp32.cpp
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.
2026-04-29 05:53:18 -05:00
J. Nick Koston 5be4f746ba [esp32] Move HAL bodies from components/esp32/core.cpp into core/hal/
Per-platform follow-up to #15977.

Move out-of-line HAL bodies (millis(), arch_restart(), arch_get_cpu_freq_hz())
from components/esp32/core.cpp into a new esphome/core/hal/hal_esp32.cpp so
HAL implementation finally lives next to the HAL header.

Inline the trivial one-liners directly in hal_esp32.h:
  delayMicroseconds(us)        -> delay_microseconds_safe(us)
  arch_feed_wdt()              -> esp_task_wdt_reset()
  arch_get_cpu_cycle_count()   -> esp_cpu_get_cycle_count()

arch_init() stays in components/esp32/core.cpp because it uses
esp32::crash_handler_read_and_clear() from the component-private
crash_handler.h header — moving it would require an awkward layering
inversion of core/ -> components/esp32/.

config.py FILTER_SOURCE_FILES gains a hal/hal_esp32.cpp entry so only
ESP32 builds compile it (same pattern wake/wake_*.cpp uses).

Cross-platform decls of delayMicroseconds(), arch_feed_wdt(), and
arch_get_cpu_cycle_count() are dropped from the dispatcher hal.h and
moved into each per-platform header — that way subsequent per-platform
follow-up PRs (libretiny, rp2040, host, zephyr) only need to touch
their own platform header instead of accumulating gates in hal.h.
2026-04-29 05:46:56 -05:00
J. Nick Koston 0f128d2f15 [esp8266] Inline delayMicroseconds/arch_feed_wdt/progmem_read_* in hal_esp8266.h
These wrappers were one-line forwarders to platform primitives:

  delayMicroseconds(us)   -> delay_microseconds_safe(us)
  arch_feed_wdt()         -> system_soft_wdt_feed()
  progmem_read_byte(p)    -> pgm_read_byte(p)
  progmem_read_ptr(p)     -> pgm_read_ptr(p) cast
  progmem_read_uint16(p)  -> pgm_read_word(p)

Mark them __attribute__((always_inline)) inline in hal_esp8266.h so the
wrapper call/return is eliminated at every call site, and remove the
out-of-line definitions from components/esp8266/core.cpp.

The IRAM_ATTR previously on delayMicroseconds() was decorative — its
body calls delay_microseconds_safe() which lives in flash, so an IRAM
ISR caller already jumped from SRAM into flash. Inlining is no worse
than the prior code (same reasoning as the libretiny IRAM_ATTR note in
the parent commit's PR description).

The dispatcher hal.h now gates its delayMicroseconds/arch_feed_wdt
declarations behind #ifndef USE_ESP8266 so clang-tidy does not flag
them as redundant on top of the inline definitions.
2026-04-29 05:37:48 -05:00
J. Nick Koston 83252df908 [core] Split hal.h into per-platform headers under core/hal/
Mirror the wake.{h,cpp} → wake/wake_<platform>.{h,cpp} decomposition
that PR #15978 did. After this change esphome/core/hal.h is a thin
dispatcher and each platform's HAL bits (IRAM_ATTR / PROGMEM macros,
in_isr_context(), the inline yield/delay/micros/millis/millis_64
wrappers, plus ESP8266's progmem_read_*) live in their own header
under esphome/core/hal/.

Scope is headers only — there is no esphome/core/hal.cpp today (every
out-of-line implementation lives in esphome/components/<platform>/core.cpp
alongside platform-specific concerns) so no new .cpp files are added
and no FILTER_SOURCE_FILES entries are needed in core/config.py.
recursive_sources=True on the core manifest already picks up the new
.h files automatically.

No public API moves, no symbol renames, no behavior change. Pure code
motion. The only observable difference is the dispatcher #errors when
no USE_* is set (today an unknown platform silently fell through to
the else branch with empty IRAM_ATTR/PROGMEM); this matches wake.h's
behavior.
2026-04-29 05:16:27 -05:00
J. Nick Koston 063fec1796 Merge branch 'dev' into inline-micros-esp32 2026-04-29 05:14:57 -05:00
J. Nick Koston 8ceada8d04 [core] Download external_files in parallel (#16021) 2026-04-29 14:32:30 +12:00
J. Nick Koston 49c7a6928e [script] Fix cpp_unit_test crash for non-MULTI_CONF platform components (#16104) 2026-04-29 14:32:13 +12:00
J. Nick Koston 2fce71e0d4 [wifi] Add phy_mode option for ESP8266 (#16055) 2026-04-29 14:31:07 +12:00
J. Nick Koston 80251c54be [climate] Add climate.control coverage to component tests via thermostat (#16052) 2026-04-29 14:27:56 +12:00
J. Nick Koston 0d51a122d0 [cover] Add cover.control / cover.template.publish coverage to template tests (#16051) 2026-04-29 14:27:40 +12:00
J. Nick Koston 5a33c50015 [light] Use constexpr template for DimRelativeAction transition_length (#16038) 2026-04-29 14:26:38 +12:00
J. Nick Koston 0d150dc57e [light] Use constexpr template for ToggleAction transition_length (#16037) 2026-04-29 14:25:18 +12:00
J. Nick Koston d287876d8d [light] Use bitmask template for LightControlAction unused fields (#16039) 2026-04-29 14:20:37 +12:00
J. Nick Koston 592486ae9a [analyze_memory] Attribute main.cpp setup()/loop() to esphome core (#16033) 2026-04-29 14:06:54 +12:00
J. Nick Koston 4f75647f63 Merge upstream/dev into inline-micros-esp32
Resolves conflict in esphome/components/esp8266/core.cpp per PR #15977 plan:
keep #15662's fast millis() accumulator and optimistic_yield delay() body;
drop the upstream wrappers for yield()/millis_64()/micros() since those
are now always-inlined in hal.h.
2026-04-28 20:54:39 -05:00
Jonathan Swoboda c3bd38af77 [feedback] Fix bugprone-unchecked-optional-access in start_direction_ (#16103) 2026-04-28 21:54:15 -04:00
J. Nick Koston eec770d622 [core] Use ETag in external_files cache to fix re-downloads from raw.githubusercontent.com (#16020) 2026-04-29 13:52:09 +12:00
J. Nick Koston d7b21a84a3 [git] Make ref fetches and submodule updates shallow (#16014) 2026-04-29 13:49:51 +12:00
J. Nick Koston f05243bd9d [api] Add 48-bit MAC address varint fast path for BLE advertisements (#15988) 2026-04-29 13:48:35 +12:00
J. Nick Koston 35cb28edfe [output] Gate FloatOutput power scaling fields behind USE_OUTPUT_FLOAT_POWER_SCALING (#15998) 2026-04-29 13:27:22 +12:00
J. Nick Koston 1363f661e6 [core] Inline ContinuationAction in If/While/RepeatAction (#16040) 2026-04-28 21:26:25 -04:00
J. Nick Koston 8af499b591 [api] Use custom deleter to fix incomplete-type error on macOS libc++ (#16050) 2026-04-28 21:26:21 -04:00
Jonathan Swoboda 1a57d9bc2f [sprinkler][pn532] Fix bugprone-unchecked-optional-access (#16102) 2026-04-29 01:04:19 +00:00
J. Nick Koston 9768380856 [api] Hoist memw out of socket ready check to once per main-loop iter (#15996) 2026-04-29 13:04:10 +12:00
J. Nick Koston 676f26919e [mdns] Drive MDNS.update() polling from IP state events on ESP8266/RP2040 (#15961) 2026-04-29 13:02:21 +12:00
J. Nick Koston 29d3a3a498 [esp8266] Replace millis() with fast accumulator, wrap Arduino callers (#15662) 2026-04-29 12:58:00 +12:00
Jonathan Swoboda 77b76ac48a [inkbird_ibsth1_mini][speaker][speaker_source] Fix performance-unnecessary-copy-initialization (#16101) 2026-04-29 00:56:03 +00:00
Clyde Stubbs 0b5835284a [lvgl] Additional layout features (#16041) 2026-04-29 12:35:24 +12:00
Jonathan SwobodaandJ. Nick Koston 15df477472 [core] Reduce copies in Callback/CallbackManager call paths (#16093)
Co-authored-by: J. Nick Koston <nick+github@koston.org>
2026-04-28 19:41:28 -04:00
Jonathan Swoboda be0ee73847 [i2c] NOLINT readability-identifier-naming on Zephyr struct forward-decl (#16099) 2026-04-28 19:22:42 -04:00
Jonathan Swoboda a241c9e622 [online_image][sim800l] Use std::string::starts_with for prefix checks (#16097) 2026-04-28 19:02:39 -04:00
Jonathan Swoboda 2f433c78bd [haier] Brace single-statement else-if in smartair2_climate (#16098) 2026-04-28 18:56:36 -04:00
Jonathan Swoboda e39c474577 [binary_sensor] Bind at_index_ once in MultiClick on_state_ (#16095) 2026-04-28 22:13:35 +00:00
Jonathan Swoboda a62e3fe4fc [json] NOLINT StackAddressEscape false positive in parse_json (#16091) 2026-04-28 21:35:40 +00:00
Jonathan Swoboda 7d6b9bee19 [wifi] Avoid copying EAP config in three connect handlers (#16094) 2026-04-28 21:22:29 +00:00
Jonathan Swoboda ab6bda50e4 [esp32_ble] Widen loop variable in as_128bit() to match uuid_.len type (#16088) 2026-04-28 20:58:40 +00:00
Jonathan Swoboda 3d195d748c [ezo] Use make_unique to construct EzoCommand (#16092) 2026-04-28 20:50:15 +00:00