Skip to content

Commit

Permalink
[Telink] Add Shell app demo (#28097)
Browse files Browse the repository at this point in the history
* 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 <misha.tkachenko@telink-semi.com>

* 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 <misha.tkachenko@telink-semi.com>
Co-authored-by: dmytro.k <ur6lal@gmail.com>
Co-authored-by: Misha Tkachenko <misha.tkachenko@telink-semi.com>
Co-authored-by: dmytro.kashkarov <dmytro.kashkarov@telink-semi.com>
  • Loading branch information
4 people authored and pull[bot] committed Sep 11, 2023
1 parent 1701019 commit 1229252
Show file tree
Hide file tree
Showing 11 changed files with 266 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/workflows/examples-telink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ jobs:
- name: clean out build output
run: rm -rf ./out

- name: Build example Telink Shell App
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-shell' build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
telink tlsr9518adk80d shell \
out/telink-tlsr9518adk80d-shell/zephyr/zephyr.elf \
/tmp/bloat_reports/
- name: clean out build output
run: rm -rf ./out

- name: Build example Telink Smoke CO Alarm App
run: |
./scripts/run_in_build_env.sh \
Expand Down
1 change: 1 addition & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@
"telink-tlsr9518adk80d-ota-requestor",
"telink-tlsr9518adk80d-pump-app",
"telink-tlsr9518adk80d-pump-controller-app",
"telink-tlsr9518adk80d-shell",
"telink-tlsr9518adk80d-smoke-co-alarm-app",
"telink-tlsr9518adk80d-temperature-measurement",
"telink-tlsr9518adk80d-thermostat",
Expand Down
1 change: 1 addition & 0 deletions examples/shell/telink/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
71 changes: 71 additions & 0 deletions examples/shell/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#
# Copyright (c) 2023 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.
#
cmake_minimum_required(VERSION 3.13.1)

set(BOARD tlsr9518adk80d)

get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connectedhomeip REALPATH)
get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH)
get_filename_component(APP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/.. REALPATH)

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.overlay")
set(LOCAL_DTC_OVERLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.overlay")
else()
unset(LOCAL_DTC_OVERLAY_FILE)
endif()

if(EXISTS "${CHIP_ROOT}/src/platform/telink/${BOARD}.overlay")
set(GLOBAL_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${BOARD}.overlay")
else()
unset(GLOBAL_DTC_OVERLAY_FILE)
endif()

if(DTC_OVERLAY_FILE)
set(DTC_OVERLAY_FILE
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
CACHE STRING "" FORCE
)
else()
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
endif()

set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf)

# Load NCS/Zephyr build system
list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module)
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})

project(chip-telink-shell-example)

include(${CHIP_ROOT}/config/telink/app/enable-gnu-std.cmake)
include(${CHIP_ROOT}/src/app/chip_data_model.cmake)

target_compile_options(app PRIVATE -fpermissive)

target_include_directories(app PRIVATE
include
${GEN_DIR}/app-common
${APP_ROOT}/shell_common/include)

add_definitions(
"-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>"
)

target_sources(app PRIVATE
${APP_ROOT}/shell_common/globals.cpp
${APP_ROOT}/shell_common/cmd_misc.cpp
${APP_ROOT}/shell_common/cmd_otcli.cpp
${APP_ROOT}/standalone/main.cpp)
52 changes: 52 additions & 0 deletions examples/shell/telink/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Matter Telink Shell Example Application

You can use this example as a reference for creating your own application.

![Telink B91 EVK](http://wiki.telink-semi.cn/wiki/assets/Hardware/B91_Generic_Starter_Kit_Hardware_Guide/connection_chart.png)

## Build and flash

1. Pull docker image from repository:

```bash
$ docker pull connectedhomeip/chip-build-telink:latest
```

1. Run docker container:

```bash
$ 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
```

here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay
attention that OUTPUT_DIR should contains ABSOLUTE path to output dir**

1. Activate the build environment:

```bash
$ source ./scripts/activate.sh
```

1. In the example dir run:

```bash
$ west build
```

1. Flash binary:

```
$ west flash --erase
```

## Usage

### UART

To get output from device, connect UART to following pins:

| Name | Pin |
| :--: | :---------------------------- |
| RX | PB3 (pin 17 of J34 connector) |
| TX | PB2 (pin 16 of J34 connector) |
| GND | GND |
48 changes: 48 additions & 0 deletions examples/shell/telink/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
* 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.
*/

/**
* @file
* Example project configuration file for CHIP.
*
* This is a place to put application or project-specific overrides
* to the default configuration values for general CHIP features.
*
*/

#pragma once

// Use a default pairing code if one hasn't been provisioned in flash.
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00

/**
* CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE
*
* Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption
*/
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8

// Enable support functions for parsing command-line arguments
#define CHIP_CONFIG_ENABLE_ARG_PARSER 1

#define CHIP_DEVICE_CONFIG_DISABLE_SHELL_PING 1

// shell app uses openthread but does not have the NETWORK_COMMISSIONING cluster or zap config
// Do not instantiate the NETWORK_COMMISSIONING thread driver
#define _NO_NETWORK_COMMISSIONING_DRIVER_
73 changes: 73 additions & 0 deletions examples/shell/telink/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# Copyright (c) 2023 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.
#

# This sample uses sample-defaults.conf to set options common for all
# samples. This file should contain only options specific for this sample
# or overrides of default values.

# enable GPIO
CONFIG_GPIO=y

# enable PWM
CONFIG_PWM=y

# OpenThread configs
#CONFIG_OPENTHREAD_MTD=n
CONFIG_OPENTHREAD_FTD=y
# CONFIG_CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT=y
CONFIG_CHIP_THREAD_SSED=n

# Default OpenThread network settings
CONFIG_OPENTHREAD_PANID=4660
CONFIG_OPENTHREAD_CHANNEL=15
CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo"
CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22"

# Disable Matter OTA DFU
CONFIG_CHIP_OTA_REQUESTOR=n

# CHIP configuration
CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h"
CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h"

CONFIG_CHIP_DEVICE_VENDOR_ID=65521
# 32786 == 0x8012 (example shell-app)
CONFIG_CHIP_DEVICE_PRODUCT_ID=32786
CONFIG_CHIP_DEVICE_TYPE=65535

CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1
CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2023"

# Enable CHIP pairing automatically on application start.
CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y

# CHIP shell
CONFIG_CHIP_LIB_SHELL=y
CONFIG_OPENTHREAD_SHELL=y
CONFIG_SHELL=y

# Disable factory data support.
CONFIG_CHIP_FACTORY_DATA=n
CONFIG_CHIP_FACTORY_DATA_BUILD=n
CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n
CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n

# Enable Power Management
CONFIG_PM=n

# Custom RF power values
CONFIG_B91_BLE_CTRL_RF_POWER_P9P11DBM=y
CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9
1 change: 1 addition & 0 deletions examples/shell/telink/third_party/connectedhomeip
1 change: 1 addition & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ def BuildTelinkTarget():
TargetPart('ota-requestor', app=TelinkApp.OTA_REQUESTOR),
TargetPart('pump', app=TelinkApp.PUMP),
TargetPart('pump-controller', app=TelinkApp.PUMP_CONTROLLER),
TargetPart('shell', app=TelinkApp.SHELL),
TargetPart('smoke-co-alarm', app=TelinkApp.SMOKE_CO_ALARM),
TargetPart('temperature-measurement',
app=TelinkApp.TEMPERATURE_MEASUREMENT),
Expand Down
5 changes: 5 additions & 0 deletions scripts/build/builders/telink.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class TelinkApp(Enum):
OTA_REQUESTOR = auto()
PUMP = auto()
PUMP_CONTROLLER = auto()
SHELL = auto()
SMOKE_CO_ALARM = auto()
TEMPERATURE_MEASUREMENT = auto()
THERMOSTAT = auto()
Expand All @@ -57,6 +58,8 @@ def ExampleName(self):
return 'pump-app'
elif self == TelinkApp.PUMP_CONTROLLER:
return 'pump-controller-app'
elif self == TelinkApp.SHELL:
return 'shell'
elif self == TelinkApp.SMOKE_CO_ALARM:
return 'smoke-co-alarm-app'
elif self == TelinkApp.TEMPERATURE_MEASUREMENT:
Expand Down Expand Up @@ -89,6 +92,8 @@ def AppNamePrefix(self):
return 'chip-telink-pump-example'
elif self == TelinkApp.PUMP_CONTROLLER:
return 'chip-telink-pump-controller-example'
elif self == TelinkApp.SHELL:
return 'chip-telink-shell-example'
elif self == TelinkApp.SMOKE_CO_ALARM:
return 'chip-telink-smoke-co-alarm-example'
elif self == TelinkApp.TEMPERATURE_MEASUREMENT:
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/testdata/all_targets_linux_x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ nrf-{nrf5340dk,nrf52840dk,nrf52840dongle}-{all-clusters,all-clusters-minimal,loc
nrf-native-posix-64-tests
qpg-qpg6105-{lock,light,shell,persistent-storage}
tizen-arm-{all-clusters,all-clusters-minimal,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan]
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]
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]
openiotsdk-{shell,lock}[-mbedtls][-psa]

0 comments on commit 1229252

Please sign in to comment.