cross-compiling toolchain for AT91RM9200

Kaivers Benoit Patrick Michel benoit.patrick.michel.kaivers at lu.unisi.ch
Sun Mar 26 11:36:44 UTC 2006


Hi,

I'm trying to build a cross-compiling toolchain for an AT91RM9200EK,
using uClibc.

uClibc = daily snapshot
linux kernel = 2.6.16
binutils = 2.16.1
GCC = 3.4.4.

At the end of this mail, I attached a copy of the script I use

everything seems to build fine, but when I try to use to cc-toolchain to
compile the typical "Hello World", I get the following error message:

./arm-unknown-linux-uclibc-gcc -o helloWorld helloWorld.c

/home/bb/masproj/arm_cc_uclibc/lib/gcc/arm-unknown-linux-uclibc/3.4.4/..
/../../../arm-unknown-linux-uclibc/bin/ld: cannot find
/home/bb/masproj/arm_cc_uclibc/sysroot/lib/libc.so.0 inside
/home/bb/masproj/arm_cc_uclibc/arm-unknown-linux-uclibc/bin/../../sysroo
t
collect2: ld returned 1 exit status

... but the libc.so.0 is present at that location...

When using a similar script for glibc instead of uclibc, everything
works fine.

the uClibc environment varialbes for the directories:
PREFIX= KERNEL_SOURCE=/home/bb/masproj/arm_cc_uclibc/sysroot/usr (which
is correct) SHARED_LIB_LOADER_PREFIX=/lib
RUNTIME_PREFIX=/home/bb/masproj/arm_cc_uclibc/sysroot
DEVEL_PREFIX==/home/bb/masproj/arm_cc_uclibc/sysroot/usr

Anyone knows what I'm doing wrong?

I would also expect to see the uclibc tools somewhere (in ..../sysroot),

but nothing... (using make CC=${CROSS_COMPILE} utils instal_utils 
from the uclibc build directory leads to errors)


Thanks,

Benoit Kaivers

----------------------------------------------------------------------

#!/bin/bash

# Setup

export PREFIX=`pwd`
export TARGET=arm-unknown-linux-uclibc SYSROOT=${PREFIX}/sysroot

BINUTILSVERS="2.16.1"
GCCVERS="3.4.4"
UCLIBCSNAP="20060322"
LXKERNELVERS="2.6.16"

export ARCH=arm
export CROSS_COMPILE=${TARGET}-
export PATH=$PATH:${PREFIX}/bin
mkdir -p ${PREFIX}/src

# Get the sources

cd ${PREFIX}/src
for URL in \
http://ftp.gnu.org/gnu/binutils/binutils-${BINUTILSVERS}.tar.gz \
http://www.drcoffee.de/fileadmin/projects/wollmilchsau/cross_compile/bin
utils-uclibc-libtool-conf.patch \
http://www.drcoffee.de/fileadmin/projects/wollmilchsau/cross_compile/bin
utils-uclibc-conf.patch \
http://ftp.gnu.org/gnu/gcc/gcc-${GCCVERS}/gcc-${GCCVERS}.tar.bz2 \
http://www.drcoffee.de/fileadmin/projects/wollmilchsau/cross_compile/gcc
-uclibc-locale.patch \
http://www.drcoffee.de/fileadmin/projects/wollmilchsau/cross_compile/gcc
-sdk-libstdc__-includes.patch \
http://www.drcoffee.de/fileadmin/projects/wollmilchsau/cross_compile/gcc
-uclibc-conf.patch \
http://www.drcoffee.de/fileadmin/projects/wollmilchsau/cross_compile/gcc
-libstdc__-pic.patch \
"http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/flow.c.diff?cvsroot=gcc&o
nly_with_tag=csl-arm-branch&r1=1.563.4.2&r2=1.563.4.3" \
http://frank.harvard.edu/~coldwell/toolchain/t-linux.diff \
http://www.uclibc.org/downloads/snapshots/uClibc-${UCLIBCSNAP}.tar.bz2 \
http://www.uclibc.org/downloads/uClibc-locale-030818.tgz \
http://frank.harvard.edu/~coldwell/toolchain/ioperm.c.diff \
http://ftp.kernel.org/pub/linux/kernel/v2.6/linux-${LXKERNELVERS}.tar.gz
\ http://maxim.org.za/AT91RM9200/2.6/${LXKERNELVERS}-at91.patch.gz \

do
    FILE=${URL##*/}
    FILE=${FILE%%\?*}
    [ -f ${FILE} ] || wget -O ${FILE} ${URL} 
done

# GNU binutils

cd ${PREFIX}/src
tar xvfz binutils-${BINUTILSVERS}.tar.gz
cd binutils-${BINUTILSVERS}
patch -Np1 -i ../binutils-uclibc-conf.patch
patch -Np1 -i ../binutils-uclibc-libtool-conf.patch
cd ..
mkdir -p BUILD/binutils-${BINUTILSVERS}
cd BUILD/binutils-${BINUTILSVERS}
	#--prefix tells the configuration script whre to install files
and directories
	#--target specifies the target architecture for which binutils
are build. char after first "-" are dropped 
	#  except for naming of the utilities (target value will prepend
the utilities name)
	#--with-sysroot value will be hard-coded in resulting binaries
(linker,..) used at runtime to locate
	#  libraries when path includes a path starting with the "="
sign (ex: =/usr/local/lib:=/lib:=/usr/lib)
	#  allows target libraries to be found by linker
../../binutils-${BINUTILSVERS}/configure --prefix=${PREFIX}
--target=${TARGET} --with-sysroot=${SYSROOT} 2>&1 | tee configure.out
make 2>&1 | tee make.out make install 2>&1 | tee -a make.out

# Linux Kernel Headers

cd ${PREFIX}/src
tar xvfz linux-${LXKERNELVERS}.tar.gz
ln -s linux-${LXKERNELVERS} linux
zcat ${LXKERNELVERS}-at91.patch.gz | patch -d linux -p1
cd linux
make at91rm9200ek_defconfig       #make linux kernel for at91rm9200ek
(default cfg)
make include/linux/version.h      #just make the linux kernel headers
mkdir -p ${SYSROOT}/usr/include
cp -a ${PREFIX}/src/linux/include/linux ${SYSROOT}/usr/include/linux cp
-a ${PREFIX}/src/linux/include/asm-arm ${SYSROOT}/usr/include/asm cp -a
${PREFIX}/src/linux/include/asm-generic
${SYSROOT}/usr/include/asm-generic

#uclibc headers

cd ${PREFIX}/src
tar xvjf uClibc-${UCLIBCSNAP}.tar.bz2
cd uClibc
install -m444 ../uClibc-locale-030818.tgz extra/locale
cd ..
mkdir ./BUILD/uClibc-${UCLIBCSNAP}
cd ./uClibc
mv ./* ../BUILD/uClibc-${UCLIBCSNAP}
cd ..
rm -rf ./uClibc
cd ./BUILD/uClibc-${UCLIBCSNAP}
BUILD_CC=gcc CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar
RANLIB=${CROSS_COMPILE}ranlib AS=${CROSS_COMPILE}as
LD=${CROSS_COMPILE}ld 

	#prepare .config file for uclibc:
echo "#" >.config
echo "# Automatically generated make config: don't edit" >>.config echo
"# Wed Mar 22 19:24:50 2006" >>.config echo "#" >>.config echo "#
TARGET_alpha is not set" >>.config echo "TARGET_arm=y" >>.config echo "#
TARGET_bfin is not set" >>.config echo "# TARGET_cris is not set"
>>.config echo "# TARGET_e1 is not set" >>.config echo "# TARGET_frv is
not set" >>.config echo "# TARGET_h8300 is not set" >>.config echo "#
TARGET_hppa is not set" >>.config echo "# TARGET_i386 is not set"
>>.config echo "# TARGET_i960 is not set" >>.config echo "# TARGET_ia64
is not set" >>.config echo "# TARGET_m68k is not set" >>.config echo "#
TARGET_microblaze is not set" >>.config echo "# TARGET_mips is not set"
>>.config echo "# TARGET_nios is not set" >>.config echo "# TARGET_nios2
is not set" >>.config echo "# TARGET_powerpc is not set" >>.config echo
"# TARGET_sh is not set" >>.config echo "# TARGET_sh64 is not set"
>>.config echo "# TARGET_sparc is not set" >>.config echo "# TARGET_v850
is not set" >>.config echo "# TARGET_vax is not set" >>.config echo "#
TARGET_x86_64 is not set" >>.config echo "" >>.config echo "#" >>.config
echo "# Target Architecture Features and Options" >>.config echo "#"
>>.config echo "TARGET_ARCH="arm"" >>.config echo
"FORCE_OPTIONS_FOR_ARCH=y" >>.config echo "# CONFIG_ARM_EABI is not set"
>>.config echo "# USE_BX is not set" >>.config echo "#
CONFIG_GENERIC_ARM is not set" >>.config echo "# CONFIG_ARM610 is not
set" >>.config echo "# CONFIG_ARM710 is not set" >>.config echo "#
CONFIG_ARM7TDMI is not set" >>.config echo "# CONFIG_ARM720T is not set"
>>.config echo "CONFIG_ARM920T=y" >>.config echo "# CONFIG_ARM922T is
not set" >>.config echo "# CONFIG_ARM926T is not set" >>.config echo "#
CONFIG_ARM1136JF_S is not set" >>.config echo "# CONFIG_ARM_SA110 is not
set" >>.config echo "# CONFIG_ARM_SA1100 is not set" >>.config echo "#
CONFIG_ARM_XSCALE is not set" >>.config echo "ARCH_ANY_ENDIAN=y"
>>.config echo "ARCH_LITTLE_ENDIAN=y" >>.config echo "#
ARCH_WANTS_BIG_ENDIAN is not set" >>.config echo
"ARCH_WANTS_LITTLE_ENDIAN=y" >>.config echo "ARCH_HAS_MMU=y" >>.config
echo "ARCH_USE_MMU=y" >>.config echo "UCLIBC_HAS_FLOATS=y" >>.config
echo "UCLIBC_HAS_FPU=y" >>.config echo "# DO_C99_MATH is not set"
>>.config echo "KERNEL_SOURCE="${PREFIX}/sysroot/usr"" >>.config echo
"HAVE_DOT_CONFIG=y" >>.config echo "" >>.config echo "#" >>.config echo
"# General Library Settings" >>.config echo "#" >>.config echo "#
HAVE_NO_PIC is not set" >>.config echo "DOPIC=y" >>.config echo "#
HAVE_NO_SHARED is not set" >>.config echo "# ARCH_HAS_NO_LDSO is not
set" >>.config echo "HAVE_SHARED=y" >>.config echo "#
FORCE_SHAREABLE_TEXT_SEGMENTS is not set" >>.config echo
"LDSO_LDD_SUPPORT=y" >>.config echo "LDSO_CACHE_SUPPORT=y" >>.config
echo "# LDSO_PRELOAD_FILE_SUPPORT is not set" >>.config echo
"LDSO_BASE_FILENAME="ld.so"" >>.config echo "UCLIBC_STATIC_LDCONFIG=y"
>>.config echo "LDSO_RUNPATH=y" >>.config echo "UCLIBC_CTOR_DTOR=y"
>>.config echo "# HAS_NO_THREADS is not set" >>.config echo
"UCLIBC_HAS_THREADS=y" >>.config echo "# PTHREADS_DEBUG_SUPPORT is not
set" >>.config echo "LINUXTHREADS_OLD=y" >>.config echo
"UCLIBC_HAS_LFS=y" >>.config echo "# MALLOC is not set" >>.config echo
"# MALLOC_SIMPLE is not set" >>.config echo "MALLOC_STANDARD=y"
>>.config echo "# MALLOC_GLIBC_COMPAT is not set" >>.config echo
"UCLIBC_DYNAMIC_ATEXIT=y" >>.config echo "# COMPAT_ATEXIT is not set"
>>.config echo "HAS_SHADOW=y" >>.config echo "#
UCLIBC_HAS_PROGRAM_INVOCATION_NAME is not set" >>.config echo
"UCLIBC_HAS___PROGNAME=y" >>.config echo "UNIX98PTY_ONLY=y" >>.config
echo "ASSUME_DEVPTS=y" >>.config echo "UCLIBC_HAS_TM_EXTENSIONS=y"
>>.config echo "UCLIBC_HAS_TZ_CACHING=y" >>.config echo
"UCLIBC_HAS_TZ_FILE=y" >>.config echo "UCLIBC_HAS_TZ_FILE_READ_MANY=y"
>>.config echo "UCLIBC_TZ_FILE_PATH="/etc/TZ"" >>.config echo ""
>>.config echo "#" >>.config echo "# Networking Support" >>.config echo
"#" >>.config echo "# UCLIBC_HAS_IPV6 is not set" >>.config echo "#
UCLIBC_HAS_RPC is not set" >>.config echo "# UCLIBC_USE_NETLINK is not
set" >>.config echo "" >>.config echo "#" >>.config echo "# String and
Stdio Support" >>.config echo "#" >>.config echo
"UCLIBC_HAS_STRING_GENERIC_OPT=y" >>.config echo
"UCLIBC_HAS_STRING_ARCH_OPT=y" >>.config echo
"UCLIBC_HAS_CTYPE_TABLES=y" >>.config echo "UCLIBC_HAS_CTYPE_SIGNED=y"
>>.config echo "UCLIBC_HAS_CTYPE_UNSAFE=y" >>.config echo "#
UCLIBC_HAS_CTYPE_CHECKED is not set" >>.config echo "#
UCLIBC_HAS_CTYPE_ENFORCED is not set" >>.config echo "# UCLIBC_HAS_WCHAR
is not set" >>.config echo "# UCLIBC_HAS_LOCALE is not set" >>.config
echo "# UCLIBC_HAS_HEXADECIMAL_FLOATS is not set" >>.config echo "#
UCLIBC_HAS_GLIBC_CUSTOM_PRINTF is not set" >>.config echo "#
USE_OLD_VFPRINTF is not set" >>.config echo
"UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9" >>.config echo "#
UCLIBC_HAS_SCANF_GLIBC_A_FLAG is not set" >>.config echo "#
UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set" >>.config echo "#
UCLIBC_HAS_STDIO_BUFSIZ_256 is not set" >>.config echo "#
UCLIBC_HAS_STDIO_BUFSIZ_512 is not set" >>.config echo "#
UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set" >>.config echo "#
UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set" >>.config echo
"UCLIBC_HAS_STDIO_BUFSIZ_4096=y" >>.config echo "#
UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set" >>.config echo
"UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y" >>.config echo "#
UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set" >>.config echo "#
UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set" >>.config echo "#
UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set" >>.config echo
"UCLIBC_HAS_STDIO_GETC_MACRO=y" >>.config echo
"UCLIBC_HAS_STDIO_PUTC_MACRO=y" >>.config echo
"UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y" >>.config echo "#
UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set" >>.config echo "#
UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE is not set" >>.config echo "#
UCLIBC_HAS_GLIBC_CUSTOM_STREAMS is not set" >>.config echo "#
UCLIBC_HAS_PRINTF_M_SPEC is not set" >>.config echo
"UCLIBC_HAS_ERRNO_MESSAGES=y" >>.config echo "# UCLIBC_HAS_SYS_ERRLIST
is not set" >>.config echo "UCLIBC_HAS_SIGNUM_MESSAGES=y" >>.config echo
"# UCLIBC_HAS_SYS_SIGLIST is not set" >>.config echo
"UCLIBC_HAS_GNU_GETOPT=y" >>.config echo "UCLIBC_HAS_GNU_GETSUBOPT=y"
>>.config echo "" >>.config echo "#" >>.config echo "# Big and Tall"
>>.config echo "#" >>.config echo "UCLIBC_HAS_REGEX=y" >>.config echo
"UCLIBC_HAS_REGEX_OLD=y" >>.config echo "UCLIBC_HAS_FNMATCH=y" >>.config
echo "UCLIBC_HAS_FNMATCH_OLD=y" >>.config echo "# UCLIBC_HAS_WORDEXP is
not set" >>.config echo "# UCLIBC_HAS_FTW is not set" >>.config echo
"UCLIBC_HAS_GLOB=y" >>.config echo "UCLIBC_HAS_GNU_GLOB=y" >>.config
echo "" >>.config echo "#" >>.config echo "# Library Installation
Options" >>.config echo "#" >>.config echo
"SHARED_LIB_LOADER_PREFIX="/lib"" >>.config echo
"RUNTIME_PREFIX="${PREFIX}/sysroot"" >>.config echo
"DEVEL_PREFIX="${PREFIX}/sysroot/usr"" >>.config echo "" >>.config echo
"#" >>.config echo "# Security options" >>.config echo "#" >>.config
echo "# UCLIBC_BUILD_PIE is not set" >>.config echo "#
UCLIBC_HAS_ARC4RANDOM is not set" >>.config echo "# HAVE_NO_SSP is not
set" >>.config echo "# UCLIBC_HAS_SSP is not set" >>.config echo
"UCLIBC_BUILD_RELRO=y" >>.config echo "# UCLIBC_BUILD_NOW is not set"
>>.config echo "UCLIBC_BUILD_NOEXECSTACK=y" >>.config echo "" >>.config
echo "#" >>.config echo "# uClibc development/debugging options"
>>.config echo "#" >>.config echo
"CROSS_COMPILER_PREFIX="arm-linux-uclibc-"" >>.config echo "# DODEBUG is
not set" >>.config echo "# DODEBUG_PT is not set" >>.config echo "#
NOSTRIP is not set" >>.config echo "# DOASSERTS is not set" >>.config
echo "# SUPPORT_LD_DEBUG is not set" >>.config echo "#
SUPPORT_LD_DEBUG_EARLY is not set" >>.config echo "WARNINGS="-Wall""
>>.config echo "# EXTRA_WARNINGS is not set" >>.config echo "# DOMULTI
is not set" >>.config echo "# UCLIBC_MJN3_ONLY is not set" >>.config

make CROSS=${CROSS_COMPILE} menuconfig | tee make.out
make CROSS=${CROSS_COMPILE} PREFIX= headers install_dev | tee make.out

# Step 4: bootstrap gcc

cd ${PREFIX}/src
bunzip2 -c gcc-${GCCVERS}.tar.bz2 | tar xvf -
patch -d gcc-${GCCVERS} -p1 < flow.c.diff
patch -d gcc-${GCCVERS} -p1 < t-linux.diff
cd gcc-${GCCVERS}
patch -Np1 -i ../gcc-uclibc-conf.patch
cd ..
mkdir -p BUILD/gcc-${GCCVERS}-stage1
cd BUILD/gcc-${GCCVERS}-stage1
../../gcc-${GCCVERS}/configure --prefix=${PREFIX} --target=${TARGET}
--enable-languages=c --with-sysroot=${SYSROOT} 2>&1 | tee configure.out

make 2>&1 | tee make.out
make install 2>&1 | tee -a make.out

#Step 5: uClibc

cd ${PREFIX}/src/BUILD/uClibc-${UCLIBCSNAP}
BUILD_CC=gcc CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar
RANLIB=${CROSS_COMPILE}ranlib AS=${CROSS_COMPILE}as
LD=${CROSS_COMPILE}ld 
make CROSS=${CROSS_COMPILE} | tee make.out
make CROSS=${CROSS_COMPILE} PREFIX="" install | tee make.out


#Step 6: full compiler

cd ${PREFIX}/src

rm -rf ./gcc-${GCCVERS}
tar xpfj gcc-3.4.4.tar.bz2
cd gcc-${GCCVERS}
patch -Np1 -i ../gcc-uclibc-conf.patch
patch -Np1 -i ../gcc-uclibc-locale.patch
patch -Np1 -i ../gcc-libstdc__-pic.patch
patch -Np1 -i ../gcc-sdk-libstdc__-includes.patch
cd ..
mkdir BUILD/gcc-${GCCVERS}
cd BUILD/gcc-${GCCVERS}
../../gcc-${GCCVERS}/configure --prefix=${PREFIX} --target=${TARGET}
--enable-languages=c  --with-sysroot=${SYSROOT} 2>&1 | tee configure.out
make 2>&1 | tee make.out make install 2>&1 | tee -a make.out cd ../..

# Step 7: Linux kernel

cd ${PREFIX}/src/linux
make zImage
make modules
make INSTALL_MOD_PATH=${SYSROOT} modules_install
cd ../..



More information about the uClibc mailing list