日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux内核编译 —— 配置文件

發(fā)布時間:2024/8/1 linux 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux内核编译 —— 配置文件 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1 開發(fā)環(huán)境

? ? 宿主機:Ubuntu16.04

? ? 開發(fā)板:Mini2440

? ? 內(nèi)核版本:2.6.34.7

2 下載與解壓

? ? 下載linux-2.6.34.7.tar.bz2并解壓:

tar -axvf linux-2.6.34.7.tar.bz2

3?默認配置

? ? 進入內(nèi)核源碼頂級目錄執(zhí)行:

make defconfig

? ? 輸出如下:

liyihai@ubuntu:~/Mini2440/Kernels/linux-2.6.34.7$ make defconfigHOSTCC scripts/basic/fixdepHOSTCC scripts/basic/docprocHOSTCC scripts/basic/hashHOSTCC scripts/kconfig/conf.o scripts/kconfig/conf.c: In function ‘conf_sym’: scripts/kconfig/conf.c:159:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]int type;^ scripts/kconfig/conf.c: In function ‘conf_choice’: scripts/kconfig/conf.c:231:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]int type;^ scripts/kconfig/conf.c:307:9: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]fgets(line, 128, stdin);^ scripts/kconfig/conf.c: In function ‘conf_askvalue’: scripts/kconfig/conf.c:105:8: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]fgets(line, 128, stdin);^HOSTCC scripts/kconfig/kxgettext.oSHIPPED scripts/kconfig/zconf.tab.cSHIPPED scripts/kconfig/lex.zconf.cSHIPPED scripts/kconfig/zconf.hash.cHOSTCC scripts/kconfig/zconf.tab.oHOSTLD scripts/kconfig/conf *** Default configuration is based on 'i386_defconfig' # # configuration written to .config #

? ? 根據(jù)上述輸出信息倒數(shù)第倒數(shù)4行可知,默認情況下內(nèi)核的配置是針對x86架構(gòu)的,并且根據(jù)i386_defconfig生成了.config(源碼中本沒有此文件,是配置時才創(chuàng)建的)。通過find命令查找i386_deconfig

? ? 使用vim打開分別打開.configi386_defconfig,發(fā)現(xiàn)它們的內(nèi)容基本一樣,通過diff命令對它們進行比較:

? ? 由上圖可見,.configi386_defconfig是不完全同的,make defconfig并非簡單的將arch/x86/configs/i386_defconfig復(fù)制到.config

3.1 默認架構(gòu)

? ? 上述默認配置是針對x86構(gòu)架的,那么怎么啟動ARM構(gòu)架的默認配置呢?答案是指定頂級MakefileARCH變量值,同時指定交叉編譯工具鏈前綴

ARCH ?= arm CROSS_COMPILE ?= arm-linux-

? ? 這時候再執(zhí)行make defconfig時,針對的就是ARM架構(gòu)了:

liyihai@ubuntu:~/Mini2440/Kernels/linux-2.6.34.7$ make defconfigHOSTCC scripts/basic/fixdepHOSTCC scripts/basic/docprocHOSTCC scripts/basic/hashHOSTCC scripts/kconfig/conf.o scripts/kconfig/conf.c: In function ‘conf_sym’: scripts/kconfig/conf.c:159:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]int type;^ scripts/kconfig/conf.c: In function ‘conf_choice’: scripts/kconfig/conf.c:231:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]int type;^ scripts/kconfig/conf.c:307:9: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]fgets(line, 128, stdin);^ scripts/kconfig/conf.c: In function ‘conf_askvalue’: scripts/kconfig/conf.c:105:8: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]fgets(line, 128, stdin);^HOSTCC scripts/kconfig/kxgettext.oSHIPPED scripts/kconfig/zconf.tab.cSHIPPED scripts/kconfig/lex.zconf.cSHIPPED scripts/kconfig/zconf.hash.cHOSTCC scripts/kconfig/zconf.tab.oHOSTLD scripts/kconfig/conf *** Default configuration is based on 'versatile_defconfig' # # configuration written to .config #

? ? 由上述信息可知,此時根據(jù)versatile_defconfig進行默認配置生成.config,使用find查找versatile_defconfig

? ? 使用diff比較versatile_defconfig.config

? ? 由上圖可見,versatile_defconfig.config還是不完全同的。

3.2 配置文件.config

? ? 由上可見,配置信息主要保存于內(nèi)核源碼頂級目錄的.config文件中,ARM構(gòu)架.config最開始部分的內(nèi)容如下所示:

# # Automatically generated make config: don't edit # Linux kernel version: 2.6.34.7 # Tue May 10 11:30:25 2016 # CONFIG_ARM=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y CONFIG_GENERIC_TIME=y CONFIG_GENERIC_CLOCKEVENTS=y CONFIG_HAVE_PROC_CPU=y CONFIG_GENERIC_HARDIRQS=y CONFIG_STACKTRACE_SUPPORT=y CONFIG_HAVE_LATENCYTOP_SUPPORT=y CONFIG_LOCKDEP_SUPPORT=y CONFIG_TRACE_IRQFLAGS_SUPPORT=y CONFIG_HARDIRQS_SW_RESEND=y CONFIG_GENERIC_IRQ_PROBE=y CONFIG_RWSEM_GENERIC_SPINLOCK=y CONFIG_GENERIC_HWEIGHT=y CONFIG_GENERIC_CALIBRATE_DELAY=y CONFIG_NEED_DMA_MAP_STATE=y CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y CONFIG_VECTORS_BASE=0xffff0000 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" CONFIG_CONSTRUCTORS=y

?

? ? 根據(jù)上述信息第2行的說明可知,.config文件的內(nèi)容是由make config自動生成的(其實i386_defconfig也是的第2行也是這么寫),不要手動修改。

? ? 第6行指定了使用ARM架構(gòu),此外,其余所有的配置項都以CONFIG_為前綴。

3.3 其它默認配置文件

? ? 根據(jù)參考資料[1]的提示,在內(nèi)核源碼arch目錄中有alphax86arm等子目錄,分別對應(yīng)相應(yīng)的架構(gòu):

? ? 其中arm目錄包含bootcommonconfigsinclude以及內(nèi)核已支持的ARM芯片子目錄:

? ? 上圖configs目錄包含了各個ARM芯片的默認配置文件(包括3.1小節(jié)的versatile_defconfig):

? ?根據(jù)參考資料[1] 的提示,若要使用這些平臺的配置文件,只能將其復(fù)制到頂級目錄并且重命名為.config

cd linux-2.6.34.7 cp arch/arm/configs/mini2440_defconfig .config

4 交互配置

? ? 進入內(nèi)核源碼頂級目錄執(zhí)行:

make config

? ? 輸出如下:

liyihai@ubuntu:~/Mini2440/Kernels/linux-2.6.34.7$ make configHOSTCC scripts/basic/fixdepHOSTCC scripts/basic/docprocHOSTCC scripts/basic/hashHOSTCC scripts/kconfig/conf.o scripts/kconfig/conf.c: In function ‘conf_sym’: scripts/kconfig/conf.c:159:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]int type;^ scripts/kconfig/conf.c: In function ‘conf_choice’: scripts/kconfig/conf.c:231:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]int type;^ scripts/kconfig/conf.c:307:9: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]fgets(line, 128, stdin);^ scripts/kconfig/conf.c: In function ‘conf_askvalue’: scripts/kconfig/conf.c:105:8: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]fgets(line, 128, stdin);^HOSTCC scripts/kconfig/kxgettext.oSHIPPED scripts/kconfig/zconf.tab.cSHIPPED scripts/kconfig/lex.zconf.cSHIPPED scripts/kconfig/zconf.hash.cHOSTCC scripts/kconfig/zconf.tab.oHOSTLD scripts/kconfig/conf scripts/kconfig/conf arch/x86/Kconfig # # using defaults found in /boot/config-3.16.0-30-generic # /boot/config-3.16.0-30-generic:1264:warning: symbol value 'm' invalid for NET_DSA /boot/config-3.16.0-30-generic:1680:warning: symbol value 'm' invalid for MTD_CMDLINE_PARTS /boot/config-3.16.0-30-generic:2418:warning: symbol value 'm' invalid for NET_DSA_MV88E6XXX /boot/config-3.16.0-30-generic:2419:warning: symbol value 'm' invalid for NET_DSA_MV88E6060 /boot/config-3.16.0-30-generic:2421:warning: symbol value 'm' invalid for NET_DSA_MV88E6131 /boot/config-3.16.0-30-generic:2422:warning: symbol value 'm' invalid for NET_DSA_MV88E6123_61_65 /boot/config-3.16.0-30-generic:2861:warning: symbol value 'm' invalid for IWL4965 /boot/config-3.16.0-30-generic:3783:warning: symbol value 'm' invalid for GPIO_UCB1400 /boot/config-3.16.0-30-generic:4259:warning: symbol value 'm' invalid for REGULATOR_88PM8607 /boot/config-3.16.0-30-generic:4318:warning: symbol value 'm' invalid for REGULATOR_TWL4030 /boot/config-3.16.0-30-generic:5396:warning: symbol value 'm' invalid for SND_HDA_CODEC_REALTEK /boot/config-3.16.0-30-generic:5397:warning: symbol value 'm' invalid for SND_HDA_CODEC_ANALOG /boot/config-3.16.0-30-generic:5398:warning: symbol value 'm' invalid for SND_HDA_CODEC_SIGMATEL /boot/config-3.16.0-30-generic:5399:warning: symbol value 'm' invalid for SND_HDA_CODEC_VIA /boot/config-3.16.0-30-generic:5402:warning: symbol value 'm' invalid for SND_HDA_CODEC_CIRRUS /boot/config-3.16.0-30-generic:5403:warning: symbol value 'm' invalid for SND_HDA_CODEC_CONEXANT /boot/config-3.16.0-30-generic:5404:warning: symbol value 'm' invalid for SND_HDA_CODEC_CA0110 /boot/config-3.16.0-30-generic:5407:warning: symbol value 'm' invalid for SND_HDA_CODEC_CMEDIA /boot/config-3.16.0-30-generic:5408:warning: symbol value 'm' invalid for SND_HDA_CODEC_SI3054 /boot/config-3.16.0-30-generic:5409:warning: symbol value 'm' invalid for SND_HDA_GENERIC /boot/config-3.16.0-30-generic:7288:warning: symbol value 'm' invalid for NFS_V3 /boot/config-3.16.0-30-generic:7290:warning: symbol value 'm' invalid for NFS_V4 * * Linux Kernel Configuration * * * General setup * Prompt for development and/or incomplete code/drivers (EXPERIMENTAL) [N/y/?] (NEW)

? ? 由上述最后1行可知,需要用戶確認是否Prompt for development and/or incomplete code/drivers (EXPERIMENTAL),因此可知這是交互式的配置,需要用戶對內(nèi)核非常了解,操作比較繁瑣。

5 菜單配置

make menuconfig

?

6 清空配置

? ? 若要刪除上述的配置值,執(zhí)行:

make mrproper

?

? ? 注:make distcean不能替代上述命令!
?

參考資料

[1]交叉編譯 Linux 內(nèi)核 for ARM

總結(jié)

以上是生活随笔為你收集整理的Linux内核编译 —— 配置文件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。