GithubHelp home page GithubHelp logo

stmicroelectronics / stmems_linux_iio_drivers Goto Github PK

View Code? Open in Web Editor NEW
73.0 27.0 42.0 1.36 GB

DISCONTINUED (October 2022): the maintenance for this repository has been discontinued. Please refer to https://github.com/STMicroelectronics/st-mems-android-linux-drivers-iio for the up-to-date drivers repository. This repository contains Linux Kernel (v3.10, v3.14, v3.18, v4.9, v4.14, v4.19) including STMicroelectronics MEMS IIO sensor support

License: Other

Makefile 0.29% C 97.54% Assembly 1.83% C++ 0.03% Shell 0.06% Awk 0.01% Python 0.05% GDB 0.01% Perl 0.13% Yacc 0.02% Lex 0.01% UnrealScript 0.01% Gherkin 0.01% XS 0.01% Roff 0.01% Clojure 0.01% M4 0.01% SmPL 0.02% Raku 0.01%
android iio kernel linux mems sensor mems-sensors stmicroelectronics

stmems_linux_iio_drivers's Introduction

Important Notice

DISCONTINUED (October 2022): the maintenance for this repository has been discontinued.

Please refer to:

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

for the up-to-date drivers repository.

Index

* Introduction
* Integration details
* More information
* Copyright

Introduction

This repository contains Linux kernel v4.4 with STMicroelectronics MEMS sensor support. STM sensor drivers are located under the directory drivers/iio organized by sensor type:

Inertial Module Unit (IMU):

LSM6DS3, LSM6DS3H, LSM6DSL, LSM6DSM, LSM9DS0, LSM9DS1, ISM330DLC, LSM6DSO, ASM330LHH, LSM6DSR, ISM330DHCX, LSM6DSO32, LSM6DSOX, LSM6DSRX, LSM6DSO32X, ASM330LHHX

Accelerometer:

LIS2DH, LIS2DH12, LIS3DH, LIS2DG, LSM303AH, LIS2DS12, LIS2HH12, LIS2DW12, LIS3LV02DL, LSM303DLH, LSM303DLHC, LSM330D, LSM330DL, LSM330DLC, LIS331DL, LIS331DLH, LSM303DL, LSM303DLM, LSM330, LSM303AGR, LIS3DHH, IIS2DH, ISM303DAC, IIS3DHHC, IIS2DLPC, AIS2IH

Gyroscope:

L3G4200D, LSM330D, LSM330DL, L3GD20, L3GD20H, L3G4IS, LSM330, LSM330DLC

Magnetometer:

LIS3MDL, LSM9DS1, LSM303AH, LSM303AGR, LSM303DLH, LSM303DLHC, LSM303DLM, LIS2MDL, IIS2MDC, ISM303DAC

Humidity:

HTS221

Pressure:

LPS22HB, LPS22HD, LPS25H, LPS331AP, LPS001WP, LPS33HW, LPS35HW, LPS22HH, LPS27HHW, LPS22DF

Temperature

STTS22H

Data collected by STM sensors are pushed to userland through the kernel buffers of Linux IIO framework. User space applications can get sensor events by reading the related IIO devices created in the /dev directory (/dev/iio{x}). Please see IIO for more information.

All STM MEMS sensors support I2C/SPI digital interface. Please refer to I2C and SPI for detailed documentation.

Integration details

In order to explain how to integrate STM sensors in a different kernel, please consider the following LSM6DSM IMU example

Source code integration

  • Copy driver source code into the target directory (e.g. drivers/iio/imu)
  • Edit related Kconfig (e.g. drivers/iio/imu/Kconfig) to include LSM6DSM support:
    source "drivers/iio/imu/st_lsm6dsm/Kconfig"
  • Edit related Makefile (e.g. drivers/iio/imu/Makefile) adding the following line:
    obj-y += lsm6dsm/
  • Add custom events into include/uapi/linux/iio/types.h (follow a sample patch for kernel 4.4):
    @@ -85,6 +93,7 @@ enum iio_event_type {
              IIO_EV_TYPE_THRESH_ADAPTIVE,
              IIO_EV_TYPE_MAG_ADAPTIVE,
              IIO_EV_TYPE_CHANGE,
    +         IIO_EV_TYPE_FIFO_FLUSH,
    };

    @@ -92,6 +101,8 @@ enum iio_event_direction {
              IIO_EV_DIR_RISING,
              IIO_EV_DIR_FALLING,
              IIO_EV_DIR_NONE,
    +         IIO_EV_DIR_FIFO_EMPTY,
    +         IIO_EV_DIR_FIFO_DATA,
    };
  • Add custom channel types include/uapi/linux/iio/types.h depending on the custom sensor implemented into driver (follow a sample patch for kernel 4.4):
     @@ -37,6 +37,14 @@ enum iio_chan_type {
              IIO_VELOCITY,
              IIO_CONCENTRATION,
              IIO_RESISTANCE,
    +         IIO_SIGN_MOTION,
    +         IIO_STEP_DETECTOR,
    +         IIO_STEP_COUNTER,
    +         IIO_TILT,
    +         IIO_TAP,
    +         IIO_TAP_TAP,
    +         IIO_WRIST_TILT_GESTURE,
    +         IIO_GESTURE,
    +         IIO_WKUP,
    +         IIO_FREE_FALL,
    };

Device Tree configuration

To enable driver probing, add the lsm6dsm node to the platform device tree as described below.

Required properties:

- compatible: "st,lsm6dsm"

- reg: the I2C address or SPI chip select the device will respond to

- interrupt-parent: phandle to the parent interrupt controller as documented in interrupts

- interrupts: interrupt mapping for IRQ as documented in interrupts

Recommended properties for SPI bus usage:

- spi-max-frequency: maximum SPI bus frequency as documented in SPI

Optional properties:

- st,drdy-int-pin: MEMS sensor interrupt line to use (default 1)

Device Tree Integration Examples

I2C example (based on Raspberry PI 3):

  &i2c0 {
  	status = "ok";
  	#address-cells = <0x1>;
  	#size-cells = <0x0>;
  	lsm6dsm@6b {
  		compatible = "st,lsm6dsm";
  		reg = <0x6b>;
  		interrupt-parent = <&gpio>;
  		interrupts = <26 IRQ_TYPE_LEVEL_HIGH>;
  };

SPI example (based on Raspberry PI 3):

  &spi0 {
  	status = "ok";
  	#address-cells = <0x1>;
  	#size-cells = <0x0>;
  	lsm6dsm@0 {
  		spi-max-frequency = <500000>;
  		compatible = "st,lsm6dsm";
  		reg = <0>;
  		interrupt-parent = <&gpio>;
  		interrupts = <26 IRQ_TYPE_LEVEL_HIGH>;
  	};

Kernel configuration

Configure kernel with make menuconfig (alternatively use make xconfig or make qconfig)

  Device Drivers  --->
  	<M> Industrial I/O support  --->
  		Inertial measurement units  --->
  		<M>   STMicroelectronics LSM6DSM/LSM6DSL sensor  --->

More Information

http://st.com

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/iio

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/i2c

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/spi

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bings/interrupt-controller/interrupts.txt

Copyright

Copyright (C) 2019 STMicroelectronics

This software is distributed under the GNU General Public License - see the accompanying COPYING file for more details.

stmems_linux_iio_drivers's People

Contributors

acmel avatar adrianbunk avatar airlied avatar alexdeucher avatar arndb avatar axellin avatar bigguiness avatar broonie avatar bzolnier avatar danvet avatar davem330 avatar dhowells avatar ebiederm avatar geertu avatar gregkh avatar herbertx avatar htejun avatar ickle avatar jmberg-intel avatar joeperches avatar kaber avatar larsclausen avatar mchehab avatar morimoto avatar olofj avatar pmundt avatar ralfbaechle avatar rddunlap avatar tiwai avatar torvalds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stmems_linux_iio_drivers's Issues

Reading lsm6dso32 data via libiio not possible

We are using lsm6dso32 accelerometer/gyroscope connected to a custom hardware (non-ST) via i2c. We are building a custom linux (kernel version 5.4) via yocto for our board and integrated this driver for lsm6dso32 support into it. I am assuming, that it is more or less the driver from this repository. I want to read lsm6dso32 data via libiio. My problem is (similar to this one for a different IMU) that I can read single values from sysfs, but there are no scan_elements folders in sysfs iio device folders. This way, I am not able, to use libiio to read measured values from a buffer. Basically, I am not able to use libiio at all, which is quite annoying.

I already created an issue in ST Microelectronics community forum:
https://community.st.com/s/question/0D53W00001m9jLYSAY/read-lsm6dso32-data-via-libiio

Just wanted to increase possible attention for the issue ;)

Why the supported ODR for st_lsm6ds3 IMU is only until 416 Hz?

This is more of a question than an issue. I initially wrote a userspace driver for lsm6ds3 but later found out that there is already a kernel IIO driver.
But after some investigation, I saw that the kernel driver st_lsm6ds3 only supports ouput data rate (ODR) upto only 416 Hz as it can be seen in this struct definition in drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_core.c:

static struct st_lsm6ds3_odr_table {
	u8 addr[2];
	u8 mask[2];
	struct st_lsm6ds3_odr_reg odr_avl[ST_LSM6DS3_ODR_LIST_NUM];
} st_lsm6ds3_odr_table = {
	.addr[ST_MASK_ID_ACCEL] = ST_LSM6DS3_ACCEL_ODR_ADDR,
	.mask[ST_MASK_ID_ACCEL] = ST_LSM6DS3_ACCEL_ODR_MASK,
	.addr[ST_MASK_ID_GYRO] = ST_LSM6DS3_GYRO_ODR_ADDR,
	.mask[ST_MASK_ID_GYRO] = ST_LSM6DS3_GYRO_ODR_MASK,
	.odr_avl[0] = { .hz = 13, .value = ST_LSM6DS3_ODR_13HZ_VAL },
	.odr_avl[1] = { .hz = 26, .value = ST_LSM6DS3_ODR_26HZ_VAL },
	.odr_avl[2] = { .hz = 52, .value = ST_LSM6DS3_ODR_52HZ_VAL },
	.odr_avl[3] = { .hz = 104, .value = ST_LSM6DS3_ODR_104HZ_VAL },
	.odr_avl[4] = { .hz = 208, .value = ST_LSM6DS3_ODR_208HZ_VAL },
	.odr_avl[5] = { .hz = 416, .value = ST_LSM6DS3_ODR_416HZ_VAL },
};

But the actual hardware supports ODR for accelerometer up to 6.66 kHz and for gyro up to 1.66 kHz. Is there a reason why the support for this ST chip is only until 416 Hz? Is there a way to scale it up?

Any help is appreciated!

ism330dhcx temperature in wrong format

According to the IIO ABI documentation the temperature output units are standardized:

Units after application of scale and offset are milli degrees Celsius.

Applying the following patch solves the problem.

Subject: [PATCH 1/1] Fix temperature scaling issue

According to the iio ABI documentation the units of the temperature
is mili degrees Celsius.
---
 drivers/iio/imu/st_ism330dhcx/st_ism330dhcx_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/imu/st_ism330dhcx/st_ism330dhcx_core.c b/drivers/iio/imu/st_ism330dhcx/st_ism330dhcx_core.c
index 07e8e2d77f5f..9939c65a1e51 100644
--- a/drivers/iio/imu/st_ism330dhcx/st_ism330dhcx_core.c
+++ b/drivers/iio/imu/st_ism330dhcx/st_ism330dhcx_core.c
@@ -781,7 +781,7 @@ static int st_ism330dhcx_read_raw(struct iio_dev *iio_dev,
  case IIO_CHAN_INFO_SCALE:
  switch (ch->type) {
  case IIO_TEMP:
- *val = 1;
+ *val = 1000;
  *val2 = ST_ISM330DHCX_TEMP_GAIN;
  ret = IIO_VAL_FRACTIONAL;
  break;

Edit: Currently the units are degrees C

How to save and read a lot of data at once?

I use ASM330LHH as Linux IIO.
Source and DTS were added.
We found that /sys/bus/iio also added a device.
I also checked reading data in direct mode from sysfs.
Therefore, I think there is no problem with the H/W connection.

I try to read the value of asm330lhh every 15mS for collision detection.
I want to fetch the collected data rather than reading the value every time.
I want to know how to save a lot of data automatically and read it at once.
How should I use it?
โ€‹

linux-5.10 support?

Dear STMicroelectronics,

I would like to know if you would support Linux kernel version 5.10 and above as most of embedded systems are pumped up to those kernel versions ?

We were successful to use your latest branch linux-4.19.y-gh into kernel 5.4.x. However, there's big jump from 5.4.x to 5.10.y and the drivers' code would need to be adapted I guess.

Thanks in advance and best regards,
Khang

linux-5.15 support

Hello,

since NXP has released a BSP with LTS kernel 5.15 for their iMX chips I would like to know if there are plans for supporting this kernel version.

When compiling the driver for LIS2DW12/IIS2DLPC for linux-5.15 I got the following error:

st_lis2dw12_buffer.c:308:18: error: implicit declaration of function 'devm_iio_kfifo_allocate'; did you mean 'iio_kfifo_allocate'? [-Werror=implicit-function-declaration]

The function 'devm_iio_kfifo_allocate' was changed to a private function in kernel 5.13 and replaced by 'devm_iio_kfifo_buffer_setup' in header 'kfifo_buf.h'

Best regards,
Markus

st_lsm6dsx Industrial IO IMU driver not loading

I have LSM6DS3 IMU sensor from ST. I was successful in writing a userspace SPI driver to interact with this sensor from my beaglebone black, and now I am trying to use an IIO kernel module driver, st_lsm6dsx_spi that comes pre-built.
However, even after countless hours of debugging, I am having trouble getting it to work from kernel space.

I adapted my overlay (posted below) to use this LKM for spi0. I can see a device being created in /sys/bus/spi as follows:

debian@beaglebone:~$ cat /sys/bus/spi/devices/spi1.0/
modalias    of_node/    power/      statistics/ subsystem/  uevent
debian@beaglebone:~$ cat /sys/bus/spi/devices/spi1.0/modalias 
spi: lsm6ds3

But I don't see the correct driver is loaded for it. It not creating any char device in /dev/ directory nor I can see any sign of it in /sys/bus/iio/devices directory.
No effect even if I try to manually load the driver, st_lsm6dsx_spi using modprobe.

Could someone say what is going on and what I am doing wrong here? Any help would be highly appreciated.

More information:
For now, I don't want to enable interrupts for fifo mode.
My DTS overlay:

  /dts-v1/;
/plugin/;

#include <dt-bindings/board/am335x-bbw-bbb-base.h>
#include <dt-bindings/pinctrl/am33xx.h>

/ {
	compatible = "ti,beaglebone", "ti,beaglebone-black";

	/* identification */
    part-number = "BB-LSM6DX";
	version = "00A0";

	/* state the resources this cape uses */
	exclusive-use =
		/* the pin header uses */
		"P9.17",	/* P9_17 (A16) spi0_cs0.spi0_cs0 */
		"P9.18",	/* P9_18 (B16) spi0_d1.spi0_d1 */
		"P9.21",	/* P9_21 (B17) spi0_d0.spi0_d0 */
		"P9.22",	/* P9_22 (A17) spi0_sclk.spi0_sclk */
		/* the hardware ip uses */
		"spi0";

	/*
	 * Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
	 */
	fragment@0 {
		target-path="/";
		__overlay__ {

			chosen {
				overlays {
					BB-LSM6DSX-00A0 = __TIMESTAMP__;
				};
			};
		};
	};

	/*
	 * Free up the pins used by the cape from the pinmux helpers.
	 */
	fragment@1 {
		target = <&ocp>;
		__overlay__ {
			P9_17_pinmux { status = "disabled"; };	/* P9_17 (A16) spi0_cs0.spi0_cs0 */
			P9_18_pinmux { status = "disabled"; };	/* P9_18 (B16) spi0_d1.spi0_d1 */
			P9_21_pinmux { status = "disabled"; };	/* P9_21 (B17) spi0_d0.spi0_d0 */
			P9_22_pinmux { status = "disabled"; };	/* P9_22 (A17) spi0_sclk.spi0_sclk */
		};
	};

	fragment@2 {
		target = <&am33xx_pinmux>;
		__overlay__ {
			bb_spi0_pins: pinmux_bb_spi0_pins {
				pinctrl-single,pins = <
					AM33XX_PADCONF(AM335X_PIN_SPI0_SCLK, PIN_INPUT, MUX_MODE0) /* P9_22 (A17) spi0_sclk.spi0_sclk */
					AM33XX_PADCONF(AM335X_PIN_SPI0_D0, PIN_INPUT, MUX_MODE0)   /* P9_21 (B17) spi0_d0.spi0_d0 */
					AM33XX_PADCONF(AM335X_PIN_SPI0_D1, PIN_INPUT, MUX_MODE0)   /* P9_18 (B16) spi0_d1.spi0_d1 */
					AM33XX_PADCONF(AM335X_PIN_SPI0_CS0, PIN_INPUT, MUX_MODE0)  /* P9_17 (A16) spi0_cs0.spi0_cs0 */
				>;
			};
		};
	};
	fragment@3 {
		target = <&spi0>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;

			status = "okay";
			pinctrl-names = "default";
			pinctrl-0 = <&bb_spi0_pins>;
            channel@0 {
                    status = "disabled"; /* Enabled by default in bb-kernel so users can use spidev from userspace */
            };
            channel@1 {
                    status = "disabled";
            };
           lsm6ds3: lsm6ds3@0 {
				spi-max-frequency = <500000>;
				compatible = "st, lsm6ds3";
                                reg = <0x0>;
			};

		};
	};
};

My sudo /opt/scripts/tools/version.sh output:

git:/opt/scripts/:[109f74fb87e6034ae1a8971a244064a8d5e090a5]
eeprom:[A335BNLT00C05014BBBK1F75]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Image 2019-08-03]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2019.04-00002-gbb4af0f50f]:[location: dd MBR]
kernel:[4.14.108-ti-r113]
nodejs:[v6.17.0]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_addr4=/lib/firmware/BB-LSM6DSX-00A0.dtbo]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.4.20190801.0-0rcnee0~stretch+20190801]
pkg:[bb-wl18xx-firmware]:[1.20190227.1-0rcnee0~stretch+20190227]
pkg:[kmod]:[23-2rcnee1~stretch+20171005]
pkg:[librobotcontrol]:[1.0.4-git20190227.1-0rcnee0~stretch+20190327]
pkg:[firmware-ti-connectivity]:[20180825+dfsg-1rcnee1~stretch+20181217]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c bluetooth netdev gpio pwm eqep remoteproc admin spi tisdk weston-launch xenomai cloud9ide]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 rng_core.default_quality=100 quiet]
dmesg | grep remote
[    1.114108] remoteproc remoteproc0: wkup_m3 is available
[    1.322488] remoteproc remoteproc0: powering up wkup_m3
[    1.322607] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[    1.326544] remoteproc remoteproc0: remote processor wkup_m3 is now up
dmesg | grep pru
dmesg | grep pinctrl-single
[    0.872348] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
dmesg | grep gpio-of-helper
[    0.873576] gpio-of-helper ocp:cape-universal: ready
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END

asm330lhhxg1 can't read any buffer data with iio_generic_buffer

Hi,

I'm porting the asm330lhhxg1 on my embedded system device(Linux/arm 4.9.257). I am attempting to use the IIO buffer to continuously read data at its sampling_frequency. However, the process seems to be stuck as shown below:

# Enable Y-axis acceleration
echo 1 > /sys/bus/iio/devices/iio:device2/scan_elements/in_accel_y_en

# Enable X-axis acceleration
echo 1 > /sys/bus/iio/devices/iio:device2/scan_elements/in_accel_x_en

# Enable timestamp
echo 1 > /sys/bus/iio/devices/iio:device2/scan_elements/in_timestamp_en

# Enable Z-axis acceleration
echo 1 > /sys/bus/iio/devices/iio:device2/scan_elements/in_accel_z_en

# Attempt to enable buffer
echo 1 > /sys/bus/iio/devices/iio:device2/buffer/enable

# Run generic buffer utility
./iio_generic_buffer -a -g -n asm330lhhx_accel
# Output from incomplete command
  iio device number being used is 2
  trigger-less mode selected
  Auto-channels selected but some channels are already activated in sysfs
  Proceeding without activating any channels
##stuck here

#Here is my device tree configuration under `i2c0`:

&i2c0 {
   asm330lhhx-imu@0x6b {
        compatible = "st,asm330lhhx";
        reg = <0x6b>;
        interrupt-parent = <&gpio0>;
        interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
        /*vddio-supply = <&sensors_vddio>;*/
        /*vdd-supply = <&sensors_vdd>;*/
	    drive-open-drain;
        st,int-pin = <1>;
        st,mlc-int-pin = <2>;
        mount-matrix = "1", "0", "0",
                   "0", "1", "0",
                   "0", "0", "1";
        };
    }

Here is the output similar to the content on this webpage:

root@tegra-ubuntu:~# ./iio_generic_buffer -a -c 10 --device-name accelerometer -g
iio device number being used is 2
trigger-less mode selected
scan element filename:/sys/bus/iio/devices/iio:device2/scan_elements/in_accel_y_en , enabled:0
scan element filename:/sys/bus/iio/devices/iio:device2/scan_elements/in_accel_x_en , enabled:0
scan element filename:/sys/bus/iio/devices/iio:device2/scan_elements/in_timestamp_en , enabled:0
scan element filename:/sys/bus/iio/devices/iio:device2/scan_elements/in_accel_z_en , enabled:0
No channels are enabled, enabling all channels
Enabling: in_accel_y_en
Enabling: in_accel_x_en
Enabling: in_timestamp_en
Enabling: in_accel_z_en
scan element filename:/sys/bus/iio/devices/iio:device2/scan_elements/in_accel_y_en , enabled:1
scan element filename:/sys/bus/iio/devices/iio:device2/scan_elements/in_accel_x_en , enabled:1
scan element filename:/sys/bus/iio/devices/iio:device2/scan_elements/in_timestamp_en , enabled:1
scan element filename:/sys/bus/iio/devices/iio:device2/scan_elements/in_accel_z_en , enabled:1
buffer directory: /sys/bus/iio/devices/iio:device2/buffer
X Axis   Y Axis    Z Axis   Timestamp [This row is not present in the output]
-9.484633 -0.103250 1.109713 4515182411776
-9.560051 -0.098761 1.115998 4515261579264
-9.547482 -0.096965 1.116896 4515340746752
-9.543890 -0.092476 1.117793 4515419914240
-9.547482 -0.096067 1.112406 4515499606016
-9.542993 -0.096965 1.112406 4515578773504
-9.550175 -0.107739 1.112406 4515657940992
-9.548379 -0.105046 1.115100 4515737108480
-9.540298 -0.101454 1.109713 4515816275968
-9.545686 -0.095170 1.116896 4515895443456
Disabling: in_accel_y_en
Disabling: in_accel_x_en
Disabling: in_timestamp_en
Disabling: in_accel_z_en

I expected to see information similar to what's on the webpage, but it did not appear.

LSM6DSMTR MotionFx library integration on ARMV8 linux

Hi,

I am using LSM6DSMTR on a Linux ARM V8 processor, I have complied the basic code using standard mems driver. I want to use the motionFx library to get the quaternion data . The provided library only includes the complied library and header files.

BIG PROBLEM with driver for LSM6DSO

I have an embedded platform AT91SAM9260 based running on a buildroot based Linux with kernel 4.19.78-linux4sam-6.2 which includes an LSM6DSO and a LIS2MDLTR as well.

When st_* drivers are loaded all communications via i2c is returning EBUSY and even gpioget does not work. Unloading the driver makes everything work fine.

libiio does not have the necessary hooks in your drivers to function properly (according to libiio developers)

So why is i2c comms always returning EBUSY?

This is VERY incovenient.

Why isn't even gpioget on our processor not working on the GPIO pin connected to INT1 on the LSM6DSO when working fine on all other GPIO pins.

your support of iio is marginal at best, no access to individual registers ... only way to access registers is by mounting /sys/kernel/debug and access from there

So should i delete your drivers from the kernel configuration and go i2c all the way seeing that it is impossible to use your iio?

Thanks for a prompt answer

ISM330DLC: Bug delay accelerometer

I found a bug in the ISM330DLC driver. st_ism330dlc_core.c

Current Behavior

When I try to read the accelerometer in Linux with sudo cat /sys/bus/iio/devices/iio:device1/in_accel_x_raw it always return 0. With y and z too.

When I perform a selftest, it pass and then I have new value in in_accel_x-y-z_raw.

I found that with the default frequency (13Hz), the delay at line 1653 is too short. 1/13 = 76ms and it's 40ms in the driver.

Possible Solution

I change this delay to 120ms and it's working well.

LSM6DS3 linux driver for ODR of higher than 416 Hz

Hello STM,

looking the the mainline kernel for the IMU line and the kernels contained here, i see some comments in the code that say the only supported ODRs are that of up to 416 Hz. is it possible to run the sensor in high performance mode with a linux driver? Is there a patchset that provides support for this or is this something that is unsupported with linux? would it be as easy as extending the ODR table definitions or would it be more complex? i'm specifically interested in both gyro and accel at 1.6 KHz or accel only at 6.66 KHz.

mainline kernel
https://elixir.bootlin.com/linux/v5.12-rc8/source/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c#L18

custom STM kernel
https://github.com/STMicroelectronics/STMems_Linux_IIO_drivers/blob/linux-4.4.y-gh/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_core.c#L61

thanks,
wes

Screen Shot 2021-04-29 at 10 08 56 AM

How to get access to the buffer and triggers with the st_imu68 IIO driver?

I am trying to use an hr timer with the st_imu68_i2c driver and the LSMDS1 IMU sensor. But even though I have the CONFIG_IIO_BUFFER enabled, the scan_elements, trigger, and buffer directory are missing.

Our config contains the following IIO configuration:

# CONFIG_TOUCHSCREEN_TSC2007_IIO is not set
# CONFIG_SENSORS_IIO_HWMON is not set
# IIO staging drivers
CONFIG_IIO=y
CONFIG_IIO_BUFFER=y
CONFIG_IIO_BUFFER_CB=y
CONFIG_IIO_KFIFO_BUF=y
CONFIG_IIO_TRIGGERED_BUFFER=y
CONFIG_IIO_CONFIGFS=y
CONFIG_IIO_TRIGGER=y
CONFIG_IIO_CONSUMERS_PER_TRIGGER=2
CONFIG_IIO_SW_DEVICE=y
CONFIG_IIO_SW_TRIGGER=y
# CONFIG_IIO_ST_ACC33 is not set
# CONFIG_IIO_ST_LIS3DHH is not set
# CONFIG_IIO_ST_ACCEL_3AXIS is not set
# CONFIG_IIO_ST_LIS2DS12 is not set
# CONFIG_IIO_ST_ISM303DAC_ACCEL is not set
# CONFIG_IIO_ST_LIS2HH12 is not set
# CONFIG_IIO_ST_LIS2DW12 is not set
# Hid Sensor IIO Common
# CONFIG_IIO_SSP_SENSORHUB is not set
# IIO dummy driver
# CONFIG_IIO_SIMPLE_DUMMY is not set
# CONFIG_IIO_ST_GYRO_3AXIS is not set
# CONFIG_IIO_ST_LSM6DSX is not set
# CONFIG_ST_LSM6DSM_IIO is not set
# CONFIG_IIO_ST_LSM6DSO is not set
# CONFIG_ST_LSM6DS3_IIO is not set
# CONFIG_ST_LSM6DS3H_IIO is not set
# CONFIG_ST_ISM330DLC_IIO is not set
CONFIG_IIO_ST_IMU68=y
CONFIG_IIO_ST_IMU68_I2C=y
CONFIG_IIO_ST_IMU68_SPI=y
# CONFIG_IIO_ST_ASM330LHH is not set
# CONFIG_IIO_ST_LSM6DSR is not set
# CONFIG_IIO_ST_ISM330DHCX is not set
# CONFIG_IIO_ST_LSM6DSO32 is not set
# CONFIG_IIO_ST_MAGN_3AXIS is not set
# CONFIG_ST_MAG40_IIO is not set
CONFIG_ST_MAG3D_IIO=y
CONFIG_ST_MAG3D_I2C_IIO=y
CONFIG_ST_MAG3D_SPI_IIO=y
# CONFIG_IIO_MUX is not set
CONFIG_IIO_HRTIMER_TRIGGER=y
CONFIG_IIO_INTERRUPT_TRIGGER=y
CONFIG_IIO_TIGHTLOOP_TRIGGER=y
CONFIG_IIO_SYSFS_TRIGGER=y
# CONFIG_IIO_ST_PRESS is not set
# CONFIG_ST_LPS22HB_IIO is not set
# CONFIG_ST_LPS33HW_IIO is not set
# CONFIG_ST_LPS22HH_IIO is not set

I only got the directories to appear after I added an interrupt to the device tree like seen below. This however is a dummy interrupt as we do not have an actual physical wire connected to the IMU to the SOM.

	lsm9ds1@6b {
		compatible = "st,lsm9ds1";
		reg = <0x6b>;
                interrupt-parent = <&gpio1>;
                interrupts = <5, IRQ_TYPE_LEVEL_HIGH>;
		status = "okay";
	};

	lsm9ds1_magn@1e {
		compatible = "st,lsm9ds1_magn";
		reg = <0x1e>;
                interrupt-parent = <&gpio1>;
                interrupts = <5, IRQ_TYPE_LEVEL_HIGH>;
		status = "okay";
	};
};

Is there something I am doing wrong? Or does the st_im68 driver only support hardware interrupts?

ASM330LHH does not generate interrupt on my board

We are using company customized development board, connecting ASM330LHH via I2C for data interface and GPIO for interrupt. We are using vanilla ASM330LHH driver in Linux kernel 5.15. Here is my situation:
H/W department said everything is good regarding their part.
USI/I2C department said everything is good regarding their part.
So I seek help here. Thank you in advance!

I configured DTS as this:

&hsi2c_10 {
status = "okay";

   #address-cells = <0x1>;
   #size-cells = <0x0>;
   asm330lhh@6a {
           compatible = "st,asm330lhh";
           reg = <0x6a>;
           interrupt-parent = <&gpp5>;
           interrupts = <5 IRQ_TYPE_EDGE_RISING>;
   };

};

Here is the result:

1. I2C operations are all good, and I am able to access ASM330LHH registers by executing I2C commands:
Command: /usr/sbin/i2cget -f -y -a 10 0x6a 0x0F
Return: 0x6b
Command: cat /sys/bus/iio/devices/iio:device0/in_anglvel_x_raw
Return: 57

2. After Linux booting done, I checked interrupts status as following (there is one gpp5-5 GPIO interrupt was generated, but do not know how it was generated)
cat /proc/interrupts |grep -E "10c30000.pinctrl|10920000.hsi2c|gpp5"
38: 1 0 0 0 0 0 0 0 0 0 GICv3 801 Level 10c30000.pinctrl
69: 61 7 3 15 0 0 0 3 0 0 GICv3 794 Level 10920000.hsi2c
375: 1 0 0 0 0 0 0 0 0 0 gpp5 5 Edge lsm6dsx

3. However, when I run libiio command (shown as following), it always goes to Connection timed out
I found there is no GPIO interrupt generated at all. I believe this leads to timeout.
So this is my question: could you help or give me some hint? Thank you very much!

iio_readdev asm330lhh_gyro anglvel_x
WARNING: High-speed mode not enabled
Unable to refill buffer: Connection timed out

4. One wierd thing is, when I execute following two i2cset commands, one GPIO interrupt will be generated and IRQ handler of ASM330LHH driver is able to read one pair of FIFO data.
/usr/sbin/i2cset -f -y -a 10 0x6a 0x12 0x44;
/usr/sbin/i2cset -f -y -a 10 0x6a 0x12 0x64;

I checked interrupts status as following (there is one more gpp5-5 GPIO interrupt was generated)
cat /proc/interrupts |grep -E "10c30000.pinctrl|10920000.hsi2c|gpp5"
38: 2 0 0 0 0 0 0 0 0 0 GICv3 801 Level 10c30000.pinctrl
69: 61 7 3 17 0 2 0 6 0 0 GICv3 794 Level 10920000.hsi2c
375: 2 0 0 0 0 0 0 0 0 0 gpp5 5 Edge lsm6dsx

Error while inserting the STM Linux driver

hello,

I am trying to get the LSMDSO32 to work with https://github.com/STMicroelectronics/STMems_Linux_IIO_drivers branch 4.19 built on 5.4 kernel.

I am able to build the kernel image on 5.4

But when i try to insmod the modules i get the following errors.

insmod st_lsm6dso32.ko

[ 3073.698696] st_lsm6dso32: Unknown symbol devm_iio_kfifo_allocate (err -2)

[ 3073.706025] st_lsm6dso32: Unknown symbol devm_iio_triggered_buffer_setup (err -2)

insmod: failed to load st_lsm6dso32.ko: No such file or directory

insmod st_lsm6dso32_i2c.ko

[ 3079.860966] st_lsm6dso32_i2c: Unknown symbol st_lsm6dso32_probe (err -2)

[ 3079.868030] st_lsm6dso32_i2c: Unknown symbol st_lsm6dso32_pm_ops (err -2)

insmod: failed to load st_lsm6dso32_i2c.ko: No such file or directory

device tree:

lsm6dso32@6a {

compatible = "st,lsm6dso32";

reg = <0x6a>;

};

How to use the st_imu68 IIO driver with a hrtimer?

I compiled the st_imu68_i2c driver for use with a 4.14 linux kernel with the industrial IO subsystem successfully. And I could read values from the device using the files that provide the "raw" values. However, it is very slow when I just cat the raw values very fast. Normally, in IIO you can define a hrtimer with scan_elements, but the iio device you get from the linux driver does not contain such a 'scan_elements' subdir so it seems I can't attach a hrtimer trigger to it. However, there is a sample_frequency file, but not clear to me what this then does or how it is supposed to work. Is there maybe a high level overview documentation somewhere of how you can get the values faster?

Running the driver on Android 10

We are using AOSP (Android 10). Kernel version is 5.4.47
imu/lsm6dsm driver in 4.19 branch ported to Linux 5.4.47
STMems_Android_Sensor_HAL_IIO/ HAL integrated into Android 10

05-05 13:02:43.222 317 317 D SensorHAL: 10 IIO devices available into /sys/bus/iio/devices/ folder.
05-05 13:02:43.223 317 317 D SensorHAL: "lsm6dsl_step_d": IIO device found and supported. Wake-up sensor: no
05-05 13:02:43.223 317 317 D SensorHAL: "lsm6dsl_sign_motion": IIO device found and supported.
05-05 13:02:43.224 317 317 D SensorHAL: "lsm6dsl_accel": IIO device found and supported. Wake-up sensor: no
05-05 13:02:43.255 317 317 D SensorHAL: "lsm6dsl_tilt": IIO device found and supported.
05-05 13:02:43.257 317 317 D SensorHAL: "lsm6dsl_step_c": IIO device found and supported. Wake-up sensor: no
05-05 13:02:43.258 317 317 D SensorHAL: "lsm6dsl_gyro": IIO device found and supported. Wake-up sensor: no
05-05 13:02:43.296 317 317 D SensorHAL: "LSM6DSL Step Detector Sensor": injection mode not available.
05-05 13:02:43.296 317 317 D SensorHAL: "LSM6DSL Step Detector Sensor": created HW class instance, handle: 1 (sensor type: 18).
05-05 13:02:43.296 317 317 D SensorHAL: "LSM6DSL Significant Motion Sensor": injection mode not available.
05-05 13:02:43.296 317 317 D SensorHAL: "LSM6DSL Significant Motion Sensor": created HW class instance, handle: 2 (sensor type: 17).
05-05 13:02:43.297 317 317 D SensorHAL: "LSM6DSL Accelerometer Sensor": injection mode not available.
05-05 13:02:43.297 317 317 D SensorHAL: "LSM6DSL Accelerometer Sensor": created HW class instance, handle: 3 (sensor type: 1).
05-05 13:02:43.297 317 317 D SensorHAL: "LSM6DSL Tilt Sensor": injection mode not available.
05-05 13:02:43.297 317 317 D SensorHAL: "LSM6DSL Tilt Sensor": created HW class instance, handle: 4 (sensor type: 22).
05-05 13:02:43.297 317 317 D SensorHAL: "LSM6DSL Step Counter Sensor": injection mode not available.
05-05 13:02:43.297 317 317 D SensorHAL: "LSM6DSL Step Counter Sensor": created HW class instance, handle: 5 (sensor type: 19).
05-05 13:02:43.297 317 317 D SensorHAL: "LSM6DSL Gyroscope Sensor": injection mode not available.
05-05 13:02:43.297 317 317 D SensorHAL: "LSM6DSL Gyroscope Sensor": created HW class instance, handle: 6 (sensor type: 4).
05-05 13:02:43.297 317 317 D SensorHAL: "Accelerometer Uncalibrated Sensor": created SW class instance, handle: 7 (sensor type: 35).
05-05 13:02:43.299 317 317 D SensorHAL: Dynamic Sensor Manager: created Dynamic Sensor Proxy, handle: 8 (sensor type: 32).
05-05 13:02:43.299 317 317 D SensorHAL: 8 sensors available and ready.

When we want to test it with sample APKs in the market the following log is output:

[ 307.355780] st-lsm6dsm-i2c 2-006b: data fifo overrun, failed to read it.

Can you send us what can cause this and steps needed to resolve this?

Configuring a hrtimer-trigger or buffered-trigger for iio-device and ODR in driver lower than actual ODR

Hello, I have been having issues with configuring configuring a hrtimer-trigger or buffered-trigger for my iio-device. I am using a ISM330dlc (IMU) and it is connected to a rasberry pi cm4. As a driver I am using the LSM6DSX driver because my IMU is listed as configurable sensor in the Documentation. My problem is that when I load my device tree overlay (dtbo file) the /sys/bus/iio/devices/iio:deviceX/ directory appears but only these files appear.
Screenshot from 2023-11-21 12-05-45
In basically every documentation file, they say that a /sys/bus/iio/devices/iio:deviceX/trigger/ directory should appear and it doesn't matter what I do it doesn't appear. I have checked and the ISM330dlc supports triggers, even 2. Chatgpt has suggested I should change some parameters in the config.txt, but I have checked and every functionality I need.
image
And as you can see everything is set to "m" or "y" so there shouldn't be a problem there.
I have also looked into my dts file:
image
And chatgbt suggested I should do it in this fashion:
image
Unfortunately I haven't found anything regarding triggers under this Documentation path linux/Documentation/devicetree/bindings/iio/imu /st,lsm6dsx.yaml .

Also just a side question, is the buffered trigger a hardware trigger from the IMU because that is what I need besides the Hrtimer-trigger. What I really need, is to compare:
-polling the Data-ready register to see whether new data is ready which then serves me as an interrupt if the data is ready
-waiting for hardware interrupt when new data is ready
To compare them I need to know if there is any chance I can do this by using iio-devices or moreover iio-triggers.

And also my ODR can just be configured to 433Hz even though I know for a fact that my IMU can be configured to an ODR of even 1.6KHz. I only need it set to 833Hz but the issue remains. I am a newbie linux, the iio-framework and the device tree, so I would be extremely thankful if you could provide some backround information to your answer, if you think you might have a solution for me.
Thank you very much in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.