Add a kernel config fragment with a .cfg file in SRC_URI
Add kernel options to a Yocto kernel with a .cfg fragment listed in SRC_URI of a linux-yocto bbappend on Scarthgap, without replacing the defconfig.
A fragment is a small file of CONFIG_ lines that the kernel recipe merges into the configuration. It leaves the rest of the config alone, which is what you want when a layer must stay maintainable across kernel updates.
CONFIG_I2C_CHARDEV=y
CONFIG_SPI_SPIDEV=mFILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI += "file://i2c-spi.cfg"Save the first block as files/i2c-spi.cfg and the second as linux-yocto_%.bbappend in your layer. The kernel-yocto class notices the .cfg suffix on a SRC_URI entry and passes it to the merge step, so you do not write a patch.
bitbake -c menuconfig virtual/kernel
grep -E 'I2C_CHARDEV|SPI_SPIDEV' tmp/work/*/linux-yocto/*/build/.configCONFIG_I2C_CHARDEV=y
CONFIG_SPI_SPIDEV=mA fragment can only set what the final dependency resolution allows. If an option depends on something that is off, the line is silently dropped, and the next snippet shows how to catch that. See the Yocto kernel development manual.