Commit Graph
24290 Commits
Author SHA1 Message Date
J. Nick Koston 940cf8f206 Merge branch 'rp2040-wrap-printf' into integration 2026-03-08 01:33:31 -10:00
J. Nick Koston f13a2e08da Add enable_full_printf test coverage 2026-03-08 01:32:25 -10:00
J. Nick Koston 27cebf591c Add enable_full_printf escape hatch 2026-03-08 01:22:22 -10:00
J. Nick Koston 55b9d81429 Add diagnostic message before abort on buffer overflow 2026-03-08 01:15:33 -10:00
J. Nick Koston e841bdfa8e Merge branch 'esp8266-wrap-printf' into integration 2026-03-08 01:08:04 -10:00
J. Nick Koston 6d3c738de2 Increase printf stub buffer to 256 bytes 2026-03-08 01:07:17 -10:00
J. Nick Koston 24613e3b1f Merge branch 'esp8266-wrap-printf' into integration 2026-03-08 01:04:37 -10:00
J. Nick Koston 55bf2d76b1 Merge branch 'rp2040-wrap-printf' into integration 2026-03-08 01:04:33 -10:00
J. Nick Koston 76a35df85a [rp2040] Wrap printf/vprintf/fprintf to eliminate _vfprintf_r (~8.9 KB flash)
Apply the same linker wrap technique used on ESP32 (PR #14362) to RP2040.
ESPHome logging uses snprintf/vsnprintf, not libc printf, so the FILE*-based
printf path (_vfprintf_r) is dead code at runtime.

The stubs redirect printf/vprintf/fprintf through vsnprintf + fwrite,
allowing the linker to GC _vfprintf_r (~8.9 KB).
2026-03-08 01:03:31 -10:00
J. Nick Koston 6feb0108f0 [esp8266] Wrap printf/vprintf/fprintf to eliminate _vfprintf_r (~900 bytes flash)
Apply the same linker wrap technique used on ESP32 (PR #14362) to ESP8266.
ESPHome logging uses ets_printf, not libc printf, so the FILE*-based printf
path is dead code. The stubs redirect through vsnprintf + fwrite, allowing
the linker to GC _vfprintf_r.

Savings are smaller than ESP32 (~900 bytes vs ~11 KB) because ESP8266's
newlib printf is more modular, but ESP8266 has much less flash headroom
so every byte counts.
2026-03-08 01:01:28 -10:00
J. Nick Koston ba971e6cbb Merge remote-tracking branch 'origin/proto-byte-buffer' into integration 2026-03-08 00:49:32 -10:00
J. Nick Koston 81b3b794bb fix 2026-03-08 00:49:07 -10:00
Oliver Kleinecke a9b5f95c76 [usb_uart] ch34x chip-type & port-count enumeration (#14544) 2026-03-08 21:24:39 +11:00
J. Nick Koston a6c76f9b97 Merge branch 'scheduler-raw-pointers' into integration 2026-03-08 00:21:51 -10:00
J. Nick Koston 4b3091b01d [scheduler] Inline delete instead of delete_item_ wrapper
A single-line wrapper around delete adds no value.
2026-03-08 00:16:21 -10:00
J. Nick Koston 09c0915d0c [scheduler] Remove redundant callback clear in delete_item_
The destructor of std::function already handles releasing captured
resources — no need to explicitly null it before delete.
2026-03-08 00:15:30 -10:00
J. Nick Koston 982998c8fb [scheduler] Replace unique_ptr with raw pointers, add leak detection
The scheduler was already managing SchedulerItem lifecycle explicitly
through its object pool (recycle_item_main_loop_ / get_item_from_pool_locked_).
The unique_ptr wrapper added overhead (11 destructor call sites on the hot path)
without providing safety — if a lifecycle path was missed, the unique_ptr would
silently delete the item and cause needless heap allocations instead of pool reuse.

Replace unique_ptr<SchedulerItem, SchedulerItemDeleter> with raw SchedulerItem*
throughout. Every item is now explicitly recycled to the pool or deleted via
delete_item_(). This eliminates all 11 unique_ptr destructor calls from the hot
path and saves ~256 bytes of firmware.

Add debug leak detection under ESPHOME_DEBUG_SCHEDULER: a live-item counter
verified at the end of every call() cycle asserts that all allocated items are
accounted for in items_, to_add_, defer_queue_, or the pool. This turns silent
heap churn from missed lifecycle management into an immediate assert failure
caught by integration tests.

Also moves the retry-cancelled check before item allocation in set_timer_common_
to avoid needless alloc+delete on the cold retry path, and fixes a thread-safety
issue where recycle_item_main_loop_ (main-loop-only) was called from
set_timer_common_ which can run on non-main-loop threads.

Enable debug_scheduler: true in all 18 scheduler integration test fixtures.
2026-03-08 00:08:22 -10:00
Keith BurzinskiJ. Nick Kostonpre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>J. Nick Koston
0c4a44566f [serial_proxy] New component (#13944)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
2026-03-08 03:55:49 -05:00
J. Nick Koston 6d5d591949 Merge remote-tracking branch 'upstream/dev' into integration 2026-03-07 22:42:17 -10:00
J. Nick Koston 297685d4bf Merge remote-tracking branch 'origin/proto-byte-buffer' into integration 2026-03-07 22:42:14 -10:00
2c705810cd [nrf52] allow to update OTA via cmd (#12344)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: J. Nick Koston <nick+github@koston.org>
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
2026-03-08 08:40:52 +00:00
J. Nick Koston 6a6b67a549 Merge remote-tracking branch 'upstream/dev' into proto-byte-buffer
# Conflicts:
#	esphome/components/api/proto.h
2026-03-07 22:11:15 -10:00
J. Nick KostonandClaude Opus 4.6 a530aeec22 [api] Inline varint and encode_varint_raw fast paths for hot loop performance (#14607)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 22:09:12 -10:00
dependabot[bot]anddependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> d9e76da806 Bump aioesphomeapi from 44.4.0 to 44.5.0 (#14617)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-08 07:59:25 +00:00
J. Nick Koston 36755d6a08 Merge remote-tracking branch 'upstream/dev' into integration 2026-03-07 21:17:44 -10:00
tomaszduda23CopilotJ. Nick KostonJ. Nick Kostonpre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
e4b89a69d4 [nrf52, ota] ble and serial OTA based on mcumgr (#11932)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: J. Nick Koston <nick+github@koston.org>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-03-07 20:32:20 -10:00
J. Nick Koston 5228c8b54d Merge branch 'inline-varint-fast-path' into integration 2026-03-07 20:18:00 -10:00
J. Nick Koston fa027ec130 Merge remote-tracking branch 'upstream/proto-byte-buffer' into integration 2026-03-07 20:16:51 -10:00
J. Nick Koston 507c29add7 Inline encode_varint_raw fast path and add [[likely]] hints
Apply the same inline fast-path / noinline slow-path split to
ProtoWriteBuffer::encode_varint_raw that was done for ProtoSize::varint.

For values < 128 (field tags, small field values, short lengths), the
single-byte write is now inlined at each call site instead of going
through a full function call. The multi-byte loop is outlined into
encode_varint_raw_slow_().

Also add [[likely]] to both varint fast paths (ProtoSize::varint and
encode_varint_raw) to hint branch prediction.
2026-03-07 20:12:33 -10:00
J. Nick Koston 78c27851bb [api] APIBuffer: add explicit include, fix stale comment, clarify docs
- Add explicit #include "api_buffer.h" in api_server.h
- Remove stale "swap trick" comment in api_frame_helper.h
- Document that exact-size allocation is intentional (no growth factor)
- Clarify debug_check_bounds_ scope to protobuf write path only
2026-03-07 20:07:34 -10:00
Keith Burzinski 04cff1c916 [usb_uart] Return flush result, expose timeout via config (#14616) 2026-03-08 00:04:14 -06:00
J. Nick Koston 84e5825fd1 Merge remote-tracking branch 'upstream/proto-byte-buffer' into integration 2026-03-07 19:46:15 -10:00
J. Nick Koston f7aeaad929 [api] Replace std::vector<uint8_t> with APIBuffer to skip zero-fill
Replace std::vector<uint8_t> with a minimal APIBuffer class for the
shared protobuf write buffer, frame helper receive buffer (rx_buf_),
and noise handshake prologue buffer.

std::vector::resize() zero-fills new bytes via memset. Every byte is
immediately overwritten by the protobuf encoder or socket reads,
making the zero-fill pure waste. APIBuffer skips zero-initialization
on resize() and uses make_unique_for_overwrite where available.

Also removes a dead write_raw_ template overload from api_frame_helper.h.
2026-03-07 19:45:50 -10:00
J. Nick Koston 409ff279b7 Merge remote-tracking branch 'upstream/proto-byte-buffer' into integration 2026-03-07 19:45:07 -10:00
J. Nick Koston 126f695b93 [api] Extract APIBuffer to own file, use for rx_buf_ and prologue_
- Move APIBuffer (renamed from ProtoByteBuffer) to api_buffer.h/cpp
- Use APIBuffer for rx_buf_ (frame helper receive buffer) and
  prologue_ (noise handshake buffer) to skip zero-fill on resize
- Remove dead write_raw_ template overload and unused <vector> include
2026-03-07 19:41:05 -10:00
Keith BurzinskiJ. Nick Kostonpre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
5e842a8b20 [uart] Return flush result, expose timeout via config (#14608)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-03-08 05:23:13 +00:00
J. Nick Koston b088c54bf5 Merge branch 'dev' into proto-byte-buffer 2026-03-07 18:59:44 -10:00
J. Nick Koston 9c245100ed Merge branch 'dev' into inline-varint-fast-path 2026-03-07 18:59:33 -10:00
J. Nick KostonandClaude Opus 4.6 be6c3c52ac [api] Add force proto field option to skip zero checks on hot path (#14610)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:59:13 -10:00
Jonathan SwobodaandClaude Opus 4.6 9fea8fe01b [vbus][rf_bridge][sensirion_common] Add buffer size guards (#14597)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:50:36 -10:00
J. Nick KostonandKeith Burzinski d55fe9a34b [api] Fix value-initialization of DeviceInfoResponse (#14615)
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
2026-03-07 18:34:35 -10:00
J. Nick Koston 66919ef969 [i2s_audio] Include legacy driver IDF component when use_legacy is set (#14613) 2026-03-07 22:33:54 -06:00
J. Nick Koston 543e9b9b54 Merge remote-tracking branch 'upstream/fix-modbus-usb-uart-timeout' into integration 2026-03-07 18:28:07 -10:00
J. Nick Koston dca303494b Merge remote-tracking branch 'upstream/proto-force-field-option' into integration 2026-03-07 18:28:00 -10:00
J. Nick Koston e6d222959b Merge remote-tracking branch 'upstream/ld2450-integration-tests' into integration 2026-03-07 18:27:54 -10:00
J. Nick Koston 6d63a478b1 Merge remote-tracking branch 'upstream/fix-i2s-legacy-driver-include' into integration 2026-03-07 18:27:33 -10:00
J. Nick Koston 3b4897381f Address review feedback
- Avoid unnecessary vector construction in static mode path
- Use wraparound-safe millis comparison for staged RX
- Fix stale comments (20ms -> 40ms, ESP-IDF -> ESP32)
- Clarify MODBUS_BITS_PER_CHAR is approximate
2026-03-07 18:25:33 -10:00
J. Nick Koston 5319b8593b Add latency simulation to uart_mock for USB UART test
Add inject_to_rx_buffer_delayed() to uart_mock which stages bytes
that aren't visible to available() until the delay elapses. This
simulates USB packet delivery latency.

The test uses a 40ms delay which is:
- Greater than the old ~2ms timeout (fails without fix)
- Less than the new 50ms fallback timeout (passes with fix)
2026-03-07 18:07:18 -10:00
J. Nick Koston ab08aa7553 fix hostname len 2026-03-07 17:51:56 -10:00
J. Nick Koston 7d9a081a84 Make RX_FULL_THRESHOLD_UNSET public
Needed since modbus accesses it from outside the class.
2026-03-07 17:49:01 -10:00