From 104011484dcb0bda4e3c1ef383b6a0a8bfb27fbb Mon Sep 17 00:00:00 2001 From: Adam Bodurka Date: Wed, 7 Dec 2022 15:46:43 +0100 Subject: [PATCH] [QPG] Added boot reason and reboot count implementation (#23949) * Reboot reason implemented * Reboot reason fixed * Bump SDK and use FTD libs * Restyled by whitespace * Restyled by clang-format * Bump SDK once again Co-authored-by: Restyled.io --- src/platform/qpg/ConfigurationManagerImpl.cpp | 34 +++++++++++++++++-- src/platform/qpg/qpgConfig.cpp | 3 +- third_party/qpg_sdk/BUILD.gn | 8 ++--- third_party/qpg_sdk/repo | 2 +- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/platform/qpg/ConfigurationManagerImpl.cpp b/src/platform/qpg/ConfigurationManagerImpl.cpp index 1825b101b3cbef..872b05cc6c08f6 100644 --- a/src/platform/qpg/ConfigurationManagerImpl.cpp +++ b/src/platform/qpg/ConfigurationManagerImpl.cpp @@ -48,6 +48,8 @@ CHIP_ERROR ConfigurationManagerImpl::Init() { CHIP_ERROR err; uint32_t rebootCount; + qvResetReason_t qvRebootReason; + BootReasonType bootReason; // Initialize the generic implementation base class. err = Internal::GenericConfigurationManagerImpl::Init(); @@ -74,12 +76,38 @@ CHIP_ERROR ConfigurationManagerImpl::Init() SuccessOrExit(err); } - if (!QPGConfig::ConfigValueExists(QPGConfig::kCounterKey_BootReason)) + qvRebootReason = qvCHIP_GetResetReason(); + + switch (qvRebootReason) { - err = StoreBootReason(to_underlying(BootReasonType::kUnspecified)); - SuccessOrExit(err); + case qvResetReason_HW_BrownOutDetected: { + bootReason = BootReasonType::kBrownOutReset; + break; + } + + case qvResetReason_HW_Watchdog: { + bootReason = BootReasonType::kHardwareWatchdogReset; + break; + } + + case qvResetReason_HW_Por: { + bootReason = BootReasonType::kPowerOnReboot; + break; } + case qvResetReason_SW_Por: { + bootReason = BootReasonType::kSoftwareReset; + break; + } + + default: + bootReason = BootReasonType::kUnspecified; + break; + } + + err = StoreBootReason(to_underlying(bootReason)); + SuccessOrExit(err); + err = CHIP_NO_ERROR; exit: diff --git a/src/platform/qpg/qpgConfig.cpp b/src/platform/qpg/qpgConfig.cpp index 0eec2eeecd4849..cb104485bedfca 100644 --- a/src/platform/qpg/qpgConfig.cpp +++ b/src/platform/qpg/qpgConfig.cpp @@ -211,7 +211,8 @@ CHIP_ERROR QPGConfig::ClearConfigValue(Key key) bool QPGConfig::ConfigValueExists(Key key) { - return qvCHIP_Nvm_ValueExists(key, NULL); + uint16_t dummy = 0; + return qvCHIP_Nvm_ValueExists(key, &dummy); } CHIP_ERROR QPGConfig::FactoryResetConfig(void) diff --git a/third_party/qpg_sdk/BUILD.gn b/third_party/qpg_sdk/BUILD.gn index 88263ed5a4ebfe..d1c60542365ae9 100755 --- a/third_party/qpg_sdk/BUILD.gn +++ b/third_party/qpg_sdk/BUILD.gn @@ -160,10 +160,10 @@ static_library("qpg_bootloader_lib") { qpg_make_build("qpg_openthread_glue") { make_sources = [ "${qpg_sdk_root}/Components/Qorvo/Matter" ] - make_output = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/OpenThreadQorvoGlue_qpg6105_mtd/libOpenThreadQorvoGlue_${qpg_target_ic}_mtd.a" ] + make_output = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/OpenThreadQorvoGlue_qpg6105_ftd/libOpenThreadQorvoGlue_${qpg_target_ic}_ftd.a" ] make_args = [ "-f", - rebase_path(qpg_sdk_root, root_build_dir) + "/Libraries/Qorvo/OpenThreadQorvoGlue/Makefile.OpenThreadQorvoGlue_${qpg_target_ic}_mtd", + rebase_path(qpg_sdk_root, root_build_dir) + "/Libraries/Qorvo/OpenThreadQorvoGlue/Makefile.OpenThreadQorvoGlue_${qpg_target_ic}_ftd", "FREERTOS_REPO_DIR=" + rebase_path(chip_root, root_build_dir) + "/third_party/freertos/repo", "MBEDTLS_REPO_DIR=" + rebase_path(chip_root, root_build_dir) + @@ -171,10 +171,10 @@ qpg_make_build("qpg_openthread_glue") { "OPENTHREAD_REPO_DIR =" + rebase_path(chip_root, root_build_dir) + "/third_party/openthread/repo", "WORKDIR=" + rebase_path(target_gen_dir, root_build_dir) + - "/${qpg_sdk_lib_dir}/OpenThreadQorvoGlue_${qpg_target_ic}_mtd", + "/${qpg_sdk_lib_dir}/OpenThreadQorvoGlue_${qpg_target_ic}_ftd", ] } static_library("qpg_openthread_glue_lib") { deps = [ "${chip_root}/third_party/qpg_sdk:qpg_openthread_glue" ] - libs = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/OpenThreadQorvoGlue_qpg6105_mtd/libOpenThreadQorvoGlue_${qpg_target_ic}_mtd.a" ] + libs = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/OpenThreadQorvoGlue_qpg6105_ftd/libOpenThreadQorvoGlue_${qpg_target_ic}_ftd.a" ] } diff --git a/third_party/qpg_sdk/repo b/third_party/qpg_sdk/repo index 617a0b065592c0..eb198408bc8581 160000 --- a/third_party/qpg_sdk/repo +++ b/third_party/qpg_sdk/repo @@ -1 +1 @@ -Subproject commit 617a0b065592c0bd298d28e4b275c830b91b3d7b +Subproject commit eb198408bc8581702fc0fccd2e05345a1491b558