OK6410A 开发板 (三) 5 u-boot-2021.01 boot 解析 u-boot 编译链接部分

1.	Makefile
  GEN     ./Makefile
scripts/kconfig/conf  --syncconfig Kconfig
  UPD     include/config.h
  CFG     u-boot.cfg
  GEN     include/autoconf.mk
  GEN     include/autoconf.mk.dep
  CFG     spl/u-boot.cfg
  GEN     spl/include/autoconf.mk
  UPD     include/config/uboot.release
  Using .. as source for U-Boot
  GEN     ./Makefile

2. UPD     
  UPD     include/generated/version_autogenerated.h
  UPD     include/generated/timestamp_autogenerated.h
  UPD     include/generated/dt.h
  CC      lib/asm-offsets.s
  UPD     include/generated/generic-asm-offsets.h
  CC      arch/arm/lib/asm-offsets.s
  UPD     include/generated/asm-offsets.h
3. scripts/dtc
  HOSTCC  scripts/dtc/dtc.o
  HOSTCC  scripts/dtc/flattree.o
  HOSTCC  scripts/dtc/fstree.o
  HOSTCC  scripts/dtc/data.o
  HOSTCC  scripts/dtc/livetree.o
  HOSTCC  scripts/dtc/treesource.o
  HOSTCC  scripts/dtc/srcpos.o
  HOSTCC  scripts/dtc/checks.o
  HOSTCC  scripts/dtc/util.o
  LEX     scripts/dtc/dtc-lexer.lex.c
  YACC    scripts/dtc/dtc-parser.tab.h
  HOSTCC  scripts/dtc/dtc-lexer.lex.o
  YACC    scripts/dtc/dtc-parser.tab.c
  HOSTCC  scripts/dtc/dtc-parser.tab.o
  HOSTLD  scripts/dtc/dtc
4.tools
  HOSTCC  tools/gen_eth_addr
  HOSTCC  tools/gen_ethaddr_crc.o
  WRAP    tools/lib/crc8.c
  HOSTCC  tools/lib/crc8.o
  HOSTLD  tools/gen_ethaddr_crc
  HOSTCC  tools/img2srec
  HOSTCC  tools/mkenvimage.o
  HOSTCC  tools/os_support.o
  WRAP    tools/lib/crc32.c
  HOSTCC  tools/lib/crc32.o
  HOSTLD  tools/mkenvimage
  HOSTCC  tools/aisimage.o
  HOSTCC  tools/atmelimage.o
  WRAP    tools/common/fdt_region.c
  HOSTCC  tools/common/fdt_region.o
  WRAP    tools/common/bootm.c
  HOSTCC  tools/common/bootm.o
  HOSTCC  tools/default_image.o
  WRAP    tools/lib/fdtdec_common.c
  HOSTCC  tools/lib/fdtdec_common.o
  WRAP    tools/lib/fdtdec.c
  HOSTCC  tools/lib/fdtdec.o
  WRAP    tools/common/image.c
  HOSTCC  tools/common/image.o
  HOSTCC  tools/imagetool.o
  HOSTCC  tools/imximage.o
  HOSTCC  tools/imx8image.o
  HOSTCC  tools/imx8mimage.o
  HOSTCC  tools/kwbimage.o
  WRAP    tools/lib/md5.c
  HOSTCC  tools/lib/md5.o
  HOSTCC  tools/lpc32xximage.o
  HOSTCC  tools/mxsimage.o
  HOSTCC  tools/omapimage.o
  HOSTCC  tools/pblimage.o
  HOSTCC  tools/pbl_crc32.o
  HOSTCC  tools/vybridimage.o
  HOSTCC  tools/stm32image.o
  WRAP    tools/lib/rc4.c
  HOSTCC  tools/lib/rc4.o
  HOSTCC  tools/rkcommon.o
  HOSTCC  tools/rkimage.o
  HOSTCC  tools/rksd.o
  HOSTCC  tools/rkspi.o
  HOSTCC  tools/socfpgaimage.o
  WRAP    tools/lib/crc16.c
  HOSTCC  tools/lib/crc16.o
  WRAP    tools/lib/sha1.c
  HOSTCC  tools/lib/sha1.o
  WRAP    tools/lib/sha256.c
  HOSTCC  tools/lib/sha256.o
  WRAP    tools/lib/sha512.c
  HOSTCC  tools/lib/sha512.o
  WRAP    tools/common/hash.c
  HOSTCC  tools/common/hash.o
  HOSTCC  tools/ublimage.o
  HOSTCC  tools/zynqimage.o
  HOSTCC  tools/zynqmpimage.o
  HOSTCC  tools/zynqmpbif.o
  HOSTCC  tools/libfdt/fdt.o
  HOSTCC  tools/libfdt/fdt_ro.o
  HOSTCC  tools/libfdt/fdt_wip.o
  HOSTCC  tools/libfdt/fdt_sw.o
  HOSTCC  tools/libfdt/fdt_rw.o
  HOSTCC  tools/libfdt/fdt_strerror.o
  HOSTCC  tools/libfdt/fdt_empty_tree.o
  HOSTCC  tools/libfdt/fdt_addresses.o
  HOSTCC  tools/libfdt/fdt_overlay.o
  HOSTCC  tools/gpimage.o
  HOSTCC  tools/gpimage-common.o
  HOSTCC  tools/mtk_image.o
  HOSTCC  tools/dumpimage.o
  HOSTLD  tools/dumpimage
  HOSTCC  tools/mkimage.o
  HOSTLD  tools/mkimage
  HOSTCC  tools/proftool
  HOSTCC  tools/fdtgrep.o
  HOSTLD  tools/fdtgrep
  HOSTCC  tools/spl_size_limit

5. arch/arm/cpu					架构,微架构代码
6. arch/arm/lib 				arm架构通用库
7. arch/arm/mach-s3c64xx 		soc相关代码
8. arch/arm/cpu/arm1176/start.S 	reset符号在的文件	
9. board/samsung/ok6410a/ok6410a.c 板级相关代码
10. 板级库 board/samsung/ok6410a/lowlevel_init.S board/samsung/ok6410a/bl2_mmc_copy.c (链接脚本中指明了链接)
11. cmd/
12. common/	
13. common/init 					
14.lib 							
15.disk 						块驱动
16.drivers						驱动
17.env 						
18.fs 	
19.net
20.u-boot.lds 				链接脚本的生成
21.u-boot 					
22.其他镜像相关文件 u-boot.srec u-boot-nodtb.bin
23. arch/arm/dts/s3c64xx-ok6410a.dtb dts/dt.dtb  dts/dt-spl.dtb
24. u-boot-dtb.bin u-boot.bin u-boot.sym u-boot.img u-boot.dtb u-boot-dtb.img


以上过程分成x种 
	1. Makefile
	2. UPD
	3. scripts/dtc
	4. tools
	5. .o文件的生成
	6. built-in.o 的生成
	7. 链接脚本u-boot.lds的生成
	8. u-boot 的生成 
	9. dtb的生成
	10. 其他镜像相关文件的生成

  • 1 Makefile
make -f ../scripts/Makefile.build obj=scripts/basic
rm -f .tmp_quiet_recordmcount
ln -fsn .. source
/bin/bash ../scripts/mkmakefile \
    .. . 2021 01
  GEN     ./Makefile


scripts/kconfig/conf  --syncconfig Kconfig
make -f ../scripts/Makefile.autoconf || \
	{
    
     rm -f include/config/auto.conf; false; }
mkdir -p include/asm
if [ -d /home/suws/ok6410/system-new/u-boot/arch/arm/mach-s3c64xx/include/mach ]; then	\
	dest=arch/arm/mach-s3c64xx/include/mach;			\
else									\
	dest=arch/arm/include/asm/arch-s3c64xx;	\
fi;									\
ln -fsn /home/suws/ok6410/system-new/u-boot/$dest include/asm/arch
set -e; mkdir -p include/; 	(echo "/* Automatically generated - do not edit */"; for i in $(echo "" | sed 's/,/ /g'); do echo \#define CONFIG_$i | sed '/=/ {s/=/	/;q; } ; { s/$/	1/; }'; done; echo \#define CONFIG_BOARDDIR board/samsung/ok6410a; echo \#include \<config_uncmd_spl.h\>; echo \#include \<configs/"ok6410a".h\>; echo \#include \<asm/config.h\>; echo \#include \<linux/kconfig.h\>; echo \#include \<config_fallbacks.h\>;) < ../scripts/Makefile.autoconf > include/config.h.tmp; if [ -r include/config.h ] && cmp -s include/config.h include/config.h.tmp; then rm -f include/config.h.tmp; else : '  UPD     include/config.h'; mv -f include/config.h.tmp include/config.h; fi

arm-linux-gnueabi-gcc -E -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing -fno-PIE -O2 -fno-stack-protector -fno-delete-null-pointer-checks  -Wno-maybe-uninitialized  -g -fstack-usage -Wno-format-nonliteral  -Wno-unused-but-set-variable -Werror=date-time  -D__KERNEL__ -D__UBOOT__   -D__ARM__ -marm -mno-thumb-interwork  -mabi=aapcs-linux  -mword-relocations  -fno-pic  -ffunction-sections -fdata-sections -fno-common -ffixed-r9  -msoft-float    -pipe -Iinclude  -I../include -I../arch/arm/include -include ../include/linux/kconfig.h  -nostdinc -isystem /home/suws/ok6410/system-new/toolchain/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/7.4.1/include  -DDO_DEPS_ONLY -dM ../include/common.h > u-boot.cfg.tmp && {
    
     grep 'define CONFIG_' u-boot.cfg.tmp > u-boot.cfg; rm u-boot.cfg.tmp; } || {
    
     rm u-boot.cfg.tmp; false; }

  sed -n -f ../tools/scripts/define2mk.sed u-boot.cfg | while read line; do if [ -n "" ] || ! grep -q "${line%=*}=" include/config/auto.conf; then echo "$line"; fi done > include/autoconf.mk


  arm-linux-gnueabi-gcc -x c -DDO_DEPS_ONLY -M -MP -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing -fno-PIE -O2 -fno-stack-protector -fno-delete-null-pointer-checks  -Wno-maybe-uninitialized  -g -fstack-usage -Wno-format-nonliteral  -Wno-unused-but-set-variable -Werror=date-time  -D__KERNEL__ -D__UBOOT__   -D__ARM__ -marm -mno-thumb-interwork  -mabi=aapcs-linux  -mword-relocations  -fno-pic  -ffunction-sections -fdata-sections -fno-common -ffixed-r9  -msoft-float    -pipe -Iinclude  -I../include -I../arch/arm/include -include ../include/linux/kconfig.h  -nostdinc -isystem /home/suws/ok6410/system-new/toolchain/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/7.4.1/include -MQ include/config/auto.conf ../include/common.h > include/autoconf.mk.dep || {
    
     rm include/autoconf.mk.dep; false; }


mkdir -p spl/
  arm-linux-gnueabi-gcc -E -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing -fno-PIE -O2 -fno-stack-protector -fno-delete-null-pointer-checks  -Wno-maybe-uninitialized  -g -fstack-usage -Wno-format-nonliteral  -Wno-unused-but-set-variable -Werror=date-time  -D__KERNEL__ -D__UBOOT__   -D__ARM__ -marm -mno-thumb-interwork  -mabi=aapcs-linux  -mword-relocations  -fno-pic  -ffunction-sections -fdata-sections -fno-common -ffixed-r9  -msoft-float    -pipe -Iinclude  -I../include -I../arch/arm/include -include ../include/linux/kconfig.h  -nostdinc -isystem /home/suws/ok6410/system-new/toolchain/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/7.4.1/include -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM ../include/common.h > spl/u-boot.cfg.tmp && {
    
     grep 'define CONFIG_' spl/u-boot.cfg.tmp > spl/u-boot.cfg; rm spl/u-boot.cfg.tmp; } || {
    
     rm spl/u-boot.cfg.tmp; false; }

mkdir -p spl/include/
  sed -n -f ../tools/scripts/define2mk.sed spl/u-boot.cfg | while read line; do if [ -n "" ] || ! grep -q "${line%=*}=" include/config/auto.conf; then echo "$line"; fi done > spl/include/autoconf.mk
touch include/config/auto.conf

set -e; mkdir -p include/config/; 	echo "2021.01$(/bin/bash ../scripts/setlocalversion ..)" < include/config/auto.conf > include/config/uboot.release.tmp; if [ -r include/config/uboot.release ] && cmp -s include/config/uboot.release include/config/uboot.release.tmp; then rm -f include/config/uboot.release.tmp; else : '  UPD     include/config/uboot.release'; mv -f include/config/uboot.release.tmp include/config/uboot.release; fi
if [ -f ../.config -o -d ../include/config ]; then \
	echo >&2 "  .. is not clean, please run 'make mrproper'"; \
	echo >&2 "  in the '..' directory.";\
	/bin/false; \
fi;

Makefile
	prepare3: include/config/uboot.release                                           
	ifneq ($(KBUILD_SRC),)                                                           
	    @$(kecho) '  Using $(srctree) as source for U-Boot'

ln -fsn .. source
/bin/bash ../scripts/mkmakefile \
    .. . 2021 01
  GEN     ./Makefile

  • 2 UPD

set -e; mkdir -p include/generated/; 	(echo \#define PLAIN_VERSION \"2021.01""-00010-gc3a300e\"; echo \#define U_BOOT_VERSION \"U-Boot \" PLAIN_VERSION; echo \#define CC_VERSION_STRING \"$(LC_ALL=C arm-linux-gnueabi-gcc --version | head -n 1)\"; echo \#define LD_VERSION_STRING \"$(LC_ALL=C arm-linux-gnueabi-ld.bfd --version | head -n 1)\"; ) < include/config/uboot.release > include/generated/version_autogenerated.h.tmp; if [ -r include/generated/version_autogenerated.h ] && cmp -s include/generated/version_autogenerated.h include/generated/version_autogenerated.h.tmp; then rm -f include/generated/version_autogenerated.h.tmp; else : '  UPD     include/generated/version_autogenerated.h'; mv -f include/generated/version_autogenerated.h.tmp include/generated/version_autogenerated.h; fi

set -e; mkdir -p include/generated/; 	(if test -n "${SOURCE_DATE_EPOCH}"; then SOURCE_DATE="@${SOURCE_DATE_EPOCH}"; DATE=""; for date in gdate date.gnu date; do ${
    
    date} -u -d "${SOURCE_DATE}" >/dev/null 2>&1 && DATE="${date}"; done; if test -n "${DATE}"; then LC_ALL=C ${
    
    DATE} -u -d "${SOURCE_DATE}" +'#define U_BOOT_DATE "%b %d %C%y"'; LC_ALL=C ${
    
    DATE} -u -d "${SOURCE_DATE}" +'#define U_BOOT_TIME "%T"'; LC_ALL=C ${
    
    DATE} -u -d "${SOURCE_DATE}" +'#define U_BOOT_TZ "%z"'; LC_ALL=C ${
    
    DATE} -u -d "${SOURCE_DATE}" +'#define U_BOOT_DMI_DATE "%m/%d/%Y"'; LC_ALL=C ${
    
    DATE} -u -d "${SOURCE_DATE}" +'#define U_BOOT_BUILD_DATE 0x%Y%m%d'; LC_ALL=C ${
    
    DATE} -u -d "${SOURCE_DATE}" +'#define U_BOOT_EPOCH %s'; else return 42; fi; else LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; LC_ALL=C date +'#define U_BOOT_TIME "%T"'; LC_ALL=C date +'#define U_BOOT_TZ "%z"'; LC_ALL=C date +'#define U_BOOT_DMI_DATE "%m/%d/%Y"'; LC_ALL=C date +'#define U_BOOT_BUILD_DATE 0x%Y%m%d'; LC_ALL=C date +'#define U_BOOT_EPOCH %s'; fi) < ../Makefile > include/generated/timestamp_autogenerated.h.tmp; if [ -r include/generated/timestamp_autogenerated.h ] && cmp -s include/generated/timestamp_autogenerated.h include/generated/timestamp_autogenerated.h.tmp; then rm -f include/generated/timestamp_autogenerated.h.tmp; else : '  UPD     include/generated/timestamp_autogenerated.h'; mv -f include/generated/timestamp_autogenerated.h.tmp include/generated/timestamp_autogenerated.h; fi

set -e; mkdir -p include/generated/; 	(if test -n "${DEVICE_TREE}"; then echo \#define DEVICE_TREE \"\"; else echo \#define DEVICE_TREE CONFIG_DEFAULT_DEVICE_TREE; fi) < ../Makefile > include/generated/dt.h.tmp; if [ -r include/generated/dt.h ] && cmp -s include/generated/dt.h include/generated/dt.h.tmp; then rm -f include/generated/dt.h.tmp; else : '  UPD     include/generated/dt.h'; mv -f include/generated/dt.h.tmp include/generated/dt.h; fi

make -f ../scripts/Makefile.build obj=scripts/basic
rm -f .tmp_quiet_recordmcount
make -f ../scripts/Makefile.build obj=.
  arm-linux-gnueabi-gcc -Wp,-MD,lib/.asm-offsets.s.d  -nostdinc -isystem /home/suws/ok6410/system-new/toolchain/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/7.4.1/include -Iinclude  -I../include  -I../arch/arm/include -include ../include/linux/kconfig.h  -I../. -I. -D__KERNEL__ -D__UBOOT__ -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing -fno-PIE -Os -fno-stack-protector -fno-delete-null-pointer-checks -Wno-maybe-uninitialized -g -fstack-usage -Wno-format-nonliteral -Wno-unused-but-set-variable -Werror=date-time -D__ARM__ -marm -mno-thumb-interwork -mabi=aapcs-linux -mword-relocations -fno-pic -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -msoft-float -pipe -march=armv5t -D__LINUX_ARM_ARCH__=6  -I../arch/arm/mach-s3c64xx/include -DDO_DEPS_ONLY    -DKBUILD_BASENAME='"asm_offsets"'  -DKBUILD_MODNAME='"asm_offsets"'  -fverbose-asm -S -o lib/asm-offsets.s ../lib/asm-offsets.c

set -e; mkdir -p include/generated/; 	(set -e; echo "#ifndef __GENERIC_ASM_OFFSETS_H__"; echo "#define __GENERIC_ASM_OFFSETS_H__"; echo "/*"; echo " * DO NOT MODIFY."; echo " *"; echo " * This file was generated by Kbuild"; echo " */"; echo ""; sed -ne 	"s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; /^->/{s:->#\(.*\):/* \1 */:; s:^->\([^ ]*\) [\$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; s:^->\([^ ]*\) [\$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; echo ""; echo "#endif" ) < lib/asm-offsets.s > include/generated/generic-asm-offsets.h.tmp; if [ -r include/generated/generic-asm-offsets.h ] && cmp -s include/generated/generic-asm-offsets.h include/generated/generic-asm-offsets.h.tmp; then rm -f include/generated/generic-asm-offsets.h.tmp; else : '  UPD     include/generated/generic-asm-offsets.h'; mv -f include/generated/generic-asm-offsets.h.tmp include/generated/generic-asm-offsets.h; fi

  arm-linux-gnueabi-gcc -Wp,-MD,arch/arm/lib/.asm-offsets.s.d  -nostdinc -isystem /home/suws/ok6410/system-new/toolchain/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/7.4.1/include -Iinclude  -I../include  -I../arch/arm/include -include ../include/linux/kconfig.h  -I../. -I. -D__KERNEL__ -D__UBOOT__ -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing -fno-PIE -Os -fno-stack-protector -fno-delete-null-pointer-checks -Wno-maybe-uninitialized -g -fstack-usage -Wno-format-nonliteral -Wno-unused-but-set-variable -Werror=date-time -D__ARM__ -marm -mno-thumb-interwork -mabi=aapcs-linux -mword-relocations -fno-pic -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -msoft-float -pipe -march=armv5t -D__LINUX_ARM_ARCH__=6  -I../arch/arm/mach-s3c64xx/include -DDO_DEPS_ONLY    -DKBUILD_BASENAME='"asm_offsets"'  -DKBUILD_MODNAME='"asm_offsets"'  -fverbose-asm -S -o arch/arm/lib/asm-offsets.s ../arch/arm/lib/asm-offsets.c

set -e; mkdir -p include/generated/; 	(set -e; echo "#ifndef __ASM_OFFSETS_H__"; echo "#define __ASM_OFFSETS_H__"; echo "/*"; echo " * DO NOT MODIFY."; echo " *"; echo " * This file was generated by Kbuild"; echo " */"; echo ""; sed -ne 	"s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; /^->/{s:->#\(.*\):/* \1 */:; s:^->\([^ ]*\) [\$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; s:^->\([^ ]*\) [\$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; echo ""; echo "#endif" ) < arch/arm/lib/asm-offsets.s > include/generated/asm-offsets.h.tmp; if [ -r include/generated/asm-offsets.h ] && cmp -s include/generated/asm-offsets.h include/generated/asm-offsets.h.tmp; then rm -f include/generated/asm-offsets.h.tmp; else : '  UPD     include/generated/asm-offsets.h'; mv -f include/generated/asm-offsets.h.tmp include/generated/asm-offsets.h; fi
  • 3 dtc
make -f ../scripts/Makefile.build obj=scripts
make -f ../scripts/Makefile.build obj=scripts/dtc
  cc 
  	-Wp,-MD,scripts/dtc/.dtc.o.d 
  	-Iscripts/dtc 
  	-Wall 
  	-Wstrict-prototypes 
  	-O2 
  	-fomit-frame-pointer 
  		// 对于不需要帧指针的函数,不要将帧指针保留在寄存器中
  	-std=gnu11  
  	-I../scripts/dtc/libfdt 
  	-c -o scripts/dtc/dtc.o ../scripts/dtc/dtc.c
  	
...

 cc   -o scripts/dtc/dtc scripts/dtc/dtc.o scripts/dtc/flattree.o scripts/dtc/fstree.o scripts/dtc/data.o scripts/dtc/livetree.o scripts/dtc/treesource.o scripts/dtc/srcpos.o scripts/dtc/checks.o scripts/dtc/util.o scripts/dtc/dtc-lexer.lex.o scripts/dtc/dtc-parser.tab.o 
  • 4 tools
make -f ../scripts/Makefile.build obj=tools
cc -Wp,-MD,tools/.gen_eth_addr.d -Itools -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu11 -include ../include/compiler.h 
-idirafterinclude 
	// -idirafter dir
	// 在dir中搜索头文件,但是在用-I指定的所有目录和标准系统目录都用完之后再执行。
	// dir被视为系统包含目录。
	// 如果dir以“=”开头,那么“=”将被sysroot中的内容替换;请参见--sysroot和-isysroot。
-idirafter../include -idirafter../arch/arm/include  -I../scripts/dtc/libfdt  -I../tools -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES -D_GNU_SOURCE -std=gnu99 
-pedantic 
	// ISO和ISO C++要求的所有警告都会输出
	// 拒绝使用禁止扩展的所有程序,以及不遵循ISO和ISO C++的其他程序。
	// 对于ISO C,遵循使用的任何-std选项指定的ISO C标准版本。
-o tools/gen_eth_addr ../tools/gen_eth_addr.c 
...
cc -Wp,-MD,tools/.spl_size_limit.d -Itools -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu11 -include ../include/compiler.h -idirafterinclude -idirafter../include -idirafter../arch/arm/include  -I../scripts/dtc/libfdt  -I../tools -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES -D_GNU_SOURCE -std=gnu99 -o tools/spl_size_limit ../tools/spl_size_limit.c
  • 5 .o文件的生成
arm-linux-gnueabi-gcc -Wp,-MD,arch/arm/cpu/arm1176/.start.o.d  -nostdinc -isystem /home/suws/ok6410/system-new/toolchain/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/7.4.1/include -Iinclude  -I../include  -I../arch/arm/include -include ../include/linux/kconfig.h -D__KERNEL__ -D__UBOOT__ -D__ASSEMBLY__ -fno-PIE -g -D__ARM__ -marm -mno-thumb-interwork -mabi=aapcs-linux 
-mword-relocations 
	// 仅对字大小的值(即R_ARM_ABS32)生成绝对重定位。
	// 默认情况下,在运行时加载程序施加此限制的目标(uClinux、SymbianOS)上以及指定-fpic或-fpic时,都会启用此功能。
-fno-pic -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -msoft-float -pipe -march=armv5t -D__LINUX_ARM_ARCH__=6  -I../arch/arm/mach-s3c64xx/include   -c -o arch/arm/cpu/arm1176/start.o ../arch/arm/cpu/arm1176/start.S
  • 6 built-in.o 的生成
arm-linux-gnueabi-ld.bfd     -r -o arch/arm/mach-s3c64xx/built-in.o arch/arm/mach-s3c64xx/timer.o arch/arm/mach-s3c64xx/clock.o arch/arm/mach-s3c64xx/cpu.o arch/arm/mach-s3c64xx/cpu_init.o
  • 7 链接脚本u-boot.lds的生成
arm-linux-gnueabi-gcc -E -Wp,-MD,./.u-boot.lds.d -D__KERNEL__ -D__UBOOT__   -D__ARM__ -marm -mno-thumb-interwork  -mabi=aapcs-linux  -mword-relocations  -fno-pic  -ffunction-sections -fdata-sections -fno-common -ffixed-r9  -msoft-float    -pipe -march=armv5t -D__LINUX_ARM_ARCH__=6  -I../arch/arm/mach-s3c64xx/include -Iinclude  -I../include  -I../arch/arm/include -include ../include/linux/kconfig.h  -nostdinc -isystem /home/suws/ok6410/system-new/toolchain/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/7.4.1/include -ansi -include ../include/u-boot/u-boot.lds.h -DCPUDIR=arch/arm/cpu/arm1176  -D__ASSEMBLY__ -x assembler-with-cpp -std=c99 -P -o u-boot.lds ../board/samsung/ok6410a/u-boot.lds
  • 8 u-boot 的生成
arm-linux-gnueabi-ld.bfd  
-pie  
	// 创建独立于位置的可执行文件。
	// 目前只有ELF平台支持这一点。
	// 位置无关的可执行文件与共享库类似,因为动态链接器会将它们重新定位到操作系统为它们选择的虚拟地址(在调用之间可能有所不同)。
	// 与普通的动态链接可执行文件一样,它们可以被执行,而在可执行文件中定义的符号不能被共享库覆盖
--gc-sections -Bstatic  --no-dynamic-linker -Ttext 0x5FB00000 -o u-boot -T u-boot.lds arch/arm/cpu/arm1176/start.o 
--start-group  
arch/arm/cpu/built-in.o  arch/arm/cpu/arm1176/built-in.o  arch/arm/lib/built-in.o  arch/arm/mach-s3c64xx/built-in.o  board/samsung/common/built-in.o  board/samsung/ok6410a/built-in.o  cmd/built-in.o  common/built-in.o  disk/built-in.o  drivers/built-in.o  drivers/dma/built-in.o  drivers/gpio/built-in.o  drivers/i2c/built-in.o  drivers/net/built-in.o  drivers/net/phy/built-in.o  drivers/power/built-in.o  drivers/power/battery/built-in.o  drivers/power/domain/built-in.o  drivers/power/fuel_gauge/built-in.o  drivers/power/mfd/built-in.o  drivers/power/pmic/built-in.o  drivers/power/regulator/built-in.o  drivers/serial/built-in.o  drivers/spi/built-in.o  drivers/usb/cdns3/built-in.o  drivers/usb/common/built-in.o  drivers/usb/dwc3/built-in.o  drivers/usb/emul/built-in.o  drivers/usb/eth/built-in.o  drivers/usb/host/built-in.o  drivers/usb/mtu3/built-in.o  drivers/usb/musb-new/built-in.o  drivers/usb/musb/built-in.o  drivers/usb/phy/built-in.o  drivers/usb/ulpi/built-in.o  env/built-in.o  fs/built-in.o  lib/built-in.o  net/built-in.o 
--end-group 
arch/arm/lib/eabi_compat.o  arch/arm/lib/lib.a -Map u-boot.map;  true
  • 9 dtb的生成
make -f ../scripts/Makefile.build obj=dts dtbs
make -f ../scripts/Makefile.build obj=arch/arm/dts dtbs
  mkdir -p arch/arm/dts/ ; (cat ../arch/arm/dts/s3c64xx-ok6410a.dts; ) > arch/arm/dts/.s3c64xx-ok6410a.dtb.pre.tmp; 

  arm-linux-gnueabi-gcc -E -Wp,-MD,arch/arm/dts/.s3c64xx-ok6410a.dtb.d.pre.tmp -nostdinc -I../arch/arm/dts -I../arch/arm/dts/include -Iinclude -I../include -I../arch/arm/include -include ../include/linux/kconfig.h -D__ASSEMBLY__ 
  -undef 
  	// 不要预定义任何特定于系统或GCC的宏。
  	// 标准预定义宏仍处于定义状态。
  -D__DTS__ -x assembler-with-cpp -o arch/arm/dts/.s3c64xx-ok6410a.dtb.dts.tmp arch/arm/dts/.s3c64xx-ok6410a.dtb.pre.tmp ;
	
	// 生成 arch/arm/dts/s3c64xx-ok6410a.dtb
  ./scripts/dtc/dtc -O dtb -o arch/arm/dts/s3c64xx-ok6410a.dtb -b 0 -i ../arch/arm/dts/  -Wno-unit_address_vs_reg -Wno-unit_address_format -Wno-avoid_unnecessary_addr_size -Wno-alias_paths -Wno-graph_child_address -Wno-graph_port -Wno-unique_unit_address -Wno-simple_bus_reg -Wno-pci_device_reg -Wno-pci_bridge -Wno-pci_device_bus_num   -Wno-unit_address_vs_reg -Wno-unit_address_format -Wno-avoid_unnecessary_addr_size -Wno-alias_paths -Wno-graph_child_address -Wno-graph_port -Wno-unique_unit_address -Wno-simple_bus_reg -Wno-pci_device_reg -Wno-pci_bridge -Wno-pci_device_bus_num  -d arch/arm/dts/.s3c64xx-ok6410a.dtb.d.dtc.tmp 
  arch/arm/dts/.s3c64xx-ok6410a.dtb.dts.tmp 
  || (echo "Check /home/suws/ok6410/system-new/u-boot/output/arch/arm/dts/.s3c64xx-ok6410a.dtb.pre.tmp for errors" && false) ; 

  cat arch/arm/dts/.s3c64xx-ok6410a.dtb.d.pre.tmp arch/arm/dts/.s3c64xx-ok6410a.dtb.d.dtc.tmp > arch/arm/dts/.s3c64xx-ok6410a.dtb.d ; 
  sed -i "s:arch/arm/dts/.s3c64xx-ok6410a.dtb.pre.tmp:../arch/arm/dts/s3c64xx-ok6410a.dts:" arch/arm/dts/.s3c64xx-ok6410a.dtb.d
  
test -e arch/arm/dts/s3c64xx-ok6410a.dtb || (						\
echo >&2;							\
echo >&2 "Device Tree Source is not correctly specified.";	\
echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'";		\
echo >&2 "or build with 'DEVICE_TREE=<device_tree>' argument";	\
echo >&2;							\
/bin/false)

cat arch/arm/dts/s3c64xx-ok6410a.dtb > dts/dt.dtb
  • 10 其他镜像相关文件的生成
// u-boot相关
arm-linux-gnueabi-objdump -t u-boot > u-boot.sym

arm-linux-gnueabi-objcopy 
--gap-fill=0xff  
	// 用val填充节之间的间隙。
	// 此操作适用于段的加载地址(LMA)。
	// 它是通过增加具有较低地址的节的大小,并填充用val创建的额外空间来完成的。
-j .text -j .secure_text -j .secure_data -j .rodata -j .hash -j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn -j .binman_sym_table -j .text_rest -j .dtb.init.rodata 
-O srec u-boot u-boot.srec
  
arm-linux-gnueabi-objcopy --gap-fill=0xff  -j .text -j .secure_text -j .secure_data -j .rodata -j .hash -j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn -j .binman_sym_table -j .text_rest -j .dtb.init.rodata 
-O binary   u-boot u-boot-nodtb.bin && {
    
      echo '  true'; true; } || rm -f u-boot-nodtb.bin
  true

// dts 相关
./tools/fdtgrep -b u-boot,dm-pre-reloc -b u-boot,dm-spl -RT arch/arm/dts/s3c64xx-ok6410a.dtb -n /chosen -n /config -O dtb | ./tools/fdtgrep -r -O dtb - 
-o dts/dt-spl.dtb -P u-boot,dm-pre-reloc -P u-boot,dm-spl -P u-boot,dm-tpl 
 
// dts 与 u-boot-nodtb 合成 u-boot 
cat u-boot-nodtb.bin dts/dt.dtb > u-boot-dtb.bin
cp u-boot-dtb.bin u-boot.bin


编译的目录

arch/arm/cpu/arm1176
arch/arm/cpu/arm1176/../arm11
arch/arm/dts
arch/arm/lib
arch/arm/mach-s3c64xx
board/samsung/ok6410a
cmd
common
common/init
disk
drivers/block
drivers/clk
drivers/core
drivers/crypto/fsl
drivers/gpio
drivers/i2c
drivers/input
drivers/mmc
drivers/net
drivers/rtc
drivers/serial
drivers/spi
dts
env
fs
fs/fat
include
include/config
include/generated
lib
lib/libfdt
lib/zlib
net
scripts/dtc
tools
tools/common
tools/lib
tools/libfdt

猜你喜欢

转载自blog.csdn.net/u011011827/article/details/115025466