How to separate camera.cfg of kernel bbappend file into two conditions? 10/3 Yocto Build Issues AMA

From @MayQueen Technologies: In the camera.cfg of kernel bbappend file, is there a way to separate two conditions where only camera customers need to add this cfg or not? Should I add a new DISTRO variable? @Ming
1 Reply
Ming
Ming4w ago
The dfirst thing is to make use of Configuration Fragments. These are files ending in .cfg that contain fragments of configuration for things like the Kernel. The configuration fragment will be applied to the configuration after the main .config file has been applied. e.g. to enable USB Cameras, you can create a cameras.cfg file containing:
CONFIG_MEDIA_CAMERA_SUPPORT=y
CONFIG_VIDEO_V4L2_SUBDEV_API=y
ONFIG_V4L2_FWNODE=y
CONFIG_V4L2_ASYNC=y
CONFIG_MEDIA_USB_SUPPORT=y
CONFIG_USB_VIDEO_CLASS=y
CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
CONFIG_MEDIA_CAMERA_SUPPORT=y
CONFIG_VIDEO_V4L2_SUBDEV_API=y
ONFIG_V4L2_FWNODE=y
CONFIG_V4L2_ASYNC=y
CONFIG_MEDIA_USB_SUPPORT=y
CONFIG_USB_VIDEO_CLASS=y
CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
Then, you will need an append file in your layer, e.g. layers/project/meta-my_bsp/recipes-kernel/linux-yocto/linux-yocto_%.bbappend containing
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"

SRC_URI:append= " file://cameras.cfg"
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"

SRC_URI:append= " file://cameras.cfg"
Then put the cameras.cfg in layers/project/meta-my_bsp/recipes-kernel/linux-yocto/linux-yocto/cameras.cfg This will get applied to all machines. If you now have two machines defined, say, my-eye that has a camera and my-blind , then to configure it so that only my-eye picks up the camera configuration, you can change the append file to make use of conditional overrides. This makes use of the OVERRIDES variable, which by default contains the Architecture, the OS and the Machine name. The format of an override is VARIABLE:append:override So, to only have my-eye pick up the camera configuration, the value of SRC_URI needs to be SRC_URI:append:my-eye = " file://cameras.cfg" This way the camera.cfg would only get picked up if the machine my-eye is used.
Want results from more Discord servers?
Add your server