[U-Boot] Board-specific commands unintentionally linked into SPL?

Christian Riesch christian.riesch at omicron.at
Thu Jul 26 19:03:42 CEST 2012


[cc'd Prabhakar Lad, Tom Rini, and Scott Wood]

Tyler,

On Thu, Jul 26, 2012 at 5:37 PM, Tyler Olmstead
<tyler.j.olmstead at gmail.com> wrote:
> Hi all,
>
> I have encountered some issues adding a board-specific command to the
> board file of a project I have been working on. Specifically, after
> adding a U-Boot shell command to my board file, I have been seeing
> link-stage failures when attempting to build SPL.

It's hard to tell without having your code, but I think this problem
was already discussed in [1]. However I do not remember how Prabhakar
solved it in the end.

In [1] I suggested to put an

#ifndef CONFIG_SPL_BUILD
U_BOOT_CMD(
...
);
#endif

around the command definition in the board file. But also other
solutions were discussed in that thread, please have a look.

Regards, Christian

[1] http://marc.info/?t=132748548900003

>
> <snip>
>
> UNDEF_SYM=`arm-arago-linux-gnueabi-objdump -x
> /home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/spl/arch/arm/cpu/arm926ejs/davinci/libdavinci.o
> /home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/spl/arch/arm/cpu/arm926ejs/libarm926ejs.o
> /home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/spl/arch/arm/lib/libarm.o
> /home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/spl/board/davinci/da8xxevm/libda8xxevm.o
> /home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/spl/drivers/mtd/nand/libnand.o
> /home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/spl/drivers/serial/libserial.o
> /home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/spl/lib/libgeneric.o
> | sed  -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`; cd
> /home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/spl/ &&
> arm-arago-linux-gnueabi-ld  -T
> /home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/spl/u-boot-spl.lds
> --gc-sections -Bstatic -Ttext 0xc1080000 $UNDEF_SYM
> arch/arm/cpu/arm926ejs/start.o --start-group
> arch/arm/cpu/arm926ejs/davinci/libdavinci.o
> arch/arm/cpu/arm926ejs/libarm926ejs.o arch/arm/lib/libarm.o
> board/davinci/da8xxevm/libda8xxevm.o drivers/mtd/nand/libnand.o
> drivers/serial/libserial.o lib/libgeneric.o --end-group
> /home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/spl/arch/arm/lib/eabi_compat.o
> -L /usr/local/ti-sdk-am180x-evm/linux-devkit/bin/../lib/gcc/arm-arago-linux-gnueabi/4.3.3
> -lgcc -Map u-boot-spl.map -o u-boot-spl
> board/davinci/da8xxevm/libda8xxevm.o: In function `do_mycmd':
> /home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/board/davinci/da8xxevm/awpb3.c:121:
> undefined reference to `eth_get_dev_by_index'
> /home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/board/davinci/da8xxevm/awpb3.c:123:
> undefined reference to `eth_write_hwaddr'
> /home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/board/davinci/da8xxevm/awpb3.c:126:
> undefined reference to `printf'
> make[1]: *** [/home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/spl/u-boot-spl]
> Error 1
> make[1]: Leaving directory
> `/home/tolmstead/tolmstead_lab-OptiPlex-380/uboot/uboot_nand/spl'
> make: *** [spl/u-boot-spl.bin] Error 2
>
> </snip>
>
> In the output above, one can see the environment variable $UNDEF_SYM
> being defined as the result of the following SPL makefile
> (spl/Makefile) target:
>
> GEN_UBOOT = \
>         UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) | \
>         sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
>         cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__START) \
>                 --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
>                 -Map u-boot-spl.map -o u-boot-spl
>
> $(obj)u-boot-spl:       depend $(START) $(LIBS) $(obj)u-boot-spl.lds
>         $(GEN_UBOOT)
>
> For my target, $UNDEF_SYM expands to the following:
> -u__u_boot_cmd_mycmd
>
> As I understand it, this is to force the inclusion of the commands
> into the command table located in the special .u_boot_cmd section so
> that unreferenced commands are not linked out of the final U-Boot
> binary. However, I don't think that the inclusion of commands into the
> SPL is intended. Removing the $UNDEF_SYM variable from the SPL
> makefile resolves my build issues. I am planning on submitting a
> patch. Does anyone see a flaw in my thinking?
>
> Thanks,
> -- Tyler
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot


More information about the U-Boot mailing list