Skip to content

Commit 1090640

Browse files
s07641069UR6LALmishadesh
authored andcommitted
[Telink] Add Shell app demo (#28097)
* UTCSH-274: add Telink draft shell app * UTCSH-274: add shell draft app * [Telink]: Examples: Shell: Introduced shell sample for Telink platform Introduced shell sample for Telink platform. Signed-off-by: Misha Tkachenko <[email protected]> * using common main.cpp file in shell folder * [Telink] Fix code style issues * [Telink] Fix workflow issues * [Telink] Fix workflow issues * [Telink] Fix workflow issues --------- Signed-off-by: Misha Tkachenko <[email protected]> Co-authored-by: dmytro.k <[email protected]> Co-authored-by: Misha Tkachenko <[email protected]> Co-authored-by: dmytro.kashkarov <[email protected]>
1 parent b80f54d commit 1090640

File tree

11 files changed

+266
-1
lines changed

11 files changed

+266
-1
lines changed

.github/workflows/examples-telink.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,18 @@ jobs:
213213
- name: clean out build output
214214
run: rm -rf ./out
215215

216+
- name: Build example Telink Shell App
217+
run: |
218+
./scripts/run_in_build_env.sh \
219+
"./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-shell' build"
220+
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
221+
telink tlsr9518adk80d shell \
222+
out/telink-tlsr9518adk80d-shell/zephyr/zephyr.elf \
223+
/tmp/bloat_reports/
224+
225+
- name: clean out build output
226+
run: rm -rf ./out
227+
216228
- name: Build example Telink Smoke CO Alarm App
217229
run: |
218230
./scripts/run_in_build_env.sh \

.vscode/tasks.json

+1
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@
673673
"telink-tlsr9518adk80d-ota-requestor",
674674
"telink-tlsr9518adk80d-pump-app",
675675
"telink-tlsr9518adk80d-pump-controller-app",
676+
"telink-tlsr9518adk80d-shell",
676677
"telink-tlsr9518adk80d-smoke-co-alarm-app",
677678
"telink-tlsr9518adk80d-temperature-measurement",
678679
"telink-tlsr9518adk80d-thermostat",

examples/shell/telink/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build/

examples/shell/telink/CMakeLists.txt

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#
2+
# Copyright (c) 2023 Project CHIP Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
cmake_minimum_required(VERSION 3.13.1)
17+
18+
set(BOARD tlsr9518adk80d)
19+
20+
get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connectedhomeip REALPATH)
21+
get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH)
22+
get_filename_component(APP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/.. REALPATH)
23+
24+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.overlay")
25+
set(LOCAL_DTC_OVERLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.overlay")
26+
else()
27+
unset(LOCAL_DTC_OVERLAY_FILE)
28+
endif()
29+
30+
if(EXISTS "${CHIP_ROOT}/src/platform/telink/${BOARD}.overlay")
31+
set(GLOBAL_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${BOARD}.overlay")
32+
else()
33+
unset(GLOBAL_DTC_OVERLAY_FILE)
34+
endif()
35+
36+
if(DTC_OVERLAY_FILE)
37+
set(DTC_OVERLAY_FILE
38+
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
39+
CACHE STRING "" FORCE
40+
)
41+
else()
42+
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
43+
endif()
44+
45+
set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf)
46+
47+
# Load NCS/Zephyr build system
48+
list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module)
49+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
50+
51+
project(chip-telink-shell-example)
52+
53+
include(${CHIP_ROOT}/config/telink/app/enable-gnu-std.cmake)
54+
include(${CHIP_ROOT}/src/app/chip_data_model.cmake)
55+
56+
target_compile_options(app PRIVATE -fpermissive)
57+
58+
target_include_directories(app PRIVATE
59+
include
60+
${GEN_DIR}/app-common
61+
${APP_ROOT}/shell_common/include)
62+
63+
add_definitions(
64+
"-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>"
65+
)
66+
67+
target_sources(app PRIVATE
68+
${APP_ROOT}/shell_common/globals.cpp
69+
${APP_ROOT}/shell_common/cmd_misc.cpp
70+
${APP_ROOT}/shell_common/cmd_otcli.cpp
71+
${APP_ROOT}/standalone/main.cpp)

examples/shell/telink/README.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Matter Telink Shell Example Application
2+
3+
You can use this example as a reference for creating your own application.
4+
5+
![Telink B91 EVK](http://wiki.telink-semi.cn/wiki/assets/Hardware/B91_Generic_Starter_Kit_Hardware_Guide/connection_chart.png)
6+
7+
## Build and flash
8+
9+
1. Pull docker image from repository:
10+
11+
```bash
12+
$ docker pull connectedhomeip/chip-build-telink:latest
13+
```
14+
15+
1. Run docker container:
16+
17+
```bash
18+
$ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" connectedhomeip/chip-build-telink:latest
19+
```
20+
21+
here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay
22+
attention that OUTPUT_DIR should contains ABSOLUTE path to output dir**
23+
24+
1. Activate the build environment:
25+
26+
```bash
27+
$ source ./scripts/activate.sh
28+
```
29+
30+
1. In the example dir run:
31+
32+
```bash
33+
$ west build
34+
```
35+
36+
1. Flash binary:
37+
38+
```
39+
$ west flash --erase
40+
```
41+
42+
## Usage
43+
44+
### UART
45+
46+
To get output from device, connect UART to following pins:
47+
48+
| Name | Pin |
49+
| :--: | :---------------------------- |
50+
| RX | PB3 (pin 17 of J34 connector) |
51+
| TX | PB2 (pin 16 of J34 connector) |
52+
| GND | GND |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
*
3+
* Copyright (c) 2023 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* @file
21+
* Example project configuration file for CHIP.
22+
*
23+
* This is a place to put application or project-specific overrides
24+
* to the default configuration values for general CHIP features.
25+
*
26+
*/
27+
28+
#pragma once
29+
30+
// Use a default pairing code if one hasn't been provisioned in flash.
31+
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021
32+
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00
33+
34+
/**
35+
* CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE
36+
*
37+
* Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption
38+
*/
39+
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8
40+
41+
// Enable support functions for parsing command-line arguments
42+
#define CHIP_CONFIG_ENABLE_ARG_PARSER 1
43+
44+
#define CHIP_DEVICE_CONFIG_DISABLE_SHELL_PING 1
45+
46+
// shell app uses openthread but does not have the NETWORK_COMMISSIONING cluster or zap config
47+
// Do not instantiate the NETWORK_COMMISSIONING thread driver
48+
#define _NO_NETWORK_COMMISSIONING_DRIVER_

examples/shell/telink/prj.conf

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#
2+
# Copyright (c) 2023 Project CHIP Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
# This sample uses sample-defaults.conf to set options common for all
18+
# samples. This file should contain only options specific for this sample
19+
# or overrides of default values.
20+
21+
# enable GPIO
22+
CONFIG_GPIO=y
23+
24+
# enable PWM
25+
CONFIG_PWM=y
26+
27+
# OpenThread configs
28+
#CONFIG_OPENTHREAD_MTD=n
29+
CONFIG_OPENTHREAD_FTD=y
30+
# CONFIG_CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT=y
31+
CONFIG_CHIP_THREAD_SSED=n
32+
33+
# Default OpenThread network settings
34+
CONFIG_OPENTHREAD_PANID=4660
35+
CONFIG_OPENTHREAD_CHANNEL=15
36+
CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo"
37+
CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22"
38+
39+
# Disable Matter OTA DFU
40+
CONFIG_CHIP_OTA_REQUESTOR=n
41+
42+
# CHIP configuration
43+
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
44+
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"
45+
46+
CONFIG_CHIP_DEVICE_VENDOR_ID=65521
47+
# 32786 == 0x8012 (example shell-app)
48+
CONFIG_CHIP_DEVICE_PRODUCT_ID=32786
49+
CONFIG_CHIP_DEVICE_TYPE=65535
50+
51+
CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1
52+
CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2023"
53+
54+
# Enable CHIP pairing automatically on application start.
55+
CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y
56+
57+
# CHIP shell
58+
CONFIG_CHIP_LIB_SHELL=y
59+
CONFIG_OPENTHREAD_SHELL=y
60+
CONFIG_SHELL=y
61+
62+
# Disable factory data support.
63+
CONFIG_CHIP_FACTORY_DATA=n
64+
CONFIG_CHIP_FACTORY_DATA_BUILD=n
65+
CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n
66+
CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n
67+
68+
# Enable Power Management
69+
CONFIG_PM=n
70+
71+
# Custom RF power values
72+
CONFIG_B91_BLE_CTRL_RF_POWER_P9P11DBM=y
73+
CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../..

scripts/build/build/targets.py

+1
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ def BuildTelinkTarget():
666666
TargetPart('ota-requestor', app=TelinkApp.OTA_REQUESTOR),
667667
TargetPart('pump', app=TelinkApp.PUMP),
668668
TargetPart('pump-controller', app=TelinkApp.PUMP_CONTROLLER),
669+
TargetPart('shell', app=TelinkApp.SHELL),
669670
TargetPart('smoke-co-alarm', app=TelinkApp.SMOKE_CO_ALARM),
670671
TargetPart('temperature-measurement',
671672
app=TelinkApp.TEMPERATURE_MEASUREMENT),

scripts/build/builders/telink.py

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class TelinkApp(Enum):
3131
OTA_REQUESTOR = auto()
3232
PUMP = auto()
3333
PUMP_CONTROLLER = auto()
34+
SHELL = auto()
3435
SMOKE_CO_ALARM = auto()
3536
TEMPERATURE_MEASUREMENT = auto()
3637
THERMOSTAT = auto()
@@ -57,6 +58,8 @@ def ExampleName(self):
5758
return 'pump-app'
5859
elif self == TelinkApp.PUMP_CONTROLLER:
5960
return 'pump-controller-app'
61+
elif self == TelinkApp.SHELL:
62+
return 'shell'
6063
elif self == TelinkApp.SMOKE_CO_ALARM:
6164
return 'smoke-co-alarm-app'
6265
elif self == TelinkApp.TEMPERATURE_MEASUREMENT:
@@ -89,6 +92,8 @@ def AppNamePrefix(self):
8992
return 'chip-telink-pump-example'
9093
elif self == TelinkApp.PUMP_CONTROLLER:
9194
return 'chip-telink-pump-controller-example'
95+
elif self == TelinkApp.SHELL:
96+
return 'chip-telink-shell-example'
9297
elif self == TelinkApp.SMOKE_CO_ALARM:
9398
return 'chip-telink-smoke-co-alarm-example'
9499
elif self == TelinkApp.TEMPERATURE_MEASUREMENT:

scripts/build/testdata/all_targets_linux_x64.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ nrf-{nrf5340dk,nrf52840dk,nrf52840dongle}-{all-clusters,all-clusters-minimal,loc
2121
nrf-native-posix-64-tests
2222
qpg-qpg6105-{lock,light,shell,persistent-storage}
2323
tizen-arm-{all-clusters,all-clusters-minimal,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan]
24-
telink-tlsr9518adk80d-{all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-shell][-rpc][-factory-data]
24+
telink-tlsr9518adk80d-{all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-shell][-rpc][-factory-data]
2525
openiotsdk-{shell,lock}[-mbedtls][-psa]

0 commit comments

Comments
 (0)