Skip to content

Commit

Permalink
[Telink] Add Telink factory data & Update Telink image to 0.6.06 (#23502
Browse files Browse the repository at this point in the history
) (#23548)
  • Loading branch information
s07641069 committed Nov 9, 2022
1 parent 0b17bce commit cbfb908
Show file tree
Hide file tree
Showing 23 changed files with 2,287 additions and 169 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples-telink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

container:
image: connectedhomeip/chip-build-telink:0.6.02
image: connectedhomeip/chip-build-telink:0.6.06
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"

Expand Down
84 changes: 61 additions & 23 deletions config/telink/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ if (CONFIG_CHIP)
include(ExternalProject)
include(../../zephyr/ota-image.cmake)
include(../../zephyr/zephyr-util.cmake)
include(generate_factory_data.cmake)

# ==============================================================================
# Declare configuration variables and define constants
Expand All @@ -45,7 +46,7 @@ list(APPEND CHIP_CFLAGS_CC)
# CHIP libraries that the application should be linked with
list(APPEND CHIP_LIBRARIES)

# GN meta-build system arguments in the form of 'key1 = value1\nkey2 = value2...' string
# GN meta-build system arguments passed to the make_gn_args.py script
string(APPEND CHIP_GN_ARGS)

# C/C++ compiler flags which should not be forwarded to CHIP
Expand All @@ -67,28 +68,27 @@ set(CHIP_CFLAG_EXCLUDES
# ==============================================================================

macro(chip_gn_arg_import FILE)
string(APPEND CHIP_GN_ARGS "import(\"${FILE}\")\n")
string(APPEND CHIP_GN_ARGS "--module\n${FILE}\n")
endmacro()

macro(chip_gn_arg_string ARG STRING)
string(APPEND CHIP_GN_ARGS "${ARG} = \"${STRING}\"\n")
string(APPEND CHIP_GN_ARGS "--arg-string\n${ARG}\n${STRING}\n")
endmacro()

macro(chip_gn_arg_bool ARG BOOLEAN)
if (${BOOLEAN})
string(APPEND CHIP_GN_ARGS "${ARG} = true\n")
macro(chip_gn_arg_bool ARG)
if (${ARGN})
string(APPEND CHIP_GN_ARGS "--arg\n${ARG}\ntrue\n")
else()
string(APPEND CHIP_GN_ARGS "${ARG} = false\n")
string(APPEND CHIP_GN_ARGS "--arg\n${ARG}\nfalse\n")
endif()
endmacro()

macro(chip_gn_arg_cflags ARG CFLAGS)
set(CFLAG_EXCLUDES "[")
foreach(cflag ${CHIP_CFLAG_EXCLUDES})
string(APPEND CFLAG_EXCLUDES "\"${cflag}\", ")
endforeach()
string(APPEND CFLAG_EXCLUDES "]")
string(APPEND CHIP_GN_ARGS "${ARG} = filter_exclude(string_split(\"${CFLAGS}\"), ${CFLAG_EXCLUDES})\n")
string(APPEND CHIP_GN_ARGS "--arg-cflags\n${ARG}\n${CFLAGS}\n")
endmacro()

macro(chip_gn_arg ARG VALUE)
string(APPEND CHIP_GN_ARGS "--arg\n${ARG}\n${VALUE}\n")
endmacro()

# ==============================================================================
Expand Down Expand Up @@ -197,8 +197,6 @@ chip_gn_arg_cflags("target_cflags_cc" ${CHIP_CFLAGS_CC})
chip_gn_arg_string("zephyr_ar" ${CMAKE_AR})
chip_gn_arg_string("zephyr_cc" ${CMAKE_C_COMPILER})
chip_gn_arg_string("zephyr_cxx" ${CMAKE_CXX_COMPILER})
chip_gn_arg_string("chip_project_config_include" "${CHIP_PROJECT_CONFIG}")
chip_gn_arg_string("chip_system_project_config_include" "${CHIP_PROJECT_CONFIG}")
chip_gn_arg_bool ("is_debug" CONFIG_DEBUG)
chip_gn_arg_bool ("chip_enable_openthread" CONFIG_NET_L2_OPENTHREAD)
chip_gn_arg_bool ("chip_openthread_ftd" CONFIG_OPENTHREAD_FTD)
Expand All @@ -208,16 +206,32 @@ chip_gn_arg_bool ("chip_build_tests" CONFIG_CHIP_BUILD_TE
chip_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS)
chip_gn_arg_bool ("chip_build_libshell" CONFIG_CHIP_LIB_SHELL)

if (CONFIG_CHIP_FACTORY_DATA)
chip_gn_arg_bool ("chip_use_transitional_commissionable_data_provider" "false")
chip_gn_arg_bool ("chip_enable_factory_data" "true")
elseif (CONFIG_CHIP_FACTORY_DATA_CUSTOM_BACKEND)
chip_gn_arg_bool ("chip_use_transitional_commissionable_data_provider" "false")
endif()

if (CONFIG_CHIP_ROTATING_DEVICE_ID)
chip_gn_arg_bool("chip_enable_rotating_device_id" "true")
chip_gn_arg_bool("chip_enable_additional_data_advertising" "true")
endif()

if (CONFIG_CHIP_ENABLE_DNSSD_SRP)
chip_gn_arg_string("chip_mdns" "platform")
endif()

if (CHIP_PROJECT_CONFIG)
chip_gn_arg_string("chip_project_config_include" ${CHIP_PROJECT_CONFIG})
chip_gn_arg_string("chip_system_project_config_include" ${CHIP_PROJECT_CONFIG})
endif()
if (CONFIG_CHIP_EXAMPLE_DEVICE_INFO_PROVIDER)
chip_gn_arg_bool("chip_build_example_providers" "true")
list(APPEND CHIP_LIBRARIES -lMatterDeviceInfoProviderExample)
endif()

file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/args.gn CONTENT ${CHIP_GN_ARGS})
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/args.tmp" CONTENT ${CHIP_GN_ARGS})

# ==============================================================================
# Define 'chip-gn' target that builds CHIP library(ies) with GN build system
Expand All @@ -227,13 +241,17 @@ ExternalProject_Add(
PREFIX ${CMAKE_CURRENT_BINARY_DIR}
SOURCE_DIR ${CHIP_ROOT}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}
CONFIGURE_COMMAND ${GN_EXECUTABLE}
CONFIGURE_COMMAND ""
BUILD_COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/make_gn_args.py
@args.tmp > args.gn &&
${GN_EXECUTABLE}
--root=${CHIP_ROOT}
--root-target=${GN_ROOT_TARGET}
--dotfile=${GN_ROOT_TARGET}/.gn
--script-executable=${Python3_EXECUTABLE}
gen --check --fail-on-unused-args ${CMAKE_CURRENT_BINARY_DIR}
BUILD_COMMAND ninja
--export-compile-commands
gen --check --fail-on-unused-args . &&
ninja
INSTALL_COMMAND ""
BUILD_BYPRODUCTS ${CHIP_LIBRARIES}
BUILD_ALWAYS TRUE
Expand Down Expand Up @@ -288,11 +306,11 @@ if (CONFIG_CHIP_OTA_IMAGE_BUILD)
west sign -t imgtool -p ${ZEPHYR_BASE}/../bootloader/mcuboot/scripts/imgtool.py -d ${PROJECT_BINARY_DIR}/.. -- --key ${ZEPHYR_BASE}/../bootloader/mcuboot/root-rsa-2048.pem
)

add_custom_target(final_bin ALL
add_custom_target(merge_mcuboot ALL
COMMAND
dd if=${PROJECT_BINARY_DIR}/../modules/chip-module/build_mcuboot/zephyr/zephyr.bin of=${PROJECT_BINARY_DIR}/zephyr_final.bin
dd if=${PROJECT_BINARY_DIR}/../modules/chip-module/build_mcuboot/zephyr/zephyr.bin of=${PROJECT_BINARY_DIR}/zephyr.bin
COMMAND
dd if=${PROJECT_BINARY_DIR}/zephyr.signed.bin of=${PROJECT_BINARY_DIR}/zephyr_final.bin bs=1024 seek=64
dd if=${PROJECT_BINARY_DIR}/zephyr.signed.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=1024 seek=64
)

chip_ota_image(chip-ota-image
Expand All @@ -301,8 +319,28 @@ if (CONFIG_CHIP_OTA_IMAGE_BUILD)
)

add_dependencies(west_sign ${ZEPHYR_FINAL_EXECUTABLE})
add_dependencies(final_bin west_sign)
add_dependencies(merge_mcuboot west_sign)
add_dependencies(chip-ota-image west_sign)
endif()

if (CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE)
add_custom_target(merge_factory_data ALL
COMMAND
dd if=${PROJECT_BINARY_DIR}/factory_data.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=1024 seek=976
)
if (CONFIG_CHIP_OTA_IMAGE_BUILD)
add_dependencies(merge_factory_data merge_mcuboot)
else()
add_dependencies(merge_factory_data ${ZEPHYR_FINAL_EXECUTABLE})
endif()
endif()

# ==============================================================================
# Define 'factory_data' target for generating a factory data partition
# ==============================================================================

if (CONFIG_CHIP_FACTORY_DATA_BUILD)
telink_generate_factory_data()
endif()

endif() # CONFIG_CHIP
208 changes: 207 additions & 1 deletion config/telink/chip-module/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,210 @@ config CHIP_EXAMPLE_DEVICE_INFO_PROVIDER
# Enable getting reboot reasons information
config HWINFO
bool
default y
default y

config CHIP_FACTORY_DATA
bool "Enable Factory Data support"
select ZCBOR
help
Enables support for reading factory data from flash memory partition.
It requires factory_data partition to exist.

config CHIP_FACTORY_DATA_CUSTOM_BACKEND
bool "Enable Factory Data custom backend"
depends on !CHIP_FACTORY_DATA
help
Enables user custom factory data implementation. It cannot be used
with the CHIP_FACTORY_DATA that enabled default Telink factory data
implementation.

config CHIP_FACTORY_DATA_BUILD
bool "Enable Factory Data build"
default n
help
Enables generation of factory data during the building.
It requires factory_data partition to exist.
As a result a new output file factory_data.bin will be created.

config CHIP_FACTORY_DATA_VERSION
int
default 1
help
The Factory data version contains a current version of a factory data
parameter set that the user cannot change.
After moving to the next version of the factory data set, change the default value.
This config is used to validate the version of a factory data set on a device-side
with the version of factory data saved in the Flash memory.

if CHIP_FACTORY_DATA_BUILD

# Factory data definitions
config CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE
bool "Enable merging generated factory data with the build target .bin file"
default y
help
Enables merging generated factory data with the build target zephyr.bin file.
As a result, output file zephyr.bin will consist of all partitions including
factory data.

# Use default certificates without generating or providing them
config CHIP_FACTORY_DATA_USE_DEFAULT_CERTS
bool "Use default certificates located in Matter repository"
default y
help
Pre-generated certificates can be used for development purpose.
This config includes default pre-generated certificates
which are located in credentials/development/attestation/ directory
instead of generating new ones.
If this config is set to `n` new certificates will be generated.

# Configs for SPAKE2 generation
config CHIP_FACTORY_DATA_GENERATE_SPAKE2_VERIFIER
bool "Enable spake2 verifier generation"
help
Enables generation of spake2 verifier according to
given iteration counter, salt and passcode.
To generate Spake2 verifier a spake2p executable must be available
from system variables environment.

config CHIP_DEVICE_GENERATE_ROTATING_DEVICE_UID
bool "Enable generation of a new Rotating device id unique id"
default y
help
Enables generation of a new Rotating device id unique id.

endif #CHIP_FACTORY_DATA_BUILD

# Factory data parameters
config CHIP_DEVICE_SERIAL_NUMBER
string "Serial number of device"
default "11223344556677889900"
help
A serial number parameter defines an unique number of manufactured device.
Maximum length of serial number is 32 characters.

config CHIP_DEVICE_VENDOR_NAME
string "Human-readable vendor name"
default "Telink Semiconductor"
help
A human-readable vendor name which provides a simple string
containing identification of device's vendor for the Content APP.
This information should be included in the Matter Basic Cluster.

config CHIP_DEVICE_PRODUCT_NAME
string "Human-readable product name"
default "not-specified"
help
A human-readable product name which provides a simple string
containing identification of the product for the Content APP.

config CHIP_DEVICE_MANUFACTURING_DATE
string "Manufacturing date in ISO 8601"
default "2022-01-01"
help
A manufacturing date specifies the date that the device was manufactured.
The format used for providing a manufacturing date is ISO 8601 e.g. YYYY-MM-DD.

config CHIP_DEVICE_HARDWARE_VERSION
int "Integer representation of hardware version"
default 0
help
A hardware version number specifies the version number
of the hardware of the device. The meaning of its value,
and the versioning scheme, are vendor defined.

config CHIP_DEVICE_HARDWARE_VERSION_STRING
string "user-friendly string representation of hardware version"
default "prerelease"
help
A hardware version string parameter specifies the version
of the hardware of the device as a more user-friendly value
than that represented by the hardware version integer value.
The meaning of its value, and the versioning scheme, are
vendor defined.

config CHIP_DEVICE_DISCRIMINATOR
hex "Device pairing discriminator"
default 0xF00
help
A 12-bit value matching the field of the same name in
the setup code. Discriminator is used during
a discovery process.

config CHIP_DEVICE_SPAKE2_PASSCODE
int "Spake2+ passcode"
default 20202021
range 1 99999998
help
A pairing passcode is a 27-bit unsigned integer which serves
as a proof of possession during commissioning.
Its value shall be restricted to the values 0x0000001 to 0x5F5E0FE
(00000001 to 99999998 in decimal), excluding the invalid Passcode values:
- 00000000, 11111111, 22222222, 33333333, 44444444, 55555555,
66666666, 77777777, 88888888, 99999999, 12345678, 87654321.

config CHIP_DEVICE_SPAKE2_IT
int "Spake2+ iteration count"
default 1000
help
The Spake2 iteration count is associated with the ephemeral
PAKE passcode verifier to be used for the commissioning.
The iteration count is used as a crypto parameter to process
spake2 verifier.

config CHIP_DEVICE_SPAKE2_SALT
string "Spake2+ salt in string format"
default "U1BBS0UyUCBLZXkgU2FsdA=="
help
The spake2 salt is random data that is used as an additional input
to a one-way function that “hashes” data.
A new salt should be randomly generated for each password.
The minimum length of spake2 salt is 16 Bytes.
The maximum length of spake2 salt is 32 Bytes.

config CHIP_DEVICE_SPAKE2_TEST_VERIFIER
string "Testing spake2+ verifier"
default "uWFwqugDNGiEck/po7KHwwMwwqZgN10XuyBajPGuyzUEV/iree4lOrao5GuwnlQ65CJzbeUB49s31EH+NEkg0JVI5MGCQGMMT/SRPFNRODm3wH/MBiehuFc6FJ/NH6Rmzw=="
help
The spake 2 verifier generated using default SPAKE2 salt,
iteration count and passcode. This value can be used for development
or testing purposes.
Generated with:
spake2p gen-verifier -o - -i 1000 -s "U1BBS0UyUCBLZXkgU2FsdA==" -p 20202021

config CHIP_DEVICE_ROTATING_DEVICE_UID
string "A rotating device id unique id"
default "91a9c12a7c80700a31ddcfa7fce63e44"
help
A device rotating id unique id which will be generated if
this config is not set in prj.conf file.

config CHIP_DEVICE_ENABLE_KEY
string "Enable Key for triggering test actions on device"
default "00112233445566778899AABBCCDDEEFF"
help
The Enable Key is a 128-bit value that triggers test action
while invoking the TestEventTrigger Command.
Pattern: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
This value is used during Certification Tests,
and should not be present on production devices.

config CHIP_CERTIFICATION_DECLARATION_STORAGE
bool "Enable storing Certification Declaration"
depends on CHIP_FACTORY_DATA
help
Enables storing Certification Declaration in Zephyr settings
instead of using hardcoded value from firmware. It also adds
support for including new Certification Declaration into a firmware
update image package sent via OTA Software Update.

if CHIP_CERTIFICATION_DECLARATION_STORAGE

config CHIP_CERTIFiCATION_DECLARATION_OTA_IMAGE_ID
int "Certification declaration OTA image id"
default 205 #0xcd
help
The image id of Certification Declaration image
for sending it via OTA Software Update purposes.

endif
Loading

0 comments on commit cbfb908

Please sign in to comment.