-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Describe the bug
Following #60410, SYS_INIT_NAMED creates a section with sub-priority equal to the literal 0. If other devices coming from DT with the same level and priority have a higher sub-priority, these may still be initialized before.
This is because the sub-priority for the DT devices are fixed to 5 digits including leading zeroes, whereas the platform devices sub-priorities are always 0_. When sorting the linker sections by name, the DT device will have precedence over the platform device.
To Reproduce
Take for example:
west build -p auto -b s32z270dc2_rtu0_r52 tests/drivers/gpio/gpio_api_1pin
the sections generated are:
*(SORT_BY_NAME(SORT_BY_ALIGNMENT(.z_init_PRE_KERNEL_1??_*)))
.z_init_PRE_KERNEL_140_00019_
0x000000003178e700 0x8 zephyr/drivers/interrupt_controller/libdrivers__interrupt_controller.a(intc_eirq_nxp_s32.c.obj)
.z_init_PRE_KERNEL_140_0_
0x000000003178e708 0x8 zephyr/libzephyr.a(soc.c.obj)
.z_init_PRE_KERNEL_140_0_
0x000000003178e710 0x8 zephyr/drivers/interrupt_controller/libdrivers__interrupt_controller.a(intc_gicv3.c.obj)
Causing intc_eirq_nxp_s32.c (an external interrupt controller) initialize before the GIC.
Expected behavior
The level/priorities/sub-priorities are respected and the devices initialized in the correct order.
Impact
Currently preventing external interrupts of s32z270dc2_rtu0_r52 to work, but other boards/devices might be affected.
Environment (please complete the following information):
- OS: Linux, Windows
- Toolchain Zephyr SDK 0.16.1
- Commit SHA a5895d6
Additional context
It's a regression of #60410.