zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.84k stars 6.6k forks source link

RFC: Provide a DT configurable sensor framework that is compatible with Android's CHRE #36963

Open yperess opened 3 years ago

yperess commented 3 years ago

Is your feature request related to a problem? Please describe. Every app currently needs to provide custom uses and calls to various peripherals. This means that every reasonable sized application will eventually need a way to manage the communication to all these peripherals. The side-effect of this is that testing is usually an after thought and is generally very difficult.

Describe the solution you'd like Add two new subsystems (possibly more in the future).

  1. The first will build Android's CHRE.. This can be done by adding a subsys/chre along with Kconfig such as CONFIG_CHRE_PATH. By default we can even add the CHRE as a submodule to Zephyr so that checkout of zephyr can also (optionally) include CHRE. If this is done, this value can have a default path that's relative to the zephyr tree (something like third_party/chre).
  2. Add another subsys/sensor_framework that will be compatible with CHRE's APIs for the Sensor PAL (Platform Abstraction Layer). This will be configured via nodes from devicetree and will communicate with the CHRE (or optionally any other client that is using the same chrePalSensorCallback interface)

The benefits of this approach are:

  1. CHRE is very well tested.
  2. Uses of the raw peripheral data can be written in nanoapps which are easier to test and possibly upstreamed to Zephyr for shared use (things like lid angle calculation from 2 accelerometers, car crash detection, sensor calibration, geo-fencing, etc).
  3. Provides a unified approach for managing and consuming raw peripheral data.
  4. Will work with other drivers (outside of sensors)

Describe alternatives you've considered The only other sensor framework I know of that is open source and is recently maintained is Chromium's. I came across a few others such as open-sensor-platform, but none of them have been updated recently. In all cases, the effort to bring them up to using the Zephyr drivers, Kconfig, and devicetree seems too great.

Additional context CHRE with Zephyr PoC - Class UML 2021-07-14

Ongoing discussions:

yperess commented 1 year ago

Adding a link to https://github.com/zephyrproject-rtos/zephyr/pull/55389 for tracking.