You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何make savedefconfig删除配置项?Yocto内核配置问题求助

Why make savedefconfig Removes Critical Vendor Configs and How to Prevent It

Let's break down what's happening here and how to fix it—this is a common pitfall when working with vendor-provided kernel defconfigs.

First, Why Does savedefconfig Delete Those Configs?

The savedefconfig command is designed to generate a minimal defconfig file. It only keeps settings that differ from the kernel's built-in default values (defined in the Kconfig tree for your architecture/platform).

The lines getting deleted—like CONFIG_ARCH_SUNXI=y, CONFIG_AEABI=y, or CONFIG_CPU_FREQ=y—are all defaults for your target platform. savedefconfig sees them as redundant and strips them out.

The problem? Your vendor included these explicitly for a reason: maybe their U-Boot setup relies on these flags being present, or they're locking in settings that might change across kernel versions to maintain stability. Even though the kernel would enable them by default, the absence of the explicit line breaks your boot flow.

Fixes to Keep Vendor Configs Intact

Here are three reliable ways to avoid losing those critical settings:

1. Use make olddefconfig Instead (Recommended)

Swap out savedefconfig with olddefconfig—this command preserves all existing explicit configs while only adding missing default values, no stripping:

cp $YOCTO_MYKERNEL/files/defconfig .config
make menuconfig  # Add your desired drivers and save
make olddefconfig  # Fills in defaults without deleting anything
cp .config $YOCTO_MYKERNEL/files/defconfig

This is the simplest, most robust approach for maintaining vendor configs while adding your own changes.

2. Force savedefconfig to Respect the Vendor Base

You can tell savedefconfig to use the vendor's defconfig as a baseline, so it only adds your new settings without removing existing ones:

cp $YOCTO_MYKERNEL/files/defconfig .config
make menuconfig  # Make your changes
# Use the vendor defconfig as the "allconfig" template to retain its lines
KCONFIG_ALLCONFIG=$YOCTO_MYKERNEL/files/defconfig make savedefconfig
cp defconfig $YOCTO_MYKERNEL/files/defconfig

This generates a minimal defconfig that includes both the vendor's explicit settings and your new drivers.

3. Yocto-Friendly Incremental Configs (Best Practice)

Instead of modifying the vendor defconfig directly, use Yocto's kernel config fragment system to add your changes separately:

  1. Create a file like my_drivers.cfg with only your new configs:
    CONFIG_MY_DESIRED_DRIVER=y
    CONFIG_ANOTHER_DRIVER=m
    
  2. In your Yocto recipe's .bbappend file, add:
    KERNEL_CONFIG_FRAGMENTS += "${THISDIR}/files/my_drivers.cfg"
    

Yocto will automatically merge this fragment with the vendor's defconfig during build, avoiding manual edits entirely.

Quick Note on Kernel Versions

Double-check that your working kernel source matches the version the vendor's defconfig was built for. If there's a version mismatch, default values might have changed, causing savedefconfig to strip more lines than expected.

内容的提问来源于stack exchange,提问作者user2941479

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:42:45