标题
1、编译u-boot镜像执行的命令
make DEVICE_TREE=stm32mp157a-fsmp1a all
2、从编译命令入手可以查看all这个目标
在看源码之前用一张图将依赖关系展示出来:
2.1 从顶层Makefile找到all目标,定义如下:
960 all: $(ALL-y)
961 eq ($(CONFIG_DEPRECATED),y)
962 $(warning "You have deprecated configuration options enabled in your .config!
2.2 发现all目标又依赖于ALL-y目标,ALL-y目标定义如下:
846 ALL-y += u-boot.srec u-boot.bin u-boot.sym System.map binary_size_check
2.3、u-boot.srec、u-boot.sym、System.map目标都依赖u-boot
1169 u-boot.hex u-boot.srec: u-boot FORCE
1170 $(call if_changed,objcopy)
1683 u-boot.sym: u-boot FORCE
1684 $(call if_changed,sym)
1875 System.map: u-boot
1876 @$(call SYSTEM_MAP,$<) > $@
而binary_size_check依赖u-boot-nodtb.bin FORCE
binary_size_check: u-boot-nodtb.bin FORCE
其中打开设备树以后u-boot.binu-boot-dtb.bin—>u-boot-nodtb.bin dts/dt.dtb
所以u-boot.bin、binary_size_check目标依赖u-boot-nodtb.bin:
1140 u-boot.bin: u-boot-nodtb.bin FORCE
1141 $(call if_changed,copy)
而u-boot-nodtb.bin、dts/dt.dtb都依赖u-boot
1235 u-boot-nodtb.bin: u-boot FORCE
1236 $(call if_changed,objcopy)
1237 $(call DO_STATIC_RELA,$<,$@,$(CONFIG_SYS_TEXT_BASE))
1238 $(BOARD_SIZE_CHECK)
1086 dts/dt.dtb: u-boot
1087 $(Q)$(MAKE) $(build)=dts dtbs
2.4 得出的结果:ALL-y的依赖u-boot.srec u-boot.bin u-boot.sym System.map binary_size_check又全部依赖u-boot
2.5 u-boot目标
1670 u-boot: $(u-boot-init) $(u-boot-main) u-boot.lds FORCE
1671 +$(call if_changed,u-boot__)
1672 ifeq ($(CONFIG_KALLSYMS),y)
1673 $(call cmd,smap)
1674 $(call cmd,u-boot__) common/system_map.o
1675 endif
1676
1677 ifeq ($(CONFIG_RISCV),y)
1678 @tools/prelink-riscv $@ 0
1679 endif
2.6、u-boot-init、u-boot-main目标
781 u-boot-init := $(head-y)
782 u-boot-main := $(libs-y)
2.7、libs-y目标
其被定义为各层驱动目录下build-in.o的集合
2.8、heda-y
95 head-y := arch/arm/cpu/$(CPU)/start.o
1656 quiet_cmd_u-boot__ ?= LD $@
1657 cmd_u-boot__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_u-boot) -o $@ \
1658 -T u-boot.lds $(u-boot-init) \
1659 --start-group $(u-boot-main) --end-group \
1660 $(PLATFORM_LIBS) -Map u-boot.map; \
1661 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
总结:u-boot 依赖 ( u − b o o t − i n i t ) , (u-boot-init), (u−boot−init),(u-boot-main) 和 u-boot.lds ,而$(u-boot-init) $(u-boot-main) 依赖 $(u-boot-dirs), KaTeX parse error: Expected group after '_' at position 59: …命令行执行cmd_u-boot_̲_将(u-boot-int)到$(u-boot-main)通过u-boot.lds链接起来.