Commit Graph
24322 Commits
Author SHA1 Message Date
J. Nick Koston c76c734bb7 Merge branch 'bump-noise-c-0.1.11' into integration 2026-03-08 14:42:41 -10:00
J. Nick Koston 005df9e305 [api] Bump noise-c to 0.1.11
Updates noise-c dependency which brings libsodium 1.10021.0:
- libsodium updated to 1.0.21
- Optimized poly1305 and chacha20 with aligned loads for embedded targets
- Fix ChaCha20-Poly1305 AEAD source path
2026-03-08 13:45:32 -10:00
J. Nick Koston 1be1207bdc Revert "Merge branch 'libsodium-native-le' into integration"
This reverts commit 94fb2ae556, reversing
changes made to 947115b1cf.
2026-03-08 12:19:01 -10:00
J. Nick Koston 8fa7cb18d4 Revert "Merge branch 'libsodium-native-le' into integration"
This reverts commit c49957fe9a, reversing
changes made to 3cde02443d.
2026-03-08 12:19:01 -10:00
d5dc4a39cb [i2s_audio] Fix mono sample swap and block 8-bit mono on ESP32 (#14516)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2026-03-08 12:10:43 -10:00
Keith Burzinski 50b3f9d25c [mixer_speaker] Add task debounce (#14581) 2026-03-08 18:09:06 -04:00
J. Nick Koston c49957fe9a Merge branch 'libsodium-native-le' into integration 2026-03-08 12:01:04 -10:00
J. Nick KostonandClaude Opus 4.6 6c7e052049 [api] Exclude ESP8266 from NATIVE_LITTLE_ENDIAN optimization
ESP8266's older Arduino GCC doesn't optimize small memcpy into single
load/store instructions, making the memcpy path 16 bytes larger than
byte-at-a-time on that platform.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 12:00:51 -10:00
J. Nick Koston 3cde02443d Merge remote-tracking branch 'upstream/api-inline-try-to-clear-buffer' into integration 2026-03-08 11:56:28 -10:00
J. Nick Koston 94fb2ae556 Merge branch 'libsodium-native-le' into integration 2026-03-08 11:56:18 -10:00
J. Nick KostonandClaude Opus 4.6 aacbb6659e [api] Define NATIVE_LITTLE_ENDIAN for libsodium on all targets
libsodium's autoconf-generated config normally sets NATIVE_LITTLE_ENDIAN,
but PlatformIO skips autoconf. Without this define, libsodium falls back
to byte-at-a-time load/store operations in poly1305 and chacha20 instead
of optimized 32-bit memcpy. This saves ~340 bytes of flash and improves
encryption/decryption throughput on every API noise packet.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 11:55:38 -10:00
J. Nick KostonandClaude Opus 4.6 813e893508 [api] Define NATIVE_LITTLE_ENDIAN for libsodium on all targets
libsodium's autoconf-generated config normally sets NATIVE_LITTLE_ENDIAN,
but PlatformIO skips autoconf. Without this define, libsodium falls back
to byte-at-a-time load/store operations in poly1305 and chacha20 instead
of optimized 32-bit memcpy. This saves ~340 bytes of flash and improves
encryption/decryption throughput on every API noise packet.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 11:54:32 -10:00
J. Nick KostonandClaude Opus 4.6 34abc08f04 [api] Define NATIVE_LITTLE_ENDIAN for libsodium on all targets
libsodium's autoconf-generated config normally sets NATIVE_LITTLE_ENDIAN,
but PlatformIO skips autoconf. Without this define, libsodium falls back
to byte-at-a-time load/store operations in poly1305 and chacha20 instead
of optimized 32-bit memcpy. This saves ~340 bytes of flash and improves
encryption/decryption throughput on every API noise packet.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 11:54:11 -10:00
J. Nick Koston 74a0052787 [api] Inline fast path of try_to_clear_buffer
Move the common-case checks (flags_.remove and can_write_without_blocking)
into an inline method in the header, leaving only the slow path (delay,
loop, retry) in the .cpp file. This avoids a function call on every
send_buffer() invocation when the TX buffer is already clear.
2026-03-08 11:47:19 -10:00
J. Nick Koston 947115b1cf Merge branch 'skip-state-action-data-path' into integration 2026-03-08 11:30:48 -10:00
J. Nick Koston 956977bd4b [api] Skip state_action_() call in noise data path
The noise frame helper was calling state_action_() (447 bytes) on every
read_packet() and write_protobuf_messages() call. In the DATA state
(steady-state after handshake), this function falls through all handshake
checks and returns OK — pure overhead on every encrypted packet.

Add check_data_state_() inline helper that replaces the call with a
single byte-load + branch instruction in the hot path. The handshake
state machine continues to be driven by loop() as before.

Also applies consistent state checking to the plaintext frame helper.
2026-03-08 11:27:40 -10:00
J. Nick Koston 2edf062a6a Merge remote-tracking branch 'origin/warn-crystal-mismatch' into integration 2026-03-08 11:16:03 -10:00
J. Nick Koston ad5811280a [ci] Add medium-pr label for PRs with ≤100 lines changed (#14628) 2026-03-08 10:59:43 -10:00
tomaszduda23andJ. Nick Koston 9be1876fae [ble_nus] make ble_nus timeout shorter than watchdog (#14619)
Co-authored-by: J. Nick Koston <nick+github@koston.org>
2026-03-08 10:52:16 -10:00
J. Nick Koston c28ad8872d Merge remote-tracking branch 'upstream/esp32-ble-hot-path-perf' into integration 2026-03-08 09:30:45 -10:00
J. Nick KostonandClaude Opus 4.6 665b0143f9 [esp32_ble] Optimize BLE event hot path performance
- LockFreeQueue: Add fast-path check to get_and_reset_dropped_count().
  On Xtensa, uint16_t atomic exchange compiles to ~25 instructions with
  a CAS retry loop and memory barriers. A relaxed load (single instruction)
  short-circuits the common case where dropped_count is zero.

- BLEEvent: Remove redundant release() calls in load_*_event() methods.
  EventPool::release() already calls event->release() before returning
  events to the free list, so every event from allocate() is already clean.

- BLEEvent::release(): Only null heap_data on the delete path. Skip
  unconditional zeroing of is_inline and heap_data when data was inline
  (no heap allocation to clean up).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 09:24:10 -10:00
J. Nick Koston 7b1ddcdc26 Merge branch 'scheduler-atomic-uint8' into integration 2026-03-08 08:41:27 -10:00
J. Nick Koston 706fdc66fb [scheduler] Use std::atomic<uint8_t> instead of std::atomic<bool> for remove flag
GCC on Xtensa (ESP32) generates an indirect function call for
std::atomic<bool>::load() instead of inlining it. This adds unnecessary
call overhead on the scheduler hot path where the remove flag is checked
multiple times per loop iteration.

std::atomic<uint8_t>::load() inlines correctly on all platforms,
producing a simple load instruction with memory barrier. This eliminates
5 indirect calls and saves 30 bytes of flash on the scheduler hot path.
2026-03-08 08:40:54 -10:00
dependabot[bot] 1b3a7f0b6a Bump aioesphomeapi from 44.5.0 to 44.5.1 (#14624)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-08 18:18:14 +00:00
J. Nick Koston cb4d969ffc Merge remote-tracking branch 'upstream/dev' into integration 2026-03-08 08:16:26 -10:00
Diorcet Yann 3f143d9f19 [ethernet] Fix commit 3f700bac1c (#14618) 2026-03-08 09:50:32 -04:00
J. Nick Koston d59c2c3435 Merge branch 'esp8266-wrap-printf' into integration 2026-03-08 01:33:36 -10:00
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 1e3eac2568 Add enable_full_printf test coverage 2026-03-08 01:32:05 -10:00
J. Nick Koston 3d1f7cea72 Increase printf stub buffer to 512 bytes to match ESP32 2026-03-08 01:26:31 -10:00
J. Nick Koston 66374edd6d Fix comments: ESP8266 logging uses Serial, not ets_printf 2026-03-08 01:22:35 -10:00
J. Nick Koston 27cebf591c Add enable_full_printf escape hatch 2026-03-08 01:22:22 -10:00
J. Nick Koston f28ac86879 Add enable_full_printf escape hatch 2026-03-08 01:18:02 -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
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