cancel
Showing results for 
Search instead for 
Did you mean: 

integration of lsm303AGR on Android 10 and kernel 5.4 versions

prasannakulkarni
Associate II

Dear Team,

We are integrating lsm303AGR accelerometer and magnetometer sensors on NXP's imx8 Android 10 platform.

https://github.com/STMicroelectronics/st-mems-android-linux-sensors-hal for HAL

https://github.com/STMicroelectronics/st-mems-android-linux-drivers-iio for linux 5.4 kernel

device registers as iio:device0 and iio:device1 x,y,z raw value we can see in cat sysfs files.

HAL finds 2 IIO devices but further

there is lack of implementation of loading bias and save bias functions in legacy 

because of this the sensors app is not able to  read the sensor data values . apps says there are 2 sensors from stm accel and magn but data is not able to read.

it is going into un-calibrated type. 

kindly help us in fixing the issue.

14 REPLIES 14
Federica Bossi
ST Employee

Hi @prasannakulkarni ,

Can you check if the Linux driver works correctly on your platform?
To verify this, once the sensor is activated, the accelerometer or magnetomer interrupts must increment regularly, otherwise there could be an issue with the configuration of the interrupt lines in the device tree. To see if the interrupts are triggered regularly, you can read the file/proc/interrupts, checking for example if the lsm303agr_accel counter increases.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Yes you are true, interrupts are getting incremented. kindly find the attached files there are no implementations for loadbias and savebias in legacy mode

legacy/SensorsLegacyInterface.cpp


/**
247 * onSaveDataRequest: receive data to store,
248 * reference: ISTMSensorsCallbackData class
249 */
250 int SensorsLegacyInterface::onSaveDataRequest(const std::string& resourceID,
251 const void *data, ssize_t len)
252 {
253 (void) resourceID;
254 (void) data;
255 (void) len;
256
257 return -EIO;
258 }
259
260 /**
261 * onLoadDataRequest: load data from disk,
262 * reference: ISTMSensorsCallbackData class
263 */
264 int SensorsLegacyInterface::onLoadDataRequest(const std::string& resourceID,
265 void *data, ssize_t len)
266 {
267 (void) resourceID;
268 (void) data;
269 (void) len;
270
271 return -EIO;
272 }

Screenshot from 2025-02-21 19-40-56.png

Screenshot from 2025-02-21 19-41-12.png

Screenshot from 2025-02-21 19-41-33.png

   

Screenshot from 2025-02-21 19-42-34.png

Screenshot from 2025-02-21 19-42-51.png

Screenshot from 2025-02-21 19-43-12.png

   

Screenshot from 2025-02-21 19-43-26.png

Screenshot from 2025-02-21 19-52-45.png

  

prasannakulkarni
Associate II

Kindly help

Hi @prasannakulkarni ,

Can you try this patch on Linux driver?

diff --git a/drivers/iio/stm/magnetometer/st_mag40_buffer.c b/drivers/iio/stm/magnetometer/st_mag40_buffer.c
index 468f26db..a853f611 100644
--- a/drivers/iio/stm/magnetometer/st_mag40_buffer.c
+++ b/drivers/iio/stm/magnetometer/st_mag40_buffer.c
@@ -131,6 +131,10 @@ static int st_mag40_buffer_postdisable(struct iio_dev *indio_dev)

static const struct iio_buffer_setup_ops st_mag40_buffer_setup_ops = {
       .preenable = st_mag40_buffer_preenable,
+#if KERNEL_VERSION(5, 10, 0) > LINUX_VERSION_CODE
+       .postenable = iio_triggered_buffer_postenable,
+       .predisable = iio_triggered_buffer_predisable,
+#endif /* LINUX_VERSION_CODE */
       .postdisable = st_mag40_buffer_postdisable,
};

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

            As in First post I have explained, I have taken code from your github latest

We are integrating lsm303AGR accelerometer and magnetometer sensors on NXP's imx8 Android 10 platform.

https://github.com/STMicroelectronics/st-mems-android-linux-sensors-hal for HAL

https://github.com/STMicroelectronics/st-mems-android-linux-drivers-iio for linux 5.4 kernel

 

     We are using Linux 5.4 kernel, accordingly we have 

following lines in the driver, lets concentrate only on Accelerometer , I have attached patch just check it

 

Hi @prasannakulkarni ,

Starting with Android 10, it is no longer suggested to use the SensorHAL 1.0 (Legacy) because Google introduced the Sensor HAL 2.0, which requires the implementation of a HIDL interface for sensors, making the legacy version obsolete. For this reason, we suggest using the HIDL 2.0 version, whose documentation is provided here: HIDL 2.0 Documentation

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.