[meta-freescale] Unable to get u-boot running on i.MX6 SABRE for Smart Devices Eval Board

Guillaume Fournier gfournier at brioconcept.com
Thu Nov 6 09:31:35 PST 2014


I was able to get the board to boot this morning.

The problem had to do with this error message I got when building u-boot
with my Yocto generated toolchain:
"arm-poky-linux-gnueabi-ld.bfd: cannot find -lgcc"

To solve this problem, I initially went looking on the web and found this:
https://lists.yoctoproject.org/pipermail/yocto/2013-October/016385.html

Basically u-boot top level Makefile contains:
PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS)
-print-libgcc-file-name`) -lgcc
The above call gets resolved to "-L ."  Doing ${CC} -print-libgcc-file-name
shows the proper value. The reason for this is that U-Boot does not pickup
$CC from our environment (which is including the --sysroot option). Without
this option -print-libgcc-file-name resolve to a simple file name without a
path. And thus dirname resolve it further to "."  So the fix suggested was
to do: make LDFLAGS="" CC="$CC" This passes the ${CC} environment variable
to the Makefile which in turns resolve the PLATFORM_LIBGCC correctly.

However, this had other implications.  One of them changed -mfloat-abi=soft
to hard and, I believe, rendered the binary/imx file unusable on the target
(it might however be for another reason that it was not booting... keep on
reading).

A better solution is to add the following line in the
environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi script:
export KCFLAGS="--sysroot=$SDKTARGETSYSROOT"

This KCFLAGS gets appended to the CFLAGS in the top level Makefile of
u-boot.  PLATFORM_LIBGCC now returns a valid lgcc path and no other flags
are modified (-mfloat-abi remains soft).



So, here is a build command before any modifications:

arm-poky-linux-gnueabi-gcc -Wp,-MD,fs/fat/.fat.o.d  -nostdinc -isystem
/media/sdb/gfournier/axiondev/toolchain/sysroots/x86_64-pokysdk-linux/usr/bi
n/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux
-gnueabi/4.9.1/include -Iinclude
-I/media/sdb/gfournier/axiondev/u-boot-fslc/arch/arm/include -include
/media/sdb/gfournier/axiondev/u-boot-fslc/include/linux/kconfig.h
-D__KERNEL__ -D__UBOOT__ -DCONFIG_SYS_TEXT_BASE=0x17800000 -Wall
-Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -Os
-fno-stack-protector -g -fstack-usage -Wno-format-nonliteral
-Werror=date-time -D__ARM__ -marm -mno-thumb-interwork -mabi=aapcs-linux
-mword-relocations -march=armv7-a -mno-unaligned-access -ffunction-sections
-fdata-sections -fno-common -ffixed-r9 -msoft-float -pipe
-D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(fat)"
-D"KBUILD_MODNAME=KBUILD_STR(fat)" -c -o fs/fat/fat.o fs/fat/fat.c

The previous build without any modifications was not finding lgcc (it's
missing the --sysroot argument).



Here is a build command after the KCFLAGS modification in
environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi.  Not the added
--sysroot:

arm-poky-linux-gnueabi-gcc -Wp,-MD,net/.arp.o.d  -nostdinc -isystem
/media/sdb/gfournier/axiondev/toolchain/sysroots/x86_64-pokysdk-linux/usr/bi
n/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux
-gnueabi/4.9.1/include -Iinclude
-I/media/sdb/gfournier/axiondev/u-boot-fslc/arch/arm/include -include
/media/sdb/gfournier/axiondev/u-boot-fslc/include/linux/kconfig.h
-D__KERNEL__ -D__UBOOT__ -DCONFIG_SYS_TEXT_BASE=0x17800000 -Wall
-Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -Os
-fno-stack-protector -g -fstack-usage -Wno-format-nonliteral
-Werror=date-time
--sysroot=/media/sdb/gfournier/axiondev/toolchain/sysroots/cortexa9hf-vfp-ne
on-poky-linux-gnueabi -D__ARM__ -marm -mno-thumb-interwork -mabi=aapcs-linux
-mword-relocations -march=armv7-a -mno-unaligned-access -ffunction-sections
-fdata-sections -fno-common -ffixed-r9 -msoft-float -pipe
-D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(arp)"
-D"KBUILD_MODNAME=KBUILD_STR(arp)" -c -o net/arp.o net/arp.c

The previous build with the KCFLAGS modification is performing as expected
and binary is usable and boots fine.



Here is a build command when calling make LDFLAGS="" CC="$CC" without the
KCFLAGS modification:

arm-poky-linux-gnueabi-gcc  -march=armv7-a -mthumb-interwork
-mfloat-abi=hard -mfpu=neon -mtune=cortex-a9
--sysroot=/media/sdb/gfournier/axiondev/toolchain/sysroots/cortexa9hf-vfp-ne
on-poky-linux-gnueabi -Wp,-MD,net/.bootp.o.d  -nostdinc -isystem
/media/sdb/gfournier/axiondev/toolchain/sysroots/x86_64-pokysdk-linux/usr/bi
n/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux
-gnueabi/4.9.1/include -Iinclude
-I/media/sdb/gfournier/axiondev/u-boot-fslc/arch/arm/include -include
/media/sdb/gfournier/axiondev/u-boot-fslc/include/linux/kconfig.h
-D__KERNEL__ -D__UBOOT__ -DCONFIG_SYS_TEXT_BASE=0x17800000 -Wall
-Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -Os
-fno-stack-protector -g -fstack-usage -Wno-format-nonliteral
-Werror=date-time -D__ARM__ -marm -mno-thumb-interwork -mabi=aapcs-linux
-mword-relocations -march=armv7-a -mno-unaligned-access -ffunction-sections
-fdata-sections -fno-common -ffixed-r9 -pipe    -D"KBUILD_STR(s)=#s"
-D"KBUILD_BASENAME=KBUILD_STR(bootp)"  -D"KBUILD_MODNAME=KBUILD_STR(bootp)"
-c -o net/bootp.o net/bootp.c

Note the huge difference in the build line (and hard vs soft).
The previous build with the make LDFLAGS="" CC="$CC" command line was
creating an unusable binary although it did compile fine.


Long story short, to solve my problem:
Add the following line in the
environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi script:
export KCFLAGS="--sysroot=$SDKTARGETSYSROOT"

May I suggest future releases include this modification in the script ?

Thanks guys for all the support!

Guillaume Fournier, eng.
Hardware Designer
Brioconcept Consulting Inc.




More information about the meta-freescale mailing list