Yocto Kernel Configuration Management with Git Patches
This guide provides a comprehensive workflow for creating and modifying kernel configuration in Yocto using proper git-based patching for linux-variscite (which is based on linux-freescale). This approach ensures maintainable, version-controlled kernel configuration changes that integrate cleanly with your Yocto build system and can be applied with git am.
Overview
When working with Yocto and linux-variscite kernel configuration, you need a proper workflow that:
- ✅ Uses the correct kernel source (linux-variscite, not linux-imx)
- ✅ Follows proper kernel configuration steps (
make olddefconfig→make menuconfig) - ✅ Creates git patches compatible with
git am - ✅ Integrates with bbappend files cleanly
- ✅ Maintains version control and attribution
Prerequisites
Required Tools and Environment
# Ensure you have git configured
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
# Yocto build environment
source oe-init-build-env
# Required packages for kernel configuration
sudo apt-get install libncurses5-dev libssl-dev bc flex bisonUnderstanding Your linux-variscite Setup
First, identify your kernel source and version:
# In your Yocto build directory
bitbake -e linux-variscite | grep "^S="
# Output: S="/path/to/tmp/work/imx8mp_var_som-poky-linux/linux-variscite/5.15.71+gitAUTOINC+hash/git"
# Check kernel version and branch
bitbake -e linux-variscite | grep "^PV="
# Output: PV="5.15.71+gitAUTOINC+hash"
bitbake -e linux-variscite | grep "SRCBRANCH"
# Output: SRCBRANCH="lf-5.15.y_var01"Working with Yocto Devshell (Recommended Approach)
Recommended: Use bitbake -c devshell virtual/kernel for kernel configuration work. This puts you in the proper build environment with all variables set correctly.
Yocto Devshell Environment
# Start kernel devshell (this is your starting point)
bitbake -c devshell virtual/kernel
# In the devshell, you're in the build directory where:
# - All environment variables are set correctly (ARCH, CROSS_COMPILE, etc.)
# - The .config file is present
# - make savedefconfig will create defconfig in current directory
# - Source files are available via $S variableUnderstanding Devshell Environment Variables
# In devshell, check important variables:
echo "Current directory: $PWD"
echo "Architecture: $ARCH"
echo "Cross compiler: $CROSS_COMPILE"
# Actual output based on your environment:
# Current directory: /workdir/tmp/work-shared/imx8mp-var-som-mlx75027/kernel-source (SOURCE directory)
# Architecture: arm64
# Cross compiler: aarch64-poky-linux-
# IMPORTANT: You're in the SOURCE directory, but make commands use BUILD directory
# Build directory: /workdir/tmp/work/imx8mp_var_som_mlx75027-poky-linux/linux-variscite/5.15.60+gitAUTOINC+740e6c7a7b-r2/buildMethod 1: Using Yocto Devshell (Recommended)
This is your starting point: bitbake -c devshell virtual/kernel
Step 1: Start Devshell
# Start kernel devshell (your starting point)
bitbake -c devshell virtual/kernel
# You're now in the build directory with all environment variables set
# Check your environment:
echo "Current directory: $PWD"
echo "Source directory: $S"
echo "Architecture: $ARCH"
echo "Cross compiler: $CROSS_COMPILE"Step 2: Configure Kernel in Devshell
# In devshell, you can directly configure the kernel
# The .config file is already present
# IMPORTANT: Always run olddefconfig first!
make olddefconfig
# Now run interactive configuration
make menuconfig
# Navigate to your ToF camera options:
# Device Drivers --->
# Multimedia support --->
# Media drivers --->
# [*] Media Controller API
# [*] V4L2 sub-device userspace API
# Camera sensor devices --->
# <M> MLX75027 ToF sensor support
# Save and exit (S, then Q)Step 3: Generate defconfig and Compare with Your Yocto Layer
# In devshell, generate the minimal defconfig
make savedefconfig
# IMPORTANT: You're in the SOURCE directory, but defconfig is created in BUILD directory
# The make output shows the build directory path:
# make[1]: Entering directory '/workdir/tmp/work/imx8mp_var_som_mlx75027-poky-linux/linux-variscite/5.15.60+gitAUTOINC+hash-r2/build'
# Find the build directory from the make output or use this pattern:
BUILD_DIR="/workdir/tmp/work/imx8mp_var_som_mlx75027-poky-linux/linux-variscite/5.15.60+gitAUTOINC+740e6c7a7b-r2/build"
# Check defconfig in build directory
ls -la "$BUILD_DIR/defconfig"
# Output: -rw-r--r-- 1 1000 1000 32091 Jul 10 14:04 defconfig
# Copy defconfig to current source directory
cp "$BUILD_DIR/defconfig" ./defconfig
# Compare with your Yocto layer defconfig (not kernel defconfig)
YOCTO_DEFCONFIG="/path/to/your/meta-layer/recipes-kernel/linux/linux-variscite/defconfig"
diff -u "$YOCTO_DEFCONFIG" defconfig
# Example output:
# +CONFIG_VIDEO_MLX7502X=m
# +CONFIG_MXC_MIPI_CSI=m
# +CONFIG_IMX8_MIPI_CSI2=mStep 4: Create New defconfig for Your Yocto Layer
The best approach is to create different defconfig files in your Yocto layer for different machines/configurations:
# Copy the new defconfig from build directory
BUILD_DIR="/workdir/tmp/work/imx8mp_var_som_mlx75027-poky-linux/linux-variscite/5.15.60+gitAUTOINC+740e6c7a7b-r2/build"
# Create different defconfig files for different configurations
YOCTO_LAYER="/path/to/your/meta-layer/recipes-kernel/linux/linux-variscite"
# For development configuration (modules)
cp "$BUILD_DIR/defconfig" "$YOCTO_LAYER/defconfig-dev"
# For production configuration (you might configure differently)
# make menuconfig # Configure for production (built-in drivers)
# make savedefconfig
# cp "$BUILD_DIR/defconfig" "$YOCTO_LAYER/defconfig-prod"
# Show what changed from original
ORIGINAL_DEFCONFIG="$YOCTO_LAYER/defconfig"
echo "Configuration changes for dev:"
diff -u "$ORIGINAL_DEFCONFIG" "$YOCTO_LAYER/defconfig-dev"
# Create git commit in your meta layer
cd "$YOCTO_LAYER/../.." # Go to meta layer root
# Initialize git if needed
if [ ! -d ".git" ]; then
git init
git add .
git commit -m "Initial meta layer commit"
fi
# Add the new defconfig files
git add recipes-kernel/linux/linux-variscite/defconfig-dev
# Create commit
git commit -m "linux-variscite: Add ToF camera defconfig for development
Add new defconfig-dev with ToF camera support:
- CONFIG_VIDEO_MLX7502X=m: MLX75027 ToF sensor driver
- CONFIG_MXC_MIPI_CSI=m: MIPI CSI receiver driver
- CONFIG_IMX8_MIPI_CSI2=m: i.MX8 MIPI CSI-2 support
This enables ToF camera functionality for development builds
with drivers as modules for easier debugging.
Signed-off-by: Your Name <your.email@example.com>"
# Generate patch for the meta layer changes
mkdir -p ~/patches
git format-patch -1 HEAD --output-directory=~/patches/Step 5: Update Your Existing bbappend for Machine-Specific defconfig
Based on your existing bbappend that uses:
do_configure:prepend () {
cp "${WORKDIR}/defconfig" "${B}/.config"
}Here’s how to modify it to support different machines:
Option 1: Conditional Logic (Flexible)
# Your linux-variscite_%.bbappend
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
# Add all defconfig files to SRC_URI
SRC_URI += " \
file://defconfig \
file://defconfig-dev \
file://defconfig-prod \
"
# Modified configure prepend with machine detection
do_configure:prepend () {
# Use machine-specific defconfig if available
case "${MACHINE}" in
"imx8mp-var-som-dev"|"imx8mp-var-som-mlx75027-dev")
if [ -f "${WORKDIR}/defconfig-dev" ]; then
echo "Using development defconfig for ${MACHINE}"
cp "${WORKDIR}/defconfig-dev" "${B}/.config"
else
echo "Development defconfig not found, using default for ${MACHINE}"
cp "${WORKDIR}/defconfig" "${B}/.config"
fi
;;
"imx8mp-var-som-prod"|"imx8mp-var-som-mlx75027-prod")
if [ -f "${WORKDIR}/defconfig-prod" ]; then
echo "Using production defconfig for ${MACHINE}"
cp "${WORKDIR}/defconfig-prod" "${B}/.config"
else
echo "Production defconfig not found, using default for ${MACHINE}"
cp "${WORKDIR}/defconfig" "${B}/.config"
fi
;;
*)
echo "Using default defconfig for ${MACHINE}"
cp "${WORKDIR}/defconfig" "${B}/.config"
;;
esac
}Option 2: Machine Override (Cleaner)
# Your linux-variscite_%.bbappend
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
# Base SRC_URI with default defconfig
SRC_URI += "file://defconfig"
# Machine-specific defconfig files (only added for specific machines)
SRC_URI:append:imx8mp-var-som-dev = " file://defconfig-dev"
SRC_URI:append:imx8mp-var-som-prod = " file://defconfig-prod"
# Base configure function (default behavior)
do_configure:prepend () {
cp "${WORKDIR}/defconfig" "${B}/.config"
}
# Machine-specific overrides (these override the base function)
do_configure:prepend:imx8mp-var-som-dev () {
if [ -f "${WORKDIR}/defconfig-dev" ]; then
echo "Using development defconfig for ${MACHINE}"
cp "${WORKDIR}/defconfig-dev" "${B}/.config"
else
echo "Development defconfig not found, using default"
cp "${WORKDIR}/defconfig" "${B}/.config"
fi
}
do_configure:prepend:imx8mp-var-som-prod () {
if [ -f "${WORKDIR}/defconfig-prod" ]; then
echo "Using production defconfig for ${MACHINE}"
cp "${WORKDIR}/defconfig-prod" "${B}/.config"
else
echo "Production defconfig not found, using default"
cp "${WORKDIR}/defconfig" "${B}/.config"
fi
}Option 3: Simple Machine-Specific Files (Recommended)
# Your linux-variscite_%.bbappend
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
# Default defconfig for all machines
SRC_URI += "file://defconfig"
# Machine-specific defconfig files (only fetched for specific machines)
SRC_URI:append:imx8mp-var-som-dev = " file://defconfig-dev"
SRC_URI:append:imx8mp-var-som-prod = " file://defconfig-prod"
# Simple machine-specific override
do_configure:prepend:imx8mp-var-som-dev () {
cp "${WORKDIR}/defconfig-dev" "${B}/.config"
}
do_configure:prepend:imx8mp-var-som-prod () {
cp "${WORKDIR}/defconfig-prod" "${B}/.config"
}
# Default behavior for other machines (uses base defconfig)
do_configure:prepend () {
# Only run if no machine-specific override was executed
if [ ! -f "${B}/.config" ]; then
cp "${WORKDIR}/defconfig" "${B}/.config"
fi
}Step 6: Test Configuration in Devshell
# Back in devshell, test your configuration
make olddefconfig
# Check if your options are enabled
grep -E "CONFIG_VIDEO_MLX7502X|CONFIG_MXC_MIPI_CSI" .config
# Expected output:
# CONFIG_VIDEO_MLX7502X=m
# CONFIG_MXC_MIPI_CSI=m
# CONFIG_IMX8_MIPI_CSI2=m
# Exit devshell
exitMethod 2: Creating Configuration Patches from Yocto Work Directory
Step 1: Set Up Working Directory from Yocto Build
# Create a working directory for kernel configuration
mkdir -p ~/kernel-config-work
cd ~/kernel-config-work
# Find your kernel work directory
KERNEL_WORK_DIR=$(bitbake -e linux-variscite | grep "^S=" | cut -d'"' -f2)
echo "Kernel work directory: $KERNEL_WORK_DIR"
# Copy the kernel source from Yocto work directory
cp -r "$KERNEL_WORK_DIR" ./linux-variscite-work
cd linux-variscite-work
# Initialize git if not already a git repository
if [ ! -d ".git" ]; then
git init
git add .
git commit -m "Initial linux-variscite kernel source from Yocto"
fiStep 2: Identify Current Configuration
# Check what defconfig is currently used
bitbake -e linux-variscite | grep "KBUILD_DEFCONFIG"
# This might show the default defconfig used
# For Variscite i.MX8MP, typical defconfigs are:
ls arch/arm64/configs/ | grep -E "imx8mp|var"
# Expected: imx8mp_var_defconfig or similar
# Check your current .config if it exists
if [ -f ".config" ]; then
echo "Current .config exists"
ls -la .config
else
echo "No .config found, will create from defconfig"
fiStep 3: Start with Base Configuration
# Set up environment variables for cross-compilation
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
# Option A: Start with existing defconfig
make imx8mp_var_defconfig
# Option B: If you have a custom defconfig from your bbappend
# Copy your existing defconfig first
# cp /path/to/your/meta-layer/recipes-kernel/linux/linux-variscite/defconfig .config
# Option C: Use the defconfig from your bbappend
BBAPPEND_DIR="/path/to/your/meta-layer/recipes-kernel/linux/linux-variscite"
if [ -f "$BBAPPEND_DIR/defconfig" ]; then
cp "$BBAPPEND_DIR/defconfig" .config
echo "Using defconfig from bbappend"
else
make imx8mp_var_defconfig
echo "Using default imx8mp_var_defconfig"
fiStep 4: Update Configuration (Critical Step!)
# IMPORTANT: Always run olddefconfig first!
# This resolves any missing or conflicting options
make olddefconfig
# This step is crucial because:
# 1. It adds any new CONFIG options that weren't in your defconfig
# 2. It resolves dependencies automatically
# 3. It ensures your .config is complete and valid
# 4. It prevents menuconfig from showing unnecessary prompts
echo "Configuration updated with olddefconfig"Step 5: Interactive Configuration with menuconfig
# Now run menuconfig for interactive configuration
make menuconfig
# Navigate through the menu system:
# Use arrow keys to navigate
# Use space to toggle options
# Use '/' to search for specific options
# Use '?' for help on any option
# For ToF camera configuration, navigate to:
# Device Drivers --->
# Multimedia support --->
# Media drivers --->
# [*] Media Controller API
# [*] V4L2 sub-device userspace API
# Camera sensor devices --->
# <M> MLX75027 ToF sensor support # Set to M for module or * for built-in
# For MIPI CSI support, navigate to:
# Device Drivers --->
# Multimedia support --->
# Media drivers --->
# Platform devices --->
# <M> i.MX8 MIPI CSI-2 receiver
# <M> i.MX8 Image Sensing Interface (ISI)
# Save and exit menuconfig when done
# Press 'S' to save, then 'Q' to quitStep 6: Verify Configuration Changes
# IMPORTANT: In Yocto out-of-tree builds, defconfig is created in the build directory
# Use 'make savedefconfig' to generate the defconfig file
make savedefconfig
# The defconfig file is created in the BUILD directory, not source directory
# Find the build directory (shown in make output)
BUILD_DIR=$(find /workdir/tmp/work -name "*linux-variscite*" -type d | grep build | head -1)
echo "Build directory: $BUILD_DIR"
# Check for defconfig in build directory
ls -la "$BUILD_DIR/defconfig"
# Output: -rw-r--r-- 1 user user 1234 Jan 10 14:00 defconfig
# Copy defconfig from build directory to current source directory
cp "$BUILD_DIR/defconfig" ./defconfig
# Now you can compare with original defconfig
diff -u arch/arm64/configs/imx8mp_var_defconfig defconfig
# This shows you exactly what options were added/changed
# Example output:
# +CONFIG_VIDEO_MLX7502X=m
# +CONFIG_MXC_MIPI_CSI=m
# +CONFIG_IMX8_MIPI_CSI2=m
# Alternative: Check defconfig directly in build directory
diff -u arch/arm64/configs/imx8mp_var_defconfig "$BUILD_DIR/defconfig"Step 7: Create Git Commit for Configuration
# Stage the configuration changes
cp defconfig arch/arm64/configs/imx8mp_var_defconfig
git add arch/arm64/configs/imx8mp_var_defconfig
# Create a descriptive commit
git commit -m "arm64: defconfig: Enable ToF camera support
Enable Melexis MLX75027 ToF sensor and required MIPI CSI drivers:
- CONFIG_VIDEO_MLX7502X=m: MLX75027 ToF sensor driver
- CONFIG_MXC_MIPI_CSI=m: MIPI CSI receiver driver
- CONFIG_IMX8_MIPI_CSI2=m: i.MX8 MIPI CSI-2 support
- CONFIG_IMX8_ISI_CORE=m: Image Sensing Interface core
- CONFIG_IMX8_ISI_CAPTURE=m: ISI capture support
This enables ToF camera functionality for distance measurement
applications on i.MX8MP platforms.
Signed-off-by: Your Name <your.email@example.com>"Step 8: Generate Git Patch
# Generate patch file compatible with git am
git format-patch -1 HEAD --output-directory=../patches/
# This creates a file like: 0001-arm64-defconfig-Enable-ToF-camera-support.patch
# Verify the patch
ls -la ../patches/
cat ../patches/0001-arm64-defconfig-Enable-ToF-camera-support.patchMethod 2: Working with Custom defconfig in bbappend
Understanding Your Current Setup
Your bbappend currently uses:
do_configure:prepend () {
cp "${WORKDIR}/defconfig" "${B}/.config"
}This means you have a custom defconfig file in your Yocto layer that gets copied to .config during build.
Step 1: Update Your Custom defconfig File
# In devshell, after making your configuration changes with menuconfig
# Generate the new defconfig
BUILD_DIR="/workdir/tmp/work/imx8mp_var_som_mlx75027-poky-linux/linux-variscite/5.15.60+gitAUTOINC+740e6c7a7b-r2/build"
make savedefconfig
cp "$BUILD_DIR/defconfig" ~/new-defconfig
# Copy the new defconfig to your Yocto layer
YOCTO_DEFCONFIG="/path/to/your/meta-layer/recipes-kernel/linux/linux-variscite/defconfig"
cp ~/new-defconfig "$YOCTO_DEFCONFIG"
# Check what changed
diff -u "$YOCTO_DEFCONFIG.backup" "$YOCTO_DEFCONFIG"Step 2: Create Git Patch for defconfig Changes
# In your meta layer directory
cd /path/to/your/meta-layer
# Initialize git if needed
if [ ! -d ".git" ]; then
git init
git add .
git commit -m "Initial meta layer commit"
fi
# Add the updated defconfig
git add recipes-kernel/linux/linux-variscite/defconfig
# Create commit
git commit -m "linux-variscite: defconfig: Enable ToF camera support
Enable Melexis MLX75027 ToF sensor and required MIPI CSI drivers:
- CONFIG_VIDEO_MLX7502X=m: MLX75027 ToF sensor driver
- CONFIG_MXC_MIPI_CSI=m: MIPI CSI receiver driver
- CONFIG_IMX8_MIPI_CSI2=m: i.MX8 MIPI CSI-2 support
This updates the custom defconfig used by the bbappend to enable
ToF camera functionality for distance measurement applications.
Signed-off-by: Your Name <your.email@example.com>"
# Generate patch for the defconfig change
mkdir -p patches
git format-patch -1 HEAD --output-directory=patches/Step 3: Alternative - Create .config Patch Instead
If you want to move away from the custom defconfig approach and use kernel patches instead:
# Create a patch that modifies .config directly
cd /workdir/tmp/work-shared/imx8mp-var-som-mlx75027/kernel-source
# Initialize git if needed
if [ ! -d ".git" ]; then
git init
git add .
git commit -m "Initial linux-variscite kernel source"
fi
# Create a patch for .config changes
cp .config .config-with-tof
git add .config-with-tof
git commit -m "kernel: config: Enable ToF camera support
Enable Melexis MLX75027 ToF sensor and required MIPI CSI drivers:
- CONFIG_VIDEO_MLX7502X=m: MLX75027 ToF sensor driver
- CONFIG_MXC_MIPI_CSI=m: MIPI CSI receiver driver
- CONFIG_IMX8_MIPI_CSI2=m: i.MX8 MIPI CSI-2 support
This patch modifies the kernel .config to enable ToF camera
functionality for distance measurement applications.
Signed-off-by: Your Name <your.email@example.com>"
# Generate patch
git format-patch -1 HEAD --output-directory=~/patches/Step 4: Update bbappend to Use Patches
If you choose to use .config patches instead of custom defconfig:
# Edit your linux-variscite_%.bbappend
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
SRC_URI += " \
file://0001-kernel-config-Enable-ToF-camera-support.patch \
"
# Remove or comment out the old defconfig approach:
# SRC_URI += "file://defconfig"
# do_configure:prepend () {
# cp "${WORKDIR}/defconfig" "${B}/.config"
# }
# The patch will be applied automatically during the patch phaseMethod 3: Integrating Patches with Your bbappend
Step 1: Copy Patch to Your Meta Layer
# Copy the generated patch to your meta layer
mkdir -p /path/to/your/meta-layer/recipes-kernel/linux/linux-variscite/
cp ../patches/0001-arm64-defconfig-Enable-ToF-camera-support.patch \
/path/to/your/meta-layer/recipes-kernel/linux/linux-variscite/Step 2: Update Your bbappend File
# Edit your linux-variscite_%.bbappend
# Add the new patch to SRC_URI
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
SRC_URI += " \
file://0001-arm64-defconfig-Enable-ToF-camera-support.patch \
file://your-existing-patches.patch \
"
# If you're replacing an existing defconfig approach:
# Remove the old defconfig handling and use patches instead
# Comment out or remove:
# SRC_URI += "file://defconfig"
# unset KBUILD_DEFCONFIG
# do_configure:prepend () {
# cp "${WORKDIR}/defconfig" "${B}/.config"
# }Step 3: Test the Patch Integration
# Clean and rebuild to test the patch
bitbake -c cleansstate linux-variscite
bitbake linux-variscite
# Verify the configuration was applied
bitbake -c devshell linux-variscite
# In the devshell:
grep -E "CONFIG_VIDEO_MLX7502X|CONFIG_MXC_MIPI_CSI" .configMethod 3: Creating Multiple Configuration Patches
For Development vs Production Configurations
# Create development configuration patch
git checkout -b dev-config
make menuconfig # Configure for development (modules)
make savedefconfig
cp defconfig arch/arm64/configs/imx8mp_var_defconfig
git add arch/arm64/configs/imx8mp_var_defconfig
git commit -m "arm64: defconfig: Enable ToF camera support for development
Configure ToF camera drivers as modules for development:
- CONFIG_VIDEO_MLX7502X=m
- CONFIG_MXC_MIPI_CSI=m
- CONFIG_IMX8_MIPI_CSI2=m
Signed-off-by: Your Name <your.email@example.com>"
git format-patch -1 HEAD --output-directory=../patches/
# Creates: 0001-arm64-defconfig-Enable-ToF-camera-support-for-development.patch
# Create production configuration patch
git checkout -b prod-config HEAD~1 # Start from base
make menuconfig # Configure for production (built-in)
make savedefconfig
cp defconfig arch/arm64/configs/imx8mp_var_defconfig
git add arch/arm64/configs/imx8mp_var_defconfig
git commit -m "arm64: defconfig: Enable ToF camera support for production
Configure ToF camera drivers as built-in for production:
- CONFIG_VIDEO_MLX7502X=y
- CONFIG_MXC_MIPI_CSI=y
- CONFIG_IMX8_MIPI_CSI2=y
Signed-off-by: Your Name <your.email@example.com>"
git format-patch -1 HEAD --output-directory=../patches/
# Creates: 0001-arm64-defconfig-Enable-ToF-camera-support-for-production.patchConditional Patch Application in bbappend
# In your linux-variscite_%.bbappend
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
# Conditional patching based on machine or image
SRC_URI += " \
file://your-base-patches.patch \
"
# Development configuration
SRC_URI:append:imx8mp-var-som-dev = " \
file://0001-arm64-defconfig-Enable-ToF-camera-support-for-development.patch \
"
# Production configuration
SRC_URI:append:imx8mp-var-som-prod = " \
file://0001-arm64-defconfig-Enable-ToF-camera-support-for-production.patch \
"
# Alternative: Image-specific patches
SRC_URI:append:pn-tof-dev-image = " \
file://0001-arm64-defconfig-Enable-ToF-camera-support-for-development.patch \
"
SRC_URI:append:pn-tof-prod-image = " \
file://0001-arm64-defconfig-Enable-ToF-camera-support-for-production.patch \
"Method 4: Working with Existing Defconfig Files
If You Already Have a Custom defconfig
# Start with your existing defconfig
cp /path/to/your/meta-layer/recipes-kernel/linux/linux-variscite/defconfig .config
# Update configuration
make olddefconfig
make menuconfig
# Create incremental patch
make savedefconfig
diff -u /path/to/your/meta-layer/recipes-kernel/linux/linux-variscite/defconfig defconfig > config.diff
# Convert to proper defconfig patch
cp defconfig arch/arm64/configs/imx8mp_var_defconfig
git add arch/arm64/configs/imx8mp_var_defconfig
git commit -m "arm64: defconfig: Update ToF camera configuration
Update existing defconfig with ToF camera support:
$(cat config.diff | grep '^+' | sed 's/^+/- /')
Signed-off-by: Your Name <your.email@example.com>"
git format-patch -1 HEAD --output-directory=../patches/Method 5: Testing and Validating Patches
Patch Validation
# Test patch application
cd ~/kernel-config-work/linux-variscite-work
git checkout HEAD~1 # Go back to clean state
git am ../patches/0001-arm64-defconfig-Enable-ToF-camera-support.patch
# Verify patch applied correctly
git log --oneline -1
git show HEAD --name-only
# Test configuration build
make ARCH=arm64 imx8mp_var_defconfig
make ARCH=arm64 olddefconfig
grep -E "CONFIG_VIDEO_MLX7502X|CONFIG_MXC_MIPI_CSI" .configIntegration Testing in Yocto
# Test in Yocto build
bitbake -c cleansstate linux-variscite
bitbake -c configure linux-variscite
# Check if configuration was applied
bitbake -c devshell linux-variscite
# In devshell:
grep -E "CONFIG_VIDEO_MLX7502X|CONFIG_MXC_MIPI_CSI" .config
exit
# Build kernel to verify no errors
bitbake linux-varisciteBest Practices
Commit Message Guidelines
# Good commit message format:
git commit -m "arm64: defconfig: Enable ToF camera support
Enable Melexis MLX75027 ToF sensor and required MIPI CSI drivers:
- CONFIG_VIDEO_MLX7502X=m: MLX75027 ToF sensor driver
- CONFIG_MXC_MIPI_CSI=m: MIPI CSI receiver driver
- CONFIG_IMX8_MIPI_CSI2=m: i.MX8 MIPI CSI-2 support
This enables ToF camera functionality for distance measurement
applications on i.MX8MP platforms.
Signed-off-by: Your Name <your.email@example.com>"
# Key elements:
# 1. Subsystem prefix (arm64: defconfig:)
# 2. Brief summary line
# 3. Blank line
# 4. Detailed description with CONFIG options
# 5. Rationale for changes
# 6. Signed-off-by linePatch Organization
# Organize patches logically:
0001-arm64-defconfig-Enable-basic-media-support.patch
0002-arm64-defconfig-Enable-MIPI-CSI-drivers.patch
0003-arm64-defconfig-Enable-ToF-sensor-support.patch
# Rather than one large patch:
0001-arm64-defconfig-Enable-all-ToF-camera-support.patchVersion Control Integration
# Tag your configuration versions
git tag -a v1.0-tof-config -m "ToF camera configuration v1.0"
# Create branches for different configurations
git checkout -b tof-dev-config
git checkout -b tof-prod-config
git checkout -b tof-experimental-configTroubleshooting
Common Issues
Issue 1: Patch Doesn’t Apply
# Check patch format
file 0001-*.patch
# Should show: ASCII text
# Check line endings
dos2unix 0001-*.patch
# Test patch manually
git apply --check 0001-*.patch
git apply --verbose 0001-*.patchIssue 2: Configuration Not Applied
# Verify patch is in SRC_URI
bitbake -e linux-variscite | grep "SRC_URI"
# Check patch was fetched
ls tmp/work/*/linux-variscite/*/
# Verify patch applied during build
bitbake -c patch linux-varisciteIssue 3: Build Failures
# Check for missing dependencies
make ARCH=arm64 olddefconfig
# Look for warnings about unmet dependencies
# Verify cross-compiler
which aarch64-linux-gnu-gcc
aarch64-linux-gnu-gcc --versionDebugging Configuration
# Compare configurations
diff -u .config.old .config | grep "^[+-]CONFIG"
# Find config option dependencies
make ARCH=arm64 menuconfig
# Use '/' to search, then see dependencies
# Check if option is available
grep -r "CONFIG_VIDEO_MLX7502X" arch/arm64/configs/Advanced Techniques
Automated Patch Generation
#!/bin/bash
# save as: generate-config-patch.sh
set -e
KERNEL_DIR="$1"
CONFIG_NAME="$2"
PATCH_DIR="$3"
if [ $# -ne 3 ]; then
echo "Usage: $0 <kernel_dir> <config_name> <patch_dir>"
echo "Example: $0 ~/linux-variscite-work tof-camera ~/patches"
exit 1
fi
cd "$KERNEL_DIR"
# Create configuration
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
make imx8mp_var_defconfig
make olddefconfig
make menuconfig
# Generate patch
make savedefconfig
cp defconfig arch/arm64/configs/imx8mp_var_defconfig
git add arch/arm64/configs/imx8mp_var_defconfig
git commit -m "arm64: defconfig: Enable $CONFIG_NAME support
Automatically generated configuration patch for $CONFIG_NAME
Signed-off-by: $(git config user.name) <$(git config user.email)>"
mkdir -p "$PATCH_DIR"
git format-patch -1 HEAD --output-directory="$PATCH_DIR"
echo "Patch generated in: $PATCH_DIR"
ls -la "$PATCH_DIR"/*.patch | tail -1Configuration Validation Script
#!/bin/bash
# save as: validate-config-patch.sh
PATCH_FILE="$1"
KERNEL_DIR="$2"
if [ $# -ne 2 ]; then
echo "Usage: $0 <patch_file> <kernel_dir>"
exit 1
fi
cd "$KERNEL_DIR"
# Test patch application
echo "Testing patch application..."
git apply --check "$PATCH_FILE"
if [ $? -eq 0 ]; then
echo "✓ Patch applies cleanly"
else
echo "✗ Patch application failed"
exit 1
fi
# Apply patch temporarily
git stash push -m "Backup before patch test"
git apply "$PATCH_FILE"
# Test configuration build
echo "Testing configuration build..."
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
make olddefconfig
if [ $? -eq 0 ]; then
echo "✓ Configuration builds successfully"
else
echo "✗ Configuration build failed"
git stash pop
exit 1
fi
# Restore original state
git stash pop
echo "✓ Patch validation successful"Summary
This guide provides a comprehensive workflow for managing kernel configuration in Yocto using proper git-based patches for linux-variscite. The key benefits of this approach are:
✅ Professional Workflow
- Proper git history with meaningful commit messages
- Version control integration for configuration changes
- Patch compatibility with
git amand standard tools - Maintainable approach that scales with project complexity
🎯 Key Steps Recap
- Set up working directory from Yocto build
- Start with base configuration (defconfig)
- Run
make olddefconfig(critical step!) - Use
make menuconfigfor interactive configuration - Create git commit with proper message format
- Generate patch with
git format-patch - Integrate with bbappend file
- Test and validate the patch
📋 Essential Commands
# Core workflow commands:
make olddefconfig # Resolve dependencies
make menuconfig # Interactive configuration
make savedefconfig # Generate minimal defconfig
git format-patch -1 HEAD # Generate patch file
git am patch-file.patch # Apply patch🔧 Integration with Yocto
# In your linux-variscite_%.bbappend:
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://0001-arm64-defconfig-Enable-ToF-camera-support.patch"📝 Best Practices
- Always run
make olddefconfigbeforemake menuconfig - Use descriptive commit messages with CONFIG option details
- Test patches before integrating with Yocto
- Organize patches logically by functionality
- Version control your configuration changes
This approach ensures your kernel configuration changes are maintainable, reviewable, and integrate cleanly with your Yocto build system while following professional development practices.
Quick Reference
Essential Workflow
# 1. Setup
cd ~/kernel-config-work/linux-variscite-work
export ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
# 2. Configure
make imx8mp_var_defconfig
make olddefconfig
make menuconfig
# 3. Generate patch
make savedefconfig
cp defconfig arch/arm64/configs/imx8mp_var_defconfig
git add arch/arm64/configs/imx8mp_var_defconfig
git commit -m "arm64: defconfig: Enable feature X"
git format-patch -1 HEAD --output-directory=../patches/
# 4. Integrate
cp ../patches/*.patch /path/to/meta-layer/recipes-kernel/linux/linux-variscite/
# Add to SRC_URI in bbappend file
# 5. Test
bitbake -c cleansstate linux-variscite
bitbake linux-varisciteThis workflow ensures professional, maintainable kernel configuration management for your linux-variscite based Yocto projects.
