Skip to content

Commit 7fff627

Browse files
ArekBalysNordicadigie
authored andcommitted
openthread: Add possibility to initialize OpenThread in POST_KERNEL
The new CONFIG_OPENTHREAD_SYS_INIT Kconfig option allows OpenThread to be automatically initialised during the Zephyr POST_KERNEL initialisation stage. If Zephyr's L2 layer OpenThread implementation is enabled, the IEEE802.15.4 shim layer initialises OpenThread in the POST_KERNEL phase. However, since Openthread may work without Zephyr's L2 layer, in this case, no object can initialise it automatically. This new Kconfig option may help start OpenThread automatically if the L2 Layer is disabled. Signed-off-by: Arkadiusz Balys <[email protected]> Signed-off-by: Adrian Gielniewski <[email protected]>
1 parent b2e187a commit 7fff627

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

modules/openthread/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ config OPENTHREAD
2121

2222
if OPENTHREAD
2323

24+
config OPENTHREAD_SYS_INIT
25+
bool "Initialize OpenThread stack during system initialization"
26+
default y
27+
depends on !NET_L2_OPENTHREAD
28+
help
29+
This option initializes the OpenThread automatically by calling the openthread_init()
30+
function during system initialization.
31+
32+
config OPENTHREAD_SYS_INIT_PRIORITY
33+
int "OpenThread system initialization priority"
34+
default 40
35+
depends on OPENTHREAD_SYS_INIT
36+
help
37+
This option sets the priority of the OpenThread system initialization.
38+
2439
choice OPENTHREAD_IMPLEMENTATION
2540
prompt "OpenThread origin selection"
2641
help

modules/openthread/openthread.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,3 +481,7 @@ void openthread_mutex_unlock(void)
481481
{
482482
(void)k_mutex_unlock(&openthread_lock);
483483
}
484+
485+
#ifdef CONFIG_OPENTHREAD_SYS_INIT
486+
SYS_INIT(openthread_init, POST_KERNEL, CONFIG_OPENTHREAD_SYS_INIT_PRIORITY);
487+
#endif /* CONFIG_OPENTHREAD_SYS_INIT */

0 commit comments

Comments
 (0)