Skip to content

Commit

Permalink
[QPG] Added boot reason and reboot count implementation (#23949)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Feb 1, 2023
1 parent 083b627 commit 1036948
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
34 changes: 31 additions & 3 deletions src/platform/qpg/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QPGConfig>::Init();
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion src/platform/qpg/qpgConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions third_party/qpg_sdk/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,21 @@ 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) +
"/third_party/mbedtls/repo",
"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" ]
}
2 changes: 1 addition & 1 deletion third_party/qpg_sdk/repo
Submodule repo updated 175 files

0 comments on commit 1036948

Please sign in to comment.