| # 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/jlink.gni") |
| import("//build_overrides/openthread.gni") |
| import("//build_overrides/qpg_sdk.gni") |
| import("qpg_platform.gni") |
| |
| declare_args() { |
| # Location of the QPG SDK. |
| qpg_sdk_root = "${chip_root}/third_party/qpg_sdk/repo" |
| |
| # subdirectory in qpg_sdk_root where the binary library builds (.a) are to be found |
| qpg_sdk_lib_dir = "Work" |
| |
| # an option to disable referencing qorvo object archive files (*.a) |
| qpg_sdk_include_platform_libs = true |
| |
| # Enable Sleepy end device |
| enable_sleepy_device = false |
| |
| # OTA parameters |
| matter_device_vid = "" |
| matter_device_pid = "" |
| matter_ota_test_image = false |
| } |
| |
| assert(qpg_sdk_root != "", "qpg_sdk_root must be specified") |
| assert(qpg_target_ic != "", "qpg_target_ic must be specified") |
| |
| # Defines an QPG SDK build target. |
| # |
| # Parameters: |
| # qpg_sdk_root - The location of the QPG SDK. |
| # sources - The sources files to build. |
| template("qpg_sdk") { |
| if (defined(invoker.qpg_sdk_root)) { |
| qpg_sdk_root = invoker.qpg_sdk_root |
| } |
| |
| if (defined(invoker.qpg_target_ic)) { |
| qpg_target_ic = invoker.qpg_target_ic |
| } |
| |
| assert(qpg_sdk_root != "", "qpg_sdk_root must be specified") |
| assert(qpg_target_ic != "", "qpg_target_ic must be specified") |
| |
| sdk_target_name = target_name |
| |
| config("${sdk_target_name}_config") { |
| include_dirs = [] |
| libs = [] |
| defines = [] |
| |
| if (defined(invoker.include_dirs)) { |
| include_dirs += invoker.include_dirs |
| } |
| |
| include_dirs += [ |
| "${qpg_sdk_root}/Components/Qorvo/Matter/qvCHIP/inc", |
| "${qpg_sdk_root}/Components/Qorvo/BSP/qvIO/inc", |
| "${openthread_root}/include", |
| ] |
| |
| if (mbedtls_alt_enabled) { |
| include_dirs += [ |
| "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt_3.3.0", |
| "${qpg_sdk_root}/Libraries/Qorvo/mbedtls_alt/inc", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/include", |
| ] |
| } else { |
| include_dirs += [ "${qpg_sdk_root}/Libraries/Qorvo/mbedtls_alt/inc" ] |
| } |
| |
| lib_dirs = [] |
| |
| #MBed TLS built from third_party/mbedtls tree - OT config not used |
| defines = [ "MBEDTLS_CONFIG_FILE=\"${qpg_target_ic}-mbedtls-config.h\"" ] |
| |
| # Overrule CHIPProjectConfig.h settings |
| if (matter_device_vid != "") { |
| defines += [ "CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID=${matter_device_vid}" ] |
| } |
| if (matter_device_pid != "") { |
| defines += [ "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=${matter_device_pid}" ] |
| } |
| if (matter_ota_test_image) { |
| defines += [ "OTA_TEST_IMAGE" ] |
| } |
| |
| if (qpg_target_ic == "qpg6200") { |
| defines += [ "QPG_6200" ] |
| } else { |
| include_dirs += [ "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt_3.3.0" ] |
| } |
| |
| if (mbedtls_alt_enabled) { |
| defines += [ "QORVO_CRYPTO_ENGINE" ] |
| } else { |
| defines += [ "MBEDTLS_SW_ONLY" ] |
| } |
| |
| #Wundef fix - to be updated in SDK |
| defines += [ "GP_SCHED_NR_OF_IDLE_CALLBACKS=0" ] |
| |
| cflags = [ "-Wundef" ] |
| |
| # Allow warning due to mbedtls |
| cflags += [ |
| "-Wno-maybe-uninitialized", |
| "-Wno-shadow", |
| ] |
| |
| # Inherit defines from invoker (i.e. examples app) |
| if (defined(invoker.defines)) { |
| defines += invoker.defines |
| } |
| |
| if (defined(invoker.enable_sleepy_device)) { |
| if (invoker.enable_sleepy_device) { |
| defines += [ "CHIP_DEVICE_CONFIG_ENABLE_SED=1" ] |
| } else { |
| defines += [ "CHIP_DEVICE_CONFIG_ENABLE_SED=0" ] |
| if (invoker.chip_openthread_ftd) { |
| defines += [ "CHIP_DEVICE_CONFIG_THREAD_FTD=1" ] |
| } else { |
| defines += [ "CHIP_DEVICE_CONFIG_THREAD_FTD=0" ] |
| } |
| } |
| } |
| } |
| |
| source_set(sdk_target_name) { |
| sources = [ |
| "${qpg_sdk_root}/Applications/Matter/shared/config/inc/FreeRTOSConfig.h", |
| "${qpg_sdk_root}/Applications/Matter/shared/config/src/hooks.c", |
| ] |
| |
| chip_glue_sources = [ |
| # |
| "${qpg_sdk_root}/Components/Qorvo/BSP/qvIO/inc/qvIO.h", |
| "${qpg_sdk_root}/Components/Qorvo/Matter/qvCHIP/inc/qvCHIP.h", |
| ] |
| sources += chip_glue_sources |
| |
| if (mbedtls_alt_enabled) { |
| mbedtls_alt_sources = [ |
| # Add alt src |
| "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt_3.3.0/aes_alt.h", |
| "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt_3.3.0/ecjpake_alt.h", |
| "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt_3.3.0/ecp_alt.h", |
| "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt_3.3.0/sha256_alt.h", |
| ] |
| } |
| |
| mbedtls_sources = [ |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/asn1parse.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/asn1write.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/bignum.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/bignum_core.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/ccm.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/cipher.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/cipher_wrap.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/ctr_drbg.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/ecdsa.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/entropy.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/hash_info.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/hkdf.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/hmac_drbg.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/md.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/oid.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/pk.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/pk_wrap.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/pkcs5.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/pkparse.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/pkwrite.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/platform.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/platform_util.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/sha1.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/sha256.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/x509_create.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/x509write_csr.c", |
| "${qpg_sdk_root}/Libraries/Qorvo/mbedtls_alt/inc/${qpg_target_ic}-mbedtls-config.h", |
| "${qpg_sdk_root}/Libraries/Qorvo/mbedtls_alt/src/trng.c", |
| ] |
| |
| sources += mbedtls_sources |
| |
| if (mbedtls_alt_enabled) { |
| sources += mbedtls_alt_sources |
| } else { |
| sources += [ |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/aes.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/constant_time.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/ecdh.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/ecp.c", |
| "${qpg_sdk_root}/Components/ThirdParty/ARM/mbedtls/v3.3.0/library/ecp_curves.c", |
| ] |
| } |
| |
| if (defined(invoker.sources)) { |
| sources += invoker.sources |
| } |
| |
| public_configs = [ ":${sdk_target_name}_config" ] |
| public_deps = [ "${chip_root}/third_party/qpg_sdk:freertos" ] |
| if (qpg_sdk_include_platform_libs) { |
| public_deps += [ |
| "${chip_root}/third_party/qpg_sdk:qpg_bootloader_lib", |
| "${chip_root}/third_party/qpg_sdk:qpg_glue_lib", |
| "${chip_root}/third_party/qpg_sdk:qpg_openthread_glue_lib", |
| "${chip_root}/third_party/qpg_sdk:qpg_stack_lib", |
| ] |
| |
| if (mbedtls_alt_enabled) { |
| public_deps += |
| [ "${chip_root}/third_party/qpg_sdk:qpg_mbedtls_alt_lib" ] |
| } |
| } |
| } |
| } |