Skip to content

Commit

Permalink
Upgrade OpenThread RCP
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Oct 15, 2024
1 parent c5dd782 commit 8d38918
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 71 deletions.
2 changes: 1 addition & 1 deletion manifests/nabucasa/skyconnect_openthread_rcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: SkyConnect OpenThread RCP
device: EFR32MG21A020F512IM32
base_project: src/openthread_rcp
filename: "{manifest_name}_{ot_rcp_version.split('/')[-1]}_gsdk_{sdk_version}"
sdk: "gecko_sdk:4.4.4"
sdk: "simplicity_sdk:2024.6.2"
toolchain: "12.2.1.20221205"

gbl:
Expand Down
2 changes: 1 addition & 1 deletion manifests/nabucasa/yellow_openthread_rcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Yellow OpenThread RCP
device: MGM210PA32JIA
base_project: src/openthread_rcp
filename: "{manifest_name}_{ot_rcp_version.split('/')[-1]}_gsdk_{sdk_version}"
sdk: "gecko_sdk:4.4.4"
sdk: "simplicity_sdk:2024.6.2"
toolchain: "12.2.1.20221205"

gbl:
Expand Down
86 changes: 64 additions & 22 deletions src/openthread_rcp/app.c
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,41 +1,72 @@
/***************************************************************************//**
/*******************************************************************************
* @file
* @brief Core application logic.
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/

#include <assert.h>
#include <openthread-core-config.h>
#include <openthread/config.h>

#include <openthread/ncp.h>
#include <openthread/diag.h>
#include <openthread/ncp.h>
#include <openthread/tasklet.h>

#include "openthread-system.h"
#include "app.h"
#include "openthread-system.h"

#include "reset_util.h"

#include "sl_component_catalog.h"
#include "sl_memory_manager.h"

#if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
#if OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE == 0
#error "Support for multiple OpenThread static instance is disabled."
#endif
otInstance *sInstances[OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_NUM] = {NULL};
#endif // OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE

/**
* This function initializes the NCP app.
*
* @param[in] aInstance The OpenThread instance structure.
*
*/
#if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
extern void otAppNcpInitMulti(otInstance **aInstances, uint8_t aCount);
#else
extern void otAppNcpInit(otInstance *aInstance);
#endif

static otInstance* sInstance = NULL;
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE && !OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
static uint8_t *sOtInstanceBuffer = NULL;
#endif
static otInstance *sInstance = NULL;

otInstance *otGetInstance(void)
{
Expand All @@ -44,19 +75,26 @@ otInstance *otGetInstance(void)

void sl_ot_create_instance(void)
{
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
size_t otInstanceBufferLength = 0;
uint8_t *otInstanceBuffer = NULL;
#if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
for (int i = 0; i < OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_NUM; i++)
{
sInstances[i] = otInstanceInitMultiple(i);

assert(sInstances[i]);
}
sInstance = sInstances[0];
#elif OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE && !OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
size_t otInstanceBufferLength = 0;

// Call to query the buffer size
(void)otInstanceInit(NULL, &otInstanceBufferLength);

// Call to allocate the buffer
otInstanceBuffer = (uint8_t *)malloc(otInstanceBufferLength);
assert(otInstanceBuffer);
sOtInstanceBuffer = (uint8_t *)sl_malloc(otInstanceBufferLength);
assert(sOtInstanceBuffer);

// Initialize OpenThread with the buffer
sInstance = otInstanceInit(otInstanceBuffer, &otInstanceBufferLength);
sInstance = otInstanceInit(sOtInstanceBuffer, &otInstanceBufferLength);
#else
sInstance = otInstanceInitSingle();
#endif
Expand All @@ -65,10 +103,14 @@ void sl_ot_create_instance(void)

void sl_ot_ncp_init(void)
{
#if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
otAppNcpInitMulti(sInstances, OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_NUM);
#else
otAppNcpInit(sInstance);
#endif
}

/**************************************************************************//**
/******************************************************************************
* Application Init.
*****************************************************************************/

Expand All @@ -77,7 +119,7 @@ void app_init(void)
OT_SETUP_RESET_JUMP(argv);
}

/**************************************************************************//**
/******************************************************************************
* Application Process Action.
*****************************************************************************/
void app_process_action(void)
Expand All @@ -86,14 +128,14 @@ void app_process_action(void)
otSysProcessDrivers(sInstance);
}

/**************************************************************************//**
/******************************************************************************
* Application Exit.
*****************************************************************************/
void app_exit(void)
{
otInstanceFinalize(sInstance);
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
free(otInstanceBuffer);
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE && !OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
sl_free(sOtInstanceBuffer);
#endif
// TO DO : pseudo reset?
}
37 changes: 25 additions & 12 deletions src/openthread_rcp/app.h
Original file line number Diff line number Diff line change
@@ -1,36 +1,49 @@
/***************************************************************************//**
/*******************************************************************************
* @file
* @brief Application interface provided to main().
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/

#ifndef APP_H
#define APP_H

/**************************************************************************//**
/******************************************************************************
* Application Init.
*****************************************************************************/
void app_init(void);

/**************************************************************************//**
/******************************************************************************
* Application Exit.
*****************************************************************************/
void app_exit(void);

/**************************************************************************//**
/******************************************************************************
* Application Process Action.
*****************************************************************************/
void app_process_action(void);

#endif
#endif
75 changes: 45 additions & 30 deletions src/openthread_rcp/main.c
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
/***************************************************************************//**
/*******************************************************************************
* @file
* @brief main() function.
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/

#include "app.h"
#include "sl_component_catalog.h"
#include "sl_system_init.h"
#include "app.h"
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
#include "sl_power_manager.h"
#endif // SL_CATALOG_POWER_MANAGER_PRESENT
Expand All @@ -28,33 +42,34 @@

int main(void)
{
// Initialize Silicon Labs device, system, service(s) and protocol stack(s).
// Note that if the kernel is present, processing task(s) will be created by
// this call.
sl_system_init();
// Initialize Silicon Labs device, system, service(s) and protocol stack(s).
// Note that if the kernel is present, processing task(s) will be created by
// this call.
sl_system_init();

// Initialize the application. For example, create periodic timer(s) or
// task(s) if the kernel is present.
app_init();
// Initialize the application. For example, create periodic timer(s) or
// task(s) if the kernel is present.
app_init();

#if defined(SL_CATALOG_KERNEL_PRESENT)
// Start the kernel. Task(s) created in app_init() will start running.
sl_system_kernel_start();
// Start the kernel. Task(s) created in app_init() will start running.
sl_system_kernel_start();
#else // SL_CATALOG_KERNEL_PRESENT
while (1) {
// Do not remove this call: Silicon Labs components process action routine
// must be called from the super loop.
sl_system_process_action();
while (1)
{
// Do not remove this call: Silicon Labs components process action routine
// must be called from the super loop.
sl_system_process_action();

// Application process.
app_process_action();
// Application process.
app_process_action();

#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
// Let the CPU go to sleep if the system allows it.
sl_power_manager_sleep();
// Let the CPU go to sleep if the system allows it.
sl_power_manager_sleep();
#endif
}
// Clean-up when exiting the application.
app_exit();
}
// Clean-up when exiting the application.
app_exit();
#endif // SL_CATALOG_KERNEL_PRESENT
}
}
6 changes: 3 additions & 3 deletions src/openthread_rcp/openthread_rcp.slcp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ component:
- vcom
- id: rail_util_pti
- id: bootloader_interface
- id: clock_manager

include:
- path: .
Expand All @@ -40,12 +41,11 @@ configuration:
- name: BUFFER_SIZE_UP
value: 768
condition: [ot_rtt_log]
- name: BUFFER_SIZE_UP
value: 128
condition: [ot_rtt_log, device_family_efr32mg1]
- name: BUFFER_SIZE_DOWN
value: 0
condition: [ot_rtt_log]
- name: CIRCULAR_QUEUE_LEN_MAX
value: 16

filter:
- name: "Wireless Technology"
Expand Down
4 changes: 2 additions & 2 deletions src/openthread_rcp/reset_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#if defined(OPENTHREAD_ENABLE_COVERAGE) && OPENTHREAD_ENABLE_COVERAGE && defined(__GNUC__)
#if __GNUC__ >= 11 || (defined(__clang__) && (defined(__APPLE__) && (__clang_major__ >= 13)) || \
(!defined(__APPLE__) && (__clang_major__ >= 12)))
void __gcov_dump();
void __gcov_reset();
void __gcov_dump(void);
void __gcov_reset(void);

static void flush_gcov(void)
{
Expand Down

0 comments on commit 8d38918

Please sign in to comment.