How to use nusensor from AOSP to test sensor HAL

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to use nusensor from AOSP to test sensor HAL

5,942件の閲覧回数
msingh1920
Contributor V

Hi Sir,

I am using iMX8M Mini EVK and Android 9 AOSP Framework.
I am successfully able to build the AOSP for my board and its running fine. 

Now i want to connect DHT 11 sensor to this board at GPIO and want to read it's value.

for that i enabled IIO and DHT11 in iMX8 AOSP kernel menuconfig and build it.

And As per my understanding there is test app is available in AOSP /hardware/libhardware/tests/nusensors folder.

Now I want to use this test App to check my sensor value via Sensor HAL.

but I am not sure how to do that.

Please suggest me how can i use this test app to raed my sensor value using sensor HAL.

Thanks & Regards,

Maneesh Singh

0 件の賞賛
返信
13 返答(返信)

2,687件の閲覧回数
Pritamsrisahoo_ss
Contributor II

@msingh1920 Have you completed the integration of DHT11 sensor on android source ?

if you have done it successfully then can you please guide me on integration of lsm6dsm sensor on android 11 source.

Thanks in advance.

0 件の賞賛
返信

2,720件の閲覧回数
Pritamsrisahoo_ss
Contributor II

@msingh1920 can You please help me out for the integration of lsm6dm integration on Android11 source .

 

0 件の賞賛
返信

5,212件の閲覧回数
felipe_lopez
Contributor I

I just guessing, but I assume that your sensor is defined on /vendor/nxp-opensource/imx/libsensors/sensors.cpp. I'm asking because you have to be sured that library is compiled, it generates the sensors.imx8.so file. There's a macro on Android.mk, located in the same folder, which has to be added on the BoardConfig.mk of your device. On it I add the following: BOARD_HAS_SENSOR := true. It was the only thing that I added, I compile the image and test-nusensors worked without a problem.

0 件の賞賛
返信

5,212件の閲覧回数
msingh1920
Contributor V

Hi Felipe,

Thanks for your reply.

As you suggested

1. I added BOARD_HAS_SENSOR := true in my Boardconfig.mk file.

2. After that I compiled the AOSP

3. but i still didn't see any sensors.imx8.so file under /out/target/product/evk_8mm/vendor/lib/hw/  directory

but when i try to run 'mm' cmd  in libsensors directory then i am getting following error -

maneesh:~/Android_AOSP_build_iMX8/vendor/nxp-opensource/imx/libsensors$ mm
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=9
TARGET_PRODUCT=evk_8mm
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=cortex-a53
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv7-a-neon
TARGET_2ND_CPU_VARIANT=cortex-a9
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-21-generic-x86_64-Ubuntu-16.04.6-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=2.0.0-ga-rc4
OUT_DIR=out
============================================
ninja: no work to do.
[1/1] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja
out/build-evk_8mm-vendor_nxp-opensource_imx_libsensors_Android.mk-cleanspec.ninja is missing, regenerating...
out/build-evk_8mm-vendor_nxp-opensource_imx_libsensors_Android.mk.ninja is missing, regenerating...
[ 99% 234/235] glob system/media/private/camera/include
ninja: error: unknown target 'MODULES-IN-vendor-nxp-opensource-imx-libsensors'
19:34:43 ninja failed with: exit status 1

#### failed to build some targets (07:59 (mm:ss)) ####

NOTE - >  I am using iMX8M Mini EVK and Android 9 version.

Thanks,

Maneesh

0 件の賞賛
返信

5,212件の閲覧回数
msingh1920
Contributor V

Hi,

In nusensor.cpp  /hardware/hardware.h header file is already included but still when i run the test-nusensors executable

it gives error.

I am following below steps -

1. build nusensor using mm command.

2. build AOSP using make command

3. flash the binaries into sdcard and boot the board

4. connect the iMX8 board to  adb

5. and run the executable -

    ./bin/test-nusensors


Is there any other files or variables i need to set ?

NOTE - I am using Android AOSP 9.0 (pie) and iMX8M Mini EVK.

Thanks & Regards,

Maneesh Singh

0 件の賞賛
返信

5,212件の閲覧回数
felipelopez
NXP Employee
NXP Employee

Hi, actually I run the steps that you wrote above and it didn't failed, the binary showed me all the sensors listed on sensors.cpp. 

Check if the Android.bp, which is on the same folder as nusensors.cpp is the same as the following:

cc_binary {
name: "test-nusensors",

srcs: ["nusensors.cpp"],

cflags: ["-Wall", "-Werror"],

shared_libs: [
"libcutils",
"libhardware",
],
}

The binary on the device is located at /system/bin/test-nusensors. Maybe the compiler outputs the binary on out/target/product/... and you have to copy it to the device, through adb.

0 件の賞賛
返信

5,212件の閲覧回数
msingh1920
Contributor V

Hi Felipe,

Thanks for your reply.

As I mentioned in my previous post i am following the same steps.

and i checked the Android.bp file with yous and it is same only.

But i think the issue is that test-nusensor is not able to find out the file for -> SENSORS_HARDWARE_MODULE_ID

when it calls function =>  hw_get_module(SENSORS_HARDWARE_MODULE_ID, (hw_module_t const**)&module);

As per the hardware/libhardware/hardware.c file it checks for .so files based on SENSORS_HARDWARE_MODULE_ID.

so it checks for .so file with below extension -

SENSORS_HARDWARE_MODULE_ID.default.so

or

  "ro.hardware", 
   "ro.product.board",
   "ro.board.platform",
   "ro.arch"

If nothing matches then it gives hw_get_module() failed (No such file or directory) error.

But my understanding is when i build AOSP then by default all the hal modules for sensors file should also get builds.

but i am not sure if i need to build any sensor hal modules separately.

In /out/target/product/evk8mm i can see many sensors.dynamic_sensors_hal.so  files but i am not sure if

test-nusensor is looking for these .so files. Please confirm.

Thanks,

Maneesh

0 件の賞賛
返信

5,212件の閲覧回数
felipe_lopez
Contributor I

Usually it look for sensors.imx8.so or something similar, could you confirm if your are compiling the libsensors directory where your sensor is declared? AOSP installs the shared library on out/target/product/<board>/vendor/lib/hw/

0 件の賞賛
返信

5,212件の閲覧回数
msingh1920
Contributor V

Hi Felipe Lopez,

Thanks for your reply.

I checked in my -

AOSP /out/target/product/evk_8mm/vendor/lib/hw/  directory.
i didn't find any sensors.imx8.so files.

In my directory for sensor only => sensors.dynamic_sensor_hal.so is available.

How can i generate => sensors.imx8.so files ?

AOSP Steps =>

1. I am downloading the AOSP for iMX8M Mini EVK and compiling it using make command.

2. After that I am compiling nusensor test app for sensor 

3. Then I am flashing everything on SDACRD and try to run the test-nusensor test app. 

Is there anything which i am missing ??

Thanks,

Maneesh

0 件の賞賛
返信

5,212件の閲覧回数
msingh1920
Contributor V

Hi,

Any suggestion or update over this ?

Thanks,

Maneesh

0 件の賞賛
返信

5,212件の閲覧回数
msingh1920
Contributor V

Hi ,

I am able to build nusensor but while running it i am facing issue -

I Followed these steps to build that nustensor module -

  • Run source build/envsetup.sh from the android root folder
  • Run lunch evk_8mm-userdebug 
  • Go to /hardware/libhardware/tests/nusensor folder and run mm
  • The executable should get generated and it will be present in out/target/product/evk_8mm/system/bin/ with the name test-nusensors
  • Build the AOSP using make and flash these output to SDCARD.
  • To run it use the command go to /system/bin/test-nusensors and execute it using -
    ./test-nusensor
  • But when ever i run this command i get error -> ./test-nusensors                                                
    hw_get_module() failed (No such file or directory)
  • Below is the PATH variable output for my board -
    echo $PATH
    /sbin:/system/sbin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin
  • NOTE : this hw_get_module() is given in hardware/hardware.h file.

    Please help me how can i test the sensor hal using nusensor or any other method.

    Thanks & Regards,
    Maneesh Singh
0 件の賞賛
返信

2,731件の閲覧回数
Pritamsrisahoo_ss
Contributor II

actually while running the tests-nusensors i am getting this.

4 sensors found:
Freescale 3-axis Accelerometer
vendor: Freescale Semiconductor Inc.
version: 1
handle: 0
type: 1
maxRange: 19.613300
resolution: 0.000599
power: 0.300000 mA
Freescale 3-axis Magnetic field sensor
vendor: Freescale Semiconductor Inc.
version: 1
handle: 1
type: 2
maxRange: 1500.000000
resolution: 0.050000
power: 0.500000 mA
Freescale Orientation sensor
vendor: Freescale Semiconductor Inc.
version: 1
handle: 2
type: 3
maxRange: 360.000000
resolution: 0.010000
power: 0.500000 mA
ISL29023 Light sensor
vendor: Intersil
version: 1
handle: 4
type: 5
maxRange: 16000.000000
resolution: 1.000000
power: 0.350000 mA
deactivate() for 'Freescale 3-axis Accelerometer'failed (Operation not permitted)

But i am getting the sensor values ..
can you please suggest me what to do for the integration of lsm6dsm sensor on Android11 source code.

thanks in advance.

0 件の賞賛
返信

2,686件の閲覧回数
Pritamsrisahoo_ss
Contributor II

@msingh1920 have you completed the integration of DHT11 sensor on your android source ?

if you have completed the integration and getting the sensor values through the application then i can you please help me on integration of lsm6dsm sensor on Android 11.

Hope for your reply.

Thanks in advance.

 

0 件の賞賛
返信