defconfig、 .config

本文深入探讨了Linux内核的配置过程,解释了defconfig和.config文件的区别及作用。defconfig文件仅包含非默认选项,保持精简,而.config文件则包含了所有配置项,默认值来自对应的Kconfig文件。文章还介绍了如何使用makesavedefconfig规则来更新defconfig文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近在裁剪内核慢慢关注这个问题

defconfig、 .config

 

defconfig 一般在arch/arm64/configs/目录下,是一个简单的内核配置,是没有展开的。

.config一般是用来执行make menuconfig的基础配置

从.config到defcong不是简单的复制操作,而是make arch=arm64 defcong 

通过menuconfig生成的.confg也不是直接拷贝成defcong,而是使用make savedefconfig

 

The .config file is not simply copied from your defconfig file. The motivation for storing defconfig in such a format is next: in defconfig we can only specify options with non-default values (i.e. options we changed for our board). This way we can keep it small and clear. Every new kernel version brings a bunch of new options, and this way we don't need to update our defconfig file each time the kernel releases. Also, it should be mentioned that kernel build system keeps very specific order of options in defconfig file, so it's better to avoid to modify it by hand. Instead you should use make savedefconfig rule.

Simplified explanation

When .config file is being generated, kernel build system goes through all Kconfig files (from all subdirs), checking all options in those Kconfig files:

  • if option is mentioned in defconfig, build system puts that option to .config with value chosen in defconfig
  • if option isn't mentioned in defconfig, build system puts that option to .config using its default value, specified in corresponding Kconfig

Check scripts/kconfig/Makefile and scripts/kconfig/conf.c files to see how it's actually done.

 

具体查看

https://stackoverflow.com/questions/41885015/what-exactly-does-linux-kernels-make-defconfig-do

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值