From 06cb1839f2d64751263ba328aba790b2e91dd391 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 12 Mar 2026 12:13:58 -1000 Subject: [PATCH] [rp2040] Fix compiler warnings in crash_handler and mdns 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. --- esphome/components/mdns/mdns_rp2040.cpp | 5 +++++ esphome/components/rp2040/crash_handler.cpp | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/esphome/components/mdns/mdns_rp2040.cpp b/esphome/components/mdns/mdns_rp2040.cpp index 05d991c1fa..8f978f5ca8 100644 --- a/esphome/components/mdns/mdns_rp2040.cpp +++ b/esphome/components/mdns/mdns_rp2040.cpp @@ -7,7 +7,12 @@ #include "esphome/core/log.h" #include "mdns_component.h" +// Arduino-Pico's PolledTimeout.h redefines IRAM_ATTR to empty; +// undef before include to avoid macro redefinition warning, then restore from hal.h. +#undef IRAM_ATTR #include +#undef IRAM_ATTR +#include "esphome/core/hal.h" namespace esphome::mdns { diff --git a/esphome/components/rp2040/crash_handler.cpp b/esphome/components/rp2040/crash_handler.cpp index 1f579c2d18..f9eb42a0f8 100644 --- a/esphome/components/rp2040/crash_handler.cpp +++ b/esphome/components/rp2040/crash_handler.cpp @@ -57,14 +57,14 @@ static const char *const TAG = "rp2040.crash"; // Placed in .noinit so BSS zero-init cannot race with crash_handler_read_and_clear(). // The valid field is explicitly cleared in crash_handler_read_and_clear() instead. -static struct { +static struct CrashData { bool valid; uint32_t pc; uint32_t lr; uint32_t sp; uint32_t backtrace[MAX_BACKTRACE]; uint8_t backtrace_count; -} __attribute__((section(".noinit"))) s_crash_data; +} s_crash_data __attribute__((section(".noinit"))); bool crash_handler_has_data() { return s_crash_data.valid; }