From db57d013efc7b7e78f19cfcf48cd89b2fea0d762 Mon Sep 17 00:00:00 2001 From: Mason Tran Date: Fri, 2 Feb 2024 17:00:00 -0500 Subject: [PATCH] [ncp] add handler for `SPINEL_PROP_LOG_CRASH_DUMP` and Set the spinel prop during RCP init if capable --- src/lib/spinel/radio_spinel.cpp | 5 +++++ src/ncp/ncp_base.cpp | 4 ++++ src/ncp/ncp_base_dispatcher.cpp | 5 +++++ src/ncp/ncp_base_radio.cpp | 12 ++++++++++++ 4 files changed, 26 insertions(+) diff --git a/src/lib/spinel/radio_spinel.cpp b/src/lib/spinel/radio_spinel.cpp index 452608382476..29f9b202ef38 100644 --- a/src/lib/spinel/radio_spinel.cpp +++ b/src/lib/spinel/radio_spinel.cpp @@ -159,6 +159,11 @@ void RadioSpinel::Init(SpinelInterface &aSpinelInterface, VerifyOrDie(IsRcp(supportsRcpApiVersion, supportsRcpMinHostApiVersion), OT_EXIT_RADIO_SPINEL_INCOMPATIBLE); + if (sSupportsLogCrashDump) + { + SuccessOrDie(Set(SPINEL_PROP_RCP_LOG_CRASH_DUMP, nullptr)); + } + if (!aSkipRcpCompatibilityCheck) { SuccessOrDie(CheckRcpApiVersion(supportsRcpApiVersion, supportsRcpMinHostApiVersion)); diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index e0b4c1881c05..0ebf84541f4b 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -1945,6 +1945,10 @@ template <> otError NcpBase::HandlePropertyGet(void) SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_RCP_RESET_TO_BOOTLOADER)); #endif +#if OPENTHREAD_CONFIG_LOG_CRASH_DUMP_ENABLE + SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_RCP_LOG_CRASH_DUMP)); +#endif + #if OPENTHREAD_PLATFORM_POSIX SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_POSIX)); #endif diff --git a/src/ncp/ncp_base_dispatcher.cpp b/src/ncp/ncp_base_dispatcher.cpp index 48bd97e82a78..e39baad20b44 100644 --- a/src/ncp/ncp_base_dispatcher.cpp +++ b/src/ncp/ncp_base_dispatcher.cpp @@ -487,6 +487,11 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey) OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_CNTR_MAC_RETRY_HISTOGRAM), #endif #endif // OPENTHREAD_MTD || OPENTHREAD_FTD + +#if OPENTHREAD_CONFIG_LOG_CRASH_DUMP_ENABLE + OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_RCP_LOG_CRASH_DUMP), +#endif + #if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_RCP_MAC_KEY), OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_RCP_MAC_FRAME_COUNTER), diff --git a/src/ncp/ncp_base_radio.cpp b/src/ncp/ncp_base_radio.cpp index cad3ef52ddc7..1c90c8e24c7c 100644 --- a/src/ncp/ncp_base_radio.cpp +++ b/src/ncp/ncp_base_radio.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -614,6 +615,17 @@ template <> otError NcpBase::HandlePropertySet( } #endif +#if OPENTHREAD_CONFIG_LOG_CRASH_DUMP_ENABLE +template <> otError NcpBase::HandlePropertySet(void) +{ + otError error = OT_ERROR_NONE; + + error = otPlatLogCrashDump(); + + return error; +} +#endif + } // namespace Ncp } // namespace ot