-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EFR32] OTA Requestor App, part 1 (#13229)
* Initial commit for EFR32 ota-requestor-app * Update EFR ota-requestor example. App compiles and runs * More EFR32 OTA file updates * Temporarily comment out LED calls as they crash the app * Updates to EFR32 OTA Requestor app * Change the requestor app from Thread FTD to MTD to save flash * Update README * Fix formatting * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Restyled by prettier-markdown * Clean up commented out code Co-authored-by: Restyled.io <[email protected]>
- Loading branch information
1 parent
eab67b3
commit a04c6d9
Showing
22 changed files
with
2,520 additions
and
0 deletions.
There are no files selected for viewing
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,28 @@ | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import("//build_overrides/build.gni") | ||
|
||
# The location of the build configuration file. | ||
buildconfig = "${build_root}/config/BUILDCONFIG.gn" | ||
|
||
# CHIP uses angle bracket includes. | ||
check_system_includes = true | ||
|
||
default_args = { | ||
target_cpu = "arm" | ||
target_os = "freertos" | ||
|
||
import("//args.gni") | ||
} |
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,190 @@ | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import("//build_overrides/build.gni") | ||
import("//build_overrides/chip.gni") | ||
import("//build_overrides/efr32_sdk.gni") | ||
import("//build_overrides/pigweed.gni") | ||
|
||
import("${build_root}/config/defaults.gni") | ||
import("${efr32_sdk_build_root}/efr32_executable.gni") | ||
import("${efr32_sdk_build_root}/efr32_sdk.gni") | ||
|
||
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") | ||
import("${chip_root}/src/platform/device.gni") | ||
|
||
if (chip_enable_pw_rpc) { | ||
import("//build_overrides/pigweed.gni") | ||
import("$dir_pw_build/target_types.gni") | ||
} | ||
|
||
assert(current_os == "freertos") | ||
|
||
efr32_project_dir = "${chip_root}/examples/ota-requestor-app/efr32" | ||
examples_plat_dir = "${chip_root}/examples/platform/efr32" | ||
|
||
declare_args() { | ||
# Dump memory usage at link time. | ||
chip_print_memory_usage = false | ||
|
||
# PIN code for PASE session establishment. | ||
setupPinCode = 73141520 | ||
setupDiscriminator = 3840 | ||
|
||
# Monitor & log memory usage at runtime. | ||
enable_heap_monitoring = false | ||
} | ||
|
||
show_qr_code = true | ||
|
||
# BRD4166A --> ThunderBoard Sense 2 (No LCD) | ||
if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") { | ||
show_qr_code = false | ||
} | ||
|
||
efr32_sdk("sdk") { | ||
sources = [ | ||
"${efr32_project_dir}/include/CHIPProjectConfig.h", | ||
"${efr32_project_dir}/include/FreeRTOSConfig.h", | ||
] | ||
|
||
include_dirs = [ | ||
"${chip_root}/src/platform/EFR32", | ||
"${efr32_project_dir}/include", | ||
"${examples_plat_dir}", | ||
] | ||
|
||
defines = [ | ||
"BOARD_ID=${efr32_board}", | ||
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", | ||
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", | ||
] | ||
|
||
if (chip_enable_pw_rpc) { | ||
defines += [ | ||
"HAL_VCOM_ENABLE=1", | ||
"PW_RPC_ENABLED", | ||
] | ||
} | ||
} | ||
|
||
efr32_executable("ota_requestor_app") { | ||
output_name = "chip-efr32-ota-requestor-example.out" | ||
|
||
sources = [ | ||
"${examples_plat_dir}/LEDWidget.cpp", | ||
"${examples_plat_dir}/heap_4_silabs.c", | ||
"${examples_plat_dir}/init_efrPlatform.cpp", | ||
"${examples_plat_dir}/uart.cpp", | ||
"src/AppTask.cpp", | ||
"src/LightingManager.cpp", | ||
"src/ZclCallbacks.cpp", | ||
"src/main.cpp", | ||
] | ||
|
||
deps = [ | ||
":sdk", | ||
"${chip_root}/examples/common/QRCode", | ||
"${chip_root}/examples/ota-requestor-app/ota-requestor-common", | ||
"${chip_root}/src/lib", | ||
"${chip_root}/src/setup_payload", | ||
"${chip_root}/third_party/openthread/platforms:libopenthread-platform", | ||
"${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", | ||
"${examples_plat_dir}:efr-matter-shell", | ||
] | ||
|
||
if (chip_openthread_ftd) { | ||
deps += [ | ||
"${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd", | ||
"${chip_root}/third_party/openthread/repo:libopenthread-ftd", | ||
] | ||
} else { | ||
deps += [ | ||
"${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd", | ||
"${chip_root}/third_party/openthread/repo:libopenthread-mtd", | ||
] | ||
} | ||
|
||
include_dirs = [ "include" ] | ||
|
||
defines = [] | ||
|
||
if (show_qr_code) { | ||
sources += [ "${examples_plat_dir}/display/lcd.c" ] | ||
defines += [ "DISPLAY_ENABLED" ] | ||
} | ||
|
||
if (chip_enable_pw_rpc) { | ||
defines += [ | ||
"PW_RPC_ENABLED", | ||
"PW_RPC_ATTRIBUTE_SERVICE=1", | ||
"PW_RPC_BUTTON_SERVICE=1", | ||
"PW_RPC_DEVICE_SERVICE=1", | ||
"PW_RPC_LIGHTING_SERVICE=1", | ||
] | ||
|
||
sources += [ | ||
"${chip_root}/examples/common/pigweed/RpcService.cpp", | ||
"${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp", | ||
"${examples_plat_dir}/PigweedLogger.cpp", | ||
"${examples_plat_dir}/Rpc.cpp", | ||
] | ||
|
||
deps += [ | ||
"$dir_pw_hdlc:rpc_channel_output", | ||
"$dir_pw_stream:sys_io_stream", | ||
"${chip_root}/config/efr32/lib/pw_rpc:pw_rpc", | ||
"${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc", | ||
"${chip_root}/examples/common/pigweed:button_service.nanopb_rpc", | ||
"${chip_root}/examples/common/pigweed:device_service.nanopb_rpc", | ||
"${chip_root}/examples/common/pigweed:lighting_service.nanopb_rpc", | ||
"${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32", | ||
] | ||
|
||
deps += pw_build_LINK_DEPS | ||
|
||
include_dirs += [ | ||
"${chip_root}/examples/common", | ||
"${chip_root}/examples/common/pigweed/efr32", | ||
] | ||
} | ||
|
||
if (enable_heap_monitoring) { | ||
sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ] | ||
defines += [ "HEAP_MONITORING" ] | ||
} | ||
|
||
ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld" | ||
|
||
inputs = [ ldscript ] | ||
|
||
ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] | ||
|
||
if (chip_print_memory_usage) { | ||
ldflags += [ | ||
"-Wl,--print-memory-usage", | ||
"-fstack-usage", | ||
] | ||
} | ||
|
||
output_dir = root_out_dir | ||
} | ||
|
||
group("efr32") { | ||
deps = [ ":ota_requestor_app" ] | ||
} | ||
|
||
group("default") { | ||
deps = [ ":efr32" ] | ||
} |
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,100 @@ | ||
#CHIP EFR32 OTA Requestor Example | ||
|
||
An example showing the use of the Matter OTA Requestor functionality on the | ||
Silicon Labs EFR32 MG12. | ||
|
||
<a name="intro"></a> | ||
|
||
## Introduction | ||
|
||
The EFR32 OTA Requestor example provides a baseline demonstration the Matter OTA | ||
Requestor functionality built with the Silicon Labs gecko SDK. It can be | ||
controlled by a Chip controller over Openthread network.. | ||
|
||
<a name="building"></a> | ||
|
||
## Building | ||
|
||
For initial setup steps please see the CHIP EFR32 Lighting Example README at | ||
examples/lighting-app/efr32/README.md | ||
|
||
- Supported hardware: | ||
|
||
MG12 boards: | ||
|
||
- BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm | ||
- BRD4164A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm | ||
- BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm | ||
- BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, | ||
915MHz@19dBm | ||
- BRD4304A / SLWSTK6000B / MGM12P Module / 2.4GHz@19dBm | ||
|
||
MG21 boards: Currently not supported due to RAM limitation. | ||
|
||
- BRD4180A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm | ||
|
||
MG24 boards : | ||
|
||
- BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm | ||
- BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm | ||
|
||
* Build the example application: | ||
|
||
cd ~/connectedhomeip | ||
./scripts/examples/gn_efr32_example.sh ./examples/ota-requestor-app/efr32/ ./out/ota-requestor-app BRD4161A | ||
|
||
- To delete generated executable, libraries and object files use: | ||
|
||
$ cd ~/connectedhomeip | ||
$ rm -rf ./out/ | ||
|
||
## Flashing the Application | ||
|
||
- On the command line: | ||
|
||
$ cd ~/connectedhomeip/out/ota-requestor-app/BRD4161A | ||
$ python3 chip-efr32-ota-requestor-example.flash.py | ||
|
||
- Or with the Ozone debugger, just load the .out file. | ||
|
||
<a name="view-logging"></a> | ||
|
||
## Viewing Logging Output | ||
|
||
See examples/lighting-app/efr32/README.md | ||
|
||
## Running the OTA Download scenario | ||
|
||
- Bring up the Open Thread Border Router as discussed in | ||
examples/lighting-app/efr32/README.md and get its operational dataset. | ||
|
||
- On a Linux or Darwin platform build the chip-tool and the ota-provider-app | ||
as follows: | ||
|
||
scripts/examples/gn_build_example.sh examples/chip-tool out/ | ||
scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/debug chip_config_network_layer_ble=false | ||
|
||
- In a terminal start the provider app passing to it the path to the image | ||
file that the Requestor is supposed to download (for example /tmp/ota.out): | ||
|
||
./out/debug/chip-ota-provider-app -f /tmp/ota.out | ||
|
||
- In a separate terminal run the chip-tool commands to provision the Provider: | ||
|
||
rm -r /tmp/chip_* | ||
./out/chip-tool pairing onnetwork 1 20202021 | ||
|
||
- If the Requestor had been previously commissioned hold Button 0 for six | ||
seconds to factory-reset the device. | ||
|
||
- In the chip-tool terminal enter: | ||
|
||
./out/chip-tool pairing ble-thread 2 hex:<operationalDataset> 73141520 3840 | ||
|
||
where operationalDataset is obtained from the Open Thread Border Router. | ||
|
||
- Once the commissioning process completes enter: | ||
|
||
./out/chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 0 2 0 | ||
|
||
- The Requestor will connect to the Provider and start the image download. |
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,28 @@ | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import("//build_overrides/chip.gni") | ||
import("//build_overrides/pigweed.gni") | ||
import("${chip_root}/src/platform/EFR32/args.gni") | ||
|
||
efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") | ||
|
||
pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" | ||
pw_assert_BACKEND = "$dir_pw_assert_log" | ||
chip_enable_openthread = true | ||
chip_openthread_ftd = false | ||
|
||
declare_args() { | ||
chip_enable_ota_requestor = true | ||
} |
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 @@ | ||
../../build_overrides |
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,46 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* Copyright (c) 2019 Google LLC. | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
// ---- Lighting Example App Config ---- | ||
|
||
#define APP_TASK_NAME "APP" | ||
|
||
// Time it takes in ms for the simulated actuator to move from one | ||
// state to another. | ||
#define ACTUATOR_MOVEMENT_PERIOS_MS 10 | ||
|
||
// EFR Logging | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
void efr32LogInit(void); | ||
|
||
void efr32Log(const char * aFormat, ...); | ||
#define EFR32_LOG(...) efr32Log(__VA_ARGS__); | ||
void appError(int err); | ||
|
||
#ifdef __cplusplus | ||
} | ||
|
||
#include <lib/core/CHIPError.h> | ||
void appError(CHIP_ERROR error); | ||
#endif |
Oops, something went wrong.