Firefly Open Source Community

Interface external MPU6050 gyro/accelerometer to I2C4 bus

54

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
54
Posted at 11/26/2017 22:50:23     
Last edited by dariuskrail In 11/26/2017 22:50 Editor

Hello all,

I am connecting a MPU6050 gyro/accelerometer breakout board to the Firefly-RK3399 board through the I2C4 SDA and SCL pins. I downloaded the AOSP source from Gitlab at https://gitlab.com/TeeFirefly/FireNow-Nougat.git. We are using Android 7.1.1 for our project. I modified the rk3399-firelfy.dts file to add support for the MPU6050 by adding the codes below.

&i2c4 {
        status = "okay";
        mpu6050:mpu@68 {
                status = "okay";
                compatible = "invensense,mpu6050";
                reg = <0x68>;
                mpu-int_config = <0x10>;
                mpu-level_shifter = <0>;
                mpu-orientation = <0 1 0 1 0 0 0 0 1>;
                orientation-x= <1>;
                orientation-y= <1>;
                orientation-z= <1>;
                /* Original is gpio1 4 (GPIO1 A4). Change to gpio 1 9 (GPIO 1 B1). */
                irq-gpio = <&gpio1 9 IRQ_TYPE_LEVEL_LOW>;
                mpu-debug = <1>;
        };
};


Next I recompiled the kernel, with the command "sudo ./FFTools/make.sh -k -j8" and "sudo ./FFTools/mkupdate/mkupdate.sh". A new rk3399-firelfy.dtb file is generated and the kernel is successfully built. Then I flashed the only the kernel, resource and boot image files (.img) to the board with the commands.

"sudo upgrade_tool di -b boot.img"
"sudo upgrade_tool di -k kernel.img"
"sudo upgrade_tool di resource resource.img"


After that we reset the board and Android boots up successfully. The MPU6050 is also successfully probed by the kernel as shown in the kernel logs with "dmesg" below.

[18:03:05][    0.773142] inv-mpu-iio 4-0068: int_config=0,level_shifter=0,client.addr=68,client.irq=6b
[18:03:05][    0.773874] inv-mpu-iio 4-0068: 0
[18:03:05][    0.773890] inv-mpu-iio 4-0068: -1
[18:03:05][    0.773899] inv-mpu-iio 4-0068: 0
[18:03:05][    0.773908] inv-mpu-iio 4-0068: -1
[18:03:05][    0.773916] inv-mpu-iio 4-0068: 0
[18:03:05][    0.773925] inv-mpu-iio 4-0068: 0
[18:03:05][    0.773934] inv-mpu-iio 4-0068: 0
[18:03:05][    0.773942] inv-mpu-iio 4-0068: 0
[18:03:05][    0.773950] inv-mpu-iio 4-0068: -1
[18:03:05][    0.773959] inv-mpu-iio 4-0068:
[18:03:05][    0.773968] inv_mpu_iio: secondary_i2c_addr=0
[18:03:05][    1.096795] inv-mpu-iio 4-0068: mpu6500 is ready to go!

[18:03:05][    1.096898] inv_mpu_iio: inv_mpu_init:744

Although the MPU6050 chip is detected in the kernel, the apps in Android is still unable to work with the MPU6050. There is no movement in the apps even when I move the MPU6050 breakout board around. Anything else do I need to do to setup the MPU6050 on I2C4 and GPIO1 B1 so that my Android apps can use the gyroscope and accelerometer?

Thank you!




Reply

Use props Report

54

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
54
Posted at 12/2/2017 02:31:32     
Bump. Any idea what other settings I need to check or change on the Linux kernel or Android source codes to enable the MPU6050?
Reply

Use props Report

You need to log in before you can reply Login | Register

This forum Credits Rules

Quick Reply Back to top Back to list