Re: [android-porting] Sensor porting HAL

1,057 views
Skip to first unread message

Ramya Mohan

unread,
May 29, 2013, 6:29:18 AM5/29/13
to jkma...@gmail.com, android-porting
Hi,

sensors.<board>.so - should be compiled & copied to system/lib/hw of the android file system.
The *.so build - should contain a struct defining that it s a SENSOR_MODULE.. 

Say :

sensors.c file 

struct sensors_module_t HAL_MODULE_INFO_SYM = {
        common: {
                tag: HARDWARE_MODULE_TAG,
                version_major: 1,
                version_minor: 0,
                id: SENSORS_HARDWARE_MODULE_ID,
                name: " Sensor module",
                author: "xxx Inc.",
                methods: &sensors_module_methods,
        },
        get_sensors_list: sensors__get_sensors_list,
};





With care
Ramya


On Wed, May 29, 2013 at 10:00 AM, 마재경 <jkma...@gmail.com> wrote:

Hi,


I'm a beginner android user, I ported accelerometer sensor named "BMA250E" and Board don't use MPU, MPL.


Only use accelerometer. On the kernel, sensor act well. when i programmed HAL code. and library file(XXX.so)


was downloaded on the target board. But, sensor was not recognized in app layer.


Should i more programmed for using it?


Please give me some advice about that.


Best Regards.

--
--
unsubscribe: android-porti...@googlegroups.com
website: http://groups.google.com/group/android-porting
 
---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-porti...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ramya Mohan

unread,
Jun 4, 2013, 5:44:43 AM6/4/13
to 마재경, android-porting
Hi,

Yes, it mostly looks for that kind of name.. 

If we want it in different name, there will be some other place in frameworks/hardware layer should be modified accordingly..
I am not sure about it.

With care
Ramya


On Fri, May 31, 2013 at 6:10 AM, 마재경 <jkma...@gmail.com> wrote:
Thanks for your advice.
 
I add code about that. I have one question, Only name "sensors.(TARGET_BOARD).so" file is supported as sensor?
 
other names are not?
 
Thanks.

2013년 5월 29일 수요일 오후 1시 30분 54초 UTC+9, 마재경 님의 말:

ffxx68

unread,
Jun 12, 2013, 8:43:31 AM6/12/13
to android...@googlegroups.com
Hi,

I have ported the BMA220 accelerometer too, as part of this JB porting project:

 https://groups.google.com/forum/?fromgroups=#!forum/renesas-emev-osp

our sensor HAL source code is here:

 https://github.com/Renesas-EMEV2/Renesas-device_emev/tree/emev-4.1/sensors

All seems working "well", and a "dumpsys sensorservice" reports the following:

root@android:/ # dumpsys sensorservice                                        
Sensor List:
BMA220 3-axis Accelerometer                     | Bosch                            | 0x00000000 | maxRate=   0.00Hz | last=< -1.0, -2.0, 16.0>
9-axis fusion disabled (0 clients), gyro-rate=   0.00Hz, q=< 0, 0, 0, 0 > (0), b=< 0, 0, 0 >
1 h/w sensors:
handle=0x00000000, active-count=0, rates(ms)={  }, selected=66.7 ms
0 active connections
Active sensors:


with the "last" value changing when moving device. Values are -16...+16 and above one is for the device laying on a flat surface.

issue is that screen orientation doesn't change on device rotation... Of course, the "auto-rotate screen" flag in display setting is set.

I also have included this file in my build:

 system/etc/permissions/android.hardware.sensor.accelerometer.xml

as well as this flag, in frameworks/base/core/res/res/values/config.sys:

    <!-- If true, the screen can be rotated via the accelerometer in all 4
         rotations as the default behavior. -->
    <bool name="config_allowAllRotations">true</bool>

I wonder if I could still be missing anything else and how to debug such missing screen rotation.

thanks
Fabio

ffxx68

unread,
Jun 14, 2013, 9:19:16 AM6/14/13
to android...@googlegroups.com
Nothing was really missing, apart from "calibration".

Since parameters for low-pass filtering (to extract gravity; hardcoded in AOSP in WindowOrientationListener.java) are based on real m/s^2 acceleration values, having sensor returning values too far from reality made some check functions reject rotations. I had to add my conversion, with these changes in HAL:

 https://github.com/Renesas-EMEV2/Renesas-device_emev/commit/7cb1a28f4baa0cb744f1124aecade3477da87c67

Indeed, after fixing calibration, rotation is correctly propagated when I rotate device. This is for example what I get when tabelt is front.facing, in portrait orientation:

V/WindowOrientationListener(  258): Raw acceleration vector: x=-7.967903, y=1.2258313, z=5.5162406, magnitude=9.768268
V/WindowOrientationListener(  258): Filtered acceleration vector: x=-7.772365, y=1.587711, z=5.426243, magnitude=9.611171
V/WindowOrientationListener(  258): Predicted: tiltAngle=34, orientationAngle=282, predictedRotation=3, predictedRotationAgeMS=349.939
V/WindowOrientationListener(  258): Result: currentRotation=0, proposedRotation=3, predictedRotation=3, timeDeltaMS=139.97, isAccelerating=false, isFlat=false, isSwinging=false, timeUntilSettledMS=0.0, timeUntilAccelerationDelayExpiredMS=0.0, timeUntilFlatDelayExpiredMS=0.0, timeUntilSwingDelayExpiredMS=0.0


Note the magnitute of about 9.8 m/s^2, which is closer to real "g", than without calibration. Magnitute was around 16 before and I was getting a lot of "proposedRotation=-1".

NOTE - Home launcher screen is never re-oriented. Not sure why... But other screens (e.g. Systems Settings, do get re-oriented).

Andrew Jones

unread,
Apr 16, 2014, 6:50:47 AM4/16/14
to android...@googlegroups.com
Hi everyone,

I'm suffering from the exact same problem as the OP.  I ported the MMA7660 accelerometer into the sensors HAL for Android 4.3.
If I do a dumpsys sensorservice my readings look reasonable:

Sensor List:
Freescale 3-axis Accelerometer                  | Freescale Semiconductor Inc.     | 0x00000000 | maxRate=  50.00Hz | last=< -1.7, 16.7,  1.1>
CM3232 Light sensor                             | Capella                          | 0x00000004 | maxRate=2000.00Hz | last=<  0.0,  0.0,  0.0>
9-axis fusion disabled (0 clients), gyro-rate=   0.00Hz, q=< 0, 0, 0, 0 > (0), b=< 0, 0, 0 >
2 h/w sensors:
handle=0x00000000, active-count=0, rates(ms)={  }, selected=200.0 ms
handle=0x00000004, active-count=0, rates(ms)={  }, selected= 0.0 ms
0 active connections
Active sensors:

But If I use any app for showing the accelerometer readings, none of them work.  They just show all zeros.
Any suggestions, any at all, would be appreciated so much!

Thankyou!
Andrew

Andrew Jones

unread,
Apr 17, 2014, 2:15:21 AM4/17/14
to android...@googlegroups.com
Hi,

Just an update.  I have calibrated the accelerometer so that when I do dumpsys sensorservice it shows pretty much the same readings as my Samsung S3 when it's flat on a table, standing upright, on its side, etc, etc.

Screen rotate will not work though.  It just flips 90 degrees once after booting, and that's it.  That might be an indication that screen rotation is alive but getting bad readings?

Any suggestions?  Thanks so much!
Andrew
Reply all
Reply to author
Forward
0 new messages