blob: 3613a0bb6b6fe7e15d2c5a674313e31cf9c32da4 [file] [log] [blame]
# 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/freertos.gni")
import("//build_overrides/mbedtls.gni")
import("//build_overrides/openthread.gni")
import("//build_overrides/pigweed.gni")
import("//build_overrides/ti_simplelink_sdk.gni")
import("${chip_root}/src/platform/device.gni")
import("${dir_pw_build}/python.gni")
import("${freertos_root}/freertos.gni")
import("${mbedtls_root}/mbedtls.gni")
import("ti_simplelink_board.gni")
declare_args() {
# Location of the TI SimpleLink SDK.
if (ti_simplelink_device_family == "cc13x2_26x2" ||
ti_simplelink_device_family == "cc13x2x7_26x2x7") {
ti_simplelink_sdk_root =
"${chip_root}/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx"
} else if (ti_simplelink_device_family == "cc32xx") {
ti_simplelink_sdk_root =
"${chip_root}/third_party/ti_simplelink_sdk/repo_cc32xx"
}
ti_sysconfig_root = ""
}
assert(ti_simplelink_sdk_root != "", "ti_simplelink_sdk_root must be specified")
assert(ti_sysconfig_root != "", "ti_sysconfig_root must be specified")
template("ti_sysconfig") {
assert(ti_sysconfig_root != "", "must be specified")
assert(ti_simplelink_sdk_root != "",
"ti_simplelink_sdk_root must be specified")
output_dir = "${target_gen_dir}/${target_name}"
gen_outputs = []
foreach(output, invoker.outputs) {
gen_outputs += [ output_dir + "/" + output ]
}
config("${target_name}_config") {
include_dirs = [
output_dir,
"${ti_simplelink_sdk_root}/source",
]
defines = []
ldflags = []
if (defined(invoker.include_dirs)) {
include_dirs += invoker.include_dirs
}
if (ti_simplelink_device_family == "cc13x2_26x2") {
ldflags += [ "-nostartfiles" ]
defines += [ "DeviceFamily_CC13X2_CC26X2" ]
} else if (ti_simplelink_device_family == "cc13x2x7_26x2x7") {
ldflags += [ "-nostartfiles" ]
defines += [ "DeviceFamily_CC26X2X7" ]
} else if (ti_simplelink_device_family == "cc32xx") {
ldflags += [ "-nostartfiles" ]
defines += [ "CC32XXWARE" ]
}
if (defined(invoker.cflags)) {
cflags = invoker.cflags
}
if (defined(invoker.ldflags)) {
ldflags += invoker.ldflags
}
}
pw_python_action("${target_name}_gen") {
script = "${ti_simplelink_sdk_build_root}/run_sysconfig.py"
sources = invoker.sources
outputs = gen_outputs
args = [
ti_sysconfig_root,
"-s",
rebase_path(ti_simplelink_sdk_root + "/.metadata/product.json",
root_build_dir),
"-o",
rebase_path(output_dir, root_build_dir),
"--compiler",
"gcc",
"--board",
"/ti/boards/" + ti_simplelink_board,
"--rtos",
"freertos",
]
foreach(source, sources) {
args += [ rebase_path(source, root_build_dir) ]
}
}
source_set(target_name) {
sources = gen_outputs
public_configs = [ ":${target_name}_config" ]
public_deps = [ ":${target_name}_gen" ]
if (defined(invoker.public_configs)) {
public_configs += invoker.public_configs
}
}
}
template("ti_simplelink_sdk") {
if (defined(invoker.ti_simplelink_sdk_root)) {
ti_simplelink_sdk_root = invoker.ti_simplelink_sdk_root
}
assert(ti_simplelink_sdk_root != "",
"ti_simplelink_sdk_root must be specified")
sdk_target_name = target_name
config("${sdk_target_name}_config") {
include_dirs = []
libs = []
if (defined(invoker.include_dirs)) {
include_dirs += invoker.include_dirs
}
# Treat these includes as system includes, so warnings in them are not fatal.
include_dirs += [
"${ti_simplelink_sdk_root}/source",
"${ti_simplelink_sdk_root}/source/third_party/CMSIS/Include",
"${chip_root}/third_party/mbedtls/repo/include",
]
defines = []
if (ti_simplelink_device_family == "cc13x2_26x2" ||
ti_simplelink_device_family == "cc13x2x7_26x2x7") {
assert(ti_simplelink_soc_family != "",
"ti_simplelink_soc_family must be specified")
assert(ti_simplelink_device_family != "",
"ti_simplelink_device_family must be specified")
libs += [
"${ti_simplelink_sdk_root}/source/ti/drivers/lib/gcc/${ti_simplelink_isa}/drivers_${ti_simplelink_soc_family}.a",
"${ti_simplelink_sdk_root}/source/ti/drivers/rf/lib/gcc/${ti_simplelink_isa}/rf_multiMode_${ti_simplelink_soc_family}.a",
]
} else if (ti_simplelink_device_family == "cc32xx") {
assert(ti_simplelink_soc_family != "",
"ti_simplelink_soc_family must be specified")
assert(ti_simplelink_device_family != "",
"ti_simplelink_device_family must be specified")
defines += [ "DeviceFamily_CC3220" ]
libs += [
"${ti_simplelink_sdk_root}/source/ti/drivers/lib/gcc/m4/drivers_cc32xx.a",
"${ti_simplelink_sdk_root}/source/ti/devices/cc32xx/driverlib/gcc/Release/driverlib.a",
"${ti_simplelink_sdk_root}/source/ti/drivers/net/wifi/gcc/rtos/simplelink.a",
"${ti_simplelink_sdk_root}/source/ti/net/lib/gcc/m4/slnetsock_debug.a",
"${ti_simplelink_sdk_root}/source/ti/drivers/net/wifi/slnetif/gcc/Release/slnetifwifi.a",
]
include_dirs += [
"${ti_simplelink_sdk_root}/examples/rtos/common/",
"${ti_simplelink_sdk_root}/examples/rtos/common/ifmod",
]
}
if (ti_simplelink_device_family == "cc13x2_26x2") {
defines += [ "DeviceFamily_CC13X2_CC26X2" ]
libs += [ "${ti_simplelink_sdk_root}/source/ti/devices/cc13x2_cc26x2/driverlib/bin/gcc/driverlib.lib" ]
} else if (ti_simplelink_device_family == "cc13x2x7_26x2x7") {
defines += [ "DeviceFamily_CC13X2X7_CC26X2X7" ]
libs += [ "${ti_simplelink_sdk_root}/source/ti/devices/cc13x2x7_cc26x2x7/driverlib/bin/gcc/driverlib.lib" ]
}
if (ti_simplelink_device_family == "cc32xx") {
assert(ti_simplelink_soc_family != "",
"ti_simplelink_soc_family must be specified")
assert(ti_simplelink_device_family != "",
"ti_simplelink_device_family must be specified")
libs += [ "${ti_simplelink_sdk_root}/source/ti/drivers/lib/gcc/m4/drivers_${ti_simplelink_soc_family}.a" ]
}
if (defined(invoker.defines)) {
defines += invoker.defines
}
}
source_set("${sdk_target_name}_dpl") {
defines = []
include_dirs = []
cflags = [ "-Wno-sign-compare" ]
sources = [
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/AppHooks_freertos.c",
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/DebugP_freertos.c",
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/MutexP_freertos.c",
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/QueueP_freertos.c",
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/SemaphoreP_freertos.c",
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/StaticAllocs_freertos.c",
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/SwiP_freertos.c",
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/SystemP_freertos.c",
]
if (ti_simplelink_device_family == "cc13x2_26x2" ||
ti_simplelink_device_family == "cc13x2x7_26x2x7") {
sources += [
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/ClockPCC26X2_freertos.c",
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/HwiPCC26X2_freertos.c",
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/PowerCC26X2_freertos.c",
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/TimerPCC26XX_freertos.c",
"${ti_simplelink_sdk_root}/kernel/freertos/startup/startup_cc13x2_cc26x2_gcc.c",
]
} else if (ti_simplelink_device_family == "cc32xx") {
sources += [
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/ClockP_freertos.c",
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/HwiPCC32XX_freertos.c",
"${ti_simplelink_sdk_root}/kernel/freertos/dpl/PowerCC32XX_freertos.c",
"${ti_simplelink_sdk_root}/kernel/freertos/startup/startup_cc32xx_gcc.c",
]
}
if (defined(invoker.sources)) {
sources += invoker.sources
}
public_deps = [ "${chip_root}/third_party/ti_simplelink_sdk:freertos" ]
public_configs = [ ":${sdk_target_name}_config" ]
}
config("${sdk_target_name}_posix_config") {
include_dirs = [ "${ti_simplelink_sdk_root}/source/ti/posix/gcc" ]
cflags_c = [ "-std=c11" ]
cflags_cc = [ "-std=c++14" ]
cflags = [
"-Wno-maybe-uninitialized",
"-Wno-sign-compare",
]
}
source_set("${sdk_target_name}_freertos") {
defines = []
include_dirs = []
# POSIX-like porting layer is incompatable with the gnu definitions from -std=gnu11
configs -= [ "${build_root}/config/compiler:std_default" ]
configs += [ ":${sdk_target_name}_posix_config" ]
sources = [
"${ti_simplelink_sdk_root}/source/ti/posix/freertos/clock.c",
"${ti_simplelink_sdk_root}/source/ti/posix/freertos/memory.c",
"${ti_simplelink_sdk_root}/source/ti/posix/freertos/mqueue.c",
"${ti_simplelink_sdk_root}/source/ti/posix/freertos/pthread.c",
"${ti_simplelink_sdk_root}/source/ti/posix/freertos/pthread_barrier.c",
"${ti_simplelink_sdk_root}/source/ti/posix/freertos/pthread_cond.c",
"${ti_simplelink_sdk_root}/source/ti/posix/freertos/pthread_mutex.c",
"${ti_simplelink_sdk_root}/source/ti/posix/freertos/pthread_rwlock.c",
"${ti_simplelink_sdk_root}/source/ti/posix/freertos/sched.c",
"${ti_simplelink_sdk_root}/source/ti/posix/freertos/semaphore.c",
"${ti_simplelink_sdk_root}/source/ti/posix/freertos/sleep.c",
"${ti_simplelink_sdk_root}/source/ti/posix/freertos/timer.c",
]
public_deps = [ ":${sdk_target_name}_dpl" ]
public_configs = [ ":${sdk_target_name}_config" ]
}
if (ti_simplelink_device_family == "cc13x2_26x2" ||
ti_simplelink_device_family == "cc13x2x7_26x2x7") {
if (chip_openthread_ftd) {
openthread_example = "cli_ftd"
} else {
openthread_example = "cli_mtd"
}
config("${sdk_target_name}_openthread_platform_config") {
defines = [ "NVOCMP_POSIX_MUTEX" ]
include_dirs = [
"${chip_root}/third_party/openthread/repo/examples/platforms",
"${chip_root}/third_party/openthread/repo/src/core",
"${ti_simplelink_sdk_root}/source/ti/devices/${ti_simplelink_device_family}",
]
if (ti_simplelink_device_family == "cc13x2_26x2") {
include_dirs += [
"${ti_simplelink_sdk_root}/source/ti/devices/cc13x2_cc26x2",
"${ti_simplelink_sdk_root}/examples/rtos/${ti_simplelink_board}/thread/${openthread_example}",
]
} else if (ti_simplelink_device_family == "cc13x2x7_26x2x7") {
include_dirs += [
"${ti_simplelink_sdk_root}/source/ti/devices/cc13x2x7_cc26x2x7",
"${ti_simplelink_sdk_root}/examples/rtos/${ti_simplelink_board}/thread/${openthread_example}",
]
}
}
source_set("${sdk_target_name}_openthread_platform") {
cflags = [
"-Wno-int-conversion",
"-Wno-address-of-packed-member",
"-Wno-implicit-fallthrough",
"-Wno-unused-label",
]
public_deps = [
":${sdk_target_name}_freertos",
"${chip_root}/third_party/ti_simplelink_sdk:freertos",
"${chip_root}/third_party/ti_simplelink_sdk:mbedtls",
"${chip_root}/third_party/ti_simplelink_sdk:ti_simplelink_sysconfig",
"${openthread_root}/src/core:libopenthread_core_headers",
]
configs -= [ "${build_root}/config/compiler:std_default" ]
configs += [ ":${sdk_target_name}_posix_config" ]
sources = [
"${ti_simplelink_sdk_root}/examples/rtos/${ti_simplelink_board}/thread/${openthread_example}/platform/alarm.c",
"${ti_simplelink_sdk_root}/examples/rtos/${ti_simplelink_board}/thread/${openthread_example}/platform/alarm_micro.c",
"${ti_simplelink_sdk_root}/examples/rtos/${ti_simplelink_board}/thread/${openthread_example}/platform/diag.c",
"${ti_simplelink_sdk_root}/examples/rtos/${ti_simplelink_board}/thread/${openthread_example}/platform/entropy.c",
"${ti_simplelink_sdk_root}/examples/rtos/${ti_simplelink_board}/thread/${openthread_example}/platform/misc.c",
"${ti_simplelink_sdk_root}/examples/rtos/${ti_simplelink_board}/thread/${openthread_example}/platform/nv/crc.c",
"${ti_simplelink_sdk_root}/examples/rtos/${ti_simplelink_board}/thread/${openthread_example}/platform/nv/nvocmp.c",
"${ti_simplelink_sdk_root}/examples/rtos/${ti_simplelink_board}/thread/${openthread_example}/platform/radio.c",
"${ti_simplelink_sdk_root}/examples/rtos/${ti_simplelink_board}/thread/${openthread_example}/platform/settings.c",
"${ti_simplelink_sdk_root}/examples/rtos/${ti_simplelink_board}/thread/${openthread_example}/platform/system.c",
]
public_configs = [
":${sdk_target_name}_config",
":${sdk_target_name}_openthread_platform_config",
"${chip_root}/third_party/openthread/repo:openthread_config",
]
if (chip_openthread_ftd) {
public_configs +=
[ "${chip_root}/third_party/openthread/repo:openthread_ftd_config" ]
} else {
public_configs +=
[ "${chip_root}/third_party/openthread/repo:openthread_mtd_config" ]
}
}
}
config("${sdk_target_name}_dmm_config") {
include_dirs = []
libs = []
include_dirs += [
# DMM/BLE:
"${ti_simplelink_sdk_root}/source",
# Eclipse the SDK config header from DMM
"${chip_root}/src/platform/cc13x2_26x2",
# CHIPoBLE Added include dirs
"${ti_simplelink_sdk_root}/source/ti/dmm/apps/common/freertos/",
"${ti_simplelink_sdk_root}/source/ti/dmm/apps/common/freertos/itm",
"${ti_simplelink_sdk_root}/source/ti/dmm/thread/platform",
"${ti_simplelink_sdk_root}/source/",
"${ti_simplelink_sdk_root}/source/ti/",
"${ti_simplelink_sdk_root}/source/ti/dmm/",
"${ti_simplelink_sdk_root}/source/ti/dmm/apps/",
"${ti_simplelink_sdk_root}/source/ti/dmm/apps/common/thread/",
"${ti_simplelink_sdk_root}/source/ti/dmm/apps/common/thread/source/activity/",
"${ti_simplelink_sdk_root}/source/ti/common/nv",
"${ti_simplelink_sdk_root}/source/ti/devices/cc13x2x7_cc26x2x7",
"${ti_simplelink_sdk_root}/source/ti/devices/cc13x2x7_cc26x2x7/inc",
"${ti_simplelink_sdk_root}/source/ti/devices/cc13x2x7_cc26x2x7/rf_patches",
"${ti_simplelink_sdk_root}/source/ti/devices/cc13x2x7_cc26x2x7/driverlib",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/common/cc26xx/npi/stack/",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/common/cc26xx/rcosc",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/controller/cc26xx/inc",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/inc",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/rom",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/common/cc26xx",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/common/cc26xx/freertos",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/icall/inc",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/icall/src",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/hal/src/target/_common",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/hal/src/target/_common/cc26xx",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/hal/src/inc",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/heapmgr",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/profiles/dev_info",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/hal/src/target/_common/cc26xx/",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/profiles/simple_profile",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/icall/src/inc",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/osal/src/inc",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/controller/cc26xx/inc/",
"${ti_simplelink_sdk_root}/source/ti/common/cc26xx",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/common/cc26xx/freertos/",
]
defines = [
"INCLUDE_BGET_STATS",
"USE_DMM",
"FLASH_ROM_BUILD",
"NVOCMP_FREERTOS_MUTEX=1",
"USEOT",
"ONE_BLE_LIB_SIZE_OPTIMIZATION",
"ICALL_EVENTS",
"ICALL_JT",
"ICALL_LITE",
"ICALL_MAX_NUM_ENTITIES=6",
"ICALL_MAX_NUM_TASKS=3",
"ICALL_STACK0_ADDR",
"POWER_SAVING",
"STACK_LIBRARY",
"TBM_ACTIVE_ITEMS_ONLY",
"NPI_USE_UART",
"NPI_FLOW_CTRL=0",
"OSAL_CBTIMER_NUM_TASKS=1",
"USE_ICALL",
"BLE_START",
"CC26XX",
"CC26X2",
"CC26X2R1_LAUNCHXL",
"FREERTOS",
]
if (ti_simplelink_device_family == "cc13x2x7_26x2x7") {
libs += [
"${ti_simplelink_sdk_root}/source/ti/dmm/lib/gcc/m4f/libdmmlib_freertos.a",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/libraries/cc26x2r1/OneLib.a",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/libraries/cc26x2r1/StackWrapper.a",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/libraries/cc26x2r1/ble_r2.symbols",
]
}
cflags = [
"-Wno-conversion",
"-Wno-comment",
"@" + rebase_path(ti_simplelink_sdk_root +
"/source/ti/ble5stack/config/build_components.opt",
root_build_dir),
"@" + rebase_path(ti_simplelink_sdk_root +
"/source/ti/ble5stack/config/factory_config.opt",
root_build_dir),
]
}
source_set("${sdk_target_name}_dmm") {
defines = []
include_dirs = [
"${chip_root}/third_party/openthread/repo/include/",
"${chip_root}/src/",
]
configs -=
[ "${build_root}/config/compiler:warnings_default" ] # removed for
# -Wshadow
cflags = [
"-Wno-sign-compare",
"-Wno-unused-variable",
"-Wno-implicit-function-declaration", # asm not defined
]
sources = [
"${ti_simplelink_sdk_root}/source/ti/ble5stack/common/cc26xx/freertos/TI_heap_wrapper.c",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/common/cc26xx/freertos/bget.c",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/common/cc26xx/rcosc/rcosc_calibration.c",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/host/gatt_uuid.c",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/host/gattservapp_util.c",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/icall/app/icall_api_lite.c",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/icall/src/icall_cc2650.c",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/icall/src/icall_user_config.c",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/icall/stack/ble_user_config_stack.c",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/profiles/dev_info/cc26xx/devinfoservice.c",
"${ti_simplelink_sdk_root}/source/ti/ble5stack/rom/agama_r1/rom_init.c",
"${ti_simplelink_sdk_root}/source/ti/dmm/apps/common/ble_remote_display/stack/osal_icall_ble.c",
"${ti_simplelink_sdk_root}/source/ti/dmm/apps/common/freertos/icall_FreeRTOS.c",
"${ti_simplelink_sdk_root}/source/ti/dmm/apps/common/freertos/util.c",
"${ti_simplelink_sdk_root}/source/ti/dmm/apps/common/thread/source/activity/dmm_thread_activity.c",
"${ti_simplelink_sdk_root}/source/ti/dmm/dmm_priority_ble_thread.c",
# Move this into the SDK
"${chip_root}/src/platform/cc13x2_26x2/ble_user_config.c",
"${chip_root}/src/platform/cc13x2_26x2/chipOBleProfile.c",
]
configs -= [ "${build_root}/config/compiler:std_default" ]
configs += [ ":${sdk_target_name}_posix_config" ]
public_deps = [
"${chip_root}/third_party/ti_simplelink_sdk:freertos",
"${chip_root}/third_party/ti_simplelink_sdk:ti_simplelink_sysconfig",
]
public_configs = [
":${sdk_target_name}_config",
":${sdk_target_name}_dmm_config",
]
}
group(sdk_target_name) {
public_deps = [
":${sdk_target_name}_dpl",
":${sdk_target_name}_freertos",
]
if (ti_simplelink_device_family == "cc13x2_26x2" ||
ti_simplelink_device_family == "cc13x2x7_26x2x7") {
public_deps += [
":${sdk_target_name}_dmm",
":${sdk_target_name}_openthread_platform",
]
}
if (defined(invoker.public_configs)) {
public_configs = invoker.public_configs
}
}
}