Search code examples
linux-device-driverraspberry-pi3yoctoiio

How to include MPU6050 driver into Yocto image from kernel-space?


I am stuck on trying to include the MPU6050 driver into Yocto. I am using a Raspberry Pi 3, and I am on the kirkstone branch. I've done the following steps to include the MPU6050 driver:

  1. Include a fragmentation file for the MPU6050 under /meta-raspberrypi/recipes-kernel/linux/files/
CONFIG_INV_MPU6050_IIO=m
CONFIG_INV_MPU6050_I2C=m
  1. Create a bbappend file under /meta-raspberrypi/recipes-kernel/
SRC_URI += "file://fragment.cfg;subdir=git"
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
  1. Rebuild the image and flash

Then after finding the driver name, I successfully call modprobe on it. I see the driver under lsmod, but I am also expecting to see files under /sys/bus/iio/devices and I do not. Is this what I should be expecting, or what is the next step?

I'm quite new to Yocto and Linux in general, so I may be severely overlooking something.


Solution

  • So there were a couple things I missed:

    1. Adding the device tree overlay file. I added this in local.conf.
    ENABLE_I2C = "1"
    KERNEL_DEVICETREE:append = " overlays/mpu6050.dtbo"
    RPI_EXTRA_CONFIG = '\ndtoverlay=mpu6050\n'
    
    1. Configuring IIO in menuconfig tool and creating a fragment file mpu-6050.cfg
    CONFIG_IIO=y
    CONFIG_IIO_BUFFER=y
    CONFIG_IIO_BUFFER_CB=y
    CONFIG_IIO_BUFFER_DMA=y
    CONFIG_IIO_BUFFER_DMAENGINE=y
    CONFIG_IIO_BUFFER_HW_CONSUMER=y
    CONFIG_IIO_KFIFO_BUF=y
    CONFIG_IIO_TRIGGERED_BUFFER=y
    CONFIG_IIO_CONFIGFS=y
    CONFIG_IIO_TRIGGER=y
    CONFIG_IIO_CONSUMERS_PER_TRIGGER=2
    CONFIG_IIO_SW_DEVICE=y
    CONFIG_IIO_SW_TRIGGER=y
    CONFIG_IIO_TRIGGERED_EVENT=y
    
    CONFIG_INV_MPU6050_IIO=y
    CONFIG_INV_MPU6050_I2C=y
    
    CONFIG_IIO_HRTIMER_TRIGGER=y
    CONFIG_IIO_INTERRUPT_TRIGGER=y
    CONFIG_IIO_TIGHTLOOP_TRIGGER=y
    CONFIG_IIO_SYSFS_TRIGGER=y
    
    1. Adding a linux-raspberrypi_5.15.bbappend file in my own layer
    FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
    SRC_URI += "file://mpu-6050.cfg"