USE THIS INSTRUCTIONS AT YOUR OWN RISK. STANDARD DISCLAIMER APPLIES: This QUICK-HOWTO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. you have to type lines beginning with "#" lines with // are comments on things you have to do before continuing // SETUP OUR WORK DIR # mkdir -p /usr/src/hri // CVS CHECKOUT OF UCLINUX MODULE FOR REGISTERED USERS # export CVS_RSH=ssh # cvs -z9 -d:ext:$EMAIL:/cvsroot/hri co uClinux // FIXME: test anonymous example # cvs -z9 -d:pserver:anonymous@cvs.sf.net:/cvsroot/hri co uClinux // NOW BUILD THE CROSS COMPILE ENVIRONMENT (need to be done only once) # mkdir -p /usr/src/hri/arm-elf # cd /usr/src/hri/arm-elf // wget the following files from snapgear.org distribution // get these from http://ftp.snapgear.org/pub/snapgear/tools/arm-elf/ STLport-4.5.3.patch STLport-4.5.3.tar.gz binutils-2.10.tar.gz build-uclinux-tools.sh elf2flt-20030314.tar.gz gcc-2.95.3-arm-mlib.patch gcc-2.95.3-arm-pic.patch gcc-2.95.3-arm-pic.patch2 gcc-2.95.3-full.patch gcc-2.95.3.tar.gz gdb-5.0.tar.gz genromfs-0.5.1.tar.gz uClibc-20030314.tar.gz // get these from http://ftp.snapgear.org/pub/snapgear/tools/m68k-elf/ binutils-2.10-full.patch gcc-2.95.3-m68k-zext.patch gcc-2.95.3-sigset.patch // now edit build script, modify following lines, then build tools # vi build-uclinux-tools.sh KERNEL="/usr/src/hri/uClinux" # TARGET=m68k-elf TARGET=arm-elf # set your install directory here and add the correct PATH PREFIX=/opt/tools # ./build-uclinux-tools.sh build // go take coffee, walk, wathever // in case build fails (i.e. you forget to download a file), correct and issue # ./build-uclinux-tools.sh continue // and the compile will follow the last successfull module compile // when it finishes, everything will go to $PREFIX (in my case, /opt/tools) PATH=/opt/tools/bin:$PATH arm-elf-gcc to compile things Published on the list on 28/Jan/2004
# cat Makefile CC = /opt/tools/bin/arm-elf-gcc # this is the method that worked here CFLAGS= -D__PIC__ --fpic -msingle-pic-base LDFLAGS= -Wl,-elf2flt # another method, I think I missed zFLAT executables on kernel #CFLAGS= #LDFLAGS= -Wl,-elf2flt=-z # a third method I found #CFLAGS = -O2 -pipe -Wall -g -fpic #LDFLAGS = -Wl,-elf2flt LIBS = OBJS = hello.o all: hello hello: $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) -o hello $(OBJS) $(LIBS) clean: rm -rf *.o *.elf *.gdb hello # eof Makefile # cat hello.c #includemain(void){ printf("Hello world!\n"); exit(0); } put it on NFS and run it from unit # ./hello Hello world! # here are some errors encountered while testing # ./hello Support for ZFLAT executables is not enabled. Support for ZFLAT executables is not enabled. bFLT: not found # ./hello BINFMT_FLAT: reloc outside program 0xa05d0000 (0 - 0x7064/0x5d80), killing hell! BINFMT_FLAT: reloc outside program 0xa05d0000 (0 - 0x7064/0x5d80), killing hell! SIGSEGV # ./hello Unhandled fault: external abort on linefetch (F4) at 0x00000001 fault-common.c(97): start_code=0x720040, start_stack=0x71ff90) Bus error Published on the list on 28/Jan/2004
On 29/Jan/2004, Erwin Authried (Midori uClinux and armtool's author) shared a tip that one would need to include PIC options in LDFLAGS to some Makefiles (that do not use CFLAGS during linking) work. His example:
Makefile: ------------------------- hello: hello.o ------------------------- If "-fpic" isn't in LDFLAGS, the linker will use wrong (non-pic) libraries, because of the multilib-support. Here's how I set the environment with Midori uClinux: CFLAGS_PIC="-msingle-pic-base -fpic" CFLAGS="-O2 ${CFLAGS_PIC}" LDFLAGS="-Wl,-elf2flt ${CFLAGS_PIC}"