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

[Telink] Fix Factory Data build and handle it by CI #25655

Merged
merged 7 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 14 additions & 0 deletions .github/workflows/examples-telink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ jobs:
- name: clean out build output
run: rm -rf ./out

- name: Build example Telink Lighting App with Factory Data
run: |
./scripts/build/gn_gen.sh
./scripts/run_in_build_env.sh "ninja -C out chip-cert chip-tool spake2p"
./scripts/run_in_build_env.sh \
./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-light-factory-data' build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
telink tlsr9518adk80d lighting-app-factory-data \
out/telink-tlsr9518adk80d-light-factory-data/zephyr/zephyr.elf \
/tmp/bloat_reports/

- name: clean out build output
run: rm -rf ./out

- name: Build example Telink Light Switch App
run: |
./scripts/run_in_build_env.sh \
Expand Down
18 changes: 11 additions & 7 deletions config/telink/chip-module/generate_factory_data.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,25 @@ else()
endif()

# find chip cert tool
find_program(chip_cert_exe NAMES chip-cert REQUIRED)
find_program(chip_cert_exe NAMES chip-cert PATHS ${CHIP_ROOT}/out REQUIRED)
string(APPEND script_args "--chip-cert-path ${chip_cert_exe}\n")

# for development purpose user can use default certs instead of generating or providing them
if(CONFIG_CHIP_FACTORY_DATA_USE_DEFAULT_CERTS)
# convert decimal VID to its hexadecimal representation to find out certification files in repository
math(EXPR LOCAL_VID "${CONFIG_CHIP_DEVICE_VENDOR_ID}" OUTPUT_FORMAT HEXADECIMAL)
string(SUBSTRING ${LOCAL_VID} 2 -1 raw_vid)
string(TOUPPER ${raw_vid} raw_vid_upper)
# convert decimal PID to its hexadecimal representation to find out certification files in repository
math(EXPR LOCAL_PID "${CONFIG_CHIP_DEVICE_PRODUCT_ID}" OUTPUT_FORMAT HEXADECIMAL)
string(SUBSTRING ${LOCAL_PID} 2 -1 raw_pid)
string(TOUPPER ${raw_pid} raw_pid_upper)
# all certs are located in ${CHIP_ROOT}/credentials/development/attestation
# it can be used during development without need to generate new certifications
string(APPEND script_args "--dac-cert \"${CHIP_ROOT}/credentials/development/attestation/Matter-Development-DAC-${raw_pid_upper}-Cert.pem\"\n")
string(APPEND script_args "--dac-key \"${CHIP_ROOT}/credentials/development/attestation/Matter-Development-DAC-${raw_pid_upper}-Key.pem\"\n")
string(APPEND script_args "--cert \"${CHIP_ROOT}/credentials/development/attestation/Matter-Development-PAI-noPID-Cert.pem\"\n")
string(APPEND script_args "--key \"${CHIP_ROOT}/credentials/development/attestation/Matter-Development-PAI-noPID-Key.pem\"\n")
string(APPEND script_args "--dac-cert \"${CHIP_ROOT}/credentials/development/attestation/Matter-Development-DAC-${raw_vid_upper}-${raw_pid_upper}-Cert.pem\"\n")
string(APPEND script_args "--dac-key \"${CHIP_ROOT}/credentials/development/attestation/Matter-Development-DAC-${raw_vid_upper}-${raw_pid_upper}-Key.pem\"\n")
string(APPEND script_args "--cert \"${CHIP_ROOT}/credentials/development/attestation/Matter-Development-PAI-${raw_vid_upper}-noPID-Cert.pem\"\n")
string(APPEND script_args "--key \"${CHIP_ROOT}/credentials/development/attestation/Matter-Development-PAI-${raw_vid_upper}-noPID-Key.pem\"\n")
string(APPEND script_args "-cd \"${CHIP_ROOT}/credentials/development/cd-certs/Chip-Test-CD-Cert.der\"\n")
string(APPEND script_args "--pai\n")
else()
Expand All @@ -95,7 +99,7 @@ else()
endif()

# find chip tool requied for generating QRCode
find_program(chip_tool_exe NAMES chip-tool REQUIRED)
find_program(chip_tool_exe NAMES chip-tool PATHS ${CHIP_ROOT}/out REQUIRED)
string(APPEND script_args "--chip-tool-path ${chip_tool_exe}\n")

# add Password-Authenticated Key Exchange parameters
Expand All @@ -104,7 +108,7 @@ string(APPEND script_args "--discriminator ${CONFIG_CHIP_DEVICE_DISCRIMINATOR}\n
string(APPEND script_args "--passcode ${CONFIG_CHIP_DEVICE_SPAKE2_PASSCODE}\n")

# request spake2p to generate a new spake2_verifier
find_program(spake_exe NAMES spake2p REQUIRED)
find_program(spake_exe NAMES spake2p PATHS ${CHIP_ROOT}/out REQUIRED)
string(APPEND script_args "--spake2-path ${spake_exe}\n")

if(CONFIG_CHIP_DEVICE_ENABLE_KEY)
Expand Down
22 changes: 22 additions & 0 deletions examples/lighting-app/telink/factory_data.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# 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 file should be used as a configuration overlay to enable Factory Data.

# Enable factory data support.
CONFIG_CHIP_FACTORY_DATA=y
CONFIG_CHIP_FACTORY_DATA_BUILD=y
CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=y
1 change: 1 addition & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ def BuildTelinkTarget():
])

target.AppendModifier('rpc', enable_rpcs=True)
target.AppendModifier('factory-data', enable_factory_data=True)

return target

Expand Down
7 changes: 6 additions & 1 deletion scripts/build/builders/telink.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,13 @@ def __init__(self,
runner,
app: TelinkApp = TelinkApp,
board: TelinkBoard = TelinkBoard.TLSR9518ADK80D,
enable_rpcs: bool = False):
enable_rpcs: bool = False,
enable_factory_data: bool = False):
super(TelinkBuilder, self).__init__(root, runner)
self.app = app
self.board = board
self.enable_rpcs = enable_rpcs
self.enable_factory_data = enable_factory_data

def get_cmd_prefixes(self):
if not self._runner.dry_run:
Expand All @@ -136,6 +138,9 @@ def generate(self):
if self.enable_rpcs:
flags.append("-DOVERLAY_CONFIG=rpc.overlay")

if self.enable_factory_data:
flags.append("-DOVERLAY_CONFIG=factory_data.overlay")

if self.options.pregen_dir:
flags.append(f"-DCHIP_CODEGEN_PREGEN_DIR={shlex.quote(self.options.pregen_dir)}")

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 @@ -19,5 +19,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-wifi][-asan][-ubsan]
telink-tlsr9518adk80d-{all-clusters,all-clusters-minimal,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,temperature-measurement,thermostat,window-covering}[-rpc]
telink-tlsr9518adk80d-{all-clusters,all-clusters-minimal,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,temperature-measurement,thermostat,window-covering}[-rpc][-factory-data]
openiotsdk-{shell,lock}