Compiler Toolchain

From OpenWiz

Jump to: navigation, search

Warning: Work in progress. These instructions are incomplete at this stage.

New find: http://mvixcommunity.com/~jeruko/ - Tony says it builds. Need to test it.

download binutils 2.18 http://ftp.gnu.org/gnu/binutils/binutils-2.18.tar.bz2

download gcc 4.2.3 http://ftp.gnu.org/gnu/gcc/gcc-4.2.3/gcc-core-4.2.3.tar.bz2

download elf2flt http://ftp.snapgear.org/pub/snapgear/tools/arm-elf/elf2flt-20030314.tar.gz

download uClibc-0.9.26-em86xx ?

download em86xx Linux kernel sources ?

download toolchain, uClinux and root file system program sources (including busybox & uClib) for the Sigma Designs port to the em86xx http://www.services.digitus.de/data/download/firmware/gpl/GPL_DA-70900.tar.gz The build instructions below don't apply to this download! I have successfully used the kernel source as a guide to the disassembled Beyonwiz kernel -- but it's not identical. Prl

Download and unpack sources.

mkdir build
cd build
wget -nd http://ftp.gnu.org/gnu/binutils/binutils-2.18.tar.bz2
wget -nd http://ftp.gnu.org/gnu/gcc/gcc-4.2.3/gcc-core-4.2.3.tar.bz2
wget -nd http://ftp.snapgear.org/pub/snapgear/tools/arm-elf/elf2flt-20030314.tar.gz
bzip2 -dc binutils-2.18.tar.bz2 | tar -x
bzip2 -dc gcc-core-4.2.3.tar.bz2 | tar -x
tar -zxf elf2flt-20030314.tar.gz
mkdir binutils-build
mkdir gcc-build

Configure and build Binutils

cd binutils-build
../binutils-2.18/configure --prefix=/usr/local/openwiz --target=arm-linux-elf
make
make install

Configure and build GCC

cd ../gcc-build
../gcc-4.2.3/configure   --prefix=/usr/local/openwiz --target=arm-linux-elf --disable-libssp --enable-languages=c
make
make install

Configure and build uClibc for the sigma em86xx

cd ../uClibc-0.9.21
cp em86xx_config.txt .config
make oldconfig
(Edit .config to change location of linux to reference your linux tree)
export PATH=/usr/local/openwiz/bin/:$PATH
make CROSS=arm-linux-elf-
make install

Configure and compile elf2flt

cd ../elf2flt
./configure --prefix=/usr/local/openwiz --target=arm-linux-elf \
--with-bfd-include-dir=../binutils-build/bfd \
--with-libbfd=../binutils-build/bfd/libbfd.a \
--with-libiberty=../binutils-build/libiberty/libiberty.a
make
make install



Simple Compiler Setup

Editing because I found this, which builds a rom image for hardware reasonably similar to our Beyonwiz, with no errors in the install (you will need to install a few things like libncurses etc, but it will be clear when you get the errors what to look for):

Discussion: http://mvixcommunity.com/showtopic.php?tid/327/

Files: http://mvixcommunity.com/~jeruko/

Below is for historical purposes-

Ok, for a simpler compiler setup than the multiple downloads at the beginning of this chapter(nothing to compile, just run a script and it is all done), follow the instructions here, also here(has good test app to try here too) particularly (section plagurised from the suggested link)-

Installing development tools on Linux

You can do this on a real Linux machine, or in a virtual machine on your Windows computer. VMware server and coLinux are good candidates. A Linux instance running under Parallels Desktop on Mac OS X works fine as well.

1. Download the arm-elf-tools. If you want some more info about arm-elf-tools, just go here. The compiler you need is version "arm-elf gcc version 2.95.3 20010315" but the version dated 20030314 seems to work just fine.

2. Run the downloaded file as user "root". For Nuke, the default root password is... "root". This will unpack the arm-elf-tools archive and install the contents in /usr/local -- components will go into /usr/local/arm-elf, /usr/local/bin, and /usr/local/lib/gcc-lib/arm-elf. Components in /usr/local/bin are prefixed with arm-elf-

Test it works:

So to compile something, say, Erics wizRemote here or here, download WizRemote, and create a shell script in the src directory called, say "makeit.sh" with the following contents:

#!/bin/sh
env PATH=/usr/local/arm-elf/bin/:$PATH gcc -O2 -I/usr/local/arm-elf/include/ -L/usr/local/arm-elf/lib/ -Wl,-elf2flt -o wizremote ezxml.c wizremote.c

I also needed to put #define EZXML_NOMMAP at the beginning of ezxml.c or else get the following compile error:

wizremote.elf2flt: In function `ezxml_parse_fd':
wizremote.elf2flt(.text+0x1fa8): undefined reference to `madvise'
wizremote.elf2flt(.text+0x1fcc): undefined reference to `madvise'


Then run the shell script

chmod+x makeit.sh
./makeit.sh

and job done, the wizremote executable is created without fuss.

Now lets really put it through its paces:
Download gnu hello here
Unzip to whereever
tar -zxvf hello-2.3.tar.gz
cd hello-2.3
Setup a script which will set the cross compile environment for this:

AR=/usr/local/bin/arm-elf-ar
AS=/usr/local/bin/arm-elf-as
LD=/usr/local/bin/arm-elf-ld
GCC=/usr/local/bin/arm-elf-gcc
CXX=/usr/local/bin/arm-elf-g++
RANLIB=/usr/local/bin/arm-elf-ranlib
STRIP=/usr/local/bin/arm-elf-strip
                CFLAGS="-O2"
               LDFLAGS="-L/usr/local/arm-elf/lib -Wl,-elf2flt -o conftest" \
                ./configure \
               --build=i386-pc-linux-gnu \
              --host=arm-elf \
              --target=arm-elf \
               --prefix=/opt \
              --disable-nls \
             --disable-static \

The "-o conftest" is to convince the configure tool in the GNU Hello to create a test binary to check the environment, there may be a better way of doing this but I spent an hour or so trying to work this out :-)
Now finally the configure should work out your cross compile environment and build a Makefile, and then simply type "make" and it will build a Wiz binary called hello in the src directory.
Then to get it across to the wiz, use wget and get it from a webserver, or I prefer to surf to a SAMBA share with the Wiz Network menu which will mount your share and make copying simple:
(assumes you created a wizremote directory already on the Wiz HDD)

# cd /tmp/mnt/idehdd/wizremote
# cp /tmp/mnt/smb/TONYSPC/storedToppyCaptures/hello .
# ./hello -v
hello (GNU hello) 2.3

Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

# ./hello --help
Usage: ./hello [OPTION]...
Print a friendly, customizable greeting.

  -h, --help          display this help and exit
  -v, --version       display version information and exit

  -t, --traditional       use traditional greeting format
  -n, --next-generation   use next-generation greeting format
  -g, --greeting=TEXT     use TEXT as the greeting message

Report bugs to <bug-hello@gnu.org>.
# ./hello -t
hello, world
# ./hello -n
+---------------+
| Hello, world! |
+---------------+
# ./hello -g "got this workig on the wiz, yay"
got this workig on the wiz, yay
Personal tools