Enable I2C on Raspberry Pi in Yocto with ENABLE_I2C
Turn on the Raspberry Pi I2C bus in a Yocto Scarthgap image with ENABLE_I2C in local.conf, which writes the dtparam line for you.
The Raspberry Pi firmware leaves I2C off until config.txt asks for it. With meta-raspberrypi you do not edit that file, you set a variable and the recipe writes the line.
ENABLE_I2C = "1"
KERNEL_MODULE_AUTOLOAD:rpi += "i2c-dev i2c-bcm2708"Put both lines in conf/local.conf of a Yocto 5.0 (Scarthgap) build. ENABLE_I2C adds dtparam=i2c_arm=on to the generated config.txt, and the second line loads i2c-dev, which creates the /dev/i2c-* nodes that i2cdetect uses. Without it the bus exists but has no character device.
grep i2c /boot/config.txt
ls /dev/i2c-*dtparam=i2c_arm=on
/dev/i2c-1The bus number is 1 on the 40-pin header of recent boards. The variable name is documented in the meta-raspberrypi layer docs. It only edits config.txt, so a change of kernel configuration or overlay is still separate. Also install i2c-tools to get i2cdetect, which is not in a minimal image.