Skip to content

drivers: sensor: migrate simulated sensors to DEVICE_API - #30

Closed
kapi-no wants to merge 3 commits into
rlubos:upmerge-07-2026from
kapi-no:upmerge-07-2026-caf_sensor_manager_fix
Closed

drivers: sensor: migrate simulated sensors to DEVICE_API#30
kapi-no wants to merge 3 commits into
rlubos:upmerge-07-2026from
kapi-no:upmerge-07-2026-caf_sensor_manager_fix

Conversation

@kapi-no

@kapi-no kapi-no commented Jul 20, 2026

Copy link
Copy Markdown

Upstream Zephyr moved device API structs into per-class iterable linker sections and made the sensor accessors resolve the API through DEVICE_API_GET(sensor, dev). With CONFIG_DEVICE_API_ASSERT enabled (default when CONFIG_ASSERT=y) this asserts that dev->api points inside the _sensor_driver_api section, otherwise it fails at runtime with "device API is not sensor".

The Nordic sensor_sim and sensor_stub drivers still declared their API as a plain "static const struct sensor_driver_api", so the struct was not placed in that section and the assert fired the first time the CAF sensor manager called sensor_sample_fetch(). This broke the caf_sensor_manager.core test (sensor_sim) and the caf_sensor_manager sample (sensor_stub) on qemu_cortex_m3 after the upmerge.

Declared both driver APIs with DEVICE_API(sensor, ...), matching the idiom used by all upstream sensor drivers, so the API lands in the _sensor_driver_api iterable section and passes the runtime check.

Ref: NCSDK-40421

rlubos and others added 3 commits July 20, 2026 11:53
Skip Zephyr tests that fail in NCS CI after the upmerge until the
underlying issues are resolved.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Update python packages.

Add PYSEC-2026-3447 to pip whitelist.
Setuptools cannot be updated atm due to conflict with spsdk package

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Signed-off-by: Jan Gałda <jan.galda@nordicsemi.no>
Upstream Zephyr moved device API structs into per-class iterable linker
sections and made the sensor accessors resolve the API through
DEVICE_API_GET(sensor, dev). With CONFIG_DEVICE_API_ASSERT enabled
(default when CONFIG_ASSERT=y) this asserts that dev->api points inside
the _sensor_driver_api section, otherwise it fails at runtime with
"device API is not sensor".

The Nordic sensor_sim and sensor_stub drivers still declared their API
as a plain "static const struct sensor_driver_api", so the struct was
not placed in that section and the assert fired the first time the CAF
sensor manager called sensor_sample_fetch(). This broke the
caf_sensor_manager.core test (sensor_sim) and the caf_sensor_manager
sample (sensor_stub) on qemu_cortex_m3 after the upmerge.

Declared both driver APIs with DEVICE_API(sensor, ...), matching the
idiom used by all upstream sensor drivers, so the API lands in the
_sensor_driver_api iterable section and passes the runtime check.

Ref: NCSDK-40421

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
@kapi-no

kapi-no commented Jul 20, 2026

Copy link
Copy Markdown
Author

Ready for integrating into the upmerge branch.

@rlubos
rlubos force-pushed the upmerge-07-2026 branch from 3b11983 to 650aac7 Compare July 20, 2026 13:11
@rlubos

rlubos commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Cherry-picked into the upmerge branch, thanks

@rlubos rlubos closed this Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants