Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
hastigondaliya authored Nov 6, 2023
2 parents 9274c98 + 5058500 commit 173984c
Show file tree
Hide file tree
Showing 30 changed files with 546 additions and 501 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
sudo apt-get --no-install-recommends install -y ninja-build libreadline-dev libncurses-dev
- name: Initialize CodeQL
uses: github/codeql-action/init@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.22.3
uses: github/codeql-action/init@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -80,6 +80,6 @@ jobs:
./script/test build
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.22.3
uses: github/codeql-action/analyze@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.1.27
uses: github/codeql-action/upload-sarif@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.1.27
with:
sarif_file: results.sarif
1 change: 1 addition & 0 deletions etc/cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ ot_option(OT_NETDIAG_CLIENT OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE "Network
ot_option(OT_OPERATIONAL_DATASET_AUTO_INIT OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT "operational dataset auto init")
ot_option(OT_OTNS OPENTHREAD_CONFIG_OTNS_ENABLE "OTNS")
ot_option(OT_PING_SENDER OPENTHREAD_CONFIG_PING_SENDER_ENABLE "ping sender" ${OT_APP_CLI})
ot_option(OT_PLATFORM_BOOTLOADER_MODE OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE "platform bootloader mode")
ot_option(OT_PLATFORM_NETIF OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE "platform netif")
ot_option(OT_PLATFORM_UDP OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE "platform UDP")
ot_option(OT_REFERENCE_DEVICE OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE "test harness reference device")
Expand Down
9 changes: 9 additions & 0 deletions examples/platforms/simulation/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ void otPlatReset(otInstance *aInstance)
#endif // OPENTHREAD_PLATFORM_USE_PSEUDO_RESET
}

#if OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE
otError otPlatResetToBootloader(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);

return OT_ERROR_NOT_CAPABLE;
}
#endif

otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
Expand Down
16 changes: 15 additions & 1 deletion include/openthread/instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
#define OPENTHREAD_API_VERSION (369)
#define OPENTHREAD_API_VERSION (370)

/**
* @addtogroup api-instance
Expand Down Expand Up @@ -255,6 +255,20 @@ void otRemoveStateChangeCallback(otInstance *aInstance, otStateChangedCallback a
*/
void otInstanceReset(otInstance *aInstance);

/**
* Triggers a platform reset to bootloader mode, if supported.
*
* Requires `OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE`.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @retval OT_ERROR_NONE Reset to bootloader successfully.
* @retval OT_ERROR_BUSY Failed due to another operation is ongoing.
* @retval OT_ERROR_NOT_CAPABLE Not capable of resetting to bootloader.
*
*/
otError otInstanceResetToBootloader(otInstance *aInstance);

/**
* Deletes all the settings stored on non-volatile memory, and then triggers a platform reset.
*
Expand Down
14 changes: 14 additions & 0 deletions include/openthread/platform/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ extern "C" {
*/
void otPlatReset(otInstance *aInstance);

/**
* Performs a hardware reset on the platform to launch bootloader mode, if supported.
*
* Used when `OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE` is enabled.
*
* @param[in] aInstance The OpenThread instance structure.
*
* @retval OT_ERROR_NONE Reset to bootloader successfully.
* @retval OT_ERROR_BUSY Failed due to another operation is ongoing.
* @retval OT_ERROR_NOT_CAPABLE Not capable of resetting to bootloader.
*
*/
otError otPlatResetToBootloader(otInstance *aInstance);

/**
* Enumeration of possible reset reason codes.
*
Expand Down
18 changes: 17 additions & 1 deletion script/test
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ build_simulation()
options+=("-DOT_LINK_METRICS_MANAGER=ON")
fi

if [[ ${OT_NODE_TYPE} == cli* ]]; then
# Only enable OT_PLATFORM_BOOTLOADER_MODE when testing cli.
# This is intended to test that the "reset bootloader" CLI command returns a "NotCapable" error

# Note: Setting this option to ON for all OT_NODE_TYPEs will cause the posix/expects CI check to fail.
# This is because the simulation RCP will have the SPINEL_CAP_RCP_RESET_TO_BOOTLOADER capability,
# causing the ot-cli POSIX app to send the reset to simulation RCP successfully instead of printing
# the expected error.
options+=("-DOT_PLATFORM_BOOTLOADER_MODE=ON")
fi

if [[ ${ot_extra_options[*]+x} ]]; then
options+=("${ot_extra_options[@]}")
fi
Expand All @@ -158,7 +169,12 @@ build_simulation()
build_posix()
{
local version="$1"
local options=("-DOT_MESSAGE_USE_HEAP=ON" "-DOT_THREAD_VERSION=${version}" "-DBUILD_TESTING=ON")
local options=(
"-DBUILD_TESTING=ON"
"-DOT_MESSAGE_USE_HEAP=ON"
"-DOT_PLATFORM_BOOTLOADER_MODE=ON"
"-DOT_THREAD_VERSION=${version}"
)

if [[ ${version} != "1.1" ]]; then
options+=("-DOT_DUA=ON")
Expand Down
11 changes: 11 additions & 0 deletions src/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3075,6 +3075,17 @@ Signal a platform reset.
> reset
```
### reset bootloader
Signal a platform reset to bootloader mode, if supported.
Requires `OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE`.
```bash
> reset bootloader
Done
```
### rloc16
Get the Thread RLOC16 value.
Expand Down
29 changes: 26 additions & 3 deletions src/cli/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,34 @@ template <> otError Interpreter::Process<Cmd("version")>(Arg aArgs[])

template <> otError Interpreter::Process<Cmd("reset")>(Arg aArgs[])
{
OT_UNUSED_VARIABLE(aArgs);
otError error = OT_ERROR_NONE;

otInstanceReset(GetInstancePtr());
if (aArgs[0].IsEmpty())
{
otInstanceReset(GetInstancePtr());
}

return OT_ERROR_NONE;
#if OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE
/**
* @cli reset bootloader
* @code
* reset bootloader
* @endcode
* @cparam reset bootloader
* @par api_copy
* #otInstanceResetToBootloader
*/
else if (aArgs[0] == "bootloader")
{
error = otInstanceResetToBootloader(GetInstancePtr());
}
#endif
else
{
error = OT_ERROR_INVALID_COMMAND;
}

return error;
}

void Interpreter::ProcessLine(char *aBuf)
Expand Down
1 change: 0 additions & 1 deletion src/core/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,6 @@ openthread_core_files = [
"thread/network_data_leader.cpp",
"thread/network_data_leader.hpp",
"thread/network_data_leader_ftd.cpp",
"thread/network_data_leader_ftd.hpp",
"thread/network_data_local.cpp",
"thread/network_data_local.hpp",
"thread/network_data_notifier.cpp",
Expand Down
4 changes: 4 additions & 0 deletions src/core/api/instance_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ void otInstanceFinalize(otInstance *aInstance) { AsCoreType(aInstance).Finalize(

void otInstanceReset(otInstance *aInstance) { AsCoreType(aInstance).Reset(); }

#if OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE
otError otInstanceResetToBootloader(otInstance *aInstance) { return AsCoreType(aInstance).ResetToBootloader(); }
#endif

#if OPENTHREAD_CONFIG_UPTIME_ENABLE
uint64_t otInstanceGetUptime(otInstance *aInstance) { return AsCoreType(aInstance).Get<Uptime>().GetUptime(); }

Expand Down
4 changes: 4 additions & 0 deletions src/core/instance/instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ Instance *Instance::Init(void *aBuffer, size_t *aBufferSize)

void Instance::Reset(void) { otPlatReset(this); }

#if OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE
Error Instance::ResetToBootloader(void) { return otPlatResetToBootloader(this); }
#endif

#if OPENTHREAD_RADIO
void Instance::ResetRadioStack(void)
{
Expand Down
12 changes: 12 additions & 0 deletions src/core/instance/instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,18 @@ class Instance : public otInstance, private NonCopyable
*/
void Reset(void);

#if OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE
/**
* Triggers a platform reset to bootloader mode, if supported.
*
* @retval kErrorNone Reset to bootloader successfully.
* @retval kErrorBusy Failed due to another operation is ongoing.
* @retval kErrorNotCapable Not capable of resetting to bootloader.
*
*/
Error ResetToBootloader(void);
#endif

#if OPENTHREAD_RADIO
/**
* Resets the internal states of the radio.
Expand Down
2 changes: 2 additions & 0 deletions src/core/mac/mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,8 @@ Error Mac::ProcessEnhAckSecurity(TxFrame &aTxFrame, RxFrame &aAckFrame)
VerifyOrExit(aAckFrame.GetSecurityEnabled(), error = kErrorNone);
VerifyOrExit(aAckFrame.IsVersion2015());

SuccessOrExit(aAckFrame.ValidatePsdu());

IgnoreError(aAckFrame.GetSecurityLevel(securityLevel));
VerifyOrExit(securityLevel == Frame::kSecurityEncMic32);

Expand Down
Loading

0 comments on commit 173984c

Please sign in to comment.