Skip to content

Commit 8dd3e20

Browse files
[Zephyr][platform][config] Update the existing Zephyr platform adaptation layer to make it reusable across multiple Zephyr-based platforms (#42198)
* [Zephyr][platform] Update the generic Zephyr platform adaptation layer to be reusable by other zephyr platforms * Adding wifi to the BUILD.gn file to support building matter-over-wifi * Adding support of wifi in the ConnectivityManagerImpl * Adding DeviceInstanceInfoProviderImpl * Adding CHIP macro config mapping with Kconfig to ease platform overrides Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * [Zephyr][platform][config] Adding Kconfig definitions to the generic config/zephyr/Kconfig * Kconfig added to the generic layer, to allow platforms to reuse the src/platform/Zephyr and override the CHIP configs easily per platform * CONFIG_CHIP_LOG_SIZE_OPTIMIZATION moved from the platform layer definition to the generic zephyr Kconfig, to allow its use in src/platform/Zephyr, and reduce duplicatio * note that the default can still be overridden per platform Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * [Zephyr][platform][config] Adding Kconfig to configure the chip task priority, stack sze and event queue size + Adding Kconfig for MRP local retry intervals (active & idle) Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * Update src/platform/Zephyr/DeviceInstanceInfoProviderImpl.h line ending to support restyle patch Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> * Restyled by whitespace * Restyled by clang-format --------- Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent ff09cbb commit 8dd3e20

File tree

13 files changed

+379
-36
lines changed

13 files changed

+379
-36
lines changed

config/nrfconnect/chip-module/Kconfig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,6 @@ config CHIP_FACTORY_RESET_ERASE_SETTINGS
300300
default y
301301
depends on NVS || ZMS
302302

303-
config CHIP_LOG_SIZE_OPTIMIZATION
304-
bool "Disable some detailed logs to decrease flash usage"
305-
help
306-
Disables some log levels for specific Matter log modules that provide
307-
information that is too detailed to be used in most cases. You can find
308-
full configuration enabled by this option in the
309-
platform/nrfconnect/CHIPPlatformConfig.h file.
310-
311303
config CHIP_IPV4
312304
bool "IPv4 support for Matter"
313305
default n

config/nxp/chip-module/Kconfig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,6 @@ config CHIP_FACTORY_RESET_ERASE_SETTINGS
203203

204204
endif
205205

206-
config CHIP_LOG_SIZE_OPTIMIZATION
207-
bool "Disable some detailed logs to decrease flash usage"
208-
help
209-
Disables some log levels for specific Matter log modules that provide
210-
information that is too detailed to be used in most cases. You can find
211-
full configuration enabled by this option in the
212-
platform/nxp/CHIPPlatformConfig.h file.
213-
214206
config CHIP_IPV4
215207
bool "IPv4 support for Matter"
216208
default n

config/nxp/chip-module/Kconfig.defaults

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,29 @@ if CHIP
2323
config CHIP_OPERATIONAL_TIME_SAVE_INTERVAL
2424
default 1
2525

26+
config CHIP_ENABLE_WIFI_STATION
27+
default y if CHIP_WIFI
28+
29+
config CHIP_SYSTEM_THREAD_LOCAL_STORAGE
30+
default n
31+
32+
config CHIP_SYSTEM_USE_ZEPHYR_SOCKET_EXTENSIONS
33+
default n
34+
35+
config CHIP_TASK_PRIORITY
36+
default 5
37+
38+
config MAX_EVENT_QUEUE_SIZE
39+
default 64
40+
41+
config CHIP_MRP_LOCAL_ACTIVE_RETRY_INTERVAL
42+
default 800 if NET_L2_OPENTHREAD
43+
default 2000
44+
45+
config CHIP_MRP_LOCAL_IDLE_RETRY_INTERVAL
46+
default 800 if NET_L2_OPENTHREAD
47+
default 2000
48+
2649
if CHIP_FACTORY_DATA
2750

2851
config CHIP_DEVICE_VENDOR_ID

config/silabs/Kconfig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,6 @@ config CHIP_FACTORY_RESET_ERASE_SETTINGS
213213
default y
214214
depends on NVS || ZMS
215215

216-
config CHIP_LOG_SIZE_OPTIMIZATION
217-
bool "Disable some detailed logs to decrease flash usage"
218-
help
219-
Disables some log levels for specific Matter log modules that provide
220-
information that is too detailed to be used in most cases. You can find
221-
full configuration enabled by this option in the
222-
platform/silabs/CHIPPlatformConfig.h file.
223-
224216
config CHIP_OPENTHREAD_JOINER_ENABLED
225217
bool "Specify whether the Thread Joiner functionality is used when it is enabled"
226218
default n

config/telink/chip-module/Kconfig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,6 @@ config CHIP_FACTORY_RESET_ERASE_SETTINGS
219219

220220
endif
221221

222-
config CHIP_LOG_SIZE_OPTIMIZATION
223-
bool "Disable some detailed logs to decrease flash usage"
224-
help
225-
Disables some log levels for specific Matter log modules that provide
226-
information that is too detailed to be used in most cases. You can find
227-
full configuration enabled by this option in the
228-
platform/telink/CHIPPlatformConfig.h file.
229-
230222
config CHIP_IPV4
231223
bool "IPv4 support for Matter"
232224
default n

config/zephyr/Kconfig

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ config CHIP_APP_LOG_LEVEL
5050
option only within the application. To set the logging level for the
5151
Matter stack, use the MATTER_LOG_LEVEL configuration option.
5252

53+
config CHIP_LOG_SIZE_OPTIMIZATION
54+
bool "Disable some detailed logs to decrease flash usage"
55+
help
56+
Disables some log levels for specific Matter log modules that provide
57+
information that is too detailed to be used in most cases. You can find
58+
full configuration enabled by this option in the
59+
platform CHIPPlatformConfig.h file.
60+
5361
# Device and firmware identifers
5462

5563
config CHIP_DEVICE_VENDOR_ID
@@ -460,6 +468,22 @@ config CHIP_OPENTHREAD_CONFIG
460468
is specified, it replaces the OpenThread configuration file supplied by
461469
Zephyr.
462470

471+
# Wi-Fi network features
472+
473+
config CHIP_ENABLE_WIFI_STATION
474+
bool "Enable Wi-Fi Station mode"
475+
depends on WIFI
476+
help
477+
Enable Wi-Fi station (client) mode for Matter-over-Wi-Fi devices.
478+
This allows the device to connect to an existing Wi-Fi network.
479+
480+
config CHIP_ENABLE_WIFI_AP
481+
bool "Enable Wi-Fi Access Point mode"
482+
depends on WIFI
483+
help
484+
Enable Wi-Fi Access Point mode for SoftAP commissioning.
485+
This allows the device to create its own Wi-Fi network for onboarding.
486+
463487
# Platform additions and configuration
464488

465489
config CHIP_CERTIFICATION_DECLARATION_STORAGE
@@ -527,6 +551,52 @@ config CHIP_MALLOC_SYS_HEAP_WATERMARKS_SUPPORT
527551

528552
endif
529553

554+
config CHIP_SYSTEM_THREAD_LOCAL_STORAGE
555+
bool "Enable thread-local storage for Matter System Layer"
556+
default y
557+
help
558+
Enable use of thread-local storage (TLS) in the Matter System Layer.
559+
560+
config CHIP_SYSTEM_USE_ZEPHYR_SOCKET_EXTENSIONS
561+
bool "Use Zephyr socket extensions in Matter System Layer"
562+
default y
563+
help
564+
Enables the use of Zephyr socket extensions in the Matter System Layer
565+
socket implementation.
566+
567+
config CHIP_TASK_PRIORITY
568+
int "Matter task priority"
569+
default 1
570+
help
571+
Set the Zephyr thread priority for the Matter main task (CHIP event loop).
572+
This value is passed to K_PRIO_PREEMPT(). Lower values mean higher priority.
573+
574+
config CHIP_TASK_STACK_SIZE
575+
int "Matter task stack size"
576+
default 8192
577+
help
578+
Set the stack size (in bytes) for the Matter main task (CHIP event loop).
579+
580+
config MAX_EVENT_QUEUE_SIZE
581+
int "Maximum Matter event queue size"
582+
default 100
583+
help
584+
Set the maximum number of events that can be queued in the Matter event loop.
585+
586+
config CHIP_MRP_LOCAL_ACTIVE_RETRY_INTERVAL
587+
int "MRP Local Active Retry Interval (ms)"
588+
default 2000 if NET_L2_OPENTHREAD
589+
default 300
590+
help
591+
Sets the local active retry interval (in milliseconds) for Matter Message Reliability Protocol (MRP).
592+
593+
config CHIP_MRP_LOCAL_IDLE_RETRY_INTERVAL
594+
int "MRP Local Idle Retry Interval (ms)"
595+
default 2000 if NET_L2_OPENTHREAD
596+
default 500
597+
help
598+
Sets the local idle retry interval (in milliseconds) for Matter Message Reliability Protocol (MRP).
599+
530600
module = MATTER
531601
module-str = Matter
532602
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"

src/platform/Zephyr/BUILD.gn

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static_library("Zephyr") {
3636
"ConfigurationManagerImpl.h",
3737
"ConnectivityManagerImpl.cpp",
3838
"ConnectivityManagerImpl.h",
39+
"DeviceInstanceInfoProviderImpl.cpp",
3940
"DiagnosticDataProviderImpl.cpp",
4041
"DiagnosticDataProviderImpl.h",
4142
"DiagnosticDataProviderImplGetter.cpp",
@@ -77,6 +78,17 @@ static_library("Zephyr") {
7778
}
7879
}
7980

81+
if (chip_enable_wifi) {
82+
sources += [
83+
"wifi/ConnectivityManagerImplWiFi.cpp",
84+
"wifi/ConnectivityManagerImplWiFi.h",
85+
"wifi/WiFiManager.cpp",
86+
"wifi/WiFiManager.h",
87+
"wifi/ZephyrWifiDriver.cpp",
88+
"wifi/ZephyrWifiDriver.h",
89+
]
90+
}
91+
8092
if (chip_malloc_sys_heap) {
8193
sources += [ "SysHeapMalloc.cpp" ]
8294
}

src/platform/Zephyr/CHIPDevicePlatformConfig.h

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,26 @@
3131
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID CONFIG_CHIP_DEVICE_VENDOR_ID
3232
#endif
3333

34+
#ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME
35+
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME CONFIG_CHIP_DEVICE_VENDOR_NAME
36+
#endif
37+
3438
#ifndef CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID
3539
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID CONFIG_CHIP_DEVICE_PRODUCT_ID
3640
#endif
3741

42+
#ifndef CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME
43+
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME CONFIG_CHIP_DEVICE_PRODUCT_NAME
44+
#endif
45+
46+
#ifndef CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION
47+
#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION CONFIG_CHIP_DEVICE_HARDWARE_VERSION
48+
#endif
49+
50+
#ifndef CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING
51+
#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING CONFIG_CHIP_DEVICE_HARDWARE_VERSION_STRING
52+
#endif
53+
3854
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
3955
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION CONFIG_CHIP_DEVICE_SOFTWARE_VERSION
4056
#endif
@@ -43,8 +59,33 @@
4359
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING
4460
#endif
4561

46-
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0
47-
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0
62+
#ifndef CHIP_DEVICE_CONFIG_TEST_MANUFACTURING_DATE
63+
#define CHIP_DEVICE_CONFIG_TEST_MANUFACTURING_DATE CONFIG_CHIP_DEVICE_MANUFACTURING_DATE
64+
#endif
65+
66+
#ifndef CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER
67+
#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER CONFIG_CHIP_DEVICE_SERIAL_NUMBER
68+
#endif
69+
70+
#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR
71+
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR CONFIG_CHIP_DEVICE_DISCRIMINATOR
72+
#endif
73+
74+
#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE
75+
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE CONFIG_CHIP_DEVICE_SPAKE2_PASSCODE
76+
#endif
77+
78+
#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SPAKE2P_ITERATION_COUNT
79+
#define CHIP_DEVICE_CONFIG_USE_TEST_SPAKE2P_ITERATION_COUNT CONFIG_CHIP_DEVICE_SPAKE2_IT
80+
#endif
81+
82+
#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SPAKE2P_SALT
83+
#define CHIP_DEVICE_CONFIG_USE_TEST_SPAKE2P_SALT CONFIG_CHIP_DEVICE_SPAKE2_SALT
84+
#endif
85+
86+
#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SPAKE2P_VERIFIER
87+
#define CHIP_DEVICE_CONFIG_USE_TEST_SPAKE2P_VERIFIER CONFIG_CHIP_DEVICE_SPAKE2_TEST_VERIFIER
88+
#endif
4889

4990
// Check if Zephyr app use NET_L2_OPENTHREAD
5091
#ifndef CHIP_DEVICE_CONFIG_ENABLE_THREAD
@@ -72,6 +113,23 @@
72113
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI 0
73114
#endif // CONFIG_WIFI
74115
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI
116+
117+
#ifndef CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
118+
#ifdef CONFIG_CHIP_ENABLE_WIFI_STATION
119+
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1
120+
#else
121+
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0
122+
#endif // CONFIG_CHIP_ENABLE_WIFI_STATION
123+
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
124+
125+
#ifndef CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP
126+
#ifdef CONFIG_CHIP_ENABLE_WIFI_AP
127+
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 1
128+
#else
129+
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0
130+
#endif // CONFIG_CHIP_ENABLE_WIFI_AP
131+
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP
132+
75133
// Check if Zephyr app use NET_L2_ETHERNET
76134

77135
#ifndef CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
@@ -121,13 +179,17 @@
121179
// ========== Platform-specific Configuration Overrides =========
122180

123181
#ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY
124-
#define CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY (K_PRIO_PREEMPT(1))
182+
#define CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY (K_PRIO_PREEMPT(CONFIG_CHIP_TASK_PRIORITY))
125183
#endif // CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY
126184

127185
#ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE
128-
#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 8192
186+
#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE CONFIG_CHIP_TASK_STACK_SIZE
129187
#endif // CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE
130188

189+
#ifndef CHIP_DEVICE_CONFIG_MAX_EVENT_QUEUE_SIZE
190+
#define CHIP_DEVICE_CONFIG_MAX_EVENT_QUEUE_SIZE CONFIG_MAX_EVENT_QUEUE_SIZE
191+
#endif // CHIP_DEVICE_CONFIG_MAX_EVENT_QUEUE_SIZE
192+
131193
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0
132194
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 0
133195
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0
@@ -150,9 +212,25 @@
150212

151213
#ifdef CONFIG_CHIP_ENABLE_ICD_SUPPORT
152214
#define CHIP_DEVICE_CONFIG_ENABLE_SED 1
215+
#ifdef CONFIG_CHIP_THREAD_SSED
153216
#define CHIP_DEVICE_CONFIG_THREAD_SSED CONFIG_CHIP_THREAD_SSED
217+
#else
218+
#define CHIP_DEVICE_CONFIG_THREAD_SSED 0
219+
#endif // CONFIG_CHIP_THREAD_SSED
154220
#endif // CONFIG_CHIP_ENABLE_ICD_SUPPORT
155221

222+
#ifndef CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL
223+
#ifdef CONFIG_CHIP_ICD_SLOW_POLL_INTERVAL
224+
#define CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL chip::System::Clock::Milliseconds32(CONFIG_CHIP_ICD_SLOW_POLL_INTERVAL)
225+
#endif // CONFIG_CHIP_ICD_SLOW_POLL_INTERVAL
226+
#endif // CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL
227+
228+
#ifndef CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL
229+
#ifdef CONFIG_CHIP_ICD_FAST_POLLING_INTERVAL
230+
#define CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL chip::System::Clock::Milliseconds32(CONFIG_CHIP_ICD_FAST_POLLING_INTERVAL)
231+
#endif // CONFIG_CHIP_ICD_FAST_POLLING_INTERVAL
232+
#endif // CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL
233+
156234
#ifdef CONFIG_CHIP_COMMISSIONABLE_DEVICE_TYPE
157235
#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE 1
158236
#endif // CONFIG_CHIP_COMMISSIONABLE_DEVICE_TYPE
@@ -170,3 +248,7 @@
170248
#endif // CONFIG_CHIP_BLE_EXT_ADVERTISING
171249

172250
#define CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS (CONFIG_CHIP_BLE_ADVERTISING_DURATION * 60)
251+
252+
#ifndef CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH
253+
#define CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH ((sizeof(CONFIG_CHIP_DEVICE_ROTATING_DEVICE_UID) - 1) / 2)
254+
#endif // CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH

0 commit comments

Comments
 (0)