Aditya Oza
Aditya Oza

Reputation: 1

Add Custom sensor in AOSP

I want to add the LSM6DS3 sensor driver in my AOSP source code. I am using SC600T device.

  1. I have already add lsm6ds3 to the location /SC600T/SC60_SC600_Android9.0.0_kernel4.9_r029/kernel/msm-4.9/drivers/iio/imu/st_lsm6ds3, with Makefile and Kconfig files.

  2. Added below line to /../../iio/imu/Kconfig file:

    source "drivers/iio/imu/st_lsm6ds3/Kconfig" 
    
  3. Added below line to /../../iio/imu/Makefile.

    obj-y += st_lsm6ds3/
  1. Content of /SC600T/../../iio/imu/st_lsm6ds3/Makefile:
   # SPDX-License-Identifier: GPL-2.0-only
   st_lsm6dsx-y := st_lsm6dsx_core.o st_lsm6dsx_buffer.o \
           st_lsm6dsx_shub.o
   
   obj-$(CONFIG_IIO_ST_LSM6DSX) += st_lsm6dsx.o
   obj-$(CONFIG_IIO_ST_LSM6DSX_I2C) += st_lsm6dsx_i2c.o
   obj-$(CONFIG_IIO_ST_LSM6DSX_SPI) += st_lsm6dsx_spi.o
   obj-$(CONFIG_IIO_ST_LSM6DSX_I3C) += st_lsm6dsx_i3c.o
  1. I have also added lsm6ds3 node in the device tree file:
    &i2c_2 {
        status = "ok";
        #address-cells = <0x1>;
        #size-cells = <0x0>;
        lsm6ds3@6b {
            compatible = "st,lsm6ds3";
            reg = <0x6b>;
            interrupt-parent = <&tlmm>;
            interrupt-gpios = <&tlmm 45 0x2008>;
            interrupts = <45 0x02>;
        };

I have connected LSM6DS3 accelerometer Sensor on SENSOR_I2C_SCL (Pin number 131) and SENSOR_I2C_SDA (Pin number 132).

After that I have compiled the source code and flash boot and dtbo on target device(SC600T) successfully.

When I am trying to check sensor data using adb shell >> /sys/bus/devices/i2C/devices node is available and lsm6ds3 address node which is 6b is also available. But lsm6ds3 sensor is not probed. enter image description here

enter image description here

Then after I will add below lines in msm8953_defconfig file.

  1. Added below lines in msm8953_defconfig fie:
    CONFIG_IIO_ST_LSM6DSX=y 
    CONFIG_IIO_ST_LSM6DSX_I2C=y
    CONFIG_IIO_ST_LSM6DSX_SPI=y
    CONFIG_IIO_ST_LSM6DSX_I3C=y 

after adding this file when i compiling the source code getting below errors:

[  2% 309/12824] Building kernel...
FAILED: out/target/product/msm8953_64/obj/kernel/msm-4.9/arch/arm64/boot/Image.gz-dtb 
/bin/bash -c "(rm -rf out/target/product/msm8953_64/obj/kernel/msm-4.9/arch/arm64/boot/dts ) && (make -j3 -C kernel/msm-4.9 O=../../out/target/product/msm8953_64/obj/kernel/msm-4.9 DTC_EXT=dtc CONFIG_BUILD_ARM64_DT_OVERLAY=y ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- KCFLAGS=-mno-android ) && (make -j3 -C kernel/msm-4.9 O=../../out/target/product/msm8953_64/obj/kernel/msm-4.9 DTC_EXT=dtc CONFIG_BUILD_ARM64_DT_OVERLAY=y ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- KCFLAGS=-mno-android modules ) && (make -j3 -C kernel/msm-4.9 O=../../out/target/product/msm8953_64/obj/kernel/msm-4.9 INSTALL_MOD_PATH=../../../dlkm INSTALL_MOD_STRIP=1 DTC_EXT=dtc CONFIG_BUILD_ARM64_DT_OVERLAY=y ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- modules_install ) && (mdpath=\`find out/target/product/msm8953_64/dlkm/lib/modules -type f -name modules.dep\`; if [ \"\$mdpath\" != \"\" ];then mpath=\`dirname \$mdpath\`; ko=\`find \$mpath/kernel -type f -name *.ko\`; for i in \$ko; do mv \$i out/target/product/msm8953_64/dlkm/lib/modules/; done; fi ) && (mdpath=\`find out/target/product/msm8953_64/dlkm/lib/modules -type f -name modules.dep\`; if [ \"\$mdpath\" != \"\" ];then mpath=\`dirname \$mdpath\`; rm -rf \$mpath; fi )"
make: Entering directory `/media/ubuntu/Vezo_360/SC600T/SC60_SC600_Android9.0.0_kernel4.9_r029/kernel/msm-4.9'
make[1]: Entering directory `/media/ubuntu/Vezo_360/SC600T/SC60_SC600_Android9.0.0_kernel4.9_r029/out/target/product/msm8953_64/obj/kernel/msm-4.9'
  GEN     ./Makefile
scripts/kconfig/conf  --silentoldconfig Kconfig
make[2]: Leaving directory `/media/ubuntu/Vezo_360/SC600T/SC60_SC600_Android9.0.0_kernel4.9_r029/out/target/product/msm8953_64/obj/kernel/msm-4.9'
make[1]: Entering directory `/media/ubuntu/Vezo_360/SC600T/SC60_SC600_Android9.0.0_kernel4.9_r029/out/target/product/msm8953_64/obj/kernel/msm-4.9'
  CHK     include/config/kernel.release
  GEN     ./Makefile
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  Using /media/ubuntu/Vezo_360/SC600T/SC60_SC600_Android9.0.0_kernel4.9_r029/kernel/msm-4.9 as source for kernel
  /media/ubuntu/Vezo_360/SC600T/SC60_SC600_Android9.0.0_kernel4.9_r029/kernel/msm-4.9 is not clean, please run 'make mrproper'
  in the '/media/ubuntu/Vezo_360/SC600T/SC60_SC600_Android9.0.0_kernel4.9_r029/kernel/msm-4.9' directory.
make[2]: *** [prepare3] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/media/ubuntu/Vezo_360/SC600T/SC60_SC600_Android9.0.0_kernel4.9_r029/out/target/product/msm8953_64/obj/kernel/msm-4.9'
make: *** [sub-make] Error 2
make: Leaving directory `/media/ubuntu/Vezo_360/SC600T/SC60_SC600_Android9.0.0_kernel4.9_r029/kernel/msm-4.9'
[  2% 312/12824] target  C: libdsutils <= vendor/qcom/proprietary/data/dsutils/src/ds_util.c
vendor/qcom/proprietary/data/dsutils/src/ds_util.c:719:7: warning: unused variable 'adb_lvl' [-Wunused-variable]
  int adb_lvl = 0;
      ^
vendor/qcom/proprietary/data/dsutils/src/ds_util.c:2357:5: warning: unused function 'ds_can_exec' [-Wunused-function]
int ds_can_exec
    ^
2 warnings generated.
[  2% 314/12824] target  C++: KmInstallKeybox <= ven...ecuremsm/keymaster_install_toolbox/InstallKeybox.cpp
ninja: build stopped: subcommand failed.
20:36:27 ninja failed with: exit status 1

#### failed to build some targets (42 seconds) ####

Adding any custom sensor in the AOSP, are this all steps mandatory or not? Why lsm6ds3 sensor is not probed? Do I need to check anything from the hardware side?

Upvotes: 0

Views: 1124

Answers (2)

Robert McLean
Robert McLean

Reputation: 366

From your log file it looks to me that your problem (and solution) got called out with this line:

  /media/ubuntu/Vezo_360/SC600T/SC60_SC600_Android9.0.0_kernel4.9_r029/kernel/msm-4.9 is not clean, please run 'make mrproper'

Sometimes a kernel build leaves cruft behind that a subsequent build has a hard time dealing with. Running that make target "mrproper" cleans everything up and starts over. From your description, it sounds like you got everything else right.

I think you should try the recommended make target: make mrproper and rebuild the kernel/everything and see if that fixes your build problems.

I should also mention that after make mrproper, you might have to go all the way back to make defconfig, then you should be able to do a proper build.

Upvotes: 0

withg
withg

Reputation: 1

Sensors on Quectel SC600 devices go through something called ADSP, that is closed source. Under this system, sensors are configured through the vendor/qcom/proprietary/sensors/dsps/reg_defaults/sensor_def_qcomdev.conf file.

There is a list of compatible sensors that can work with the ADSP. You have to ask it to your Quectel representative. Otherwise you have to ask them to integrate the sensor you want, and this is, of course, too much to ask, so consider it impossible (unless Qualcomm hands you the ADSP source code, which I don't think it is going to happen).

Upvotes: 0

Related Questions