Skip to content

Commit

Permalink
[slc] add ot_crash_handler to platform projects (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmnotran authored Mar 11, 2024
1 parent 84e9141 commit 1d9a570
Show file tree
Hide file tree
Showing 13 changed files with 1,651 additions and 6 deletions.
6 changes: 3 additions & 3 deletions script/build
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ generate()
echo "========================================================================================================="
set -x
"${repo_dir}/script/generate" \
"${repo_dir}/src/platform_projects/openthread-efr32-soc.slcp" \
"${repo_dir}/slc/platform_projects/openthread-efr32-soc.slcp" \
"${slc_generated_projects_dir}/soc" \
"${board}"
fi
Expand All @@ -117,7 +117,7 @@ generate()
echo "========================================================================================================="
set -x
"${repo_dir}/script/generate" \
"${repo_dir}/src/platform_projects/openthread-efr32-rcp-uart.slcp" \
"${repo_dir}/slc/platform_projects/openthread-efr32-rcp-uart.slcp" \
"${slc_generated_projects_dir}/rcp_uart" \
"${board}"
fi
Expand All @@ -128,7 +128,7 @@ generate()
echo "========================================================================================================="
set -x
"${repo_dir}/script/generate" \
"${repo_dir}/src/platform_projects/openthread-efr32-rcp-spi.slcp" \
"${repo_dir}/slc/platform_projects/openthread-efr32-rcp-spi.slcp" \
"${slc_generated_projects_dir}/rcp_spi" \
"${board}"
fi
Expand Down
6 changes: 3 additions & 3 deletions script/build_example_apps
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ generate()
set -x

generation_dir="${slc_generated_projects_dir}/soc-with-buttons"
slcp="${repo_dir}/src/platform_projects/openthread-efr32-soc-with-buttons.slcp"
slcp="${repo_dir}/slc/platform_projects/openthread-efr32-soc-with-buttons.slcp"

"${repo_dir}/script/generate" \
"${slcp}" \
Expand All @@ -101,7 +101,7 @@ generate()
set -x

generation_dir="${slc_generated_projects_dir}/soc-with-buttons-power-manager"
slcp="${repo_dir}/src/platform_projects/openthread-efr32-soc-with-buttons-power-manager.slcp"
slcp="${repo_dir}/slc/platform_projects/openthread-efr32-soc-with-buttons-power-manager.slcp"

"${repo_dir}/script/generate" \
"${slcp}" \
Expand All @@ -116,7 +116,7 @@ generate()
set -x

generation_dir="${slc_generated_projects_dir}/soc-with-buttons-power-manager-csl"
slcp="${repo_dir}/src/platform_projects/openthread-efr32-soc-with-buttons-power-manager-csl.slcp"
slcp="${repo_dir}/slc/platform_projects/openthread-efr32-soc-with-buttons-power-manager-csl.slcp"

"${repo_dir}/script/generate" \
"${slcp}" \
Expand Down
19 changes: 19 additions & 0 deletions slc/component/ot_core_vendor_extension.slcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
id: ot_core_vendor_extension
label: Silicon Labs OpenThread Core Vendor Extension
package: OpenThread
category: OpenThread
quality: production
description: |-
This component implements ot::Extension::ExtensionBase for EFR32.
When used with the OT Crash Handler component, crash info will be printed after the OpenThread instance is initialized.
provides:
- name: ot_core_vendor_extension
include:
- path: openthread/src/
file_list:
- path: ncp/ncp_base.hpp
source:
- path: src/openthread/core/vendor_extension.cpp
define:
- name: OPENTHREAD_ENABLE_VENDOR_EXTENSION
value: 1
63 changes: 63 additions & 0 deletions slc/component/ot_crash_handler.slcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
id: ot_crash_handler
label: Crash Handler
package: OpenThread
category: OpenThread
quality: production
description: |-
This component provides a set of APIs for printing crash info.
In the case of a crash, this component captures the details.
The provided `efr32PrintResetInfo()` API prints the crash details.
provides:
- name: ot_crash_handler
conflicts:
- name: legacy_hal_soc
requires:
- name: component_catalog
- name: device
- name: emlib_rmu
- name: event_handler
include:
- path: third_party/silabs/gecko_sdk/protocol/openthread/src/legacy_hal/include
file_list:
- path: crash_handler.h
- path: third_party/silabs/gecko_sdk/platform/service/legacy_hal/inc
file_list:
- path: asm.h
- path: efm32_micro.h
condition:
- device_cortexm
- path: micro-common.h
- path: micro-types.h
- path: micro.h
- path: reset-def.h
- path: platform-header.h
- path: cortexm3/diagnostic.h
condition:
- device_cortexm
source:
- path: third_party/silabs/gecko_sdk/platform/service/legacy_hal/src/faults.s
- path: third_party/silabs/gecko_sdk/protocol/openthread/src/legacy_hal/crash_handler.c
- path: third_party/silabs/src/legacy_hal/diagnostic.c
define:
- name: "PLATFORM_HEADER"
value: "\"platform-header.h\""
- name: CORTEXM3_EFM32_MICRO
condition:
- device_cortexm
- name: CORTEXM3
condition:
- device_cortexm
- name: CORTEXM3_EFR32
condition:
- device_cortexm
- name: PHY_RAIL
condition:
- device_cortexm
template_contribution:
- name: component_catalog
value: ot_crash_handler
- name: event_handler
value:
event: platform_init
include: crash_handler.h
handler: sl_ot_crash_handler_init
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ category: OpenThread Examples
quality: production

component:
- id: ot_crash_handler
from: ot-efr32
- id: ot_platform_abstraction_core
- id: ot_mbedtls
- id: ot_stack_features_config
from: ot-efr32
- id: ot_core_vendor_extension
from: ot-efr32
- id: ot_ncp_spidrv
- id: rail_util_pti

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ category: OpenThread Examples
quality: production

component:
- id: ot_crash_handler
from: ot-efr32
- id: ot_platform_abstraction_core
- id: ot_mbedtls
- id: ot_stack_features_config
from: ot-efr32
- id: ot_core_vendor_extension
from: ot-efr32
- id: uartdrv_usart
instance:
- vcom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ category: OpenThread Examples
quality: production

component:
- id: ot_crash_handler
from: ot-efr32
- id: ot_platform_abstraction_core
- id: ot_psa_crypto
- id: ot_mbedtls
- id: ot_stack_features_config
from: ot-efr32
- id: ot_core_vendor_extension
from: ot-efr32
- id: uartdrv_usart
instance:
- vcom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ category: OpenThread Examples
quality: production

component:
- id: ot_crash_handler
from: ot-efr32
- id: ot_platform_abstraction_core
- id: ot_psa_crypto
- id: ot_mbedtls
- id: ot_stack_features_config
from: ot-efr32
- id: ot_core_vendor_extension
from: ot-efr32
- id: uartdrv_usart
instance:
- vcom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ category: OpenThread Examples
quality: production

component:
- id: ot_crash_handler
from: ot-efr32
- id: ot_platform_abstraction_core
- id: ot_psa_crypto
- id: ot_mbedtls
- id: ot_stack_features_config
from: ot-efr32
- id: ot_core_vendor_extension
from: ot-efr32
- id: uartdrv_usart
instance:
- vcom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ category: OpenThread Examples
quality: production

component:
- id: ot_crash_handler
from: ot-efr32
- id: ot_platform_abstraction_core
- id: ot_psa_crypto
- id: ot_mbedtls
- id: ot_stack_features_config
from: ot-efr32
- id: ot_core_vendor_extension
from: ot-efr32
- id: uartdrv_usart
instance:
- vcom
Expand Down
109 changes: 109 additions & 0 deletions src/openthread/core/vendor_extension.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright (c) 2024, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

/**
* @file
* This file implements a OpenThread vendor extension for EFR32
*/

#include "openthread-core-config.h"

#include <stdbool.h>
#include <stdint.h>

#include "common/code_utils.hpp"
#include "common/new.hpp"

#include "instance/extension.hpp"

#if defined(SL_COMPONENT_CATALOG_PRESENT)
#include "sl_component_catalog.h"
#endif

#include "platform-efr32.h"

namespace ot {
namespace Extension {

/**
* Defines the vendor extension object.
*
*/
class Extension : public ExtensionBase
{
public:
explicit Extension(Instance &aInstance)
: ExtensionBase(aInstance)
{
}
};

// ----------------------------------------------------------------------------
// `ExtensionBase` API
// ----------------------------------------------------------------------------

static OT_DEFINE_ALIGNED_VAR(sExtensionRaw, sizeof(Extension), uint64_t);

ExtensionBase &ExtensionBase::Init(Instance &aInstance)
{
ExtensionBase *ext = reinterpret_cast<ExtensionBase *>(&sExtensionRaw);

VerifyOrExit(!ext->mIsInitialized);

ext = new (&sExtensionRaw) Extension(aInstance);

exit:
return *ext;
}

void ExtensionBase::SignalInstanceInit(void)
{
// OpenThread instance is initialized and ready.

#if defined(SL_CATALOG_OT_CRASH_HANDLER_PRESENT)
efr32PrintResetInfo();
#endif
}

void ExtensionBase::SignalNcpInit(Ncp::NcpBase &aNcpBase)
{
// NCP instance is initialized and ready.
OT_UNUSED_VARIABLE(aNcpBase);

#if defined(SL_CATALOG_OT_CRASH_HANDLER_PRESENT)
efr32PrintResetInfo();
#endif
}

void ExtensionBase::HandleNotifierEvents(Events aEvents)
{
OT_UNUSED_VARIABLE(aEvents);
}

} // namespace Extension
} // namespace ot
8 changes: 8 additions & 0 deletions src/src/platform-efr32.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#ifndef PLATFORM_EFR32_H_
#define PLATFORM_EFR32_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <openthread/instance.h>

#include "em_device.h"
Expand Down Expand Up @@ -186,4 +190,8 @@ bool efr32AllowSleepCallback(void);

otError railStatusToOtError(RAIL_Status_t status);

#ifdef __cplusplus
}
#endif

#endif // PLATFORM_EFR32_H_
Loading

0 comments on commit 1d9a570

Please sign in to comment.