编译uboot的过程分析

This commit is contained in:
weidongshan
2023-05-15 00:50:47 +08:00
parent 79a6a28a54
commit f7959b7669
2 changed files with 20 additions and 16 deletions

View File

@@ -359,14 +359,16 @@ endif
![](pic/10_u-boot_cfg.png) ![](pic/10_u-boot_cfg.png)
## 5.3 编译过程详细分析(IMX6ULL) ## 5.3 编译过程详细分析(IMX6ULL)
### 5.3.1 结论 ### 5.3.1 结论
以IMX6ULL为例先说结论 以IMX6ULL为例先说结论
![image-20230423141920708](pic/12_create_imx.png)
细节如下:
* 执行make命令时要编译得到哪些文件由`ALL-y`决定 * 执行make命令时要编译得到哪些文件由`ALL-y`决定
* 规则如下 * 规则如下
@@ -434,30 +436,29 @@ endif
$(DTB): arch-dtbs $(DTB): arch-dtbs
$(obj)/dt.dtb: $(DTB) FORCE $(obj)/dt.dtb: $(DTB) FORCE
$(call if_changed,shipped) $(call if_changed,shipped)
targets += dt.dtb
targets += dt.dtb
$(DTB): arch-dtbs $(DTB): arch-dtbs
$(Q)test -e $@ || ( \ $(Q)test -e $@ || ( \
echo >&2; \ echo >&2; \
echo >&2 "Device Tree Source is not correctly specified."; \ echo >&2 "Device Tree Source is not correctly specified."; \
echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'"; \ echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'"; \
echo >&2 "or build with 'DEVICE_TREE=<device_tree>' argument"; \ echo >&2 "or build with 'DEVICE_TREE=<device_tree>' argument"; \
echo >&2; \ echo >&2; \
/bin/false) /bin/false)
arch-dtbs: arch-dtbs:
$(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbs $(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbs
.SECONDARY: $(obj)/dt.dtb.S .SECONDARY: $(obj)/dt.dtb.S
obj-$(CONFIG_OF_EMBED) := dt.dtb.o obj-$(CONFIG_OF_EMBED) := dt.dtb.o
dtbs: $(obj)/dt.dtb dtbs: $(obj)/dt.dtb
@: @:
``` ```
* 最后把u-boot、设备树打包: `make -f ./scripts/Makefile.build obj=arch/arm/imx-common u-boot-dtb.imx` * 最后把u-boot、设备树打包: `make -f ./scripts/Makefile.build obj=arch/arm/imx-common u-boot-dtb.imx`
@@ -472,7 +473,10 @@ endif
### 5.3.2 顶层Makefile ### 5.3.2 顶层Makefile
顶层Makefile里指定了第1个文件head-y、指定了要编译哪些子目录libs-y 顶层Makefile里
* 包含架构相关的Makefile里面指定了第1个文件head-y
* 指定了要编译哪些子目录libs-y
从顶层Makefile开始分析 从顶层Makefile开始分析
@@ -551,7 +555,7 @@ $(u-boot-dirs): prepare scripts
然后使用scripts/Makefile.build进行处理$(Q)$(MAKE) $(build)=$@ ,展开就是: 然后使用scripts/Makefile.build进行处理$(Q)$(MAKE) $(build)=$@ ,展开就是:
```shell ```shell
make -f /scripts/Makefile.build obj=arch/arm/cpu/armv7/ make -f scripts/Makefile.build obj=arch/arm/cpu/armv7/
``` ```
scripts/Makefile.build是编译u-boot源码的关键 scripts/Makefile.build是编译u-boot源码的关键