从零移植uboot 2017 到nuc970(第十二天)

来源:互联网 发布:apmserv php升级5.6 编辑:程序博客网 时间:2024/05/17 04:23
    我再看下uboot2017.3月份,如果这是个bug,一定会有人提出来的
    首先还是贴出来makefile.spl
libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/libs-y += drivers/libs-$(CONFIG_SPL_USB_GADGET_SUPPORT) += drivers/usb/dwc3/libs-y += dts/libs-y += fs/libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/libs-$(CONFIG_SPL_NET_SUPPORT) += net/head-y        := $(addprefix $(obj)/,$(head-y))libs-y        := $(addprefix $(obj)/,$(libs-y))u-boot-spl-dirs    := $(patsubst %/,%,$(filter %/, $(libs-y)))
   也就是说,libs-y 最后是一系列 /spl/drivers/built-in.o的东西,单单拿出来一个考虑
 $(obj)/$(SPL_BIN): $(u-boot-spl-platdata) $(u-boot-spl-init) \        $(u-boot-spl-main) $(obj)/u-boot-spl.lds FORCE    $(call if_changed,u-boot-spl) 

    展开

spl/u-boot-spl:  /spl/drivers/built-in.o             $(call if_changed,u-boot-spl)

    那么问题就在/spl/drivers/built-in.o的依赖怎么产生的。这个.o的产生着实让我不知道在哪里,因为本来这个文件是不存在的。而且一定会有对应的规则吧,找这个规则。先看命令行的详细版:
arm-linux-gcc -x c -DDO_DEPS_ONLY -M -MP -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -O2 -fno-stack-protector -fno-delete-null-pointer-checks -g -fstack-usage -Wno-format-nonliteral   -D__KERNEL__ -D__UBOOT__   -D__ARM__ -marm -mno-thumb-interwork  -mabi=aapcs-linux  -mword-relocations  -fno-pic  -mno-unaligned-access  -ffunction-sections -fdata-sections -fno-common -ffixed-r9  -msoft-float   -pipe -Iinclude  -I./arch/arm/include -include ./include/linux/kconfig.h  -nostdinc -isystem /usr/local/arm_linux_4.8/lib/gcc/arm-nuvoton-linux-uclibceabi/4.8.4/include -MQ include/config/auto.conf ./include/common.h > include/autoconf.mk.dep || { rm include/autoconf.mk.dep; false; }mkdir -p spl/ //这里创建了spl目录arm-linux-gcc -E -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -O2 -fno-stack-protector -fno-delete-null-pointer-checks -g -fstack-usage -Wno-format-nonliteral   -D__KERNEL__ -D__UBOOT__   -D__ARM__ -marm -mno-thumb-interwork  -mabi=aapcs-linux  -mword-relocations  -fno-pic  -mno-unaligned-access  -ffunction-sections -fdata-sections -fno-common -ffixed-r9  -msoft-float   -pipe -Iinclude  -I./arch/arm/include -include ./include/linux/kconfig.h  -nostdinc -isystem /usr/local/arm_linux_4.8/lib/gcc/arm-nuvoton-linux-uclibceabi/4.8.4/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; } 这里创建了spl/u-boot.cfgmkdir -p spl/include/ //创建了/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 创建了这个autoconf.mkarm-linux-gcc -Wp,-MD,cmd/.spl.o.d  -nostdinc -isystem /usr/local/arm_linux_4.8/lib/gcc/arm-nuvoton-linux-uclibceabi/4.8.4/include -Iinclude    -I./arch/arm/include -include ./include/linux/kconfig.h -D__KERNEL__ -D__UBOOT__ -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -Os -fno-stack-protector -fno-delete-null-pointer-checks -g -fstack-usage -Wno-format-nonliteral -D__ARM__ -Wa,-mimplicit-it=always -mthumb -mthumb-interwork -mabi=aapcs-linux -mword-relocations -fno-pic -mno-unaligned-access -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -msoft-float -pipe -march=armv7-a -D__LINUX_ARM_ARCH__=7 -I./arch/arm/mach-omap2/include    -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(spl)"  -D"KBUILD_MODNAME=KBUILD_STR(spl)" -c -o cmd/spl.o cmd/spl.c//命令很多,我特别追踪下drivers,因为就是这里出了问题make -f ./scripts/Makefile.build obj=spl/drivers ///这里没有问题,make -f ./scripts/Makefile.build obj=spl/drivers/block arm-linux-gcc -Wp,-MD,spl/drivers/block/.blk_legacy.o.d  -nostdinc -isystem /usr/local/arm_linux_4.8/lib/gcc/arm-nuvoton-linux-uclibceabi/4.8.4/include -Iinclude    -I./arch/arm/include -include ./include/linux/kconfig.h -D__KERNEL__ -D__UBOOT__ -DCONFIG_SPL_BUILD -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -Os -fno-stack-protector -fno-delete-null-pointer-checks -g -fstack-usage -Wno-format-nonliteral -ffunction-sections -fdata-sections -D__ARM__ -Wa,-mimplicit-it=always -mthumb -mthumb-interwork -mabi=aapcs-linux -mno-unaligned-access -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -msoft-float -pipe -march=armv7-a -D__LINUX_ARM_ARCH__=7 -I./arch/arm/mach-omap2/include    -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(blk_legacy)"  -D"KBUILD_MODNAME=KBUILD_STR(blk_legacy)" -c -o spl/drivers/block/blk_legacy.o drivers/block/blk_legacy.c //最后是关键,原来是由主目录的drivers/xxxx.c生成的
//把全部的都精简下来spl/drivers/block/libata.o drivers/block/libata.carm-linux-ld.bfd     -r -o spl/drivers/block/built-in.o spl/drivers/block/blk_legacy.o spl/drivers/block/ahci.o spl/drivers/block/libata.omake -f ./scripts/Makefile.build obj=spl/drivers/serial  //这是出问题的地方arm-linux-gcc -Wp,-MD,spl/drivers/serial/.serial.o.d  -nostdinc -isystem /usr/local/arm_linux_4.8/lib/gcc/arm-nuvoton-linux-uclibceabi/4.8.4/include -Iinclude    -I./arch/arm/include -include ./include/linux/kconfig.h -D__KERNEL__ -D__UBOOT__ -DCONFIG_SPL_BUILD -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -Os -fno-stack-protector -fno-delete-null-pointer-checks -g -fstack-usage -Wno-format-nonliteral -ffunction-sections -fdata-sections -D__ARM__ -Wa,-mimplicit-it=always -mthumb -mthumb-interwork -mabi=aapcs-linux -mno-unaligned-access -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -msoft-float -pipe -march=armv7-a -D__LINUX_ARM_ARCH__=7 -I./arch/arm/mach-omap2/include    -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(serial)"  -D"KBUILD_MODNAME=KBUILD_STR(serial)" -c -o spl/drivers/serial/serial.o drivers/serial/serial.c  看来是从drivers/serial/serial.c编译的arm-linux-ld.bfd     -r -o spl/drivers/serial/built-in.o spl/drivers/serial/serial.o spl/drivers/serial/serial_ns16550.o spl/drivers/serial/ns16550.o //刚刚一直困扰我的问题就清楚了,原来是这样产生built-in.o的make -f ./scripts/Makefile.build obj=spl/drivers/spiarm-linux-gcc -Wp,-MD,spl/drivers/spi/.spi.o.d  -nostdinc -isystem /usr/local/arm_linux_4.8/lib/gcc/arm-nuvoton-linux-uclibceabi/4.8.4/include -Iinclude    -I./arch/arm/include -include ./include/linux/kconfig.h -D__KERNEL__ -D__UBOOT__ -DCONFIG_SPL_BUILD -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -Os -fno-stack-protector -fno-delete-null-pointer-checks -g -fstack-usage -Wno-format-nonliteral -ffunction-sections -fdata-sections -D__ARM__ -Wa,-mimplicit-it=always -mthumb -mthumb-interwork -mabi=aapcs-linux -mno-unaligned-access -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -msoft-float -pipe -march=armv7-a -D__LINUX_ARM_ARCH__=7 -I./arch/arm/mach-omap2/include    -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(spi)"  -D"KBUILD_MODNAME=KBUILD_STR(spi)" -c -o spl/drivers/spi/spi.o drivers/spi/spi.c    arm-linux-ld.bfd     -r -o spl/drivers/spi/built-in.o spl/drivers/spi/spi.o spl/drivers/spi/ti_qspi.o
   spi.c也是同样的道理,但是有个问题,我如果去掉drivers/spi里面的编译选项 看看还会有spi的编译吗?没有了,ok 同样的,我试下之前的uboot2017.1月分,也是没有的。都正常了,我使用了下在最新的版的默任的里面 am57xx.h,加上CONFIG_SPL_BUILD,最后编译失败,虽然cc的是按照说明文档的方式,但是最后是失败的,为了确认下,是否所有的默认官方的头文件,都不包含CONFIG_SPL_BUILD
  因为我laptop使用的是fedora,我个人一直用linux作为日常操作的系统,所以很好测试下,
 [root@localhost u-boot]# grep '#define CONFIG_SPL_BUILD' -r ./include/configs/./include/configs/am57xx_evm.h:#define CONFIG_SPL_BUILD
  也就是说,除了我刚刚自己添加的,剩下的都没有在头文件定义这个spl_build 关于这个疑问,我要google下,等下午走的时候吧
  现在再看最初的- CONFIG_SPL_BUILD
      Modifies the behaviour of start.S when compiling a loader        that is executed before the actual U-Boot. E.g. when        compiling a NAND SPL. 

  有点哭笑不得,我可能理解不对吧,但是我可以确认的是,网上只要是从原本的默认修改的,比如smdk2410-smdk2440,(新版本可能不这么命名了)总之网上很多从官方默认配置cp,然后做少量修改的,都是没有定义spl的。

   注:其实在make的过程中,会有包含一个文件,其中定义了config_spl_build.如果使用make spl/u-boot.bin,追踪源码就会很清楚。唯一的官方的一个没有解释的地方就是我们是否需要自己定义CONFIG_SPL_BUILD。

 
0 0