From 60ba06ba0be4e17978e91d971822bc1f347e5ea0 Mon Sep 17 00:00:00 2001 From: marius-alex-tache Date: Fri, 20 Dec 2024 16:13:44 +0200 Subject: [PATCH 1/6] [openthread][mcxw71] Add ot-nxp platform file as include directory Signed-off-by: marius-alex-tache --- .../openthread/platforms/nxp/mcxw71_k32w1/BUILD.gn | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/third_party/openthread/platforms/nxp/mcxw71_k32w1/BUILD.gn b/third_party/openthread/platforms/nxp/mcxw71_k32w1/BUILD.gn index 2050591b8f4345..a9d753ec844258 100644 --- a/third_party/openthread/platforms/nxp/mcxw71_k32w1/BUILD.gn +++ b/third_party/openthread/platforms/nxp/mcxw71_k32w1/BUILD.gn @@ -24,7 +24,10 @@ import("${nxp_sdk_build_root}/nxp_sdk.gni") openthread_nxp_root = "${chip_root}/third_party/openthread/ot-nxp" config("openthread_k32w1_config") { - include_dirs = [ "${openthread_nxp_root}/src/k32w1" ] + include_dirs = [ + "${openthread_nxp_root}/src/k32w1", + "${openthread_nxp_root}/src/mcxw71" + ] defines = [ "OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1", @@ -111,10 +114,13 @@ source_set("libopenthread-k32w1") { "../..:libopenthread-platform-utils", ] + public_deps += [ + "${nxp_sdk_build_root}:nxp_mbedtls" + ] + if (!nxp_external_sdk) { public_deps += [ - "${nxp_sdk_build_root}:nxp_mbedtls", - nxp_sdk_target, + nxp_sdk_target ] } } From 562479820a612a37a6df86bd54a18bc34f611d20 Mon Sep 17 00:00:00 2001 From: marius-alex-tache Date: Thu, 16 Jan 2025 08:27:48 +0200 Subject: [PATCH 2/6] [platform][mcxw71] Remove unused openthread dep in mbedtls config file Signed-off-by: marius-alex-tache --- .../mcxw71_k32w1/k32w1-chip-mbedtls-config.h | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/src/platform/nxp/mcxw71_k32w1/k32w1-chip-mbedtls-config.h b/src/platform/nxp/mcxw71_k32w1/k32w1-chip-mbedtls-config.h index f3d9949f730df0..d7f4209ebd1209 100644 --- a/src/platform/nxp/mcxw71_k32w1/k32w1-chip-mbedtls-config.h +++ b/src/platform/nxp/mcxw71_k32w1/k32w1-chip-mbedtls-config.h @@ -19,15 +19,9 @@ #ifndef MBEDTLS_CONFIG_H #define MBEDTLS_CONFIG_H -#include "openthread-core-config.h" - #include #include -#include -#include -#include - #undef MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES #define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf @@ -67,16 +61,6 @@ #define MBEDTLS_SSL_PROTO_DTLS #define MBEDTLS_SSL_TLS_C -#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || OPENTHREAD_CONFIG_COMMISSIONER_ENABLE || OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE -#define MBEDTLS_SSL_COOKIE_C -#define MBEDTLS_SSL_SRV_C -#endif - -#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE -#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED -#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED -#endif - #ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED #define MBEDTLS_BASE64_C #define MBEDTLS_ECDH_C @@ -87,15 +71,6 @@ #define MBEDTLS_X509_CRT_PARSE_C #endif -#if OPENTHREAD_CONFIG_ECDSA_ENABLE -#define MBEDTLS_BASE64_C -#define MBEDTLS_ECDH_C -#define MBEDTLS_ECDSA_C -#define MBEDTLS_ECDSA_DETERMINISTIC -#define MBEDTLS_OID_C -#define MBEDTLS_PEM_PARSE_C -#define MBEDTLS_PK_WRITE_C -#endif #define MBEDTLS_MPI_WINDOW_SIZE 1 /**< Maximum windows size used. */ #define MBEDTLS_MPI_MAX_SIZE 32 /**< Maximum number of bytes for usable MPIs. */ @@ -104,19 +79,9 @@ #define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 /**< Enable fixed-point speed-up */ #define MBEDTLS_ENTROPY_MAX_SOURCES 2 /**< Maximum number of sources supported */ -#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE -#define MBEDTLS_PLATFORM_STD_CALLOC otPlatCAlloc /**< Default allocator to use, can be undefined */ -#define MBEDTLS_PLATFORM_STD_FREE otPlatFree /**< Default free to use, can be undefined */ -#else #define MBEDTLS_MEMORY_BUFFER_ALLOC_C -#endif -#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE -#define MBEDTLS_SSL_MAX_CONTENT_LEN 900 /**< Maxium fragment length in bytes */ -#else #define MBEDTLS_SSL_MAX_CONTENT_LEN 768 /**< Maxium fragment length in bytes */ -#endif - #define MBEDTLS_SSL_IN_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN #define MBEDTLS_SSL_OUT_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN #define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 From 9a6884f655340c4d8f6ff991c98a61013ff3afe4 Mon Sep 17 00:00:00 2001 From: marius-alex-tache Date: Thu, 16 Jan 2025 18:57:35 +0200 Subject: [PATCH 3/6] [platform][common] Add ota.gni to be reused by platform layer List some OTA files in an organized manner to avoid duplication in other gn files. Signed-off-by: marius-alex-tache --- src/platform/nxp/common/ota/ota.gni | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/platform/nxp/common/ota/ota.gni diff --git a/src/platform/nxp/common/ota/ota.gni b/src/platform/nxp/common/ota/ota.gni new file mode 100644 index 00000000000000..9746ed96837486 --- /dev/null +++ b/src/platform/nxp/common/ota/ota.gni @@ -0,0 +1,36 @@ +# Copyright (c) 2025 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/nxp_sdk.gni") +import("${nxp_sdk_build_root}/nxp_sdk.gni") + +ota_root = get_path_info(".", "abspath") + +ota_sources = [ + "${ota_root}/OTAImageProcessorImpl.cpp", + "${ota_root}/OTAImageProcessorImpl.h", + "${ota_root}/OTATlvProcessor.cpp", + "${ota_root}/OTATlvProcessor.h", + "${ota_root}/OTAFirmwareProcessor.cpp", + "${ota_root}/OTAFirmwareProcessor.h", + "${ota_root}/OTAHooks.cpp", +] + +if (nxp_use_factory_data && nxp_enable_ota_factory_data_processor) { + ota_sources += [ + "${ota_root}/OTAFactoryDataProcessor.cpp", + "${ota_root}/OTAFactoryDataProcessor.h", + ] +} From ce4b15f345ff40929e382f0b53c586638cb10212 Mon Sep 17 00:00:00 2001 From: marius-alex-tache Date: Thu, 16 Jan 2025 18:58:39 +0200 Subject: [PATCH 4/6] [platform][mcxw71] Use ota.gni Signed-off-by: marius-alex-tache --- src/platform/nxp/mcxw71_k32w1/BUILD.gn | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/platform/nxp/mcxw71_k32w1/BUILD.gn b/src/platform/nxp/mcxw71_k32w1/BUILD.gn index ca0953b1b10ca9..759bd0dba78eb4 100644 --- a/src/platform/nxp/mcxw71_k32w1/BUILD.gn +++ b/src/platform/nxp/mcxw71_k32w1/BUILD.gn @@ -18,6 +18,7 @@ import("//build_overrides/openthread.gni") import("${chip_root}/src/crypto/crypto.gni") import("${chip_root}/src/platform/device.gni") +import("${chip_root}/src/platform/nxp/common/ota/ota.gni") import("${nxp_sdk_build_root}/nxp_sdk.gni") @@ -53,22 +54,7 @@ source_set("nxp_factory_data") { source_set("nxp_ota") { public = [ "../common/ota/OTAImageProcessorImpl.h" ] - sources = [ - "../common/ota/OTAFirmwareProcessor.cpp", - "../common/ota/OTAFirmwareProcessor.h", - "../common/ota/OTAHooks.cpp", - "../common/ota/OTAImageProcessorImpl.cpp", - "../common/ota/OTAImageProcessorImpl.h", - "../common/ota/OTATlvProcessor.cpp", - "../common/ota/OTATlvProcessor.h", - ] - - if (nxp_use_factory_data && nxp_enable_ota_factory_data_processor) { - sources += [ - "../common/ota/OTAFactoryDataProcessor.cpp", - "../common/ota/OTAFactoryDataProcessor.h", - ] - } + sources = ota_sources deps = [ ":nxp_platform", @@ -150,6 +136,12 @@ static_library("nxp_platform") { ] } + # When the app is built using cmake, we must ensure the OTA platform files are also compiled. + # When the app is built using gn, the app selects the nxp_ota target through its build file. + if (nxp_external_sdk && chip_enable_ota_requestor) { + sources += ota_sources + } + if (nxp_use_plain_dac_key) { defines += [ "CHIP_USE_PLAIN_DAC_KEY=1" ] } else { From faac615f72b8e90182b5b040e0f62cc866d062ac Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 20 Jan 2025 10:29:08 +0000 Subject: [PATCH 5/6] Restyled by clang-format --- src/platform/nxp/mcxw71_k32w1/k32w1-chip-mbedtls-config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/platform/nxp/mcxw71_k32w1/k32w1-chip-mbedtls-config.h b/src/platform/nxp/mcxw71_k32w1/k32w1-chip-mbedtls-config.h index d7f4209ebd1209..ef244a7f4da479 100644 --- a/src/platform/nxp/mcxw71_k32w1/k32w1-chip-mbedtls-config.h +++ b/src/platform/nxp/mcxw71_k32w1/k32w1-chip-mbedtls-config.h @@ -71,7 +71,6 @@ #define MBEDTLS_X509_CRT_PARSE_C #endif - #define MBEDTLS_MPI_WINDOW_SIZE 1 /**< Maximum windows size used. */ #define MBEDTLS_MPI_MAX_SIZE 32 /**< Maximum number of bytes for usable MPIs. */ #define MBEDTLS_ECP_MAX_BITS 256 /**< Maximum bit size of groups */ From 44090579b496c80ccede039c25d5aad33b999c9c Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 20 Jan 2025 10:29:11 +0000 Subject: [PATCH 6/6] Restyled by gn --- src/platform/nxp/common/ota/ota.gni | 23 +++++++++---------- .../platforms/nxp/mcxw71_k32w1/BUILD.gn | 10 +++----- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/platform/nxp/common/ota/ota.gni b/src/platform/nxp/common/ota/ota.gni index 9746ed96837486..9bb621f56282c3 100644 --- a/src/platform/nxp/common/ota/ota.gni +++ b/src/platform/nxp/common/ota/ota.gni @@ -12,25 +12,24 @@ # See the License for the specific language governing permissions and # limitations under the License. - import("//build_overrides/nxp_sdk.gni") import("${nxp_sdk_build_root}/nxp_sdk.gni") ota_root = get_path_info(".", "abspath") ota_sources = [ - "${ota_root}/OTAImageProcessorImpl.cpp", - "${ota_root}/OTAImageProcessorImpl.h", - "${ota_root}/OTATlvProcessor.cpp", - "${ota_root}/OTATlvProcessor.h", - "${ota_root}/OTAFirmwareProcessor.cpp", - "${ota_root}/OTAFirmwareProcessor.h", - "${ota_root}/OTAHooks.cpp", + "${ota_root}/OTAFirmwareProcessor.cpp", + "${ota_root}/OTAFirmwareProcessor.h", + "${ota_root}/OTAHooks.cpp", + "${ota_root}/OTAImageProcessorImpl.cpp", + "${ota_root}/OTAImageProcessorImpl.h", + "${ota_root}/OTATlvProcessor.cpp", + "${ota_root}/OTATlvProcessor.h", ] if (nxp_use_factory_data && nxp_enable_ota_factory_data_processor) { - ota_sources += [ - "${ota_root}/OTAFactoryDataProcessor.cpp", - "${ota_root}/OTAFactoryDataProcessor.h", - ] + ota_sources += [ + "${ota_root}/OTAFactoryDataProcessor.cpp", + "${ota_root}/OTAFactoryDataProcessor.h", + ] } diff --git a/third_party/openthread/platforms/nxp/mcxw71_k32w1/BUILD.gn b/third_party/openthread/platforms/nxp/mcxw71_k32w1/BUILD.gn index a9d753ec844258..2bbfc4fae4b03a 100644 --- a/third_party/openthread/platforms/nxp/mcxw71_k32w1/BUILD.gn +++ b/third_party/openthread/platforms/nxp/mcxw71_k32w1/BUILD.gn @@ -26,7 +26,7 @@ openthread_nxp_root = "${chip_root}/third_party/openthread/ot-nxp" config("openthread_k32w1_config") { include_dirs = [ "${openthread_nxp_root}/src/k32w1", - "${openthread_nxp_root}/src/mcxw71" + "${openthread_nxp_root}/src/mcxw71", ] defines = [ @@ -114,13 +114,9 @@ source_set("libopenthread-k32w1") { "../..:libopenthread-platform-utils", ] - public_deps += [ - "${nxp_sdk_build_root}:nxp_mbedtls" - ] + public_deps += [ "${nxp_sdk_build_root}:nxp_mbedtls" ] if (!nxp_external_sdk) { - public_deps += [ - nxp_sdk_target - ] + public_deps += [ nxp_sdk_target ] } }