-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HAL module request: hal_tdk #71561
Comments
Hi @afontaine-invn! We appreciate you submitting your first issue for our open-source project. 🌟 Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙 |
From my perspective I think this could be really nice. I do want to caution though that Zephyr is moving towards an asynchronous bus API, and asynchronous sensor API using a completion queue API. There are many reasons for this, but maybe some of the large ones are... memory management should be done by the application not the driver, manipulating the sensor readings should be optional, and ideally don't want to have threads dealing with gpio interrupts. It adds latency, it adds memory cost, it prevents potential hardware optimizations. @PetervdPerk-NXP noted at EOSS2024 that simply going to that gpio ISR is time consuming when instead a DMA could be preprogrammed to react and start a SPI/I2C transfer. We want Zephyr to be as optimal of a solution possible for sensing while still being generalized. The newer API gets us, I think, a lot closer. So I guess my question for this and actually stmemsc for @avisconti as well is... can we still take advantage of the code in these sensor libraries here with the async bus APIs, desired power management functionality (saving state on power mode swaps potentially), and more? I think providing register maps is great. Providing utilities around converting configuration values is maybe nice. But the bus API abstraction that is in these libraries is usually making some assumptions that I don't know work well with the goals Zephyr has for sensing and that should be talked about. |
Hi @teburd ,
I opened this issue to create the tdk_hal repository to match how competitor's sensor driver are supported in Zephyr. Indeed, I based the driver implementation on competitor drivers (Bosh & ST). Most of them have the same implementation regarding interrupt, thread, etc ... For sure, I'm available to talk about this if we want to schedule a meeting. |
This has more to do with the existing sensor_fetch + sensor_get API pair, where the model was to have the driver read the sensor, then provide individual channel readings. The memory to hold those readings was kept in the sensor driver instance. The newer API expects to be given a buffer that the driver can dump the sensor encodeded (perhaps the entire FIFO worth) of readings into. From there you can convert vectors of the data into fixed point values that are more amenable to things like cmsis dsp filters.
I get that, but I want to ensure whatever HAL code we pull in doesn't try and dictate how interrupts are dealt with. For example from the application API with sensors, the newer API does not provide any callback mechanisms. This means, potentially, the hardware could be programmed to trigger DMA directly from a gpio interrupt entirely avoiding the issue of ISR latencies.
No interrupts would be supported, but the way interrupts are reported back to the application changes from callbacks to queued events. We could absolutely reconsider this, but I'd note that callbacks as a whole in Zephyr are a bit complicated.
I'd prefer if we didn't do this in a sensor HAL, it forces a specific flow of bus usages. Today the way sensors handle triggers is by starting a work queue task or waking up a thread dedicated to the sensor to handle it. As noted in our docs they have tradeoffs between the options, one has a latency implication, the other has a memory implication. Both actually are less than ideal, when really all we wanted to do 90% of the time or more is start an I2C or SPI read. The newer API uses an asynchronous operation queue. The driver is expected, in the ISR, request a bus read with an attached callback. On completion, report back to the sensor driver caller than their read is done with a completion queue item being added. No threads needed, no context switches needed, etc.
I think that might help, perhaps you'd be interested in joining the next sensor WG meeting to discuss? https://github.com/zephyrproject-rtos/zephyr/wiki/Sensors-Working-Group If you haven't looked at the section on async sensors in the docs that would be a good place to start. I won't block this HAL or the driver by any means, but I do want to make sure there's some critical thinking and consideration for where we want to go taken into account. https://docs.zephyrproject.org/latest/hardware/peripherals/sensor.html#async-read The first driver we did for this newer API was in fact... the ICM42688p on using the TDK Robokit1 to develop it! |
Hi @afontaine-invn, today's meeting was cancelled due to the US holiday. I suggest joining next week to go over this and move forward with the process. |
Hi @nashif , Hi @MaureenHelm , |
@afontaine-invn why do you still have the original license in the code? The text below copyright looks like ISC license....
In general it should be enough to have:
|
The text below the SPDX Identifier is validated and provided by our legals to provide open-source code. I don't understand why it's not compliant. The hal_nordic https://github.com/zephyrproject-rtos/hal_nordic for example has the same licence header in the files. |
The SPDX Identifier on the first line indicates a BSD 3-Clause license, but full text of the license on the following lines aren't actually a BSD 3-Clause license. If you want to include both the SPDX identifier and the full text of the license, they need to be consistent. |
Hi @nashif , Hi @MaureenHelm , |
Hi @nashif , I'm glad the motion is passed on last TSC meeting. What's the next step now? |
@stephanosio May you help on creating the module repo in @zephyrproject-rtos? Thanks! |
Hi @stephanosio , sorry to ping you directly, could we move forward to create the repository? Or do you have an ETA for this task? Thanks |
Hi @henrikbrixandersen, Hi @carlescufi |
@afontaine-invn repo is created: https://github.com/zephyrproject-rtos/hal_tdk please submit a PR to add it to the manifest and other files needed for it to be used. |
also add an entry to the MAINTAINER file |
Hi @nashif , we have a PR opened in the tdk hal repository to fix the integration in the zephyr-rtos project. zephyrproject-rtos/hal_tdk#1 |
Origin
The new repository will contain TDK sensor drivers, which is currently available for registered user only. As example, find icm42670p driver here: https://invensense.tdk.com/products/motion-tracking/6-axis/icm-42670-p/#documentation
This is part of our current effort to put in place a public git repository.
Purpose
Support TDK sensor drivers.
Mode of integration
The module should be integrated as an external HAL module. The proposed name is hal_tdk.
Maintainership
tdk_hal will be maintained by:
Pull Request
#71374
Description
This provides TDK official sensor drivers. Initially for IMUs.
As first step, we proposed this tree layout:
Other chip reference could be added; icm42671s, icm42671p, icm42370
And in next step we could update existing icm drivers to use this hal
The demo repository is available:
https://github.com/tdk-invn-oss/zephyr.hal_tdk
Dependencies
None
Revision
7f0f547109b8db79722ee2f8c2854577ccb610af
Initial push with separate PR.
License
BSD-3-Clause
The text was updated successfully, but these errors were encountered: