blob: 59cbd6afbc8dd2c8acd0c439297233a542ac3741 [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/chip.gni")
import("//build_overrides/efr32_sdk.gni")
import("//build_overrides/jlink.gni")
import("//build_overrides/mbedtls.gni")
import("efr32_board.gni")
declare_args() {
# Location of the efr32 SDK.
efr32_sdk_root = ""
}
if (efr32_sdk_root == "") {
efr32_sdk_root = getenv("EFR32_SDK_ROOT")
}
assert(efr32_sdk_root != "", "efr32_sdk_root must be specified")
# Defines an efr32 SDK build target.
#
# Parameters:
# efr32_sdk_root - The location of the erf32 SDK.
# sources - The sources files to build.
template("efr32_sdk") {
if (defined(invoker.efr32_sdk_root)) {
efr32_sdk_root = invoker.efr32_sdk_root
}
assert(efr32_sdk_root != "", "efr32_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 = [
"${efr32_sdk_root}",
"${efr32_sdk_root}/util/third_party/freertos/Source/include",
"${efr32_sdk_root}/platform/radio/rail_lib/hal",
"${efr32_sdk_root}/platform/radio/rail_lib/hal/efr32",
"${efr32_sdk_root}/hardware/kit/common/bsp",
"${efr32_sdk_root}/hardware/kit/common/drivers",
"${efr32_sdk_root}/platform/base",
"${efr32_sdk_root}/platform/base/hal",
"${efr32_sdk_root}/platform/base/hal/micro/cortexm3/compiler",
"${efr32_sdk_root}/platform/base/hal/micro/cortexm3/efm32",
"${efr32_sdk_root}/platform/base/hal/micro/cortexm3/efm32/config",
"${efr32_sdk_root}/platform/base/hal/micro/cortexm3",
"${efr32_sdk_root}/platform/base/hal/plugin",
"${efr32_sdk_root}/platform/CMSIS/Include",
"${efr32_sdk_root}/platform/emdrv/common/inc",
"${efr32_sdk_root}/platform/emdrv/gpiointerrupt/inc",
"${efr32_sdk_root}/platform/emdrv/uartdrv/inc",
"${efr32_sdk_root}/platform/emdrv/uartdrv/config",
"${efr32_sdk_root}/platform/emdrv/ustimer/inc",
"${efr32_sdk_root}/platform/emdrv/dmadrv/config",
"${efr32_sdk_root}/platform/emdrv/dmadrv/inc",
"${efr32_sdk_root}/platform/emdrv/nvm3/inc",
"${efr32_sdk_root}/platform/emdrv/rtcdrv/inc",
"${efr32_sdk_root}/platform/emdrv/sleep/inc",
"${efr32_sdk_root}/platform/emlib/inc",
"${efr32_sdk_root}/platform/halconfig/inc/hal-config",
"${efr32_sdk_root}/platform/radio/rail_lib/common",
"${efr32_sdk_root}/platform/radio/rail_lib/chip/efr32",
"${efr32_sdk_root}/platform/radio/rail_lib/protocol/ieee802154",
"${efr32_sdk_root}/platform/radio/rail_lib/chip/efr32/rf/common/cortex",
"${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions",
"${efr32_sdk_root}/util/plugin/plugin-common/fem-control",
"${efr32_sdk_root}/protocol/bluetooth/ble_stack/inc/soc",
"${efr32_sdk_root}/protocol/bluetooth/ble_stack/inc/common",
"${efr32_sdk_root}/app/bluetooth/common/util",
"${efr32_sdk_root}/util/third_party/freertos/Source/include",
"${efr32_sdk_root}/platform/service/mpu/inc",
"${efr32_sdk_root}/platform/service/sleeptimer/inc",
"${efr32_sdk_root}/platform/service/sleeptimer/config",
"${efr32_sdk_root}/platform/common/inc",
"${efr32_sdk_root}/platform/emdrv/nvm3/inc",
"${efr32_sdk_root}/platform/middleware/glib",
"${efr32_sdk_root}/platform/middleware/glib/glib",
"${efr32_sdk_root}/platform/middleware/glib/dmd",
"${efr32_sdk_root}/hardware/kit/config",
"${efr32_sdk_root}/util/silicon_labs/silabs_core/graphics",
"${efr32_sdk_root}/util/third_party/mbedtls/include",
"${efr32_sdk_root}/util/third_party/mbedtls/include/mbedtls",
"${efr32_sdk_root}/util/third_party/mbedtls/sl_crypto/include",
"${mbedtls_root}/repo/include",
]
defines = [
"MBEDTLS_CONFIG_FILE=\"efr32-chip-mbedtls-config.h\"",
"__STARTUP_CLEAR_BSS",
"HARD_FAULT_LOG_ENABLE",
"RETARGET_VCOM",
"RETARGET_USART0",
"PLATFORM_HEADER='<hal/micro/cortexm3/compiler/gcc.h>'",
"CORTEXM3_EFM32_MICRO",
"EFR32_LOG_ENABLED=1",
"NVM3_DEFAULT_NVM_SIZE=40960",
"EFR32_OPENTHREAD_API",
"NVIC_CONFIG=<platform/base/hal/micro/cortexm3/efm32/nvic-config.h>",
"PHY=EMBER_PHY_RAIL",
"CORTEXM3",
"MICRO=EMBER_MICRO_CORTEXM3_EFR32",
"PLAT=EMBER_PLATFORM_CORTEXM3",
"${efr32_mcu}",
"${efr32_board}=1",
]
defines += board_defines
if (efr32_family == "efr32mg12") {
_include_dirs += [
"${efr32_sdk_root}/hardware/kit/EFR32MG12_${efr32_board}/config",
"${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG12P/Include",
"${efr32_sdk_root}/platform/radio/rail_lib/chip/efr32/efr32xg1x",
"${efr32_sdk_root}/util/third_party/freertos/Source/portable/GCC/ARM_CM4F",
]
libs += [
"${efr32_sdk_root}/protocol/bluetooth/lib/EFR32MG12P/GCC/libbluetooth.a",
"${efr32_sdk_root}/platform/radio/rail_lib/autogen/librail_release/librail_multiprotocol_efr32xg12_gcc_release.a",
"${efr32_sdk_root}/platform/emdrv/nvm3/lib/libnvm3_CM4_gcc.a",
"${efr32_sdk_root}/protocol/bluetooth/lib/EFR32MG12P/GCC/libmbedtls.a",
]
defines += [ "EFR32MG12" ]
} else if (efr32_family == "efr32mg21") {
_include_dirs += [
"${efr32_sdk_root}/hardware/kit/EFR32MG21_${efr32_board}/config",
"${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG21/Include",
"${efr32_sdk_root}/platform/radio/rail_lib/chip/efr32/efr32xg2x",
"${efr32_sdk_root}/util/third_party/freertos/Source/portable/GCC/ARM_CM3",
]
libs += [
"${efr32_sdk_root}/protocol/bluetooth/lib/EFR32MG21/GCC/libbluetooth.a",
"${efr32_sdk_root}/platform/radio/rail_lib/autogen/librail_release/librail_multiprotocol_efr32xg21_gcc_release.a",
"${efr32_sdk_root}/platform/emdrv/nvm3/lib/libnvm3_CM33_gcc.a",
"${efr32_sdk_root}/protocol/bluetooth/lib/EFR32MG21/GCC/libmbedtls.a",
]
defines += [
"EFR32MG21",
"EFR32_SERIES2_CONFIG1_MICRO",
]
}
cflags = []
foreach(include_dir, _include_dirs) {
cflags += [ "-isystem" + rebase_path(include_dir, root_build_dir) ]
}
cflags += [ "-Wno-maybe-uninitialized" ]
if (defined(invoker.defines)) {
defines += invoker.defines
}
}
source_set(sdk_target_name) {
sources = [
"${chip_root}/third_party/mbedtls/repo/include/mbedtls/platform.h",
"${efr32_sdk_root}/hardware/kit/common/bsp/bsp_bcc.c",
"${efr32_sdk_root}/hardware/kit/common/bsp/bsp_init.c",
"${efr32_sdk_root}/hardware/kit/common/bsp/bsp_stk.c",
"${efr32_sdk_root}/hardware/kit/common/bsp/bsp_stk_leds.c",
"${efr32_sdk_root}/hardware/kit/common/drivers/retargetserial.c",
"${efr32_sdk_root}/hardware/kit/common/drivers/udelay.c",
"${efr32_sdk_root}/platform/emdrv/dmadrv/src/dmadrv.c",
"${efr32_sdk_root}/platform/emdrv/gpiointerrupt/src/gpiointerrupt.c",
"${efr32_sdk_root}/platform/emdrv/nvm3/src/nvm3_default.c",
"${efr32_sdk_root}/platform/emdrv/nvm3/src/nvm3_hal_flash.c",
"${efr32_sdk_root}/platform/emdrv/nvm3/src/nvm3_lock.c",
"${efr32_sdk_root}/platform/emdrv/sleep/src/sleep.c",
"${efr32_sdk_root}/platform/emdrv/uartdrv/src/uartdrv.c",
"${efr32_sdk_root}/platform/emdrv/ustimer/src/ustimer.c",
"${efr32_sdk_root}/platform/emlib/src/em_adc.c",
"${efr32_sdk_root}/platform/emlib/src/em_cmu.c",
"${efr32_sdk_root}/platform/emlib/src/em_core.c",
"${efr32_sdk_root}/platform/emlib/src/em_crypto.c",
"${efr32_sdk_root}/platform/emlib/src/em_emu.c",
"${efr32_sdk_root}/platform/emlib/src/em_gpio.c",
"${efr32_sdk_root}/platform/emlib/src/em_ldma.c",
"${efr32_sdk_root}/platform/emlib/src/em_leuart.c",
"${efr32_sdk_root}/platform/emlib/src/em_msc.c",
"${efr32_sdk_root}/platform/emlib/src/em_prs.c",
"${efr32_sdk_root}/platform/emlib/src/em_rmu.c",
"${efr32_sdk_root}/platform/emlib/src/em_rtcc.c",
"${efr32_sdk_root}/platform/emlib/src/em_se.c",
"${efr32_sdk_root}/platform/emlib/src/em_system.c",
"${efr32_sdk_root}/platform/emlib/src/em_timer.c",
"${efr32_sdk_root}/platform/emlib/src/em_usart.c",
"${efr32_sdk_root}/platform/middleware/glib/glib/bmp.c",
"${efr32_sdk_root}/platform/middleware/glib/glib/glib.c",
"${efr32_sdk_root}/platform/middleware/glib/glib/glib_bitmap.c",
"${efr32_sdk_root}/platform/middleware/glib/glib/glib_circle.c",
"${efr32_sdk_root}/platform/middleware/glib/glib/glib_font_narrow_6x8.c",
"${efr32_sdk_root}/platform/middleware/glib/glib/glib_font_normal_8x8.c",
"${efr32_sdk_root}/platform/middleware/glib/glib/glib_font_number_16x20.c",
"${efr32_sdk_root}/platform/middleware/glib/glib/glib_line.c",
"${efr32_sdk_root}/platform/middleware/glib/glib/glib_polygon.c",
"${efr32_sdk_root}/platform/middleware/glib/glib/glib_rectangle.c",
"${efr32_sdk_root}/platform/middleware/glib/glib/glib_string.c",
"${efr32_sdk_root}/platform/radio/rail_lib/hal/efr32/hal_efr.c",
"${efr32_sdk_root}/platform/radio/rail_lib/hal/hal_common.c",
"${efr32_sdk_root}/platform/service/mpu/src/sl_mpu.c",
"${efr32_sdk_root}/platform/service/sleeptimer/src/sl_sleeptimer.c",
"${efr32_sdk_root}/platform/service/sleeptimer/src/sl_sleeptimer_hal_rtcc.c",
"${efr32_sdk_root}/util/third_party/freertos/Source/croutine.c",
"${efr32_sdk_root}/util/third_party/freertos/Source/event_groups.c",
"${efr32_sdk_root}/util/third_party/freertos/Source/include/FreeRTOS.h",
"${efr32_sdk_root}/util/third_party/freertos/Source/list.c",
"${efr32_sdk_root}/util/third_party/freertos/Source/portable/MemMang/heap_3.c",
"${efr32_sdk_root}/util/third_party/freertos/Source/queue.c",
"${efr32_sdk_root}/util/third_party/freertos/Source/tasks.c",
"${efr32_sdk_root}/util/third_party/freertos/Source/timers.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/aes.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/aesni.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/arc4.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/asn1parse.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/asn1write.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/base64.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/bignum.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/blowfish.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/camellia.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ccm.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/certs.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/cipher.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/cipher_wrap.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ctr_drbg.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/debug.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/des.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/dhm.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ecdh.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ecdsa.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ecjpake.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ecp.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ecp_curves.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/entropy.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/entropy_poll.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/error.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/gcm.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/hmac_drbg.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/md.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/md5.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/md_wrap.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/oid.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/pem.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/pk.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/pk_wrap.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/pkcs12.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/pkcs5.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/pkparse.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/pkwrite.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/platform.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ripemd160.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/rsa.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/rsa_internal.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/sha1.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/sha256.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/sha512.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ssl_cache.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ssl_ciphersuites.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ssl_cli.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ssl_cookie.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ssl_srv.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ssl_ticket.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/ssl_tls.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/threading.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/timing.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/version.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/version_features.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/x509.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/x509_create.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/x509_crl.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/x509_csr.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/x509write_crt.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/x509write_csr.c",
"${efr32_sdk_root}/util/third_party/mbedtls/library/xtea.c",
"${efr32_sdk_root}/util/third_party/mbedtls/sl_crypto/src/aes_aes.c",
"${efr32_sdk_root}/util/third_party/mbedtls/sl_crypto/src/crypto_aes.c",
"${efr32_sdk_root}/util/third_party/mbedtls/sl_crypto/src/crypto_ble.c",
"${efr32_sdk_root}/util/third_party/mbedtls/sl_crypto/src/crypto_ecp.c",
"${efr32_sdk_root}/util/third_party/mbedtls/sl_crypto/src/crypto_management.c",
"${efr32_sdk_root}/util/third_party/mbedtls/sl_crypto/src/crypto_sha.c",
"${efr32_sdk_root}/util/third_party/mbedtls/sl_crypto/src/se_trng.c",
"${efr32_sdk_root}/util/third_party/mbedtls/sl_crypto/src/shax.c",
"${efr32_sdk_root}/util/third_party/mbedtls/sl_crypto/src/trng.c",
"${mbedtls_root}/repo/library/hkdf.c",
"${mbedtls_root}/repo/library/platform_util.c",
]
if (defined(enable_fem)) {
sources += [
"${efr32_sdk_root}/util/plugin/plugin-common/fem-control/fem-control.c",
]
}
if (defined(invoker.show_qr_code)) {
if (invoker.show_qr_code) {
sources += [
"${efr32_sdk_root}/hardware/kit/common/drivers/display.c",
"${efr32_sdk_root}/hardware/kit/common/drivers/displayls013b7dh03.c",
"${efr32_sdk_root}/hardware/kit/common/drivers/displaypalemlib.c",
"${efr32_sdk_root}/platform/middleware/glib/dmd/display/dmd_display.c",
"${efr32_sdk_root}/util/silicon_labs/silabs_core/graphics/graphics.c",
]
}
}
if (efr32_family == "efr32mg12") {
sources += [
"${efr32_sdk_root}/hardware/kit/common/drivers/mx25flash_spi.c",
"${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG12P/Source/GCC/startup_efr32mg12p.c",
"${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG12P/Source/system_efr32mg12p.c",
"${efr32_sdk_root}/util/third_party/freertos/Source/portable/GCC/ARM_CM4F/port.c",
]
} else if (efr32_family == "efr32mg21") {
sources += [
"${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG21/Source/GCC/startup_efr32mg21.c",
"${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG21/Source/system_efr32mg21.c",
"${efr32_sdk_root}/util/third_party/freertos/Source/portable/GCC/ARM_CM3/port.c",
]
}
public_deps = [
"${segger_rtt_root}:segger_rtt",
"${segger_rtt_root}:segger_rtt_printf",
"${segger_rtt_root}:segger_rtt_syscalls",
]
if (defined(invoker.sources)) {
sources += invoker.sources
}
public_configs = [ ":${sdk_target_name}_config" ]
}
}