Skip to content

Commit c7024d3

Browse files
[NXP] Add ota gn file & minor fixes (#37121)
* [openthread][mcxw71] Add ot-nxp platform file as include directory Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [platform][mcxw71] Remove unused openthread dep in mbedtls config file Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * [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 <marius.tache@nxp.com> * [platform][mcxw71] Use ota.gni Signed-off-by: marius-alex-tache <marius.tache@nxp.com> * Restyled by clang-format * Restyled by gn --------- Signed-off-by: marius-alex-tache <marius.tache@nxp.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 789e941 commit c7024d3

File tree

4 files changed

+50
-57
lines changed

4 files changed

+50
-57
lines changed

src/platform/nxp/common/ota/ota.gni

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (c) 2025 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/nxp_sdk.gni")
16+
import("${nxp_sdk_build_root}/nxp_sdk.gni")
17+
18+
ota_root = get_path_info(".", "abspath")
19+
20+
ota_sources = [
21+
"${ota_root}/OTAFirmwareProcessor.cpp",
22+
"${ota_root}/OTAFirmwareProcessor.h",
23+
"${ota_root}/OTAHooks.cpp",
24+
"${ota_root}/OTAImageProcessorImpl.cpp",
25+
"${ota_root}/OTAImageProcessorImpl.h",
26+
"${ota_root}/OTATlvProcessor.cpp",
27+
"${ota_root}/OTATlvProcessor.h",
28+
]
29+
30+
if (nxp_use_factory_data && nxp_enable_ota_factory_data_processor) {
31+
ota_sources += [
32+
"${ota_root}/OTAFactoryDataProcessor.cpp",
33+
"${ota_root}/OTAFactoryDataProcessor.h",
34+
]
35+
}

src/platform/nxp/mcxw71_k32w1/BUILD.gn

+8-16
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import("//build_overrides/openthread.gni")
1818

1919
import("${chip_root}/src/crypto/crypto.gni")
2020
import("${chip_root}/src/platform/device.gni")
21+
import("${chip_root}/src/platform/nxp/common/ota/ota.gni")
2122

2223
import("${nxp_sdk_build_root}/nxp_sdk.gni")
2324

@@ -53,22 +54,7 @@ source_set("nxp_factory_data") {
5354
source_set("nxp_ota") {
5455
public = [ "../common/ota/OTAImageProcessorImpl.h" ]
5556

56-
sources = [
57-
"../common/ota/OTAFirmwareProcessor.cpp",
58-
"../common/ota/OTAFirmwareProcessor.h",
59-
"../common/ota/OTAHooks.cpp",
60-
"../common/ota/OTAImageProcessorImpl.cpp",
61-
"../common/ota/OTAImageProcessorImpl.h",
62-
"../common/ota/OTATlvProcessor.cpp",
63-
"../common/ota/OTATlvProcessor.h",
64-
]
65-
66-
if (nxp_use_factory_data && nxp_enable_ota_factory_data_processor) {
67-
sources += [
68-
"../common/ota/OTAFactoryDataProcessor.cpp",
69-
"../common/ota/OTAFactoryDataProcessor.h",
70-
]
71-
}
57+
sources = ota_sources
7258

7359
deps = [
7460
":nxp_platform",
@@ -138,6 +124,12 @@ static_library("nxp_platform") {
138124
]
139125
}
140126

127+
# When the app is built using cmake, we must ensure the OTA platform files are also compiled.
128+
# When the app is built using gn, the app selects the nxp_ota target through its build file.
129+
if (nxp_external_sdk && chip_enable_ota_requestor) {
130+
sources += ota_sources
131+
}
132+
141133
if (nxp_use_plain_dac_key) {
142134
defines += [ "CHIP_USE_PLAIN_DAC_KEY=1" ]
143135
} else {

src/platform/nxp/mcxw71_k32w1/k32w1-chip-mbedtls-config.h

-36
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,9 @@
1919
#ifndef MBEDTLS_CONFIG_H
2020
#define MBEDTLS_CONFIG_H
2121

22-
#include "openthread-core-config.h"
23-
2422
#include <stdio.h>
2523
#include <stdlib.h>
2624

27-
#include <openthread/config.h>
28-
#include <openthread/platform/logging.h>
29-
#include <openthread/platform/memory.h>
30-
3125
#undef MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
3226
#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf
3327

@@ -67,16 +61,6 @@
6761
#define MBEDTLS_SSL_PROTO_DTLS
6862
#define MBEDTLS_SSL_TLS_C
6963

70-
#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || OPENTHREAD_CONFIG_COMMISSIONER_ENABLE || OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
71-
#define MBEDTLS_SSL_COOKIE_C
72-
#define MBEDTLS_SSL_SRV_C
73-
#endif
74-
75-
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
76-
#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
77-
#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
78-
#endif
79-
8064
#ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
8165
#define MBEDTLS_BASE64_C
8266
#define MBEDTLS_ECDH_C
@@ -87,36 +71,16 @@
8771
#define MBEDTLS_X509_CRT_PARSE_C
8872
#endif
8973

90-
#if OPENTHREAD_CONFIG_ECDSA_ENABLE
91-
#define MBEDTLS_BASE64_C
92-
#define MBEDTLS_ECDH_C
93-
#define MBEDTLS_ECDSA_C
94-
#define MBEDTLS_ECDSA_DETERMINISTIC
95-
#define MBEDTLS_OID_C
96-
#define MBEDTLS_PEM_PARSE_C
97-
#define MBEDTLS_PK_WRITE_C
98-
#endif
99-
10074
#define MBEDTLS_MPI_WINDOW_SIZE 1 /**< Maximum windows size used. */
10175
#define MBEDTLS_MPI_MAX_SIZE 32 /**< Maximum number of bytes for usable MPIs. */
10276
#define MBEDTLS_ECP_MAX_BITS 256 /**< Maximum bit size of groups */
10377
#define MBEDTLS_ECP_WINDOW_SIZE 2 /**< Maximum window size used */
10478
#define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 /**< Enable fixed-point speed-up */
10579
#define MBEDTLS_ENTROPY_MAX_SOURCES 2 /**< Maximum number of sources supported */
10680

107-
#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
108-
#define MBEDTLS_PLATFORM_STD_CALLOC otPlatCAlloc /**< Default allocator to use, can be undefined */
109-
#define MBEDTLS_PLATFORM_STD_FREE otPlatFree /**< Default free to use, can be undefined */
110-
#else
11181
#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
112-
#endif
11382

114-
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
115-
#define MBEDTLS_SSL_MAX_CONTENT_LEN 900 /**< Maxium fragment length in bytes */
116-
#else
11783
#define MBEDTLS_SSL_MAX_CONTENT_LEN 768 /**< Maxium fragment length in bytes */
118-
#endif
119-
12084
#define MBEDTLS_SSL_IN_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN
12185
#define MBEDTLS_SSL_OUT_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN
12286
#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8

third_party/openthread/platforms/nxp/mcxw71_k32w1/BUILD.gn

+7-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import("${nxp_sdk_build_root}/nxp_sdk.gni")
2424
openthread_nxp_root = "${chip_root}/third_party/openthread/ot-nxp"
2525

2626
config("openthread_k32w1_config") {
27-
include_dirs = [ "${openthread_nxp_root}/src/k32w1" ]
27+
include_dirs = [
28+
"${openthread_nxp_root}/src/k32w1",
29+
"${openthread_nxp_root}/src/mcxw71",
30+
]
2831

2932
defines = [
3033
"OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1",
@@ -111,10 +114,9 @@ source_set("libopenthread-k32w1") {
111114
"../..:libopenthread-platform-utils",
112115
]
113116

117+
public_deps += [ "${nxp_sdk_build_root}:nxp_mbedtls" ]
118+
114119
if (!nxp_external_sdk) {
115-
public_deps += [
116-
"${nxp_sdk_build_root}:nxp_mbedtls",
117-
nxp_sdk_target,
118-
]
120+
public_deps += [ nxp_sdk_target ]
119121
}
120122
}

0 commit comments

Comments
 (0)