Skip to content

Commit 9a5f4b9

Browse files
ArekBalysNordickartben
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 <arkadiusz.balys@nordicsemi.no>
1 parent d750daa commit 9a5f4b9

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

modules/openthread/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ config OPENTHREAD
1717

1818
if OPENTHREAD
1919

20+
config 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+
28+
config 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+
35+
2036
choice OPENTHREAD_IMPLEMENTATION
2137
prompt "OpenThread origin selection"
2238
help

modules/openthread/openthread.c

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

modules/openthread/platform/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ zephyr_library_sources(
88
platform.c
99
)
1010

11-
zephyr_library_sources_ifndef(CONFIG_HDLC_RCP_IF
12-
radio.c
13-
spi.c
14-
)
11+
if(NOT CONFIG_HDLC_RCP_IF)
12+
# Radio platform implementation dedicated for L2 Platform adaptation layer
13+
zephyr_library_sources_ifdef(CONFIG_NET_L2_OPENTHREAD radio.c)
14+
zephyr_library_sources(spi.c)
15+
endif()
1516

1617
zephyr_library_sources_ifdef(CONFIG_HDLC_RCP_IF
1718
radio_spinel.cpp

0 commit comments

Comments
 (0)