三、.config
四、之間聯絡
.config、 kconfig 、makefile 之間的關係
1、linux核心原始碼的每個目錄下都有乙個makefile,由該 makefile 對源**的編譯、鏈結等操作進行控制。
2、編譯完成後,每個源**目錄下都會生成乙個名叫 built-in.o的檔案。這個檔案由每個源**目錄下的所有原始檔編譯後的目標檔案鏈結而成;而不同的built-in.o 又被上層目錄中的makefile鏈結成更大的builtin. o,直到最後鏈結成為乙個核心vmlinux.o。
3、在linux根目錄下 make 或 make uimage 後生成最終的檔案iamge(uimage)放在/arch/arm/boot下 、uimage就可燒錄到開發板
在進行make menuconfig時,可視介面的生成依賴於kconfig檔案。一般來說,每個源**目錄下都有乙個kconfig檔案。在kconfig下的東西才能在menu內顯示。
kconfig檔案的基本要素主要包括:config條目常被其它條目包含,用來生成選單、進行多項選擇等,它是kconfig的最小單位,用於生成乙個變數。1、config條目(entry)
2、 menu條目
3、choice條目
4、source
它控制著make menucofig時,出現的配置選項,並根據使用者在配置介面中的選擇,把核心配置所做的修改最終反應在.config檔案中(即會生成配置檔案.config)。
例子(把這個config條目放置在/drivers/
char
/kconfig檔案裡,看看效果?)
config module_hello #配置項
tristate 「module hello「 #型別和提示
depends on xx #依賴
default y #預設值
select crc32 #反向依賴
select mii
---help--
- #幫助提示
support for module hello.
to compile this driver as a module, choose m here.
the module will be called hello.
配置項:
型別:bool
(2鐘選擇y、n)、tristate
(3種、y、m、n)、int、hex、string
數值範圍:只用於int和hex兩種型別 可進行配置賦值
預設值:使用者沒有設定過,配置選項就是使用預設值
依賴:依賴其他config條目 其他滿足此條目才可顯示
反向依賴:此條目滿足,反向依賴也滿足
幫助:幫助的提示資訊
在make menuconfig下可以看到 「module hello」
按空格可進行3個轉態的切換 【 * 、m、「 」 】
menu 「module (test)"
……endmenu
menu和endmenu是關鍵字,中間可配置若干config條目或choice條目或source。
它最後在配置選單的體現形式為:
module (test)
--->
例子:menu 「module (test)」 #選單項
config module_hello #配置項
tristate 「module hello「 #型別和提示
depends on arm || blackfin || mips #依賴
default y #預設值 def_tristate y
…config module_goodbye #配置項
bool 「module goodbye「 #型別和提示
depends on arm || blackfin || mips #依賴
default y #預設值 def_tristate y
endmenu #選單項 結束
choice #單選項
prompt 「module
(test)"
……endchoice
choice和endchoice是關鍵字,中間可配置若干config條目。
它最後在配置選單的體現形式為:進入只可選其一
module
(test)
--->
例:choice #單選項
prompt 「module (test)"
default module_hello
config module_hello #配置項
tristate 「module hello「 #型別和提示
depends on arm || blackfin || mips #依賴
default y #預設值 def_tristate y
…config module_goodbye #配置項
bool 「module goodbye「 #型別和提示
depends on arm || blackfin || mips #依賴
default y #預設值 def_tristate y
endchoice #單選項 結束
不選擇的話預設是module_hello項
source "drivers/net/fec_8xx/kconfig"
用於引入另乙個kconfig檔案 類似於include
1、.config檔案是linux編譯時所依賴的檔案。我們在配置核心時所做的任何修改,最終都會在這個檔案中體現出來。它是makefile對核心進行處理的重要依據。
2、一般來說,核心提供了晶元公司demo板的.config檔案,我們一般找乙個近似的進行修改。如s3c2410平台上,可以選擇目錄arch/arm/configs下的s3c2410_defconfig這個檔案。
3、make menuconfig 後即可生成 .config
…config_module_hello=y
…make menuconfig對核心配置所做的修改最終反應在
.config檔案中。如上所示,在.config檔案中
config_module_hello=y被定義為y。
…obj-$(config_module_hello)+=hello.o
…config_module_hello是tristate型別,有三個可能取值:
y:編譯進核心
m:編譯成模組make module生成
n:不進行編譯
若是bool型別,則只有兩種可能,y或者n。
當config_module_hello為y是hello.c才可以編譯成hello.o檔案,進而編進核心 為 m時make module生成模組
make clean:僅僅是清除上次的make命令所產生的object檔案(字尾為「.o」
的檔案)及可執行檔案 。但是會保留核心的配置檔案.config。
make mrproper:刪除所有的編譯生成檔案, 還有核心配置檔案,
再加上各種備份檔案。
make distclean: 刪除mrproper刪除的檔案,
加上編輯備份檔案和一些補丁檔案。
make zimage:生成核心壓縮映像檔案zimage(放置在arch/arm/boot下)
make image:生成核心映像檔案zimage(放置在arch/arm/boot下)
make uimage:生成uboot專用的映像檔案,它是在zimage之前加上乙個長度為64
位元組的「頭」,說明這個核心的版本、載入位置、生成時間、大小等資訊;其0x40之
後與zimage沒區別。 (放置在arch/arm/boot下)
前面提到,.config是核心編譯時所依賴的重要檔案,與具體的硬體構架和開發板型別相關。我們選擇核心提供的s3c2410_defconfig進行修改。
cp arch/arm/configs/s3c2410_defconfig .config
在arch/arm/configs下有一些不同硬體開發板的.config可以使用 在需要時copy到根目下 的.config
。
核心的配置與編譯
核心的配置與編譯 1 清除臨時檔案 中間檔案和配置檔案。make clean remove most generated files but keep the config make mrproper remove all generated files config files make dist...
Linux 核心配置與編譯
嵌入式系統的乙個很重要的特性就是可移植可裁剪配置。這篇博文主要簡單總結下在x86體系下配置編譯核心的過程。取得原始碼後的步驟就是配置核心。使用make menuconfig命令,配置成功後儲存會在核心源 目錄下生成乙個.config檔案。這個檔案是隱藏的,需要用ls a命令才可看到。配置選項比較多,...
linux核心配置與編譯
linux核心配置與編譯 1.清除臨時檔案 1.make clean 刪除產生的檔案,但儲存配置。2.make mrproper 刪除產生的檔案同時刪除配置 3.make distclean 刪除mrproper並且刪除補丁之類的。2 對確定的目標系統的軟硬體配置情況。比如cpu 網絡卡型號,所需支...