1# Copyright (c) 2022 Nordic Semiconductor ASA
2# Copyright 2025 NXP
3# SPDX-License-Identifier: Apache-2.0
4
5config OPENTHREAD
6	bool "OpenThread Support"
7	imply FLASH
8	imply FLASH_MAP
9	imply MPU_ALLOW_FLASH_WRITE
10	select SETTINGS if FLASH
11	select OPENTHREAD_SETTINGS_RAM if !FLASH
12	select CPP
13	select REBOOT
14	select ENTROPY_GENERATOR
15	help
16	  This option enables the OpenThread library
17
18if OPENTHREAD
19
20config OPENTHREAD_SYS_INIT
21	bool "Initialize OpenThread stack during system initialization"
22	default y
23	depends on !NET_L2_OPENTHREAD
24	help
25	  This option initializes the OpenThread automatically by calling the openthread_init()
26	  function during system initialization.
27
28config OPENTHREAD_SYS_INIT_PRIORITY
29	int "OpenThread system initialization priority"
30	default 40
31	depends on OPENTHREAD_SYS_INIT
32	help
33	  This option sets the priority of the OpenThread system initialization.
34
35choice OPENTHREAD_IMPLEMENTATION
36	prompt "OpenThread origin selection"
37	help
38	  Select OpenThread stack to use for build. Custom OpenThread implementations
39	  can be added to the application Kconfig.
40
41config OPENTHREAD_SOURCES
42	bool "OpenThread from sources"
43	help
44	  Build Zephyr's OpenThread port from sources.
45
46endchoice
47
48config OPENTHREAD_MANUAL_START
49	bool "Start OpenThread stack manually"
50	help
51	  If enabled, OpenThread stack will have to be configured and
52	  started manually, with respective API calls or CLI/NCP commands.
53	  Otherwise, OpenThread will configure the network parameters and try to
54	  join the Thread network automatically during initialization (using
55	  credentials stored in persistent storage, obtained during
56	  commissioning or pre-commissioned with other Kconfig options,
57	  depending on configuration used).
58
59menu "Logging"
60
61menuconfig OPENTHREAD_DEBUG
62	bool "OpenThread stack logging support"
63	help
64	  This option enables logging support for OpenThread.
65
66choice OPENTHREAD_LOG_LEVEL_CHOICE
67	prompt "OpenThread stack log level"
68	depends on OPENTHREAD_DEBUG
69	help
70	  This option selects log level for OpenThread stack.
71
72config OPENTHREAD_LOG_LEVEL_CRIT
73	bool "Critical"
74
75config OPENTHREAD_LOG_LEVEL_WARN
76	bool "Warning"
77
78config OPENTHREAD_LOG_LEVEL_NOTE
79	bool "Notice"
80
81config OPENTHREAD_LOG_LEVEL_INFO
82	bool "Informational"
83
84config OPENTHREAD_LOG_LEVEL_DEBG
85	bool "Debug"
86
87endchoice # OPENTHREAD_LOG_LEVEL_CHOICE
88
89config OPENTHREAD_LOG_LEVEL
90	int
91	default 1 if OPENTHREAD_LOG_LEVEL_CRIT
92	default 2 if OPENTHREAD_LOG_LEVEL_WARN
93	default 3 if OPENTHREAD_LOG_LEVEL_NOTE
94	default 4 if OPENTHREAD_LOG_LEVEL_INFO
95	default 5 if OPENTHREAD_LOG_LEVEL_DEBG
96	default 0
97	help
98	  Log level for OpenThread stack.
99
100config OPENTHREAD_PLATFORM_LOG_LEVEL
101	int
102	default 1 if OPENTHREAD_LOG_LEVEL_CRIT
103	default 2 if OPENTHREAD_LOG_LEVEL_WARN
104	default 3 if OPENTHREAD_LOG_LEVEL_NOTE || OPENTHREAD_LOG_LEVEL_INFO
105	default 4 if OPENTHREAD_LOG_LEVEL_DEBG
106	default 0
107	help
108	  Log level for OpenThread Zephyr platform.
109
110endmenu # "Logging"
111
112menu "Zephyr optimizations"
113
114config OPENTHREAD_THREAD_PREEMPTIVE
115	bool "Set Openthread thread to be preemptive"
116
117config OPENTHREAD_THREAD_PRIORITY
118	int "OpenThread thread priority"
119	default 0 if OPENTHREAD_THREAD_PREEMPTIVE
120	default 8
121
122config OPENTHREAD_THREAD_STACK_SIZE
123	int "OpenThread thread stack size"
124	default 6144 if OPENTHREAD_COMMISSIONER || OPENTHREAD_JOINER
125	default 6240 if (OPENTHREAD_COMMISSIONER || OPENTHREAD_JOINER) && MPU_STACK_GUARD && FPU_SHARING && CPU_CORTEX_M
126	default 3168 if MPU_STACK_GUARD && FPU_SHARING && CPU_CORTEX_M
127	default 3072
128
129config OPENTHREAD_PKT_LIST_SIZE
130	int "List size for IPv6 packet buffering"
131	default 10
132
133config OPENTHREAD_RADIO_WORKQUEUE_STACK_SIZE
134	int "OpenThread radio transmit workqueue stack size"
135	default 608 if MPU_STACK_GUARD && FPU_SHARING && CPU_CORTEX_M
136	default 512
137
138config OPENTHREAD_RADIO_WORKQUEUE_PRIORITY
139	int "OpenThread radio transmit workqueue priority"
140	default 0 if OPENTHREAD_THREAD_PREEMPTIVE
141	default 7
142
143endmenu # "Zephyr optimizations"
144
145config OPENTHREAD_SHELL
146	bool "OpenThread shell"
147	depends on SHELL
148
149config MBEDTLS_PROMPTLESS
150	default y if !CUSTOM_OPENTHREAD_SECURITY
151
152choice OPENTHREAD_SECURITY
153	prompt "OpenThread security"
154	default OPENTHREAD_MBEDTLS_CHOICE
155
156config CUSTOM_OPENTHREAD_SECURITY
157	bool "Custom"
158	help
159	  Security settings will be controlled directly by the user.
160	  Enabling this setting will give access to full control of mbed TLS
161	  configuration.
162
163config OPENTHREAD_MBEDTLS_CHOICE
164	bool "mbed TLS built-in"
165	select OPENTHREAD_MBEDTLS
166	help
167	  Use the OpenThread mbed TLS configuration pre-defined security scheme.
168
169endchoice
170
171config OPENTHREAD_MBEDTLS
172	bool
173	select MBEDTLS
174	select MBEDTLS_ENABLE_HEAP
175	select MBEDTLS_CIPHER_AES_ENABLED
176	select MBEDTLS_CIPHER_CCM_ENABLED
177	select MBEDTLS_SHA256
178	select MBEDTLS_ENTROPY_C
179	select MBEDTLS_CMAC
180	select MBEDTLS_CIPHER
181	select MBEDTLS_MD_C
182	select MBEDTLS_SSL_PROTO_TLS1_2 if OPENTHREAD_COMMISSIONER || OPENTHREAD_JOINER
183	select MBEDTLS_SSL_PROTO_DTLS if OPENTHREAD_COMMISSIONER || OPENTHREAD_JOINER
184	select MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED if OPENTHREAD_COMMISSIONER || OPENTHREAD_JOINER
185	select MBEDTLS_ECJPAKE_C if OPENTHREAD_COMMISSIONER || OPENTHREAD_JOINER
186	select MBEDTLS_ECP_DP_SECP256R1_ENABLED if OPENTHREAD_COMMISSIONER || OPENTHREAD_JOINER || \
187	    OPENTHREAD_SRP_CLIENT || OPENTHREAD_SRP_SERVER
188	select MBEDTLS_ECP_NIST_OPTIM if OPENTHREAD_COMMISSIONER || OPENTHREAD_JOINER
189	select MBEDTLS_CTR_DRBG_C if OPENTHREAD_COMMISSIONER || OPENTHREAD_JOINER
190	select MBEDTLS_HMAC_DRBG_C if OPENTHREAD_COMMISSIONER || OPENTHREAD_JOINER || \
191	    OPENTHREAD_SRP_CLIENT || OPENTHREAD_SRP_SERVER
192	select MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED if OPENTHREAD_ECDSA
193	select MBEDTLS_ECDH_C if OPENTHREAD_ECDSA
194	select MBEDTLS_ECDSA_C if OPENTHREAD_ECDSA
195	select MBEDTLS_ECDSA_DETERMINISTIC if OPENTHREAD_ECDSA
196	select MBEDTLS_PK_WRITE_C if OPENTHREAD_ECDSA
197	select MBEDTLS_ECP_C if OPENTHREAD_COMMISSIONER || OPENTHREAD_JOINER || OPENTHREAD_ECDSA
198
199config OPENTHREAD_MBEDTLS_LIB_NAME
200	string "mbedtls lib name"
201	default "mbedTLS"
202	help
203	  This option allows to specify one or more mbedtls library files to be
204	  linked with OpenThread. Separate multiple values with space " ".
205
206config OPENTHREAD_COPROCESSOR
207	bool "OpenThread Co-Processor"
208	select OPENTHREAD_MANUAL_START
209	select RING_BUFFER
210	select UART_INTERRUPT_DRIVEN
211	help
212	  Enable Co-Processor in OpenThread stack.
213
214if OPENTHREAD_COPROCESSOR
215
216choice OPENTHREAD_COPROCESSOR_CHOICE
217	prompt "OpenThread Co-Processor type"
218	help
219	  This option selects Thread network co-processor type
220
221config OPENTHREAD_COPROCESSOR_NCP
222	bool "NCP - Network Co-Processor"
223
224config OPENTHREAD_COPROCESSOR_RCP
225	bool "RCP - Radio Co-Processor"
226
227endchoice # OPENTHREAD_COPROCESSOR_CHOICE
228
229config OPENTHREAD_COPROCESSOR_UART_RING_BUFFER_SIZE
230	int "Set Co-Processor UART ring buffer size"
231	default 4096
232	help
233	  TX buffer size for the OpenThread Co-Processor UART.
234
235config OPENTHREAD_COPROCESSOR_VENDOR_HOOK_SOURCE
236	string "Path to vendor hook source file"
237	help
238	  Provides path to compile vendor hook file.
239
240endif # OPENTHREAD_COPROCESSOR
241
242config OPENTHREAD_PLATFORM_INFO
243	string "Platform information for OpenThread"
244	default "ZEPHYR"
245	help
246	  Platform information for OpenThread
247
248config OPENTHREAD_CUSTOM_PARAMETERS
249	string "Custom Parameters to pass to OpenThread build system"
250	default ""
251	help
252	  This option is intended for advanced users only.
253	  Pass additional parameters that do not have corresponding Kconfig
254	  options to the OpenThread build system. Separate multiple values with
255	  space " ", for example:
256	  "OPENTHREAD_CONFIG_JOINER_ENABLE=1 OPENTHREAD_CONFIG_JOINER_MAX_CANDIDATES=3"
257
258config OPENTHREAD_NUM_MESSAGE_BUFFERS
259	int "The number of message buffers in the buffer pool"
260	default 512 if OPENTHREAD_ZEPHYR_BORDER_ROUTER
261	default 128
262	help
263	  "The number of message buffers in the buffer pool."
264
265config OPENTHREAD_MESSAGE_BUFFER_SIZE
266	int "The size of a message buffer in bytes"
267	default 128
268	help
269	  "The size of a message buffer in bytes"
270
271config OPENTHREAD_PLATFORM_MESSAGE_MANAGEMENT
272	bool "Use platform message management"
273	help
274	  The message pool is managed by platform defined logic.
275
276config OPENTHREAD_MAX_STATECHANGE_HANDLERS
277	int "The maximum number of state-changed callback handlers"
278	default 2
279	help
280	  The maximum number of state-changed callback handlers
281	  set using otSetStateChangedCallback.
282
283config OPENTHREAD_TMF_ADDRESS_CACHE_ENTRIES
284	int "The number of EID-to-RLOC cache entries"
285	default 20
286	help
287	  The number of EID-to-RLOC cache entries.
288
289config OPENTHREAD_TMF_ADDRESS_CACHE_MAX_SNOOP_ENTRIES
290	int "The maximum number of EID-to-RLOC cache entries"
291	default 2
292	help
293	  The maximum number of EID-to-RLOC cache entries that can be used for
294	  "snoop optimization" where an entry is created by inspecting a received
295	  message.
296
297config OPENTHREAD_LOG_PREPEND_LEVEL_ENABLE
298	bool "Prepending the log level to all OpenThread log messages"
299	help
300	  When enabled the OpenThread logs will be prepended with the appropriate
301	  log level prefix i.e. [CRIT], [WARN], [NOTE], [INFO], [DEBG].
302
303config OPENTHREAD_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE
304	bool "Software ACK timeout logic"
305	default y
306	help
307	  Set y if the radio supports AckTime event
308
309config OPENTHREAD_MAC_SOFTWARE_RETRANSMIT_ENABLE
310	bool "Software retransmission logic"
311	default y
312	help
313	  Set y if the radio supports tx retry logic with collision avoidance (CSMA)
314
315config OPENTHREAD_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE
316	bool "Software CSMA backoff logic"
317	default y
318	help
319	  Set y to enable software CSMA backoff. The option can be disabled if
320	  the radio has hardware support for this feature (IEEE802154_HW_CSMA).
321
322config OPENTHREAD_CRYPTO_PSA
323	bool "ARM PSA crypto API"
324	depends on PSA_CRYPTO_CLIENT
325	select OPENTHREAD_PLATFORM_KEY_REF if !OPENTHREAD_COPROCESSOR_RCP
326	imply OPENTHREAD_PLATFORM_KEYS_EXPORTABLE_ENABLE
327	help
328	  Enable crypto backend library implementation based on ARM PSA crypto
329	  API instead of the default, using mbedTLS.
330
331config OPENTHREAD_PLATFORM_KEYS_EXPORTABLE_ENABLE
332	bool "Make MAC keys exportable"
333	depends on OPENTHREAD_PLATFORM_KEY_REF
334	help
335	  Enable the creation of exportable MAC keys in the OpenThread Key Manager.
336
337config OPENTHREAD_INTERFACE_EARLY_UP
338	bool "Make OpenThread interface ready as soon as Thread is enabled"
339	help
340	  When enabled, OpenThread interface will be marked ready (operational
341	  UP) as soon as Thread has been enabled. This means the interface will
342	  be ready to transmit application packets during the Mesh Link
343	  Establishment phase.
344	  Otherwise, OpenThread interface will be marked operational UP only
345	  after the device joins a Thread network.
346
347config OPENTHREAD_PLATFORM_PKT_TXTIME
348	bool
349	default y if NET_PKT_TXTIME
350	help
351	  Enable packet TX time support. This is needed for when the application
352	  wants to set the exact time when the packet should be sent.
353
354config OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS
355	bool
356	default y if OPENTHREAD_DIAG && IEEE802154_CARRIER_FUNCTIONS
357	help
358	  Enable support for functions such as modulated carrier and continuous carrier.
359
360config OPENTHREAD_PLATFORM_USEC_TIMER
361	bool
362	default y if (OPENTHREAD_CSL_RECEIVER && !OPENTHREAD_THREAD_VERSION_1_1) || OPENTHREAD_WAKEUP_END_DEVICE
363	help
364	  Enable microsecond backoff timer implemented in platform.
365
366menu "OpenThread Border Router"
367
368config OPENTHREAD_ZEPHYR_BORDER_ROUTER
369	bool "Adds support for Border Router functionality [EXPERIMENTAL]"
370	select EXPERIMENTAL
371	select NET_ROUTING
372	select NET_PKT_FILTER if OPENTHREAD_NAT64_TRANSLATOR
373	select NET_PKT_FILTER_IPV4_HOOK if OPENTHREAD_NAT64_TRANSLATOR
374	help
375	  Enable support for Border Router using Openthread's implementation.
376
377if OPENTHREAD_ZEPHYR_BORDER_ROUTER
378
379config OPENTHREAD_ZEPHYR_BORDER_ROUTER_VENDOR_NAME
380	string "Base name from which mDNS host name will be derived."
381	default "Zephyr-OTBR"
382	help
383	  This value represents part of the mDNS host that will be register within OpenThread
384	  Border Router.
385
386config OPENTHREAD_ZEPHYR_BORDER_ROUTER_BASE_SERVICE_NAME
387	string "Base name from which a service instance name will be derived."
388	default "Zephyr-BorderRouter"
389	help
390	  This value represents part of a service instance name which will be registered
391	  within OpenThread Border Router.
392
393config OPENTHREAD_ZEPHYR_BORDER_ROUTER_MODEL_NAME
394	string "Name of the Border Agent product model"
395	default "BorderRouter"
396	help
397	  This value represents Border Agent's product model.
398
399config OPENTHREAD_ZEPHYR_BORDER_ROUTER_MAX_UDP_SERVICES
400	int "The maximum number of pollable UDP sockets to be registered in platform code."
401	default 5
402	help
403	  This configuration defines the maximum number of pollable UDP sockets
404	  to be used within platform UDP module.
405
406config OPENTHREAD_ZEPHYR_BORDER_ROUTER_MAX_MDNS_SERVICES
407	int "The maximum number of pollable mDNS sockets to be registered in platform code."
408	default 1 if NET_IPV6 && !NET_IPV4
409	default 2 if NET_IPV6 && NET_IPV4
410	help
411	  This configuration defines the maximum number of pollable mDNS sockets
412	  to be used within platform mDNS module.
413
414config OPENTHREAD_ZEPHYR_BORDER_ROUTER_TREL_SERVICES
415	int "The maximum number of pollable TREL sockets to be registered in platform code."
416	default 1
417	help
418	  This configuration defines the maximum number of pollable TREL sockets
419	  to be used within platform TREL module.
420
421config OPENTHREAD_ZEPHYR_BORDER_ROUTER_DHCP6_PD_SERVICES
422	int "The maximum number of pollable DHCP6_PD sockets to be registered in platform code."
423	default 1
424	help
425	  This configuration defines the maximum number of pollable DHCP6_PD sockets
426	  to be used within platform DHCP6_PD module.
427
428config OPENTHREAD_ZEPHYR_BORDER_ROUTER_NAT64_SERVICES
429	int "The maximum number of pollable RAW IPV4 sockets to be registered in platform code."
430	depends on OPENTHREAD_NAT64_TRANSLATOR
431	default 1
432	help
433	  This configuration defines the maximum number of pollable RAW IPV4 sockets
434	  to be used within platform Infrastructure Interface module.
435
436config OPENTHREAD_ZEPHYR_BORDER_ROUTER_MSG_POOL_NUM
437	int "Maximum entries of backbone message pool."
438	default 10
439	help
440	  This value represents the maximum number of messages from backbone interface
441	  that could be stored without being processed.
442
443config OPENTHREAD_ZEPHYR_BORDER_ROUTER_MDNS_BUFFER_THRESHOLD
444	int "Threshold value to determine if an mDNS packet will be processed"
445	default 40
446	help
447	  This value is used to calculate if OpenThread mDNS module should
448	  accept an incoming message or not. It is used to determine if
449	  number of available OT message buffers will drop under a certain
450	  threshold if the mDNS packet is accepted and processed.
451
452endif # OPENTHREAD_ZEPHYR_BORDER_ROUTER
453
454endmenu # "OpenThread Border Router"
455
456menu "OpenThread stack features"
457rsource "Kconfig.features"
458endmenu
459
460menu "Thread Network configuration"
461rsource "Kconfig.thread"
462endmenu
463
464endif # OPENTHREAD
465