[IMX6Q]uboot_v2015.04编译流程分析

u-boot版本: v2015.04
branch: imx_v2015.04_3.14.52_1.1.0_ga
[cpp]  view plain  copy
  1. #make mx6qecovacsandroid_config  
Makefile:
[cpp]  view plain  copy
  1. %config: scripts_basic outputmakefile FORCE  
  2.     $(Q)$(MAKE) $(build)=scripts/kconfig $@  
scripts/kconfig/Makefile:
[cpp]  view plain  copy
  1. # Added for U-Boot (backward compatibility)  
  2. %_config: %_defconfig  
  3.     @:  
  4.   
  5. %_defconfig: $(obj)/conf  
  6.     $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)  
$<为$(obj)/conf,是个可执行程序,$(SRCARCH)是.., $@是mx6qecovacsandroid_defconfig
$(Kconfig)为根目录Kconfig。
所以 $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
就是
$(obj)/conf --defconfig=configs/mx6qecovacsandroid_defconfig Kconfig

这个过程主要是把mx6qecovacsandroid_defconfig和Kconfig的定义导出到.config文件中,
下一步make会用到它,其中Kconfig会递归包含相应目录下的Kconfig,如下列出是我们关注的部分:
[cpp]  view plain  copy
  1. source "arch/Kconfig"  
  2.   
  3. arch/Kconfig:  
  4. source "arch/arm/Kconfig"  
  5.   
  6. arch/arm/Kconfig:  
  7. source "board/freescale/mx6qecovacs/Kconfig"  
  8. 包含到了我们自己定义的Kconfig了!  
  9.   
  10. board/freescale/mx6qecovacs/Kconfig:  
  11. if TARGET_MX6QECOVACS  
  12.   
  13. config SYS_BOARD  
  14.     default "mx6qecovacs"  
  15.   
  16. config SYS_VENDOR  
  17.     default "freescale"  
  18.   
  19. config SYS_SOC  
  20.     default "mx6"  
  21.   
  22. config SYS_CONFIG_NAME  
  23.     default "mx6qecovacs"  
  24.   
  25. endif  
这几个参数和u-boot_v2009.08中的就如出一辙了,所以其实只是编译的方法不一样而已。
新版为了兼容性能更好,使用了和kernel一样的编译方法。先利用conf解析Kconfig生成.config,
之后编译系统会想将以.config生成include/config/auto.conf,然后Makefile和sripts/Makefile.build
会包含进来,这样子目录的Makefile就可以通过这些变量来确定哪些文件要被编译进来了。


接下来调用
#make

默认目标是_all:
[cpp]  view plain  copy
  1. PHONY += all  
  2. ifeq ($(KBUILD_EXTMOD),)  
  3. _all: all  
  4. else  
  5. _all: modules  
  6. endif  



all的定义:
#grep 'ALL-y' . -rns
[cpp]  view plain  copy
  1. ./scripts/Makefile.spl:152:ALL-y    += $(obj)/$(SPL_BIN).bin  
  2. ./scripts/Makefile.spl:155:ALL-y    += $(obj)/$(BOARD)-spl.bin  
  3. ./scripts/Makefile.spl:159:ALL-y    += $(obj)/sunxi-spl.bin  
  4. ./scripts/Makefile.spl:163:ALL-y    += boot.bin  
  5. ./scripts/Makefile.spl:166:all:    $(ALL-y)  
  6. ./Makefile:731:ALL-y += u-boot.srec u-boot.bin System.map binary_size_check  
  7. ./Makefile:760:ALL-y += u-boot-dtb-tegra.bin  
  8. ./Makefile:762:ALL-y += u-boot-nodtb-tegra.bin  
  9. ./Makefile:769:ALL-y += $(CONFIG_BUILD_TARGET:"%"=%)  
  10. ./Makefile:792:all:        $(ALL-y)  
  11. ./arch/arm/config.mk:104:ALL-y += checkarmreloc  
  12. ./arch/arm/config.mk:125:ALL-y += SPL  
  13. ./arch/arm/config.mk:129:ALL-y += u-boot-dtb.imx  
  14. ./arch/arm/config.mk:131:ALL-y += u-boot.imx  
auto.conf会在编译之前会被间接调用到:
Makefile:
[cpp]  view plain  copy
  1. include/config/uboot.release: include/config/auto.conf FORCE  
  2.     $(call filechk,uboot.release)  
Makefile:
[cpp]  view plain  copy
  1. include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd  
  2.     $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig  
  3.     @# If the following part fails, include/config/auto.conf should be  
  4.     @# deleted so "make silentoldconfig" will be re-run on the next build.  
  5.     $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf || \  
  6.         { rm -f include/config/auto.conf; false; }  
  7.     @# include/config.h has been updated after "make silentoldconfig".  
  8.     @# We need to touch include/config/auto.conf so it gets newer  
  9.     @# than include/config.h.  
  10.     @# Otherwise, 'make silentoldconfig' would be invoked twice.  
  11.     $(Q)touch include/config/auto.conf  
scripts/kconfig/Makefile:
[cpp]  view plain  copy
  1. silentoldconfig: $(obj)/conf  
  2.     $(Q)mkdir -p include/config include/generated  
  3.     $< --$@ $(Kconfig)  
$< --$@ $(Kconfig)也就是
$(obj)/conf --silentoldconfig Kconfig

使用conf生成auto.conf,autoconf.h这两个重要文件。

后面就是根据auto.conf和autoconf.h的定义生成u-boot.bin, u-boot.imx等这些文件
拿u-boot.imx举例:
[cpp]  view plain  copy
  1. ./arch/arm/imx-common/Makefile:53:u-boot.imx: u-boot.bin $(IMX_CONFIG) FORCE  
  2.   
  3. ./Makefile:848:u-boot.bin: u-boot FORCE  
  4.   
  5. ./Makefile:1128:u-boot:    $(u-boot-init) $(u-boot-main) u-boot.lds  
  6.   
  7. ./Makefile:678:u-boot-init := $(head-y)  
  8.   
  9. ./Makefile:679:u-boot-main := $(libs-y)  
  10.   
  11. ./arch/arm/Makefile:65:head-y := arch/arm/cpu/$(CPU)/start.o  
  12.   
  13. ./Makefile:627:libs-y += lib/  
  14. ./Makefile:630:libs-y += fs/  
  15. ./Makefile:631:libs-y += net/  
  16. ./Makefile:632:libs-y += disk/  
  17. ./Makefile:633:libs-y += drivers/  
  18. ./Makefile:634:libs-y += drivers/dma/  
  19. ./Makefile:635:libs-y += drivers/gpio/  
  20. ./Makefile:636:libs-y += drivers/i2c/  
  21. ......  
  22. ./arch/arm/Makefile:63:libs-y += $(machdirs)  
  23. ./arch/arm/Makefile:73:libs-y += arch/arm/cpu/$(CPU)/  
  24. ./arch/arm/Makefile:74:libs-y += arch/arm/cpu/  
  25. ./arch/arm/Makefile:75:libs-y += arch/arm/lib/  
  26. ./arch/arm/Makefile:79:libs-y += arch/arm/imx-common/  
  27. ......
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值