ELC 2021 Zephyr Startup v0.2
ELC 2021 Zephyr Startup v0.2
#lfelc
Architecture
#ospocon
Zephyr Early Startup
• Goal of early startup sequence:
#ospocon
RISCV early startup view
#ospocon
Kernel Initialization
#ospocon
Preparing Scheduler
#ospocon
bg_thread_main: final system initialization
• Zephyr Kernel & Scheduler now running. Kernel
services are fully available for the rest of the
initialization.
#ospocon
Device Drivers and System Driver
– PRE_KERNEL_1
• Used for initialization objects that have no dependencies, such as those that rely solely on hardware present in the processor/SOC. These
objects cannot use any kernel services during configuration, since they are not yet available.
– PRE_KERNEL_2
• Used for initialization objects that rely on objects initialized as part of the PRE_KERNEL_1 level. These objects cannot use any kernel
services during configuration, since they are not yet available.
– POST_KERNEL
• Used for initialization objects that require kernel services during configuration.
– APPLICATION
• Used for application components (i.e. non-kernel components) that need automatic configuration. The devices can use all services
provided by the kernel during configuration. Init functions at this level run on the kernel main task.
– SMP
• Initialization that requires kernel services during configuration after Symmetric Multi-Processing (SMP) initialization.
• The initialization priority of the object is relative to other objects of the same initialization level.
– Specified as an integer value in the range 0 to 99; Lower values have higher priority
– The order of multiple objects with the same priority level is undefined. Use different priority levels between related
objects if you wish to control initialization order of multiple object within the same initialization level.
• drivers/serial/mcux_lpuart.c:
DEVICE_DT_INST_DEFINE(n,\
&mcux_lpuart_init,\
NULL,\
&mcux_lpuart_##n##_data,\
&mcux_lpuart_##n##_config,\
PRE_KERNEL_1,\
CONFIG_KERNEL_INIT_PRIORITY_DEVICE,\
&mcux_lpuart_driver_api);\
• soc/arm/nxp_imx/rt/soc_rt10xx.c:
• An initLevel section in which contains the init device objects sorted by the constructed section
attribute names to ensures the priority order within an initialization level.
• z_init_static_threads() will iterate through the list of static threads to initialize and schedule each of them.
• samples/net/sockets/packet/src/packet.c:
K_THREAD_DEFINE(receiver_thread_id, STACK_SIZE,
recv_packet, NULL, NULL, NULL,
THREAD_PRIORITY, 0, -1);
K_THREAD_DEFINE(sender_thread_id, STACK_SIZE,
send_packet, NULL, NULL, NULL,
THREAD_PRIORITY, 0, -1);
• zephyr.map:
_static_thread_data_area
0x8000088c 0x60 load address 0x70017c90
0x8000088c __static_thread_data_list_start = .
*(SORT_BY_NAME(SORT_BY_ALIGNMENT(.__static_thread_data.static.*)))
.__static_thread_data.static._k_thread_data_receiver_thread_id
0x8000088c 0x30 app/libapp.a(packet.c.obj)
0x8000088c _k_thread_data_receiver_thread_id
.__static_thread_data.static._k_thread_data_sender_thread_id
0x800008bc 0x30 app/libapp.a(packet.c.obj)
0x800008bc _k_thread_data_sender_thread_id
0x800008ec __static_thread_data_list_end = .
• Orientation:
– https://zephyrproject.org/
– https://docs.zephyrproject.org/latest/index.html
• Github:
– https://github.com/zephyrproject-rtos/zephyr
– https://github.com/zephyrproject-rtos/zephyr/wiki
• Mail Lists:
– https://lists.zephyrproject.org/g/main