forked from NabuCasa/silabs-firmware-builder
-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
246 additions
and
0 deletions.
There are no files selected for viewing
188 changes: 188 additions & 0 deletions
188
OpenThreadRCP/GeckoSDK/0001-third_party-openthread-Support-reset-into-bootloader.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
From 59e7a11a59cd10e2c292bf5dd1439a672b1bc898 Mon Sep 17 00:00:00 2001 | ||
Message-ID: <59e7a11a59cd10e2c292bf5dd1439a672b1bc898.1686305449.git.stefan@agner.ch> | ||
From: Stefan Agner <[email protected]> | ||
Date: Fri, 9 Jun 2023 12:10:44 +0200 | ||
Subject: [PATCH] third_party: openthread: Support reset into bootloader | ||
|
||
--- | ||
.../openthread/include/openthread/instance.h | 8 ++++++++ | ||
.../include/openthread/platform/misc.h | 8 ++++++++ | ||
.../openthread/src/core/api/instance_api.cpp | 1 + | ||
.../openthread/src/core/common/instance.cpp | 11 ++++++++++- | ||
.../openthread/src/core/common/instance.hpp | 6 ++++++ | ||
.../openthread/src/lib/spinel/radio_spinel.hpp | 2 +- | ||
.../openthread/src/lib/spinel/spinel.h | 5 +++-- | ||
.../third_party/openthread/src/ncp/ncp_base.cpp | 17 ++++++++++++++--- | ||
.../third_party/openthread/src/ncp/ncp_config.h | 7 +++++++ | ||
9 files changed, 58 insertions(+), 7 deletions(-) | ||
|
||
diff --git a/util/third_party/openthread/include/openthread/instance.h b/util/third_party/openthread/include/openthread/instance.h | ||
index 580f334c5..7d9408cef 100644 | ||
--- a/util/third_party/openthread/include/openthread/instance.h | ||
+++ b/util/third_party/openthread/include/openthread/instance.h | ||
@@ -250,6 +250,14 @@ void otRemoveStateChangeCallback(otInstance *aInstance, otStateChangedCallback a | ||
*/ | ||
void otInstanceReset(otInstance *aInstance); | ||
|
||
+/** | ||
+ * This method reboots the platform into its bootloader. | ||
+ * | ||
+ * @param[in] aInstance A pointer to an OpenThread instance. | ||
+ * | ||
+ */ | ||
+void otInstanceRebootBootloader(otInstance *aInstance); | ||
+ | ||
/** | ||
* Deletes all the settings stored on non-volatile memory, and then triggers a platform reset. | ||
* | ||
diff --git a/util/third_party/openthread/include/openthread/platform/misc.h b/util/third_party/openthread/include/openthread/platform/misc.h | ||
index 99c3ed3f5..9b8419294 100644 | ||
--- a/util/third_party/openthread/include/openthread/platform/misc.h | ||
+++ b/util/third_party/openthread/include/openthread/platform/misc.h | ||
@@ -61,6 +61,14 @@ extern "C" { | ||
*/ | ||
void otPlatReset(otInstance *aInstance); | ||
|
||
+/** | ||
+ * This function reboots the platform into its bootloader, if supported. | ||
+ * | ||
+ * @param[in] aInstance The OpenThread instance structure. | ||
+ * | ||
+ */ | ||
+void otPlatRebootBootloader(otInstance *aInstance); | ||
+ | ||
/** | ||
* Enumeration of possible reset reason codes. | ||
* | ||
diff --git a/util/third_party/openthread/src/core/api/instance_api.cpp b/util/third_party/openthread/src/core/api/instance_api.cpp | ||
index 06db73ce3..04c473af6 100644 | ||
--- a/util/third_party/openthread/src/core/api/instance_api.cpp | ||
+++ b/util/third_party/openthread/src/core/api/instance_api.cpp | ||
@@ -112,6 +112,7 @@ otError otInstanceErasePersistentInfo(otInstance *aInstance) { return AsCoreType | ||
#endif // OPENTHREAD_MTD || OPENTHREAD_FTD | ||
|
||
#if OPENTHREAD_RADIO | ||
+void otInstanceRebootBootloader(otInstance *aInstance) { AsCoreType(aInstance).RebootBootloader(); } | ||
void otInstanceResetRadioStack(otInstance *aInstance) { AsCoreType(aInstance).ResetRadioStack(); } | ||
#endif | ||
|
||
diff --git a/util/third_party/openthread/src/core/common/instance.cpp b/util/third_party/openthread/src/core/common/instance.cpp | ||
index d0aebecd3..55fda63b3 100644 | ||
--- a/util/third_party/openthread/src/core/common/instance.cpp | ||
+++ b/util/third_party/openthread/src/core/common/instance.cpp | ||
@@ -309,12 +309,21 @@ exit: | ||
void Instance::Reset(void) { otPlatReset(this); } | ||
|
||
#if OPENTHREAD_RADIO | ||
+void Instance::RebootBootloader(void) | ||
+{ | ||
+#if OPENTHREAD_CONFIG_NCP_REBOOT_BOOTLOADER_ENABLE | ||
+ otPlatRebootBootloader(this); | ||
+#else | ||
+ Reset(); | ||
+#endif | ||
+} | ||
+ | ||
void Instance::ResetRadioStack(void) | ||
{ | ||
mRadio.Init(); | ||
mLinkRaw.Init(); | ||
} | ||
-#endif | ||
+#endif // OPENTHREAD_RADIO | ||
|
||
void Instance::AfterInit(void) | ||
{ | ||
diff --git a/util/third_party/openthread/src/core/common/instance.hpp b/util/third_party/openthread/src/core/common/instance.hpp | ||
index 8ce6eba09..6ccf5ea25 100644 | ||
--- a/util/third_party/openthread/src/core/common/instance.hpp | ||
+++ b/util/third_party/openthread/src/core/common/instance.hpp | ||
@@ -225,6 +225,12 @@ public: | ||
void Reset(void); | ||
|
||
#if OPENTHREAD_RADIO | ||
+ /** | ||
+ * This method reboots the radio into its bootloader. | ||
+ * | ||
+ */ | ||
+ void RebootBootloader(void); | ||
+ | ||
/** | ||
* This method resets the internal states of the radio. | ||
* | ||
diff --git a/util/third_party/openthread/src/lib/spinel/radio_spinel.hpp b/util/third_party/openthread/src/lib/spinel/radio_spinel.hpp | ||
index 5aa474415..b4e0c349a 100644 | ||
--- a/util/third_party/openthread/src/lib/spinel/radio_spinel.hpp | ||
+++ b/util/third_party/openthread/src/lib/spinel/radio_spinel.hpp | ||
@@ -875,7 +875,7 @@ public: | ||
/** | ||
* This method tries to reset the co-processor. | ||
* | ||
- * @prarm[in] aResetType The reset type, SPINEL_RESET_PLATFORM or SPINEL_RESET_STACK. | ||
+ * @prarm[in] aResetType The reset type, SPINEL_RESET_PLATFORM, SPINEL_RESET_STACK, or SPINEL_RESET_BOOTLOADER. | ||
* | ||
* @retval OT_ERROR_NONE Successfully removed item from the property. | ||
* @retval OT_ERROR_BUSY Failed due to another operation is on going. | ||
diff --git a/util/third_party/openthread/src/lib/spinel/spinel.h b/util/third_party/openthread/src/lib/spinel/spinel.h | ||
index d2a3644e9..31aedadfb 100644 | ||
--- a/util/third_party/openthread/src/lib/spinel/spinel.h | ||
+++ b/util/third_party/openthread/src/lib/spinel/spinel.h | ||
@@ -901,8 +901,9 @@ enum | ||
|
||
enum | ||
{ | ||
- SPINEL_RESET_PLATFORM = 1, | ||
- SPINEL_RESET_STACK = 2, | ||
+ SPINEL_RESET_PLATFORM = 1, | ||
+ SPINEL_RESET_STACK = 2, | ||
+ SPINEL_RESET_BOOTLOADER = 3, | ||
}; | ||
|
||
enum | ||
diff --git a/util/third_party/openthread/src/ncp/ncp_base.cpp b/util/third_party/openthread/src/ncp/ncp_base.cpp | ||
index fa79b0aef..a1e87ba7b 100644 | ||
--- a/util/third_party/openthread/src/ncp/ncp_base.cpp | ||
+++ b/util/third_party/openthread/src/ncp/ncp_base.cpp | ||
@@ -1370,9 +1370,20 @@ otError NcpBase::CommandHandler_RESET(uint8_t aHeader) | ||
else | ||
#endif | ||
{ | ||
- // Signal a platform reset. If implemented, this function | ||
- // shouldn't return. | ||
- otInstanceReset(mInstance); | ||
+#if OPENTHREAD_RADIO | ||
+ if (reset_type == SPINEL_RESET_BOOTLOADER) | ||
+ { | ||
+ // Reboot into the bootloader. If implemented, this function | ||
+ // shouldn't return. | ||
+ otInstanceRebootBootloader(mInstance); | ||
+ } | ||
+ else | ||
+#endif | ||
+ { | ||
+ // Signal a platform reset. If implemented, this function | ||
+ // shouldn't return. | ||
+ otInstanceReset(mInstance); | ||
+ } | ||
|
||
#if OPENTHREAD_MTD || OPENTHREAD_FTD | ||
// We only get to this point if the | ||
diff --git a/util/third_party/openthread/src/ncp/ncp_config.h b/util/third_party/openthread/src/ncp/ncp_config.h | ||
index bc54fb52a..bb11d5b33 100644 | ||
--- a/util/third_party/openthread/src/ncp/ncp_config.h | ||
+++ b/util/third_party/openthread/src/ncp/ncp_config.h | ||
@@ -189,4 +189,11 @@ | ||
#define OPENTHREAD_ENABLE_NCP_VENDOR_HOOK 0 | ||
#endif | ||
|
||
+/** | ||
+ * @def OPENTHREAD_CONFIG_NCP_REBOOT_BOOTLOADER_ENABLE | ||
+ */ | ||
+#ifndef OPENTHREAD_CONFIG_NCP_REBOOT_BOOTLOADER_ENABLE | ||
+#define OPENTHREAD_CONFIG_NCP_REBOOT_BOOTLOADER_ENABLE 0 | ||
+#endif | ||
+ | ||
#endif // CONFIG_NCP_H_ | ||
-- | ||
2.41.0 | ||
|
58 changes: 58 additions & 0 deletions
58
OpenThreadRCP/GeckoSDK/0002-openthread-efr32-Implement-reset-into-bootloader-pla.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
From cf28b5b8c1e5e8c23ab374d93f7726e73cd35119 Mon Sep 17 00:00:00 2001 | ||
Message-Id: <cf28b5b8c1e5e8c23ab374d93f7726e73cd35119.1678797513.git.stefan@agner.ch> | ||
In-Reply-To: <774ce9b07d1f4a9b077da187ba413269900cd5db.1678797513.git.stefan@agner.ch> | ||
References: <774ce9b07d1f4a9b077da187ba413269900cd5db.1678797513.git.stefan@agner.ch> | ||
From: Stefan Agner <[email protected]> | ||
Date: Tue, 14 Mar 2023 13:13:19 +0100 | ||
Subject: [PATCH] openthread: efr32: Implement reset into bootloader platform | ||
support | ||
|
||
--- | ||
.../platform-abstraction/efr32/misc.c | 24 +++++++++++++++++++ | ||
1 file changed, 24 insertions(+) | ||
|
||
diff --git a/protocol/openthread/platform-abstraction/efr32/misc.c b/protocol/openthread/platform-abstraction/efr32/misc.c | ||
index 2ed8355..66fc003 100644 | ||
--- a/protocol/openthread/platform-abstraction/efr32/misc.c | ||
+++ b/protocol/openthread/platform-abstraction/efr32/misc.c | ||
@@ -36,6 +36,10 @@ | ||
#include "em_rmu.h" | ||
#include "platform-efr32.h" | ||
|
||
+#ifdef SL_CATALOG_GECKO_BOOTLOADER_INTERFACE_PRESENT | ||
+#include "btl_interface.h" | ||
+#endif // SL_CATALOG_GECKO_BOOTLOADER_INTERFACE_PRESENT | ||
+ | ||
static uint32_t sResetCause; | ||
|
||
void efr32MiscInit(void) | ||
@@ -53,6 +57,26 @@ void otPlatReset(otInstance *aInstance) | ||
NVIC_SystemReset(); | ||
} | ||
|
||
+void otPlatRebootBootloader(otInstance *aInstance) | ||
+{ | ||
+ OT_UNUSED_VARIABLE(aInstance); | ||
+ | ||
+#if defined(SL_CATALOG_GECKO_BOOTLOADER_INTERFACE_PRESENT) | ||
+ BootloaderResetCause_t* resetCause = (BootloaderResetCause_t*) (RAM_MEM_BASE); | ||
+ resetCause->reason = BOOTLOADER_RESET_REASON_BOOTLOAD; | ||
+ resetCause->signature = BOOTLOADER_RESET_SIGNATURE_VALID; | ||
+#endif | ||
+ | ||
+#if defined(RMU_PRESENT) | ||
+ // Clear resetcause | ||
+ RMU->CMD = RMU_CMD_RCCLR; | ||
+ // Trigger a software system reset | ||
+ RMU->CTRL = (RMU->CTRL & ~_RMU_CTRL_SYSRMODE_MASK) | RMU_CTRL_SYSRMODE_EXTENDED; | ||
+#endif | ||
+ | ||
+ NVIC_SystemReset(); | ||
+} | ||
+ | ||
otPlatResetReason otPlatGetResetReason(otInstance *aInstance) | ||
{ | ||
OT_UNUSED_VARIABLE(aInstance); | ||
-- | ||
2.39.2 | ||
|