From 090cfba7fec54dcb24bd2ca8408ee43499557c1e Mon Sep 17 00:00:00 2001 From: Thomas Langewouters <82949801+q-thla@users.noreply.github.com> Date: Wed, 28 Sep 2022 14:11:33 +0200 Subject: [PATCH] Build Qorvo libraries, use QMatter v0.9.0.0-libs (#22864) Build Qorvo libraries instead of using binary artifacts Reduce mbedtls sources list Use ld path without '_mrom' in the name use compiler executables from $PATH --- .gitmodules | 4 +- third_party/openthread/platforms/qpg/BUILD.gn | 4 - third_party/qpg_sdk/BUILD.gn | 131 ++++++++++++++++++ third_party/qpg_sdk/make.py | 23 +++ third_party/qpg_sdk/qpg_sdk.gni | 129 +++++------------ third_party/qpg_sdk/repo | 2 +- 6 files changed, 190 insertions(+), 103 deletions(-) create mode 100755 third_party/qpg_sdk/make.py diff --git a/.gitmodules b/.gitmodules index f5b4f75ec7b6ac..5a60849e011130 100644 --- a/.gitmodules +++ b/.gitmodules @@ -51,8 +51,8 @@ branch = master [submodule "qpg_sdk"] path = third_party/qpg_sdk/repo - url = https://github.com/Qorvo/qpg-connectedhomeip - branch = master + url = https://github.com/Qorvo/QMatter + branch = v0.9.0.0-libs platforms = qpg [submodule "zap"] path = third_party/zap/repo diff --git a/third_party/openthread/platforms/qpg/BUILD.gn b/third_party/openthread/platforms/qpg/BUILD.gn index 4a3c7634b2f7d9..d7e0b9590386b1 100644 --- a/third_party/openthread/platforms/qpg/BUILD.gn +++ b/third_party/openthread/platforms/qpg/BUILD.gn @@ -64,10 +64,6 @@ source_set("libopenthread-qpg") { ] include_dirs += [ "${openthread_root}/examples/apps" ] - if (qpg_sdk_include_platform_libs) { - libs = [ "${qpg_sdk_root}/${qpg_sdk_lib_dir}/OpenThreadQorvoGlue_${qpg_target_ic}_mtd/libOpenThreadQorvoGlue_${qpg_target_ic}_mtd.a" ] - } - public_deps = [ ":openthread_core_config_qpg", "${openthread_root}/src/core:libopenthread_core_headers", diff --git a/third_party/qpg_sdk/BUILD.gn b/third_party/qpg_sdk/BUILD.gn index c7cf2b29d0b7bc..88263ed5a4ebfe 100755 --- a/third_party/qpg_sdk/BUILD.gn +++ b/third_party/qpg_sdk/BUILD.gn @@ -47,3 +47,134 @@ freertos_target("freertos") { public_configs = [ ":qpg_freertos_config" ] } + +template("qpg_make_build") { + forward_variables_from(invoker, + [ + "make_sources", + "make_args", + "make_output", + ]) + action(target_name) { + script = "make.py" + sources = make_sources + outputs = make_output + args = [ + "-s", + + #use PATH variable lookup for compiler + "TOOLCHAIN=", + ] + args += make_args + } +} + +qpg_make_build("qpg_mbedtls_alt") { + make_sources = [ "${qpg_sdk_root}/Components/ThirdParty/Silex" ] + make_output = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/mbedtls_alt_${qpg_target_ic}/libmbedtls_alt_${qpg_target_ic}.a" ] + make_args = [ + "-f", + rebase_path(qpg_sdk_root, root_build_dir) + + "/Libraries/Qorvo/mbedtls_alt/Makefile.mbedtls_alt_${qpg_target_ic}", + "MBEDTLS_REPO_DIR=" + rebase_path(chip_root, root_build_dir) + + "/third_party/mbedtls/repo", + "WORKDIR=" + rebase_path(target_gen_dir, root_build_dir) + + "/${qpg_sdk_lib_dir}/mbedtls_alt_${qpg_target_ic}", + ] +} + +static_library("qpg_mbedtls_alt_lib") { + deps = [ "${chip_root}/third_party/qpg_sdk:qpg_mbedtls_alt" ] + libs = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/mbedtls_alt_${qpg_target_ic}/libmbedtls_alt_${qpg_target_ic}.a" ] +} + +qpg_make_build("qpg_stack") { + make_sources = [ "${qpg_sdk_root}/Components/Qorvo" ] + make_output = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/QorvoStack/libQorvoStack_${qpg_target_ic}.a" ] + make_args = [ + "-f", + rebase_path(qpg_sdk_root, root_build_dir) + + "/Libraries/Qorvo/QorvoStack/Makefile.QorvoStack_${qpg_target_ic}", + "FREERTOS_REPO_DIR=" + rebase_path(chip_root, root_build_dir) + + "/third_party/freertos/repo", + "WORKDIR=" + rebase_path(target_gen_dir, root_build_dir) + + "/${qpg_sdk_lib_dir}/QorvoStack", + ] +} + +static_library("qpg_stack_lib") { + deps = [ "${chip_root}/third_party/qpg_sdk:qpg_stack" ] + libs = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/QorvoStack/libQorvoStack_${qpg_target_ic}.a" ] +} + +qpg_make_build("qpg_glue") { + make_sources = [ "${qpg_sdk_root}/Components/Qorvo/Matter" ] + make_output = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/MatterQorvoGlue/libMatterQorvoGlue_${qpg_target_ic}_libbuild.a" ] + make_args = [ + "-f", + rebase_path(qpg_sdk_root, root_build_dir) + "/Libraries/Qorvo/MatterQorvoGlue/Makefile.MatterQorvoGlue_${qpg_target_ic}_libbuild", + "FREERTOS_REPO_DIR=" + rebase_path(chip_root, root_build_dir) + + "/third_party/freertos/repo", + "MBEDTLS_REPO_DIR=" + rebase_path(chip_root, root_build_dir) + + "/third_party/mbedtls/repo", + "WORKDIR=" + rebase_path(target_gen_dir, root_build_dir) + + "/${qpg_sdk_lib_dir}/MatterQorvoGlue", + ] +} +static_library("qpg_glue_lib") { + deps = [ "${chip_root}/third_party/qpg_sdk:qpg_glue" ] + libs = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/MatterQorvoGlue/libMatterQorvoGlue_${qpg_target_ic}_libbuild.a" ] +} + +# openthread toevoegen +# bootloader build +# +qpg_make_build("qpg_bootloader") { + make_sources = [ "${qpg_sdk_root}/Libraries/Qorvo/Bootloader" ] + make_output = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/Bootloader_${qpg_target_ic}_compr_secure/libBootloader_${qpg_target_ic}_compr_secure.a" ] + make_args = [ + "-f", + rebase_path(qpg_sdk_root, root_build_dir) + "/Libraries/Qorvo/Bootloader/Makefile.Bootloader_${qpg_target_ic}_compr_secure", + "FREERTOS_REPO_DIR=" + rebase_path(chip_root, root_build_dir) + + "/third_party/freertos/repo", + "MBEDTLS_REPO_DIR=" + rebase_path(chip_root, root_build_dir) + + "/third_party/mbedtls/repo", + "WORKDIR=" + rebase_path(target_gen_dir, root_build_dir) + + "/${qpg_sdk_lib_dir}/Bootloader_${qpg_target_ic}_compr_secure", + "UMB_WORKDIR=" + rebase_path(target_gen_dir, root_build_dir) + + "/${qpg_sdk_lib_dir}/UMB_QPG6105DK_B01_nrt_flash_compr_secure", + ] +} +config("qpg_retain_bootloader") { + ldflags = [ + "-Wl,-u_binary_bl_userlicense_bin_start", + "-Wl,-u_binary_bootloader_bin_start", + ] +} + +static_library("qpg_bootloader_lib") { + deps = [ "${chip_root}/third_party/qpg_sdk:qpg_bootloader" ] + libs = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/Bootloader_${qpg_target_ic}_compr_secure/libBootloader_${qpg_target_ic}_compr_secure.a" ] + public_configs = [ ":qpg_retain_bootloader" ] +} + +qpg_make_build("qpg_openthread_glue") { + make_sources = [ "${qpg_sdk_root}/Components/Qorvo/Matter" ] + make_output = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/OpenThreadQorvoGlue_qpg6105_mtd/libOpenThreadQorvoGlue_${qpg_target_ic}_mtd.a" ] + make_args = [ + "-f", + rebase_path(qpg_sdk_root, root_build_dir) + "/Libraries/Qorvo/OpenThreadQorvoGlue/Makefile.OpenThreadQorvoGlue_${qpg_target_ic}_mtd", + "FREERTOS_REPO_DIR=" + rebase_path(chip_root, root_build_dir) + + "/third_party/freertos/repo", + "MBEDTLS_REPO_DIR=" + rebase_path(chip_root, root_build_dir) + + "/third_party/mbedtls/repo", + "OPENTHREAD_REPO_DIR =" + rebase_path(chip_root, root_build_dir) + + "/third_party/openthread/repo", + "WORKDIR=" + rebase_path(target_gen_dir, root_build_dir) + + "/${qpg_sdk_lib_dir}/OpenThreadQorvoGlue_${qpg_target_ic}_mtd", + ] +} +static_library("qpg_openthread_glue_lib") { + deps = [ "${chip_root}/third_party/qpg_sdk:qpg_openthread_glue" ] + libs = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/OpenThreadQorvoGlue_qpg6105_mtd/libOpenThreadQorvoGlue_${qpg_target_ic}_mtd.a" ] +} diff --git a/third_party/qpg_sdk/make.py b/third_party/qpg_sdk/make.py new file mode 100755 index 00000000000000..d6a1b3ee0ebc84 --- /dev/null +++ b/third_party/qpg_sdk/make.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2022 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. +# + +'''Python wrapper to call make based builds within the SDK +''' +import subprocess +import sys + +subprocess.run(['make', '-j'] + sys.argv[1:], check=True) diff --git a/third_party/qpg_sdk/qpg_sdk.gni b/third_party/qpg_sdk/qpg_sdk.gni index 708a29c15b6b74..c1415af3743f93 100644 --- a/third_party/qpg_sdk/qpg_sdk.gni +++ b/third_party/qpg_sdk/qpg_sdk.gni @@ -23,9 +23,7 @@ declare_args() { 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 - # for connectedhomeip-qpg: Binaries (default) - # for matter endnodes sdk: Work - qpg_sdk_lib_dir = "Binaries" + qpg_sdk_lib_dir = "Work" # Target IC for QPG SDK qpg_target_ic = "qpg6105" @@ -69,28 +67,12 @@ template("qpg_sdk") { "${qpg_sdk_root}/Components/Qorvo/BSP/qvIO/inc", "${qpg_sdk_root}/Libraries/Qorvo/mbedtls_alt/inc", "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt", - "${qpg_sdk_root}/Components/ThirdParty/Lwip", - "${qpg_sdk_root}/Components/ThirdParty/Lwip/arch", "${mbedtls_root}/repo/include", "${openthread_root}/include", ] lib_dirs = [] - if (qpg_sdk_include_platform_libs) { - libs += [ - "${qpg_sdk_root}/${qpg_sdk_lib_dir}/MatterQorvoGlue_${qpg_target_ic}_libbuild/libMatterQorvoGlue_${qpg_target_ic}_libbuild.a", - "${qpg_sdk_root}/${qpg_sdk_lib_dir}/QorvoStack_${qpg_target_ic}/libQorvoStack_${qpg_target_ic}.a", - "${qpg_sdk_root}/${qpg_sdk_lib_dir}/mbedtls_alt_${qpg_target_ic}/libmbedtls_alt_${qpg_target_ic}.a", - "${qpg_sdk_root}/${qpg_sdk_lib_dir}/Bootloader_${qpg_target_ic}_compr_secure/libBootloader_${qpg_target_ic}_compr_secure.a", - ] - } - - ldflags = [ - "-Wl,-u_binary_bl_userlicense_bin_start", - "-Wl,-u_binary_bootloader_bin_start", - ] - #MBed TLS built from third_party/mbedtls tree - OT config not used defines = [ "QORVO_CRYPTO_ENGINE", @@ -111,108 +93,54 @@ template("qpg_sdk") { source_set(sdk_target_name) { sources = [ - "${chip_root}/third_party/mbedtls/repo/include/mbedtls/platform.h", - "${chip_root}/third_party/mbedtls/repo/library/aes.c", - "${chip_root}/third_party/mbedtls/repo/library/aesni.c", - "${chip_root}/third_party/mbedtls/repo/library/arc4.c", - "${chip_root}/third_party/mbedtls/repo/library/aria.c", + "${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 + + mbedtls_alt_sources = [ + # Add alt src + "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt/aes_alt.h", + "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt/ccm_alt.h", + "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt/ecjpake_alt.h", + "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt/ecp_alt.h", + "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt/sha256_alt.h", + "${qpg_sdk_root}/Libraries/Qorvo/mbedtls_alt/inc/${qpg_target_ic}-mbedtls-config.h", + "${qpg_sdk_root}/Libraries/Qorvo/mbedtls_alt/src/trng.c", + ] + mbedtls_sources = [ "${chip_root}/third_party/mbedtls/repo/library/asn1parse.c", "${chip_root}/third_party/mbedtls/repo/library/asn1write.c", - "${chip_root}/third_party/mbedtls/repo/library/base64.c", "${chip_root}/third_party/mbedtls/repo/library/bignum.c", - "${chip_root}/third_party/mbedtls/repo/library/blowfish.c", - "${chip_root}/third_party/mbedtls/repo/library/camellia.c", "${chip_root}/third_party/mbedtls/repo/library/ccm.c", - "${chip_root}/third_party/mbedtls/repo/library/certs.c", - "${chip_root}/third_party/mbedtls/repo/library/chacha20.c", - "${chip_root}/third_party/mbedtls/repo/library/chachapoly.c", "${chip_root}/third_party/mbedtls/repo/library/cipher.c", "${chip_root}/third_party/mbedtls/repo/library/cipher_wrap.c", - "${chip_root}/third_party/mbedtls/repo/library/cmac.c", - "${chip_root}/third_party/mbedtls/repo/library/constant_time.c", "${chip_root}/third_party/mbedtls/repo/library/ctr_drbg.c", - "${chip_root}/third_party/mbedtls/repo/library/debug.c", - "${chip_root}/third_party/mbedtls/repo/library/des.c", - "${chip_root}/third_party/mbedtls/repo/library/dhm.c", - "${chip_root}/third_party/mbedtls/repo/library/ecdh.c", "${chip_root}/third_party/mbedtls/repo/library/ecdsa.c", - "${chip_root}/third_party/mbedtls/repo/library/ecjpake.c", - "${chip_root}/third_party/mbedtls/repo/library/ecp.c", - "${chip_root}/third_party/mbedtls/repo/library/ecp_curves.c", "${chip_root}/third_party/mbedtls/repo/library/entropy.c", - "${chip_root}/third_party/mbedtls/repo/library/entropy_poll.c", - "${chip_root}/third_party/mbedtls/repo/library/error.c", - "${chip_root}/third_party/mbedtls/repo/library/gcm.c", - "${chip_root}/third_party/mbedtls/repo/library/havege.c", "${chip_root}/third_party/mbedtls/repo/library/hkdf.c", "${chip_root}/third_party/mbedtls/repo/library/hmac_drbg.c", "${chip_root}/third_party/mbedtls/repo/library/md.c", - "${chip_root}/third_party/mbedtls/repo/library/md2.c", - "${chip_root}/third_party/mbedtls/repo/library/md4.c", - "${chip_root}/third_party/mbedtls/repo/library/md5.c", - "${chip_root}/third_party/mbedtls/repo/library/memory_buffer_alloc.c", - "${chip_root}/third_party/mbedtls/repo/library/net_sockets.c", - "${chip_root}/third_party/mbedtls/repo/library/nist_kw.c", "${chip_root}/third_party/mbedtls/repo/library/oid.c", - "${chip_root}/third_party/mbedtls/repo/library/padlock.c", - "${chip_root}/third_party/mbedtls/repo/library/pem.c", "${chip_root}/third_party/mbedtls/repo/library/pk.c", "${chip_root}/third_party/mbedtls/repo/library/pk_wrap.c", - "${chip_root}/third_party/mbedtls/repo/library/pkcs11.c", - "${chip_root}/third_party/mbedtls/repo/library/pkcs12.c", "${chip_root}/third_party/mbedtls/repo/library/pkcs5.c", "${chip_root}/third_party/mbedtls/repo/library/pkparse.c", "${chip_root}/third_party/mbedtls/repo/library/pkwrite.c", "${chip_root}/third_party/mbedtls/repo/library/platform.c", "${chip_root}/third_party/mbedtls/repo/library/platform_util.c", - "${chip_root}/third_party/mbedtls/repo/library/poly1305.c", - "${chip_root}/third_party/mbedtls/repo/library/psa_crypto.c", - "${chip_root}/third_party/mbedtls/repo/library/psa_crypto_driver_wrappers.c", - "${chip_root}/third_party/mbedtls/repo/library/psa_crypto_se.c", - "${chip_root}/third_party/mbedtls/repo/library/psa_crypto_slot_management.c", - "${chip_root}/third_party/mbedtls/repo/library/psa_crypto_storage.c", - "${chip_root}/third_party/mbedtls/repo/library/psa_its_file.c", - "${chip_root}/third_party/mbedtls/repo/library/ripemd160.c", - "${chip_root}/third_party/mbedtls/repo/library/rsa.c", - "${chip_root}/third_party/mbedtls/repo/library/rsa_internal.c", "${chip_root}/third_party/mbedtls/repo/library/sha1.c", "${chip_root}/third_party/mbedtls/repo/library/sha256.c", - "${chip_root}/third_party/mbedtls/repo/library/sha512.c", - "${chip_root}/third_party/mbedtls/repo/library/ssl_cache.c", - "${chip_root}/third_party/mbedtls/repo/library/ssl_ciphersuites.c", - "${chip_root}/third_party/mbedtls/repo/library/ssl_cli.c", - "${chip_root}/third_party/mbedtls/repo/library/ssl_cookie.c", - "${chip_root}/third_party/mbedtls/repo/library/ssl_msg.c", - "${chip_root}/third_party/mbedtls/repo/library/ssl_srv.c", - "${chip_root}/third_party/mbedtls/repo/library/ssl_ticket.c", - "${chip_root}/third_party/mbedtls/repo/library/ssl_tls.c", - "${chip_root}/third_party/mbedtls/repo/library/ssl_tls13_keys.c", - "${chip_root}/third_party/mbedtls/repo/library/threading.c", - "${chip_root}/third_party/mbedtls/repo/library/timing.c", - "${chip_root}/third_party/mbedtls/repo/library/version.c", - "${chip_root}/third_party/mbedtls/repo/library/version_features.c", - "${chip_root}/third_party/mbedtls/repo/library/x509.c", "${chip_root}/third_party/mbedtls/repo/library/x509_create.c", - "${chip_root}/third_party/mbedtls/repo/library/x509_crl.c", - "${chip_root}/third_party/mbedtls/repo/library/x509_crt.c", - "${chip_root}/third_party/mbedtls/repo/library/x509_csr.c", - "${chip_root}/third_party/mbedtls/repo/library/x509write_crt.c", "${chip_root}/third_party/mbedtls/repo/library/x509write_csr.c", - "${chip_root}/third_party/mbedtls/repo/library/xtea.c", - "${qpg_sdk_root}/Applications/Matter/shared/config/inc/FreeRTOSConfig.h", - "${qpg_sdk_root}/Applications/Matter/shared/config/src/hooks.c", - "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt/aes_alt.h", - "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt/ccm_alt.h", - "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt/ecjpake_alt.h", - "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt/ecp_alt.h", - "${qpg_sdk_root}/Components/ThirdParty/Silex/cryptosoc/mbedtls_alt/sha256_alt.h", - "${qpg_sdk_root}/Libraries/Qorvo/mbedtls_alt/inc/${qpg_target_ic}-mbedtls-config.h", - "${qpg_sdk_root}/Libraries/Qorvo/mbedtls_alt/src/trng.c", - - # mbedtls_hardware_poll - "${qpg_sdk_root}/Components/Qorvo/BSP/qvIO/inc/qvIO.h", - "${qpg_sdk_root}/Components/Qorvo/Matter/qvCHIP/inc/qvCHIP.h", ] + sources += mbedtls_sources + mbedtls_alt_sources if (defined(invoker.sources)) { sources += invoker.sources @@ -220,5 +148,14 @@ template("qpg_sdk") { 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_mbedtls_alt_lib", + "${chip_root}/third_party/qpg_sdk:qpg_openthread_glue_lib", + "${chip_root}/third_party/qpg_sdk:qpg_stack_lib", + ] + } } } diff --git a/third_party/qpg_sdk/repo b/third_party/qpg_sdk/repo index 35ccb383fb401a..e92a7eb78f7f8a 160000 --- a/third_party/qpg_sdk/repo +++ b/third_party/qpg_sdk/repo @@ -1 +1 @@ -Subproject commit 35ccb383fb401ad8ed02162a33915b1dff2af9d0 +Subproject commit e92a7eb78f7f8aa4de774cdd973272767eab2e8a