The debug component's reset reason text sensor was returning an empty
string on RP2040/RP2350 platforms. Read the chip reset registers to
report the actual reset source.
RP2040: reads VREG_AND_CHIP_RESET for POR and RUN pin.
RP2350: reads POWMAN chip_reset for POR, brown-out, RUN pin, and
power supply glitch.
Both: checks watchdog_caused_reboot() from the Pico SDK, and
distinguishes between crash (HardFault), watchdog timeout, and
software reset by consulting the crash handler data.
Also adds buf_append_str() helper to helpers.h for efficient plain
string appends without format parsing overhead.
Fix two GCC warnings on RP2040 builds:
1. crash_handler.cpp: Move __attribute__((section(".noinit"))) from
the struct type to the variable declaration where it belongs.
2. mdns_rp2040.cpp: Suppress IRAM_ATTR macro redefinition warning
caused by Arduino-Pico's PolledTimeout.h redefining it to empty.
The debug component's reset reason text sensor was returning an empty
string on RP2040/RP2350 platforms. Read the chip reset registers to
report the actual reset source.
RP2040: reads VREG_AND_CHIP_RESET for POR, RUN pin, and debug port.
RP2350: reads POWMAN chip_reset for POR, brown-out, RUN pin, watchdog
variants, glitch detect, debugger, rescue, and core powerdown.
Both: checks watchdog_caused_reboot() from the Pico SDK.
Also adds buf_append_str() helper to helpers.h for efficient plain
string appends without format parsing overhead.
Move __attribute__((section(".noinit"))) from the struct type to the
variable declaration where it belongs. GCC warns because the section
attribute applies to variables, not types.
The RP2040's LEAmDNS library relies on LwipIntf::stateUpCB() to
restart mDNS when the network interface reconnects. However, this
callback is stubbed out in arduino-pico because the original ESP8266
implementation used schedule_function() which doesn't exist in
arduino-pico, and the callback can't safely run directly since netif
status callbacks fire from IRQ context while _restart() allocates
UDP sockets.
The previous workaround blocked all component setup via can_proceed()
until WiFi connected, which only helped on initial boot but did not
handle reconnects.
Replace with a proper fix: detect WiFi reconnection from the existing
50ms mDNS update interval (main loop context) and call
MDNS.notifyAPChange() to restart mDNS probing and announcing.
The RP2040's LEAmDNS library relies on LwipIntf::stateUpCB() to
restart mDNS when the network interface reconnects. However, this
callback is stubbed out in arduino-pico because the original ESP8266
implementation used schedule_function() which doesn't exist in
arduino-pico, and the callback can't safely run directly since netif
status callbacks fire from IRQ context while _restart() allocates
UDP sockets.
The previous workaround blocked all component setup via can_proceed()
until WiFi connected, which only helped on initial boot but did not
handle reconnects.
Replace with a proper fix: detect WiFi reconnection from the existing
50ms mDNS update interval (main loop context) and call
MDNS.notifyAPChange() to restart mDNS probing and announcing.
Add FixedRingBuffer<T, MAX_CAPACITY> to helpers.h as the runtime-sized
equivalent of StaticRingBuffer. Uses std::conditional_t to auto-select
uint8_t/uint16_t/uint32_t index types based on MAX_CAPACITY.
Convert SlidingWindowFilter from manual ring buffer logic on FixedVector
to FixedRingBuffer<float>, eliminating window_head_, window_count_,
and window_size_ fields.
When calling set_effect("None") from a lambda, the compiler cannot
choose between set_effect(optional<std::string>) and
set_effect(const std::string&) since both require one implicit
conversion from const char*. Add explicit const char* overload to
resolve the ambiguity.
Fixes https://github.com/esphome/esphome/issues/14728
readv() holds LWIP_LOCK for the entire scatter-gather operation and
previously called read() internally, which would call wait_for_data_()
→ socket_delay() while the lock was held — blocking recv_fn() on RP2040.
Extract read_locked_() with the state checks and copy logic. Both
read() and readv() call wait_for_data_() before acquiring the lock,
then use read_locked_() under the lock.
Remove the redundant s_socket_woke = false between the early-return
check and the while loop. If an IRQ fires in that window (recv_fn
sets s_socket_woke = true), clearing the flag would lose the wake
and sleep until the timer fires. Now the while loop sees the flag
immediately and exits. The flag is cleared after the loop instead.
Replace read_locked_() approach with a simpler wait_for_data_() called
at the top of both read() and readv(), keeping the original read/readv
structure intact.
- Extract read_locked_() to avoid holding LWIP_LOCK during socket_delay(),
which would block recv_fn() on RP2040 (needs async_context lock)
- Loop around socket_delay() for remaining time on spurious wakes from
other sockets, ensuring SO_RCVTIMEO semantics are correct
- Fix readv() to use read_locked_() directly instead of calling read(),
avoiding recursive locking and unintended socket_delay() waits
When rx_buf_ is empty during the client hello phase of the noise
handshake, rx_buf_.data() can return nullptr. Passing nullptr to
std::memcpy as the source argument is undefined behavior even when
the size is 0. Guard the memcpy with a size check.
Found by UndefinedBehaviorSanitizer in #14718.
StringRef fields decoded from protobuf point into the receive buffer
and are NOT null-terminated. DumpBuffer::append(const char*) calls
strlen() which reads past the buffer. Use the (const char*, size_t)
overload instead.
Found by AddressSanitizer in #14718.