4

I'm attempting to get the i2c bus to work from a raspberry pi image created from yocto. I have looked at other peoples solutions but they are all o do with raspbian or some other flavour of os.

My /boot/config.txt looks like this:

    root@raspberrypi2:~# cat /boot/config.txt 
    dtparam=i2c_arm=on
    dtparam=i2c_vc=on
    bcm2708.vc_i2c_override=1

lsmod gives me:

root@raspberrypi2:~# lsmod
    Not tainted
ipv6 340199 18 [permanent], Live 0x7f02c000
i2c_bcm2708 4932 0 - Live 0x7f027000
i2c_dev 5810 0 - Live 0x7f022000
bcm2835_gpiomem 2852 0 - Live 0x7f01e000
uio_pdrv_genirq 2924 0 - Live 0x7f012000
uio 8039 1 uio_pdrv_genirq, Live 0x7f000000

dmesg has the following in it:

root@raspberrypi2:~# cat /var/log/dmesg | grep i2c
[    3.645233] i2c /dev entries driver

looking in /proc/device-tree gives me:

root@raspberrypi2:~# find /proc/device-tree/ | grep i2c
/proc/device-tree/soc/i2c@7e205000
/proc/device-tree/soc/i2c@7e205000/reg
/proc/device-tree/soc/i2c@7e205000/name
/proc/device-tree/soc/i2c@7e205000/interrupts
/proc/device-tree/soc/i2c@7e205000/pinctrl-0
/proc/device-tree/soc/i2c@7e205000/compatible
/proc/device-tree/soc/i2c@7e205000/clock-frequency
/proc/device-tree/soc/i2c@7e205000/clocks
/proc/device-tree/soc/i2c@7e205000/status
/proc/device-tree/soc/i2c@7e205000/#address-cells
/proc/device-tree/soc/i2c@7e205000/phandle
/proc/device-tree/soc/i2c@7e205000/#size-cells
/proc/device-tree/soc/i2c@7e205000/pinctrl-names
/proc/device-tree/soc/i2c@7e205000/linux,phandle
/proc/device-tree/soc/i2c@7e804000
/proc/device-tree/soc/i2c@7e804000/reg
/proc/device-tree/soc/i2c@7e804000/name
/proc/device-tree/soc/i2c@7e804000/interrupts
/proc/device-tree/soc/i2c@7e804000/pinctrl-0
/proc/device-tree/soc/i2c@7e804000/compatible
/proc/device-tree/soc/i2c@7e804000/clock-frequency
/proc/device-tree/soc/i2c@7e804000/clocks
/proc/device-tree/soc/i2c@7e804000/status
/proc/device-tree/soc/i2c@7e804000/#address-cells
/proc/device-tree/soc/i2c@7e804000/phandle
/proc/device-tree/soc/i2c@7e804000/#size-cells
/proc/device-tree/soc/i2c@7e804000/pinctrl-names
/proc/device-tree/soc/i2c@7e804000/linux,phandle
/proc/device-tree/soc/i2c@7e805000
/proc/device-tree/soc/i2c@7e805000/reg
/proc/device-tree/soc/i2c@7e805000/name
/proc/device-tree/soc/i2c@7e805000/interrupts
/proc/device-tree/soc/i2c@7e805000/compatible
/proc/device-tree/soc/i2c@7e805000/clock-frequency
/proc/device-tree/soc/i2c@7e805000/clocks
/proc/device-tree/soc/i2c@7e805000/status
/proc/device-tree/soc/i2c@7e805000/#address-cells
/proc/device-tree/soc/i2c@7e805000/phandle
/proc/device-tree/soc/i2c@7e805000/#size-cells
/proc/device-tree/soc/i2c@7e805000/linux,phandle
/proc/device-tree/soc/gpio@7e200000/i2c0
/proc/device-tree/soc/gpio@7e200000/i2c0/name
/proc/device-tree/soc/gpio@7e200000/i2c0/phandle
/proc/device-tree/soc/gpio@7e200000/i2c0/brcm,function
/proc/device-tree/soc/gpio@7e200000/i2c0/brcm,pins
/proc/device-tree/soc/gpio@7e200000/i2c0/linux,phandle
/proc/device-tree/soc/gpio@7e200000/i2c1
/proc/device-tree/soc/gpio@7e200000/i2c1/name
/proc/device-tree/soc/gpio@7e200000/i2c1/phandle
/proc/device-tree/soc/gpio@7e200000/i2c1/brcm,function
/proc/device-tree/soc/gpio@7e200000/i2c1/brcm,pins
/proc/device-tree/soc/gpio@7e200000/i2c1/linux,phandle
/proc/device-tree/__symbols__/i2c
/proc/device-tree/__symbols__/i2c0
/proc/device-tree/__symbols__/i2c1
/proc/device-tree/__symbols__/i2c2
/proc/device-tree/__symbols__/i2c_arm
/proc/device-tree/__symbols__/i2c_vc
/proc/device-tree/__symbols__/i2c0_pins
/proc/device-tree/__symbols__/i2c1_pins
/proc/device-tree/__symbols__/clk_i2c
/proc/device-tree/aliases/i2c
/proc/device-tree/aliases/i2c0
/proc/device-tree/aliases/i2c1
/proc/device-tree/aliases/i2c2
/proc/device-tree/aliases/i2c_arm
/proc/device-tree/aliases/i2c_vc
/proc/device-tree/__overrides__/i2c
/proc/device-tree/__overrides__/i2c0
/proc/device-tree/__overrides__/i2c1
/proc/device-tree/__overrides__/i2c_arm
/proc/device-tree/__overrides__/i2c2_iknowwhatimdoing
/proc/device-tree/__overrides__/i2c0_baudrate
/proc/device-tree/__overrides__/i2c_vc_baudrate
/proc/device-tree/__overrides__/i2c_vc
/proc/device-tree/__overrides__/i2c1_baudrate
/proc/device-tree/__overrides__/i2c_baudrate
/proc/device-tree/__overrides__/i2c2_baudrate
/proc/device-tree/__overrides__/i2c_arm_baudrate

but if I 'ls /dev/i2*' I get no /dev/i2c devices. I'm expecting /dev/i2c-0 or an equivalent alias, does anyone know what is happening?

2 Answers 2

1

Device tree does not create the I2C devices (just to be contrary device tree does create the similar SPI devices).

Add the following line to /etc/modules and reboot.

i2c_dev

For a quick test you could just modprobe i2c_dev.


EDITED TO ADD

I'm confused now as your lsmod does show i2c_dev.

3
  • Yeah it's just not showing /dev/i2c I installed udev rules and it should show up but it doesn't I've triedeverything
    – Chris
    Commented May 12, 2016 at 18:05
  • @Chris Did you resolve the issue? If yes, please share.
    – Sandeep
    Commented Oct 2, 2017 at 0:40
  • No I didn't resolve this but it was a personal project so didn't end up finishing it. I'll get back to it at some stage and will write an answer when I get to solving it.
    – Chris
    Commented Jan 15, 2018 at 10:51
1

I had the same problem and think I just got it to work.

Set the following in local.conf (according to doc/extra-build-config.md)

ENABLE_I2C = "1"
KERNEL_MODULE_AUTOLOAD_rpi += " i2c-dev i2c-bcm2708"

This will append the following to config.txt (in the build path, eg tmp/deploy/images//bootfiles):

# Enable I2C
dtparam=i2c1=on
dtparam=i2c_arm=on

Also, it will put the modules to load at boot:

root@raspberrypi2:/etc/modules-load.d# ls
i2c-bcm2708.conf  i2c-dev.conf

Test with i2cdetect shows:

root@raspberrypi2:~# i2cdetect -l
i2c-1   i2c             bcm2835 (i2c@7e804000)                  I2C adapter
1
  • Thank you for your response. I just would like to add that with a new Yocto variable you need to write as KERNEL_MODULE_AUTOLOAD:rpi .
    – caglar
    Commented Nov 7, 2022 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.