Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from Gecko SDK 4.4.4 to Simplicity SDK 2024.6.2 #83

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ RUN \
&& unzip -q -d simplicity_sdk_2024.6.2 simplicity_sdk_2024.6.2.zip \
&& rm simplicity_sdk_2024.6.2.zip

# Gecko SDK 4.4.4
RUN \
curl -o gecko_sdk_4.4.4.zip -L https://github.com/SiliconLabs/gecko_sdk/releases/download/v4.4.4/gecko-sdk.zip \
&& unzip -q -d gecko_sdk_4.4.4 gecko_sdk_4.4.4.zip \
&& rm gecko_sdk_4.4.4.zip

ARG USERNAME=builder
ARG USER_UID=1000
ARG USER_GID=$USER_UID
Expand Down
30 changes: 14 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ ZBT-1/SkyConnect and the Home Assistant Yellow's IEEE 802.15.4 radio. The firmwa
manifests are entirely generic, however, and are intended to be written easily for any
Silicon Labs EFR32 device.

It uses the Silicon Labs Gecko SDK and proprietary Silicon Labs tools such as the
Silicon Labs Configurator (slc) and the Simplicity Commander standalone utility.
It uses the Silicon Labs Gecko/Simplicity SDK and proprietary Silicon Labs tools such as
the Silicon Labs Configurator (slc) and the Simplicity Commander standalone utility.

## Background
The project templates in this repository are configured and built for specific boards
Expand All @@ -14,34 +14,32 @@ manifest file configures the Zigbee firmware for the SkyConnect/Connect ZBT-1.

## Setting up Simplicity Studio (for development)
If you are going to be developing using Simplicity Studio, note that each project can
potentially use a different Gecko SDK release. It is recommended to forego the typical
potentially use a different Simplicity SDK release. It is recommended to forego the typical
Simplicity Studio SDK management workflow and manually manage SDKs:

1. Clone a specific version of the Gecko SDK:
1. Clone a specific version of the Simplicity SDK:
```bash
# For macOS
mkdir ~/SimplicityStudio/SDKs/gecko_sdk_4.4.2
cd ~/SimplicityStudio/SDKs/gecko_sdk_4.4.2
mkdir ~/SimplicityStudio/SDKs/simplicity_sdk_2024.6.2
cd ~/SimplicityStudio/SDKs/simplicity_sdk_2024.6.2

git clone -b v4.4.2 https://github.com/SiliconLabs/gecko_sdk .
git clone -b v2024.6.2 https://github.com/SiliconLabs/simplicity_sdk .
git checkout -b branch_tag
```

2. Open preferences, navigate to **Simplicity Studio > SDKs**, click the `Add SDK...` button, and browse to the above location.
3. Once the SDK is added, select its entry and click `Add Extension...`.
4. In this repo, add the extensions under `gecko_sdk_extensions`.

Repeat this process for every necessary SDK version.

> [!TIP]
> If you have build issues after switching commits, make sure to delete any
> `gecko_sdk_*` and `template` folders from the Simplicity working tree.
> `simplicity_sdk_*`, `gecko_sdk_*`, and `template` folders from the project working tree.

## Building with a firmware manifest (for building device firmware)
Command line building requires:
- [`slc-cli`](https://docs.silabs.com/simplicity-studio-5-users-guide/latest/ss-5-users-guide-tools-slc-cli/02-installation)
- [Simplicity Commander](https://www.silabs.com/developers/mcu-programming-options) (`commander`)
- The exact Gecko SDK version required by the project. Note that this doesn't have to be a Git working tree, you can use [a GitHub release](https://github.com/SiliconLabs/gecko_sdk/releases).
- The exact Simplicity SDK version required by the project. Note that this doesn't have to be a Git working tree, you can use [a GitHub release](https://github.com/SiliconLabs/gecko_sdk/releases).
- A compatible toolchain. Take a look at the `Dockerfile` for the necessary toolchains.

> [!TIP]
Expand All @@ -57,8 +55,8 @@ Command line building requires:
SDK extensions for every SDK you plan to use:

```bash
slc signature trust --sdk ~/SimplicityStudio/SDKs/gecko_sdk_4.4.2
slc signature trust --sdk ~/SimplicityStudio/SDKs/gecko_sdk_4.4.2 --extension-path ~/SimplicityStudio/SDKs/gecko_sdk_4.4.2/extension/nc_efr32_watchdog_extension
slc signature trust --sdk ~/SimplicityStudio/SDKs/simplicity_sdk_2024.6.2
slc signature trust --sdk ~/SimplicityStudio/SDKs/simplicity_sdk_2024.6.2 --extension-path ~/SimplicityStudio/SDKs/simplicity_sdk_2024.6.2/extension/nc_efr32_watchdog_extension
```

`tools/build_project.py` is the main entry point for building firmwares. Provide paths
Expand All @@ -73,9 +71,9 @@ tool will automatically determine which SDK and toolchain to use.
pip install ruamel.yaml # Only dependency

python tools/build_project.py \
# The following SDK and toolchain flags can be omitted on macOS
--sdk ~/SimplicityStudio/SDKs/gecko_sdk_4.4.0 \
--sdk ~/SimplicityStudio/SDKs/gecko_sdk_4.4.2 \
# The following SDK and toolchain flags can be omitted on macOS, they are all autodetected
--sdk ~/SimplicityStudio/SDKs/gecko_sdk_4.4.4 \
--sdk ~/SimplicityStudio/SDKs/simplicity_sdk_2024.6.0 \
--toolchain '/Applications/Simplicity Studio.app/Contents/Eclipse/developer/toolchains/gnu_arm/10.3_2021.10' \
--toolchain '/Applications/Simplicity Studio.app/Contents/Eclipse/developer/toolchains/gnu_arm/12.2.rel1_2023.7' \

Expand Down
2 changes: 1 addition & 1 deletion manifests/nabucasa/skyconnect_bootloader.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: SkyConnect Bootloader
device: EFR32MG21A020F512IM32
base_project: src/bootloader
filename: "{manifest_name}_{gecko_bootloader_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/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
17 changes: 8 additions & 9 deletions manifests/nabucasa/skyconnect_zigbee_ncp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: SkyConnect Zigbee
device: EFR32MG21A020F512IM32
base_project: src/zigbee_ncp
filename: "{manifest_name}_{ezsp_version}"
sdk: "gecko_sdk:4.4.4"
sdk: "simplicity_sdk:2024.6.2"
toolchain: "12.2.1.20221205"

gbl:
Expand All @@ -11,16 +11,15 @@ gbl:
baudrate: 115200

configuration:
EMBER_CHILD_TABLE_SIZE: 32
SL_ZIGBEE_CHILD_TABLE_SIZE: 32

c_defines:
EMBER_APS_UNICAST_MESSAGE_COUNT: 32
EMBER_BINDING_TABLE_SIZE: 32
EMBER_BROADCAST_TABLE_SIZE: 64
EMBER_KEY_TABLE_SIZE: 12
EMBER_MAX_END_DEVICE_CHILDREN: 32
EMBER_PACKET_BUFFER_COUNT: 255
EMBER_SOURCE_ROUTE_TABLE_SIZE: 200
SL_ZIGBEE_APS_UNICAST_MESSAGE_COUNT: 32
SL_ZIGBEE_BINDING_TABLE_SIZE: 32
SL_ZIGBEE_BROADCAST_TABLE_SIZE: 64
SL_ZIGBEE_KEY_TABLE_SIZE: 12
SL_ZIGBEE_MAX_END_DEVICE_CHILDREN: 32
SL_ZIGBEE_SOURCE_ROUTE_TABLE_SIZE: 200

SL_IOSTREAM_USART_VCOM_BAUDRATE: 115200
SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE: usartHwFlowControlCtsAndRts
Expand Down
2 changes: 1 addition & 1 deletion manifests/nabucasa/yellow_bootloader.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Yellow Bootloader
device: MGM210PA32JIA
base_project: src/bootloader
filename: "{manifest_name}_{gecko_bootloader_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
17 changes: 8 additions & 9 deletions manifests/nabucasa/yellow_zigbee_ncp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Yellow Zigbee
device: MGM210PA32JIA
base_project: src/zigbee_ncp
filename: "{manifest_name}_{ezsp_version}"
sdk: "gecko_sdk:4.4.4"
sdk: "simplicity_sdk:2024.6.2"
toolchain: "12.2.1.20221205"

gbl:
Expand All @@ -15,16 +15,15 @@ add_components:
instance: [board_activity]

configuration:
EMBER_CHILD_TABLE_SIZE: 32
SL_ZIGBEE_CHILD_TABLE_SIZE: 32

c_defines:
EMBER_APS_UNICAST_MESSAGE_COUNT: 32
EMBER_BINDING_TABLE_SIZE: 32
EMBER_BROADCAST_TABLE_SIZE: 64
EMBER_KEY_TABLE_SIZE: 12
EMBER_MAX_END_DEVICE_CHILDREN: 32
EMBER_PACKET_BUFFER_COUNT: 255
EMBER_SOURCE_ROUTE_TABLE_SIZE: 200
SL_ZIGBEE_APS_UNICAST_MESSAGE_COUNT: 32
SL_ZIGBEE_BINDING_TABLE_SIZE: 32
SL_ZIGBEE_BROADCAST_TABLE_SIZE: 64
SL_ZIGBEE_KEY_TABLE_SIZE: 12
SL_ZIGBEE_MAX_END_DEVICE_CHILDREN: 32
SL_ZIGBEE_SOURCE_ROUTE_TABLE_SIZE: 200

SL_IOSTREAM_USART_VCOM_BAUDRATE: 115200
SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE: usartHwFlowControlCtsAndRts
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?
}
Loading
Loading