On Wednesday, October 16, 2013 at 1:02:59 AM UTC+3, [email protected] 
wrote:
>
> We are using the Invensense MPU6050 IMU on I2C with Beaglebone Black 
> (Angstrom 3.8.13). We can use I2C-tools and file I/O thru /dev/i2c but the 
> read speed is disappointingly slow.  We only read the 3x gyros and 3x 
> accels (each one byte at a time plus the 2 byte temperature reading) and it 
> takes ~2msecs.  My estimate of the I2C bus cycles for a block read 
> suggests this should take ~160 bus cycles or .38msec on a 400MHz I2C bus. 
>
> The distribution includes the Invensense driver inv-mpu6050.ko but there 
> is no indication that reading through /dev/i2c invokes it.  This is a 
> very popular IMU and Invensense widely distributes the driver over many 
> Linux platforms.  The driver source includes “successful installation 
> will create two directories under /sys/bus/iio/devices” and lists the files 
> there (aka functions). I can never get these to show up.
>
> I can “insmod 
> /lib/modules/3.8.13/kernel/drivers/iio/imu/inv_mpu6050/inv-mpu6050.ko” and 
> “echo inv-mpu6050 0x68 > /sys/class/i2c-adapter/i2c-1/new_device”. This 
> causes a new directory named 1-0068 to show in 
> /sys/class/i2c-adapter/i2c-1with entries like name and modalias but no 
> functions.  It never shows in /sys/bus/iio/devices.
>
> What constitutes “successful installation”?  
>
> What else is needed to get the inv-mpu6050 to expose functions in 
> /sys/bus/iio/devices like the driver sources says?
>
> Beaglebone Black uses bone_capemgr for exposing driver functions for many 
> devices.  “echo inv-mpu6050 0x68 > /sys/devices/bone_capmgr.9/slots” 
> raises the gripe “write error: no such file or directory”.  (I can 
> successfully load the am33xx_pwm driver this way.) Is this because there is 
> no matching DT fragment in /lib/firmware? Is the inv-mpu6050 driver 
> supposed to be invoked thru cape manager?
> Then, most importantly, if I did read and write through the /sys tree 
> using the Invensense driver would it be faster than /dev/i2c?
> Help on sorting this out would be much appreciated.
>
 
Hello!
I know this is an old topic and so and I'm just passing by. I also wanted 
to use MPU-6050 with its IIO driver, albeit on UDOO board, not a Beagle.
Indeed, I also found out that just using modprobe to load inv-mpu6050 doesn't 
work. Why? Because it cannot know which I²C bus to use and which GPIO is 
the interrupt pin connected to.

Through a bit of perseverance I found out this is doable by declaring the 
device in the device tree files (arch/arm/boot/dts/), somewhat like this:
&i2c1 {
    accelerometer: imu@69 { // Name not really important, but it should be 
descriptive (as in human-readable)
        compatible = "invensense,mpu6050";      // This declares what 
driver you're attaching
        reg = <0x69>;                           // I2C address (0x69 in my 
case)
        interrupt-parent = <&gpio5>;
        interrupts = <22 IRQ_TYPE_EDGE_RISING>;
    };
};
where:
&i2c1 refers to the I²C bus declaration, you should look up the relevant 
bus and its alias designation in BeagleBone Black .dts/.dtsi files (caveat: 
the suffix number *does not* necessarily coincide with the /dev/i2c-x 
number);
interrupt-parent and interrupts *must* be correct if you're going to use 
FIFO aided (streaming) data reading, their meaning however is 
board-specific.
In my case, <&gpio5> means fifth GPIO block and 22 is the pin number within 
that block. IRQ_TYPE_EDGE_RISING (which is a constant 1) declares that 
interrupt is triggered on rising edge.
Also, be careful to use angle brackets ('<' and '>') as shown, as they have 
important semantic meaning in device tree syntax.

Once adapted for your case, compile the device tree (make dtbs under Linux 
source tree) and copy over the relevant .dtb file where your bootloader 
expects it (/boot/dts/ most likely).

I found the device tree binding information at 
https://kernel.googlesource.com/pub/scm/linux/kernel/git/rzhang/linux/+/release/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt

I hope this is useful for you or anyone who stumbles on this topic (as I 
did). Cheers!

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/d25780da-1d14-42c2-a718-5a7991845462%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to