Screen Auto-Rotation Issue When Porting ICM-20948 Sensor on Android 11

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

Screen Auto-Rotation Issue When Porting ICM-20948 Sensor on Android 11

ソリューションへジャンプ
2,912件の閲覧回数
hank2024
Contributor II

Hi,

I'd like to seek assistance regarding a screen auto-rotation issue I encountered while attempting to port the ICM-20948 IMU sensor on Android 11.

Hardware and Software Details:

  • CPU: i.MX8MQ
  • Operating System: Android 11
  • IMU Sensor: ICM-20948

Description of the Issue: I've been working on adding support for the ICM-20948 IMU sensor in Android to enable screen auto-rotation. However, I've encountered a problem where the screen rotation is consistently off by 90 degrees.

1697103680532.jpg    1697103598408.jpg

Any assistance or guidance on resolving this issue would be greatly appreciated. If there are any specific areas of concern or details required, please let me know. Thank you in advance for your help.

References:

https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/Porting-MPU6050-on-Android-to-realize-au...

https://community.nxp.com/t5/i-MX-Processors/Android-10-i-MX8MMini-g2d-rotation-issue/m-p/1051924

 

0 件の賞賛
返信
1 解決策
2,604件の閲覧回数
hank2024
Contributor II

The problem has already been solved, and it is recorded here that you need to modify the Android HAL layer yourself and adjust the IMU direction.

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
2,605件の閲覧回数
hank2024
Contributor II

The problem has already been solved, and it is recorded here that you need to modify the Android HAL layer yourself and adjust the IMU direction.

0 件の賞賛
返信
2,887件の閲覧回数
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello,

You have to port the IMU driver to your android since kernel is not detected.

Regards

0 件の賞賛
返信
2,877件の閲覧回数
hank2024
Contributor II

Thanks, 

@Bio_TICFSL  I believe the ICM2048 driver has already been loaded and is running. You can see the following information by entering it in the Android terminal

130|evk_8mq:/ # dumpsys senzsorservice
Captured at: 07:19:11.364
Sensor Device:
Total 4 h/w sensors, 4 running 0 disabled clients:
0x00000002) active-count = 1; sampling_period(ms) = {66.7}, selected = 66.67 ms; batching_period(ms) = {100.0}, selected = 100.00 ms
Sensor List:
0x00000001) icm20948                z  | nxp             | ver: 1 | type: android.sensor.gyroscope(4) | perm: n/a | flags: 0x00000050
        continuous | minRate=5.00Hz | maxRate=12195.12Hz | FIFO (max,reserved) = (100, 0) events | non-wakeUp | data-injection, has-additional-info,
0x00000002) icm20948                  | nxp             | ver: 1 | type: android.sensor.accelerometer(1) | perm: n/a | flags: 0x00000010
        continuous | minRate=5.00Hz | maxRate=1209.19Hz | FIFO (max,reserved) = (100, 0) events | non-wakeUp | data-injection,
0x00000003) icm20948                  | nxp             | ver: 1 | type: android.sensor.magnetic_field(2) | perm: n/a | flags: 0x00000010
        continuous | maxDelay=0us | minDelay=-1us | FIFO (max,reserved) = (100, 0) events | non-wakeUp | data-injection,
0x00000004) opt3001                   | nxp             | ver: 1 | type: android.sensor.light(5) | perm: n/a | flags: 0x00000012
        on-change | minRate=10.00Hz | maxRate=1.25Hz | FIFO (max,reserved) = (100, 0) events | non-wakeUp | data-injection,
0x5f636779) Corrected Gyroscope Sensor | AOSP            | ver: 1 | type: android.sensor.gyroscope(4) | perm: n/a | flags: 0x00000000
        continuous | maxDelay=0us | maxRate=12195.12Hz | no batching | non-wakeUp |
0x5f676172) Game Rotation Vector Sensor | AOSP            | ver: 3 | type: android.sensor.game_rotation_vector(15) | perm: n/a | flags: 0x00000000
        continuous | maxDelay=0us | maxRate=1209.19Hz | no batching | non-wakeUp |
0x5f676273) Gyroscope Bias (debug)    | AOSP            | ver: 1 | type: android.sensor.accelerometer(1) | perm: n/a | flags: 0x00000000
        continuous | maxDelay=0us | maxRate=1209.19Hz | no batching | non-wakeUp |
0x5f67656f) GeoMag Rotation Vector Sensor | AOSP            | ver: 3 | type: android.sensor.geomagnetic_rotation_vector(20) | perm: n/a | flags: 0x00000000
        continuous | maxDelay=0us | maxRate=1209.19Hz | no batching | non-wakeUp |
0x5f677276) Gravity Sensor            | AOSP            | ver: 3 | type: android.sensor.gravity(9) | perm: n/a | flags: 0x00000000
        continuous | maxDelay=0us | maxRate=1209.19Hz | no batching | non-wakeUp |
0x5f6c696e) Linear Acceleration Sensor | AOSP            | ver: 3 | type: android.sensor.linear_acceleration(10) | perm: n/a | flags: 0x00000000
        continuous | maxDelay=0us | maxRate=1209.19Hz | no batching | non-wakeUp |
0x5f726f76) Rotation Vector Sensor    | AOSP            | ver: 3 | type: android.sensor.rotation_vector(11) | perm: n/a | flags: 0x00000000
        continuous | maxDelay=0us | maxRate=1209.19Hz | no batching | non-wakeUp |
0x5f797072) Orientation Sensor        | AOSP            | ver: 1 | type: android.sensor.orientation(3) | perm: n/a | flags: 0x00000000
        continuous | maxDelay=0us | maxRate=1209.19Hz | no batching | non-wakeUp |
Fusion States:
9-axis fusion disabled (0 clients), gyro-rate= 200.00Hz, q=< 0, 0, 0, 0 > (0), b=< 0, 0, 0 >
game fusion(no mag) disabled (0 clients), gyro-rate= 200.00Hz, q=< 0, 0, 0, 0 > (0), b=< 0, 0, 0 >
geomag fusion (no gyro) disabled (0 clients), gyro-rate= 200.00Hz, q=< 0, 0, 0, 0 > (0), b=< 0, 0, 0 >
Recent Sensor events:
icm20948: last 50 events
         1 (ts=164.197915226, wall=07:19:09.580) -0.10, 0.34, 10.23,
         2 (ts=164.233717707, wall=07:19:09.616) -0.11, 0.32, 10.24,
         3 (ts=164.269666349, wall=07:19:09.652) -0.09, 0.37, 10.18,
         4 (ts=164.305628430, wall=07:19:09.688) -0.06, 0.36, 10.18,
         5 (ts=164.341558952, wall=07:19:09.724) -0.08, 0.34, 10.21,
         6 (ts=164.377450473, wall=07:19:09.760) -0.10, 0.34, 10.18,
         7 (ts=164.413300474, wall=07:19:09.796) -0.05, 0.38, 10.12,
         8 (ts=164.449162836, wall=07:19:09.832) -0.08, 0.26, 10.18,
         9 (ts=164.484990637, wall=07:19:09.867) -0.14, 0.40, 10.16,
        10 (ts=164.520888279, wall=07:19:09.903) -0.08, 0.32, 10.14,
        11 (ts=164.556830200, wall=07:19:09.939) -0.14, 0.31, 10.17,
        12 (ts=164.592663642, wall=07:19:09.975) -0.21, 0.32, 10.13,
        13 (ts=164.628550363, wall=07:19:10.011) -0.13, 0.37, 10.11,
        14 (ts=164.664386205, wall=07:19:10.047) -0.16, 0.29, 10.31,
        15 (ts=164.700226486, wall=07:19:10.083) -0.08, 0.27, 10.19,
        16 (ts=164.736121487, wall=07:19:10.119) -0.13, 0.32, 10.17,
        17 (ts=164.771977249, wall=07:19:10.154) -0.11, 0.36, 10.25,
        18 (ts=164.807675090, wall=07:19:10.190) -0.16, 0.32, 10.17,
        19 (ts=164.843559172, wall=07:19:10.226) -0.02, 0.41, 9.99,
        20 (ts=164.879316413, wall=07:19:10.262) -0.09, 0.35, 10.14,
        21 (ts=164.915070775, wall=07:19:10.297) -0.14, 0.27, 10.22,
        22 (ts=164.950877096, wall=07:19:10.333) -0.14, 0.43, 10.13,
        23 (ts=164.986675018, wall=07:19:10.369) -0.10, 0.32, 10.36,
        24 (ts=165.022657019, wall=07:19:10.405) -0.05, 0.34, 10.32,
        25 (ts=165.058468860, wall=07:19:10.441) -0.12, 0.29, 10.14,
        26 (ts=165.094219382, wall=07:19:10.477) -0.06, 0.37, 10.13,
        27 (ts=165.129978543, wall=07:19:10.512) -0.10, 0.39, 10.24,
        28 (ts=165.165803945, wall=07:19:10.548) -0.09, 0.35, 10.24,
        29 (ts=165.201513906, wall=07:19:10.584) -0.12, 0.32, 10.19,
        30 (ts=165.237281708, wall=07:19:10.620) -0.05, 0.36, 10.09,
        31 (ts=165.272960109, wall=07:19:10.655) -0.10, 0.31, 10.23,
        32 (ts=165.308887511, wall=07:19:10.691) -0.11, 0.34, 10.16,
        33 (ts=165.344873472, wall=07:19:10.727) -0.12, 0.38, 10.17,
        34 (ts=165.380659393, wall=07:19:10.763) -0.09, 0.36, 10.10,
        35 (ts=165.416434395, wall=07:19:10.799) -0.13, 0.35, 10.19,
        36 (ts=165.452194276, wall=07:19:10.835) -0.06, 0.33, 10.16,
        37 (ts=165.487941798, wall=07:19:10.870) -0.10, 0.36, 10.15,
        38 (ts=165.523702879, wall=07:19:10.906) -0.12, 0.28, 10.20,
        39 (ts=165.559502241, wall=07:19:10.942) -0.14, 0.35, 10.07,
        40 (ts=165.595351762, wall=07:19:10.978) -0.10, 0.35, 10.20,
        41 (ts=165.631182203, wall=07:19:11.014) -0.06, 0.31, 10.21,
        42 (ts=165.666988765, wall=07:19:11.049) -0.07, 0.35, 10.17,
        43 (ts=165.702813686, wall=07:19:11.085) -0.12, 0.30, 10.15,
        44 (ts=165.738647728, wall=07:19:11.121) -0.10, 0.34, 10.17,
        45 (ts=165.774543569, wall=07:19:11.157) -0.10, 0.36, 10.12,
        46 (ts=165.810368611, wall=07:19:11.193) -0.10, 0.33, 10.23,
        47 (ts=165.846284972, wall=07:19:11.229) -0.14, 0.34, 10.14,
        48 (ts=165.882086854, wall=07:19:11.265) -0.11, 0.33, 10.22,
        49 (ts=165.918105575, wall=07:19:11.301) -0.07, 0.32, 10.16,
        50 (ts=165.954057096, wall=07:19:11.336) -0.14, 0.43, 9.99,
Active sensors:
icm20948 (handle=0x00000002, connections=1)
Socket Buffer size = 984 events
WakeLock Status: not held
Mode : NORMAL
Sensor Privacy: disabled
1 active connections
Connection Number: 0
        Operating Mode: NORMAL
         com.android.server.policy.WindowOrientationListener | WakeLockRefCount 0 | uid 1000 | cache size 0 | max cache size 0
         icm20948 0x00000002 | status: active | pending flush events 0
0 direct connections
Previous Registrations:
07:16:57 + 0x00000002 pid=  556 uid= 1000 package=com.android.server.policy.WindowOrientationListener samplingPeriod=66667us batchingPeriod=100000us
evk_8mq:/ #
evk_8mq:/ # cat /sys/bus/iio/devices/iio\:device1/in_accel_x_raw
-88
evk_8mq:/ # cat /sys/bus/iio/devices/iio\:device1/in_accel_y_raw
468
evk_8mq:/ # cat /sys/bus/iio/devices/iio\:device1/in_accel_z_raw
16904
 
The main issue is that when rotating the screen, it rotates an extra 90 degrees counterclockwise.
0 件の賞賛
返信