1.1:menuconfig 重點會用到兩個文件:.config 和 Kconfig,.config 文件前面已經說了,這個文件保存着 uboot 的配置項,使用 menuconfig 配置完 uboot 以后肯定要更新.config 文件。Kconfig文件是圖形界面的描述文件,也就是描述界面應該有什么內容,很多目錄下都會有 Kconfig 文件
1.2:打開圖形界面,設置好要設置的項目后,make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8再編譯uboot,注意不能用用mx6ull_alientek_emmc.sh ,因為在編譯之前會清理工程,會刪除掉.config 文件
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mx6ull_alientek_emmc_defconfig make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
1.3:過程分析:當輸入 make menuconfig 以后會匹配到頂層 Makefile 的如下代碼
%config: scripts_basic outputmakefile FORCE $(Q)$(MAKE) $(build)=scripts/kconfig $@
展開即為
@ make -f ./scripts/Makefile.build obj=scripts/kconfig menuconfig
Makefile.build 會讀取 scripts/kconfig/Makefile 中的內容,在 scripts/kconfig/Makefile 中可以找到如下代碼
menuconfig: $(obj)/mconf $< $(silent) $(Kconfig)
展開即為
menuconfig: scripts/kconfig/mconf scripts/kconfig/mconf Kconfig
以上目標 menuconfig 依賴 scripts/kconfig/mconf,因此 scripts/kconfig/mconf.c 這個文件會被編譯,生成 mconf 這個可執行文件。目標 menuconfig 對應的規則為 scripts/kconfig/mconf Kconfig,也就是說 mconf 會調用 uboot 根目錄下的 Kconfig 文件開始構建圖形配置界面
1.4:Kconfig語法(通過根目錄Kconfig分析)
1.4.1:mainmenu就是主菜單
mainmenu "U-Boot $UBOOTVERSION Configuration"
1.4.2:調用其他Kconfig
source "xxx/Kconfig" //xxx 為具體的目錄名,相對路徑
1.4.3:menu 用於生成菜單,endmenu 就是菜單結束標志,這兩個一般是成對出現的。在頂層Kconfig 中有如下
menu "General setup" config LOCALVERSION string "Local version - append to U-Boot release" help Append an extra string to the end of your U-Boot version. This will show up on your boot log, for example. The string you set here will be appended after the contents of any files with a filename matching localversion* in your object and source tree, in that order. Your total string can be a maximum of 64 characters. config LOCALVERSION_AUTO bool "Automatically append version information to the version string" default y help This will try to automatically determine if the current tree is a release tree by looking for git tags that belong to the current top of tree revision. A string of the format -gxxxxxxxx will be added to the localversion if a git-based tree is found. The string generated by this will be appended after any matching localversion* files, and after the value set in CONFIG_LOCALVERSION. (The actual string used here is the first eight characters produced by running the command: $ git rev-parse --verify HEAD which is done within the script "scripts/setlocalversion".) config CC_OPTIMIZE_FOR_SIZE bool "Optimize for size" default y help Enabling this option will pass "-Os" instead of "-O2" to gcc resulting in a smaller U-Boot image. This option is enabled by default for U-Boot. config SYS_MALLOC_F bool "Enable malloc() pool before relocation" default y if DM help Before relocation memory is very limited on many platforms. Still, we can provide a small malloc() pool if needed. Driver model in particular needs this to operate, so that it can allocate the initial serial device and any others that are needed. config SYS_MALLOC_F_LEN hex "Size of malloc() pool before relocation" depends on SYS_MALLOC_F default 0x400 help Before relocation memory is very limited on many platforms. Still, we can provide a small malloc() pool if needed. Driver model in particular needs this to operate, so that it can allocate the initial serial device and any others that are needed. menuconfig EXPERT bool "Configure standard U-Boot features (expert users)" default y help This option allows certain base U-Boot options and settings to be disabled or tweaked. This is for specialized environments which can tolerate a "non-standard" U-Boot. Only use this if you really know what you are doing. if EXPERT config SYS_MALLOC_CLEAR_ON_INIT bool "Init with zeros the memory reserved for malloc (slow)" default y help This setting is enabled by default. The reserved malloc memory is initialized with zeros, so first malloc calls will return the pointer to the zeroed memory. But this slows the boot time. It is recommended to disable it, when CONFIG_SYS_MALLOC_LEN value, has more than few MiB, e.g. when uses bzip2 or bmp logo. Then the boot time can be significantly reduced. Warning: When disabling this, please check if malloc calls, maybe should be replaced by calloc - if expects zeroed memory. endif endmenu # General setup
1.3.4:上面可以看到有很多config開頭的項目,比如config LOCALVERSION,這個就是菜單 "General setup"的具體配置項,使能了此項功能之后,.config文件就會生成CONFIG_LOCALVERSION;config項目下面的就是此項的具體屬性(類型、輸入提示、依賴關系、幫助信息和默認值等)
1.3.5:
depends on:選中HAVE_GENERIC_BOARD后才能選SYS_GENERIC_BOARD;
select:選中ARC之后會選中后面select的幾項
config SYS_GENERIC_BOARD bool depends on HAVE_GENERIC_BOARD choice prompt "Architecture select" default SANDBOX config ARC bool "ARC architecture" select HAVE_PRIVATE_LIBGCC select HAVE_GENERIC_BOARD select SYS_GENERIC_BOARD select SUPPORT_OF_CONTROL
endchoice
1.3.6:menuconfig 和 menu 很類似,但是 menuconfig 是個帶選項的菜單,只有選中MODULES后,if和endif之間的內容才可見
menuconfig MODULES bool "menu_name" 3 if MODULES ... endif # MODULES
1.3.7:comment 用 於 注 釋