From bb2abd741497eee90f3040440b6712e6874974ee Mon Sep 17 00:00:00 2001 From: Mason Tran Date: Fri, 2 Feb 2024 16:56:45 -0500 Subject: [PATCH] [spinel] add `SPINEL_CAP_RCP_LOG_CRASH_DUMP` and `SPINEL_PROP_RCP_LOG_CRASH_DUMP` --- src/lib/spinel/radio_spinel.cpp | 15 +++++++++++++++ src/lib/spinel/radio_spinel.hpp | 1 + src/lib/spinel/spinel.c | 3 +++ src/lib/spinel/spinel.h | 13 +++++++++++++ 4 files changed, 32 insertions(+) diff --git a/src/lib/spinel/radio_spinel.cpp b/src/lib/spinel/radio_spinel.cpp index b41fde342666..93dc9af1ee15 100644 --- a/src/lib/spinel/radio_spinel.cpp +++ b/src/lib/spinel/radio_spinel.cpp @@ -61,6 +61,7 @@ bool RadioSpinel::sSupportsLogStream = false; ///< RCP supports `LOG_STREAM` property with OpenThread log meta-data format. bool RadioSpinel::sSupportsResetToBootloader = false; ///< RCP supports resetting into bootloader mode. +bool RadioSpinel::sSupportsLogCrashDump = false; ///< RCP supports logging a crash dump. otRadioCaps RadioSpinel::sRadioCaps = OT_RADIO_CAPS_NONE; @@ -302,6 +303,11 @@ bool RadioSpinel::IsRcp(bool &aSupportsRcpApiVersion, bool &aSupportsRcpMinHostA sSupportsResetToBootloader = true; } + if (capability == SPINEL_CAP_RCP_LOG_CRASH_DUMP) + { + sSupportsLogCrashDump = true; + } + if (capability == SPINEL_PROP_RCP_MIN_HOST_API_VERSION) { aSupportsRcpMinHostApiVersion = true; @@ -2685,6 +2691,15 @@ void RadioSpinel::LogSpinelFrame(const uint8_t *aFrame, uint16_t aLength, bool a } break; + case SPINEL_PROP_RCP_LOG_CRASH_DUMP: + { + const char *name; + name = "log-crash-dump"; + + start += Snprintf(start, static_cast(end - start), ", %s", name); + } + break; + case SPINEL_PROP_MAC_ENERGY_SCAN_RESULT: case SPINEL_PROP_PHY_CHAN_MAX_POWER: { diff --git a/src/lib/spinel/radio_spinel.hpp b/src/lib/spinel/radio_spinel.hpp index 7cdd1f8def8d..c7b3d6fb102e 100644 --- a/src/lib/spinel/radio_spinel.hpp +++ b/src/lib/spinel/radio_spinel.hpp @@ -1294,6 +1294,7 @@ class RadioSpinel static bool sIsReady; ///< NCP ready. static bool sSupportsLogStream; ///< RCP supports `LOG_STREAM` property with OpenThread log meta-data format. static bool sSupportsResetToBootloader; ///< RCP supports resetting into bootloader mode. + static bool sSupportsLogCrashDump; ///< RCP supports logging a crash dump. #if OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT > 0 diff --git a/src/lib/spinel/spinel.c b/src/lib/spinel/spinel.c index c85d2444cf41..4a22ddb3d985 100644 --- a/src/lib/spinel/spinel.c +++ b/src/lib/spinel/spinel.c @@ -1427,6 +1427,7 @@ const char *spinel_prop_key_to_cstr(spinel_prop_key_t prop_key) {SPINEL_PROP_SERVER_LEADER_SERVICES, "SERVER_LEADER_SERVICES"}, {SPINEL_PROP_RCP_API_VERSION, "RCP_API_VERSION"}, {SPINEL_PROP_RCP_MIN_HOST_API_VERSION, "RCP_MIN_HOST_API_VERSION"}, + {SPINEL_PROP_RCP_LOG_CRASH_DUMP, "RCP_LOG_CRASH_DUMP"}, {SPINEL_PROP_UART_BITRATE, "UART_BITRATE"}, {SPINEL_PROP_UART_XON_XOFF, "UART_XON_XOFF"}, {SPINEL_PROP_15_4_PIB_PHY_CHANNELS_SUPPORTED, "15_4_PIB_PHY_CHANNELS_SUPPORTED"}, @@ -1489,6 +1490,7 @@ const char *spinel_prop_key_to_cstr(spinel_prop_key_t prop_key) {SPINEL_PROP_DEBUG_TEST_WATCHDOG, "DEBUG_TEST_WATCHDOG"}, {SPINEL_PROP_RCP_MAC_FRAME_COUNTER, "RCP_MAC_FRAME_COUNTER"}, {SPINEL_PROP_RCP_MAC_KEY, "RCP_MAC_KEY"}, + {SPINEL_PROP_RCP_LOG_CRASH_DUMP, "RCP_LOG_CRASH_DUMP"}, {SPINEL_PROP_DEBUG_LOG_TIMESTAMP_BASE, "DEBUG_LOG_TIMESTAMP_BASE"}, {SPINEL_PROP_DEBUG_TREL_TEST_MODE_ENABLE, "DEBUG_TREL_TEST_MODE_ENABLE"}, {0, NULL}, @@ -1608,6 +1610,7 @@ const char *spinel_capability_to_cstr(spinel_capability_t capability) {SPINEL_CAP_RCP_API_VERSION, "RCP_API_VERSION"}, {SPINEL_CAP_RCP_MIN_HOST_API_VERSION, "RCP_MIN_HOST_API_VERSION"}, {SPINEL_CAP_RCP_RESET_TO_BOOTLOADER, "RCP_RESET_TO_BOOTLOADER"}, + {SPINEL_CAP_RCP_LOG_CRASH_DUMP, "RCP_LOG_CRASH_DUMP"}, {SPINEL_CAP_MAC_ALLOWLIST, "MAC_ALLOWLIST"}, {SPINEL_CAP_MAC_RAW, "MAC_RAW"}, {SPINEL_CAP_OOB_STEERING_DATA, "OOB_STEERING_DATA"}, diff --git a/src/lib/spinel/spinel.h b/src/lib/spinel/spinel.h index d91a039ac461..17b93bb3a623 100644 --- a/src/lib/spinel/spinel.h +++ b/src/lib/spinel/spinel.h @@ -1295,6 +1295,7 @@ enum SPINEL_CAP_RCP_API_VERSION = (SPINEL_CAP_RCP__BEGIN + 0), SPINEL_CAP_RCP_MIN_HOST_API_VERSION = (SPINEL_CAP_RCP__BEGIN + 1), SPINEL_CAP_RCP_RESET_TO_BOOTLOADER = (SPINEL_CAP_RCP__BEGIN + 2), + SPINEL_CAP_RCP_LOG_CRASH_DUMP = (SPINEL_CAP_RCP__BEGIN + 3), SPINEL_CAP_RCP__END = 80, SPINEL_CAP_OPENTHREAD__BEGIN = 512, @@ -4397,6 +4398,18 @@ enum */ SPINEL_PROP_RCP_MIN_HOST_API_VERSION = SPINEL_PROP_RCP__BEGIN + 1, + /// Crash Dump + /** Format: `U` (read-only) + * + * Required capability: SPINEL_CAP_RADIO and SPINEL_CAP_RCP_LOG_CRASH_DUMP. + * + * This property gives the crash dump from the RCP. + * + * Please see "Spinel definition compatibility guideline" section. + * + */ + SPINEL_PROP_RCP_LOG_CRASH_DUMP = SPINEL_PROP_RCP__BEGIN + 2, + SPINEL_PROP_RCP__END = 0xFF, SPINEL_PROP_INTERFACE__BEGIN = 0x100,