mirror of
https://github.com/esphome/esphome.git
synced 2026-09-16 17:48:40 +00:00
Merge fix-rp2040-debug-reset-reason into integration
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "debug_component.h"
|
||||
#ifdef USE_RP2040
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include <Arduino.h>
|
||||
#include <hardware/watchdog.h>
|
||||
@@ -8,6 +9,9 @@
|
||||
#else
|
||||
#include <hardware/structs/vreg_and_chip_reset.h>
|
||||
#endif
|
||||
#ifdef USE_RP2040_CRASH_HANDLER
|
||||
#include "esphome/components/rp2040/crash_handler.h"
|
||||
#endif
|
||||
namespace esphome {
|
||||
namespace debug {
|
||||
|
||||
@@ -20,24 +24,8 @@ const char *DebugComponent::get_reset_reason_(std::span<char, RESET_REASON_BUFFE
|
||||
|
||||
#if defined(PICO_RP2350)
|
||||
uint32_t chip_reset = powman_hw->chip_reset;
|
||||
if (chip_reset & 0x10000000) // HAD_WATCHDOG_RESET_RSM
|
||||
pos = buf_append_str(buf, size, pos, "Watchdog (RSM)|");
|
||||
if (chip_reset & 0x08000000) // HAD_HZD_SYS_RESET_REQ
|
||||
pos = buf_append_str(buf, size, pos, "Hazard debugger reset|");
|
||||
if (chip_reset & 0x04000000) // HAD_GLITCH_DETECT
|
||||
pos = buf_append_str(buf, size, pos, "Power supply glitch|");
|
||||
if (chip_reset & 0x02000000) // HAD_SWCORE_PD
|
||||
pos = buf_append_str(buf, size, pos, "Switched core powerdown|");
|
||||
if (chip_reset & 0x01000000) // HAD_WATCHDOG_RESET_SWCORE
|
||||
pos = buf_append_str(buf, size, pos, "Watchdog (SWCORE)|");
|
||||
if (chip_reset & 0x00800000) // HAD_WATCHDOG_RESET_POWMAN
|
||||
pos = buf_append_str(buf, size, pos, "Watchdog (POWMAN)|");
|
||||
if (chip_reset & 0x00400000) // HAD_WATCHDOG_RESET_POWMAN_ASYNC
|
||||
pos = buf_append_str(buf, size, pos, "Watchdog (POWMAN async)|");
|
||||
if (chip_reset & 0x00200000) // HAD_RESCUE
|
||||
pos = buf_append_str(buf, size, pos, "Rescue reset|");
|
||||
if (chip_reset & 0x00080000) // HAD_DP_RESET_REQ
|
||||
pos = buf_append_str(buf, size, pos, "Debugger reset|");
|
||||
if (chip_reset & 0x00040000) // HAD_RUN_LOW
|
||||
pos = buf_append_str(buf, size, pos, "RUN pin|");
|
||||
if (chip_reset & 0x00020000) // HAD_BOR
|
||||
@@ -46,8 +34,6 @@ const char *DebugComponent::get_reset_reason_(std::span<char, RESET_REASON_BUFFE
|
||||
pos = buf_append_str(buf, size, pos, "Power-on reset|");
|
||||
#else
|
||||
uint32_t chip_reset = vreg_and_chip_reset_hw->chip_reset;
|
||||
if (chip_reset & 0x00100000) // HAD_PSM_RESTART
|
||||
pos = buf_append_str(buf, size, pos, "Debug port restart|");
|
||||
if (chip_reset & 0x00010000) // HAD_RUN
|
||||
pos = buf_append_str(buf, size, pos, "RUN pin|");
|
||||
if (chip_reset & 0x00000100) // HAD_POR
|
||||
@@ -55,10 +41,15 @@ const char *DebugComponent::get_reset_reason_(std::span<char, RESET_REASON_BUFFE
|
||||
#endif
|
||||
|
||||
if (watchdog_caused_reboot()) {
|
||||
if (watchdog_enable_caused_reboot()) {
|
||||
#ifdef USE_RP2040_CRASH_HANDLER
|
||||
if (rp2040::crash_handler_has_data()) {
|
||||
pos = buf_append_str(buf, size, pos, "Crash (HardFault)|");
|
||||
} else
|
||||
#endif
|
||||
if (watchdog_enable_caused_reboot()) {
|
||||
pos = buf_append_str(buf, size, pos, "Watchdog timeout|");
|
||||
} else {
|
||||
pos = buf_append_str(buf, size, pos, "Watchdog reboot|");
|
||||
pos = buf_append_str(buf, size, pos, "Software reset|");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,13 +65,13 @@ const char *DebugComponent::get_reset_reason_(std::span<char, RESET_REASON_BUFFE
|
||||
|
||||
const char *DebugComponent::get_wakeup_cause_(std::span<char, RESET_REASON_BUFFER_SIZE> buffer) { return ""; }
|
||||
|
||||
uint32_t DebugComponent::get_free_heap_() { return rp2040.getFreeHeap(); }
|
||||
uint32_t DebugComponent::get_free_heap_() { return ::rp2040.getFreeHeap(); }
|
||||
|
||||
size_t DebugComponent::get_device_info_(std::span<char, DEVICE_INFO_BUFFER_SIZE> buffer, size_t pos) {
|
||||
constexpr size_t size = DEVICE_INFO_BUFFER_SIZE;
|
||||
char *buf = buffer.data();
|
||||
|
||||
uint32_t cpu_freq = rp2040.f_cpu();
|
||||
uint32_t cpu_freq = ::rp2040.f_cpu();
|
||||
ESP_LOGD(TAG, "CPU Frequency: %" PRIu32, cpu_freq);
|
||||
pos = buf_append_printf(buf, size, pos, "|CPU Frequency: %" PRIu32, cpu_freq);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user