CrossToolToolchainPreApophis

Crosstool Toolchains on scratchbox 1.0.2

Notice: These instructions depreceated on Scratchbox Apophis and newer.

The rest of the page is also a terrible mess.. please split out to separate document if there is something worth saving.

a livecd scratchbox-multiCpu is available at 
   
            http://mirror.opf.slu.cz/scratchbox/iso/

Most binaries for the toolchains described below can be downloaded from
            http://mirror.opf.slu.cz/scratchbow/tarballs/
     
snapshot 
           http://groups.yahoo.com/group/tstembed/files/scratchbox-live-dvd-under-Qemu.png

            http://perso.wanadoo.fr/hoan/ScratchboxMultiCpu.png
 

This page describes how to build a scratchbox toolchain using [WWW] Dan Kegel's crosstool This example will take you through the building of a toolchain to target an xscale processor in big-endian mode.

Preparing scratchbox

Change the group ownership of /scratchbox/compilers to sbox. This will give your scratchbox user write access to this directory.

vesuvius@pompeii:~$ sudo chgrp sbox /scratchbox/compilers

Enter scratchbox and make sure you have scratchbox configured to use the HOST target:

vesuvius@pompeii:~$ sb-conf se HOST
vesuvius@pompeii:~$ scratchbox
[sbox-HOST: ~] >

Preparing crosstool

Download [WWW] crosstool

[sbox-HOST: ~] > wget http://kegel.com/crosstool/crosstool-0.38.tar.gz
[sbox-HOST: ~] > tar xzf crosstool-0.38.tar.gz
[sbox-HOST: ~] > cd crosstool-0.38

Crosstool 0.38 didn't have support for gcc-3.4.5 yet, but I found that my toolchain worked by copying gcc-3.4.4 patches. YMMV:

[sbox-HOST: ~/crosstool-0.38] > cd patches
[sbox-HOST: ~/crosstool-0.38/patches] > cp -a gcc-3.4.{4,5}
[sbox-HOST: ~/crosstool-0.38/patches] > cd ..

I created a gcc-3.4.5-glibc-2.3.5-hdrs-2.6.11.2.dat file:

[sbox-HOST: ~/crosstool-0.38] > cat gcc-3.4.5-glibc-2.3.5-hdrs-2.6.11.2.dat
BINUTILS_DIR=binutils-2.15
GCC_DIR=gcc-3.4.5
GLIBC_DIR=glibc-2.3.5
LINUX_DIR=linux-2.6.15
LINUX_SANITIZED_HEADER_DIR=linux-libc-headers-2.6.11.2
GLIBCTHREADS_FILENAME=glibc-linuxthreads-2.3.5

And I created a demo-sbox-armv5b-softfloat.sh script:

[sbox-HOST: ~/crosstool-0.38] > cat demo-sbox-armv5b-softfloat.sh
#!/bin/sh
set -ex
TARBALLS_DIR=$HOME/downloads
RESULT_TOP=/scratchbox/compilers
PREFIX=$RESULT_TOP/armv5b-gcc-3.4.5-glibc-2.3.5
export TARBALLS_DIR RESULT_TOP PREFIX
GCC_LANGUAGES="c,c++"
export GCC_LANGUAGES

mkdir -p $RESULT_TOP
unset LD_LIBRARY_PATH
# Build the toolchain.  Takes a couple hours and a couple gigabytes.

eval `cat armv5b-softfloat.dat gcc-3.4.5-glibc-2.3.5-hdrs-2.6.11.2.dat` sh all.sh --notest

echo Done.

A couple of things to note in the above script is that $RESULT_TOP must point to /scratchbox/compilers and that the $PREFIX directory must be only one more directory deep under $RESULT_TOP. By default crosstool puts $PREFIX as $RESULT_TOP/$TOOL_COMBO/$TARGET which is two directories down from $RESULT_TOP. The other thing is that crosstool doesn't like having LD_LIBRARY_PATH set during the build, so we unset it before the build starts.

Build the toolchain

Start up the script and wait a couple of hours. The script will take care of downloading needed files if they are not already in $HOME/downloads.

[sbox-HOST: ~/crosstool-0.38] > ./demo-sbox-armv5b-softfloat.sh

Scratchbox post configuration

Once the script has successfully finished, we need to create some additional files to let scratchbox know about the new toolchain.

sbox symbolic links

We need to create some symbolic link files in your compiler's bin directory that scratchbox expects:

[sbox-HOST: ~/crosstool-0.38] > cd /scratchbox/compilers/armv5b-gcc-3.4.5-glibc-2.3.5/bin/
[sbox-HOST: /scratchbox/compilers/armv5b-gcc-3.4.5-glibc-2.3.5/bin] > for f in `ls`; do ln -s $f sbox-$f; done

compiler-name

Create a file compiler-name in your compiler's top directory. Mine looks like this:

[sbox-HOST: /scratchbox/compilers/armv5b-gcc-3.4.5-glibc-2.3.5] > cat compiler-name
armv5b-gcc-3.4.5-glibc-2.3.5:/scratchbox/compilers/armv5b-gcc-3.4.5-glibc-2.3.5:armv5b:softfloat-linux:glibc:armeb

This file is a : delimited file. The fields are as follows as far as I could tell:

  1. Name of the compiler. This name must be exactly the same as the name of directory where this compiler-name file is.

  2. Full path to the compiler directory.

  3. Toolchain's target architecture.

  4. Toolchain's target sub-arch.

  5. glibc or uclibc

  6. qemu emulation

target_setup.sh

Create a target_setup.sh script in your compiler's top directory. Mine looks like this. Replace source appropriately for your setup:

[sbox-HOST: /scratchbox/compilers/armv5b-gcc-3.4.5-glibc-2.3.5] > cat target_setup.sh
#!/bin/sh

target=$1
source=/scratchbox/compilers/armv5b-gcc-3.4.5-glibc-2.3.5/armv5b-softfloat-linux

mkdir -p $target/lib
mkdir -p $target/usr/lib
mkdir -p $target/usr/include
mkdir -p $target/usr/bin

cp -af $source/lib/*                 $target/lib/
cp -af $source/lib/* $target/usr/lib/

cp -af $source/include/* $target/usr/include/

ln -sf /bin/cpp $target/lib/
ln -sf /bin/cc  $target/usr/bin/

chmod +x $target/lib/ld-*.so

gcc.specs

We need to copy the toolchains specs file to where scratchbox expects to see it:

[sbox-HOST: /scratchbox/compilers/armv5b-gcc-3.4.5-glibc-2.3.5] > cp `find . -name specs` gcc.specs

qemu emulation

This part is only needed if scratchbox doesn't have qemu emulation for your arch already but qemu does have support for your arch available. This was the case for me since I needed qemu-armeb.

First of all you'll need write access to get temporary ownership of /scratchbox/tools. Since all directories and files under there are owned by root, it will be easy to revert the ownership back to root when we're done.

vesuvius@pompeii:~$ sudo chown -R vesuvius /scratchbox/tools

Download and build qemu for the needed emulation:

[sbox-HOST: ~] > wget http://www.qemu.com/qemu-0.8.0.tar.gz
[sbox-HOST: ~] > tar xzf qemu-0.8.0.tar.gz
[sbox-HOST: ~] > cd qemu-0.8.0
[sbox-HOST: ~/qemu-0.8.0] > ./configure --prefix=/scratchbox/tools --target-list=armeb-user --static
[sbox-HOST: ~/qemu-0.8.0] > make
[sbox-HOST: ~/qemu-0.8.0] > make install
vesuvius@pompeii:~$ sudo chown -R root /scratchbox/tools

Edit /scratchbox/etc/cputransp-methods to add qemu-armeb to the list.

Issues

One needs to build device_tools namely sbrshd and fakeroot to communicate thru CPU_Transparency with the device and gdbserver for debugging.An example of a realdevice,nslu2_ixp425 with kanotix_debian_scratchbox-1.0 is described at


BuildScratchboxNslu2


0. Intro.

1. install scratchbox :core,lib ,toolchains

Base (required):

Development kits (optional):

Toolchains (optional):

  1. Build device_tools for armeb_target

(needs to communicate/debug thru CPU_transparency with nslu2)

gdbserver,gdb (DDD) Download those src files into /scratchbox/packages
Login scratchbox,select HOST then untar src ,select target armeb



and a "#include "asm/ptrace.h" to signal.c and syscall.c

root@laixa:/scratchbox/users/wangji/home/wangji/strace-4.5.11# patch -p0 < patches/arm-syscallent.patch
patching file strace-4.5.4/linux/arm/syscallent.h
root@laixa:/scratchbox/users/wangji/home/wangji/strace-4.5.11# patch -p1 < patches/quota.patch
patching file resource.c
root@laixa:/scratchbox/users/wangji/home/wangji/strace-4.5.11# patch -p1 < patches/arm-syscall.patch
patching file linux/arm/syscall.h
patching file linux/arm/dummy.h
root@laixa:/scratchbox/users/wangji/home/wangji/strace-4.5.11# patch -p1 < patches/arm-compilation.patch
patching file syscall.c
Hunk #1 succeeded at 747 (offset 51 lines).
root@laixa:/scratchbox/users/wangji/home/wangji/strace-4.5.11# cat patches/arm-syscall.patch

 [sbox-nslu2: ~/build_strace] > ../strace-4.5.11/configure --build=i386-pc-linux-gnu --host=armv5b-softfloat-linux --target=armv5b-softfloat-linux  
        

[sbox-nslu2: ~/build_strace] > make
[sbox-nslu2: ~/build_strace] > file strace
strace: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), stripped


Since this strace runs on the nslu2-armeb target ,copy it to TARGET/nslu2/usr/sbin





compilation_of_sbrsh


rm -f sbrsh sbrshd sb-exportfs *.o
[sbox-HOST: ~/sbrsh-7.0] > make sbrsh
[sbox-HOST: ~/sbrsh-7.0] > file sbrsh
sbrsh: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.0, dynamically linked (uses shared libs), not stripped


compilation_of_daemon_sbrshd


[sbox-HOST: ~/sbrsh-7.0] > sb-conf se nslu2
Shell restarting...
[sbox-nslu2: ~] >
[sbox-nslu2: ~] > cd sbrsh-7.0/
[sbox-nslu2: ~/sbrsh-7.0] > make clean
rm -f sbrsh sbrshd sb-exportfs *.o

[sbox-nslu2: ~/sbrsh-7.0] > make sbrshd CPPFLAGS="-I/scratchbox/device_tools/fakeroot-1.4.2/armv5b-gcc-3.4.4-glibc-2.3.5/include/
"   

[sbox-nslu2: ~/sbrsh-7.0] > file sbrshd sbrshd: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not stripped

The daemon sbrshd will be copied to /scratchbox/device_tools/sbrsh-7.0/etc/init.d/sbrshd
This sbrsh will be copied to /scratchbox/device_tools/sbrsh-7.0/armv5b-gcc-3.4.4-glibc-2.3.5/sbin/
and sbrshd.init as /scratchbox/device_tools/sbrsh-7.0/armv5b-gcc-3.4.4-glibc-2.3.5/etc/sbrshd
Those etc and sbin containing sbrshd must be transfered by some way-serial connection,scp ..- to the rootfilesystem of target nslu2 .
There is however a remark : let's check the lib dependencies
[sbox-nslu2: ~/sbrsh-7.0] > ldd sbrshd

If it happens that our target does not have the same libraries,then we need to put on the target not only sbrshd binary,but also the libc .

 [sbox-nslu2: ~/sbrsh-7.0] > make sbrshd CPPFLAGS="-I/scratchbox/device_tools/fakeroot-1.4.2/armv5b-gcc-3.4.4-glibc-2.3.5/include" LDFLAGS="-static"    

sbrshd: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, statically linked, not stripped
[sbox-nslu2: ~/sbrsh-7.0] >

fakeroot-1.4.2
    

to build this daemon.

fakemon needs to be patched with

<a href="[WWW] http://scratchbox.org/repos/1.2/sb-toolchains/device_tools/fakeroot/files/communication.patch"><img src="crosstooltoolchain_files/moin-www.png" alt="[WWW]" height="11" width="11"> [WWW] http://scratchbox.org/repos/1.2/sb-toolchains/device_tools/fakeroot/files/communication.patch</a> and compile with

communicate.c -fPIC -DPIC -shared -lpthread -ldl -Wl,-soname -Wl,libfakeroot-tcp.so.0

for the rest about fakeroot,follow

<a href="[WWW] http://scratchbox.org/documentation/docbook/fakeroot.html"><img src="crosstooltoolchain_files/moin-www.png" alt="[WWW]" height="11" width="11"> [WWW] http://scratchbox.org/documentation/docbook/fakeroot.html</a>






~$ scratchbox

Welcome to Scratchbox, the cross-compilation toolkit!
Use 'sb-menu' to change your compilation target.
See /scratchbox/doc/ for documentation.
download from the net,untargz and patch

[sbox-nslu2: ~] >tar xzf /scratchbox/packages/gdb-6.3.tar.gz
[sbox-nslu2: ~] > cd gdb-6.3

patching file bfd/config.bfd
patching file bfd/configure.in
patching file bfd/configure

[sbox-nslu2: ~/gdb-6.3] > patch -p1 < ../gdb_patch/gdbserver-cflags-last.diff
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:



|--- gdb/gdbserver/Makefile.in.orig 2004-10-05 18:52:56.298419032 +0200
|+++ gdb/gdbserver/Makefile.in 2004-10-05 18:53:10.442268840 +0200



File to patch:


patching file gdb/gdbserver/Makefile.in

[sbox-nslu2: ~/gdb-6.3] > cd ..
[sbox-nslu2: ~] > mkdir build_gdbarmeb
[sbox-nslu2: ~] > cd build_gdbarmeb/
[sbox-nslu2: ~/build_gdbarmeb] >

[sbox-nslu2: ~/build_gdbarmeb] > ../gdb-6.3/gdb/gdbserver/configure --host=armv5b-softfloat-linux  

[sbox-nslu2: ~/build_gdbarmeb] > make

[sbox-nslu2: ~/build_gdbarmeb] > file gdbserver
gdbserver: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not stripped
[sbox-nslu2: ~/build_gdbarmeb] > strip gdbserver
[sbox-nslu2: ~/build_gdbarmeb] > file gdbserver
gdbserver: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), stripped
[sbox-nslu2: ~/build_gdbarmeb] > ls gdb*
gdbreplay gdbreplay.o gdbserver
[sbox-nslu2: ~/build_gdbarmeb] > file gdbreplay
gdbreplay: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not stripped
[sbox-nslu2: ~/build_gdbarmeb] > strip gdbreplay && file gdbreplay
gdbreplay: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), stripped
[sbox-nslu2: ~/build_gdbarmeb] >

These armeb-gdbserver armeb-gdbreplay have to be put on somewhere /usr/bin or /usr/sbin of the armeb-nslu2-target !
that's it !


cross gdb


After building armeb-gdbserver (patches done) let's build our cross-gdb running on host-i386 aiming at target armeb-nslu2 for ex.
Since this a tool in sbox point of view,let switch to HOST target
[sbox-nslu2: ~/build_gdbarmeb] > sb-conf se HOST
Shell restarting...

[sbox-HOST: ~/gdb-6.3] > patch -p1 &#060; ../gdb_patch/sim-install.patch  

[sbox-HOST: ~] > mkdir build-crossgdbarmeb
[sbox-HOST: ~] > cd build-crossgdbarmeb/

[sbox-HOST: ~/build-crossgdbarmeb] > ../gdb-6.3/configure --host=i386-pc-linux-gnu --target=armv5b-softfloat-linux
      

[sbox-HOST: ~/build-crossgdbarmeb] >make

After a while :
[sbox-HOST: ~/build-crossgdbarmeb] > file gdb/gdb gdb/gdb: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.0, dynamically linked (uses shared libs), not stripped

Instead of mounting,you can login the devel_target_partition with sb-armeb> sh /login_target.sh ;this results in a login to a virtual_nslu2 with a true IXP425_cpu operating on the devel_target_dir as root_fs (nfsmount).Although jailed here,you can ssh to outside world so that a cross compile in an env_HOST could be tested immediately by tranfering with scp to the jailed_target.

.(this nslu2 part edited by nnhoan_acong_yahoo_cham_com)


BuildScratchboxMipselWgt634u



mipsel-toolchain: sbox-demo-mipsel.sh


#!/bin/sh set -ex
# Little-endian MIPS
#
# To create a toolchain for the Linksys wrt54g, select glibc-2.2.3
# See [WWW] http://seattlewireless.net/index.cgi/LinksysWrt54g
# [WWW] http://www.batbox.org/wrt54g-linux.html
# Note: recent wrt54g firmware uses uclibc, which behaves like a subsetted glibc.
# There are patches to build uclibc toolchains in the contrib directory,
# but they're not integrated yet. However, you can still use a glibc
# toolchain; you'll either have to
# a) not call the missing functions,
# b) use a stub library like [WWW] http://www.xse.com/leres/tivo/downloads/libtivohack/
# or c) link your programs statically if you want them to run on
# the wrt54g.

TARBALLS_DIR=$HOME/downloads
RESULT_TOP=/scratchbox/compilers
PREFIX=$RESULT_TOP/mipsel-gcc-3.3.6-glibc-2.3.2
export TARBALLS_DIR RESULT_TOP PREFIX
GCC_LANGUAGES="c,c++"
export GCC_LANGUAGES

unset LD_LIBRARY_PATH
mkdir -p $RESULT_TOP

# Build the toolchain. Takes a couple hours and a couple gigabytes.

echo Done.


select HOST ,gcc-host with sb-menu. To build toolchain,from inside crosstool-0.38 type

[sbox-HOST:~/crosstool-0.38] > sh sbox-demo-mipsel.sh 

Once the toolchain is built,finish up the symlinks at two places

[sbox-HOST:/scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2/bin]> for f in `ls`; do ln -s $f sbox-$f; done 

and in

[sbox-HOST:/scratchbox/compilers/bin/] modify the file wrapper_links to reflect this:
PREFICES="host- arm-linux- i386-linux- i686-linux- powerpc-linux- mips-linux- armv5b-softfloat-linux- armeb-linux- mipsel-unknown-linux-gnu-" 

then do

[sbox-HOST:/scratchbox/compilers/bin/] > ./wrapper_links create
 

Create three following files,to render the toolchain readable by sbox

[sbox-HOST:/scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2/[compiler-name  gcc.specs target_setup.sh ]

compiler-name:
mipsel-gcc-3.4.4-glibc-2.3.2:/scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2:mipsel:unknown-linux-gnu:glibc:mipsel

gcc.specs:
 *cross_compile:
0
%rename cpp old_cpp
*cpp:
-isystem /usr/local/include -isystem /usr/include %(old_cpp)
 

target_setup.sh :
#!/bin/sh

target=$1

mkdir -p $target/lib
mkdir -p $target/usr/lib
mkdir -p $target/usr/include
mkdir -p $target/usr/bin

cp -af /scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2/lib/*                 $target/lib/
cp -af /scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2/mipsel-unknown-linux-gnu/lib/*  $target/lib/
cp -af /scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2/mipsel-unknown-linux-gnu/lib/libstdc++* $target/usr/lib/

find /scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2/usr/ -mindepth 1 -maxdepth 1 -not -name libexec -exec cp -af {} $target/usr/ \;

cp -af /scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2/include/* $target/usr/include/

ln -sf /bin/cpp $target/lib/
ln -sf /bin/cc  $target/usr/bin/

chmod +x $target/lib/ld-*.so

Use sb-menu to create a target : mips_le (little endian ) with cross compiler :mipsel-gcc-3.4.4-glibc-2.3.2
The target rootstrap will be created later in another part of this tutorial !!!
Now,we need to build the device tools for message passing between sbox and the device


device_tools


build libfakeroot-tcp.so.0.0.1 get fakeroot-1.4.2.tar.gz from

ftp://ftp.debian.org/debian/pool/main/f/fakeroot/fakeroot_1.4.2.tar.gz

patch communicate.patch from

http://scratchbox.org/repos/1.2/sb-toolchains/device_tools/fakeroot/files/communication.patch

install -d $(WORKDIR)/lib/libfakeroot

$(CC) -o ../lib/libfakeroot/libfakeroot-tcp.so.0.0.1 libfakeroot.c communicate.c -fPIC -DPIC -shared -lpthread -ldl -Wl,-soname -Wl,libfakeroot-tcp.so.0

        ln -s libfakeroot-tcp.so.0.0.1 $(WORKDIR)/lib/libfakeroot/libfakeroot-tcp.so.0
        [sbox-mips_le:~/sbrsh-7.0] > make sbrshd   

Copy then sbrshd to

 /scratchbox/device_tools/sbrsh-7.0/mipsel-gcc-3.4.4-glibc-2.3.2/sbin/sbrshd 

and to the target board and setup the /etc/sbrshd.conf file.


Just play with sb-menu and your wgt634u ! (1st edited by wangji_nnhoan_acong_yahoo_cham_com)


HowtoBuildMipseluClibcToolchainScratchbox


get the src_tree_openwrt:  svn co -r 3246 https://svn.openwrt.org/openwrt/branches/whiterussian/openwrt/ 
mine was svn_checkout_3246_16feb2006
build it in the host_pc just to verify it works (and also to get the rootfs for mipsel-uClibc-0.9.28)
Try to build the same openwrt_tree inside scratchbox ,under HOST_host-gcc we rapidly get stopped after compiling binutils !
But the good new is all the unpack,patching are supplied inside the toolchain_build_mipsel directory !
The cross toolchain openwrt just built on our host_pc is good enough to crosscompile everything,but we cannot just move it inside scratchbox.
Most part can be just copied ,ie rootfs,but we need to compile the binutil,gcc,uClibc from the jailed sbox.
So here is a hack :manual build it
Create /scratchbox/compilers/openwrt/[include,sysroot,sysroot/usr/include] ;Copy the include from the rootfs_mipsel-uClibc-0.9.28 built at the beginning !!!!so as to have the right include files

Configured with:
../gcc-3.4.5/configure --prefix=/scratchbox/compilers/openwrt/ --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=mipsel-linux-uclibc --enable-languages=c,c++ --enable-shared --enable-target-optspace --disable-nls --disable-__cxa_atexit --with-sysroot=/scratchbox/compilers/openwrt/sysroot/
"make" does compile well cpp,gcc g++,libgcc,but gets blocked at libstdc++-v3 ;
Let's do make install even without this libstdc++-v3 (but we can copy from our rootfs_on_pc)
Modify as needed at the compilers/openwrt rootdir gcc.specs,compiler-name,target-setup.sh
and the sbox-mipsel-linux-uclibc-* links in openwrt/bin_dir.Put the rootfs_mipsel into wrt_target as rootstrap_stuff !
Now checking and the rest.
compile hello-world :
[sbox-wrt: ~] > cd hello-world/
[sbox-wrt: ~/hello-world] > make
make all-am
make[1]: Entering directory `/home/wangji/hello-world'
if gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.c; \ then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fi
gcc -g -O2 -o hello main.o
make[1]: Leaving directory `/home/wangji/hello-world'
[sbox-wrt: ~/hello-world] > ./hello
bash: ./hello: cannot execute binary file
[sbox-wrt: ~/hello-world] > file hello hello: ELF 32-bit LSB executable, MIPS, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
[sbox-wrt: ~/hello-world] > qemu-mipsel hello
Hello World!
[sbox-wrt: ~/hello-world] >


Note

The reason why ./hello did not run is due to a typo in register_misc_runner of scratchbox-base_1.0.2.deb package.One has to correct the /scratchbox/sbin/register_misc_runner with the foolowing :
#register mipsel little '\x0a'
register mipsel little '\x08'
then everything will be in order !!!!!
(added by wangji thursday april 20 2006 )



cross-compile sbrshd
[sbox-wrt: ~/sbrsh-7.0] > make clean
rm -f sbrsh sbrshd sb-exportfs *.o
[sbox-wrt: ~/sbrsh-7.0] > make sbrshd
cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o daemon.o daemon.c
In file included from daemon.c:16:
fakeroot.h:13:29: fakeroot/config.h: No such file or directory
fakeroot.h:14:30: fakeroot/message.h: No such file or directory
make: *** [daemon.o] Error 1

in order to see where to put the fakeroot/headers ,do
[sbox-wrt: ~/sbrsh-7.0] > cpp -v
Reading specs from /scratchbox/compilers/openwrt/bin/../lib/gcc/mipsel-linux-uclibc/3.4.5/specs
Reading specs from /scratchbox/compilers/openwrt/gcc.specs
Configured with: ../gcc-3.4.5/configure --prefix=/scratchbox/compilers/openwrt/ --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=mipsel-linux-uclibc --enable-languages=c,c++ --enable-shared --enable-target-optspace --disable-nls --disable-cxa_atexit --with-sysroot=/scratchbox/compilers/openwrt/sysroot/
Thread model: posix
gcc version 3.4.5 (OpenWrt-2.0)

ignoring nonexistent directory
"/scratchbox/compilers/openwrt/bin/../lib/gcc/mipsel-linux-uclibc/3.4.5/../../../../mipsel-linux-uclibc/include"
ignoring nonexistent directory "/scratchbox/compilers/openwrt/sysroot//usr/local/include"
ignoring duplicate directory "/scratchbox/compilers/openwrt//lib/gcc/mipsel-linux-uclibc/3.4.5/include"
ignoring nonexistent directory
"/scratchbox/compilers/openwrt//lib/gcc/mipsel-linux-uclibc/3.4.5/../../../../mipsel-linux-uclibc/include"
#include "..." search starts here:
#include <...> search starts here:

End of search list.

so we copy the fakeroot/headers to the right include_dir

[sbox-wrt: ~/sbrsh-7.0] >cp -r fakeroot /scratchbox/compilers/openwrt/sysroot/usr/include

[sbox-wrt: ~/sbrsh-7.0] > make sbrshd
cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o daemon.o daemon.c
cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o fakeroot.o fakeroot.c
cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o ident.o ident.c
cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o buffer.o buffer.c
cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o common.o common.c
cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o mount.o mount.c
cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o protocol.o protocol.c
cc -o sbrshd daemon.o fakeroot.o ident.o buffer.o common.o mount.o protocol.o -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -lutil
[sbox-wrt: ~/sbrsh-7.0] >
the compilation is fine;let's verify
[sbox-wrt: ~/sbrsh-7.0] > file sbrshd
sbrshd: ELF 32-bit LSB executable, MIPS, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
[sbox-wrt: ~/sbrsh-7.0] >

to build libfakeroot-tcp.so.0.0.1 and put in doc_directory.Compile fakeroot in host_pc first,then copy [wrap*.h ] into our fakeroot_topdir-remember to patch with communicate.c-
This is necessary because we don't have wrapawk from inside scratchbox !
[sbox-wrt: ~/fakeroot-1.4.2] > ./configure \

&& make &&make install

[sbox-wrt: ~/fakeroot-1.4.2/fake] > ./configure --prefix=/usr --mandir=/usr/share/man --program-suffix=-tcp --host=mipsel-linux-uclibc --build=i686-pc-none &&make && make install

 [sbox-wrt: ~/gdb-6.3/gdb/gdbserver] > ./configure --host=mipsel-linux-uclibc  && make


BuildPowerpcToolchainScratchbox


>sb-conf sh Compiler: host-gcc Devkits: none CPU-transparency: none


make sure you choose this gcc-glibc configuration


demo-ppc405.sh : 
 eval `cat powerpc-405.dat gcc-3.4.4-glibc-2.3.5-hdrs-2.6.11.2.dat` sh all.sh  --notest
create /scratchbox/compilers/ppc-405 then execute "sh demo-ppc405.sh"


create your links to sbox for gcc_wrapper stuffs
>ls /scratchbox/compilers/ppc-405/bin/sbox*
/scratchbox/compilers/ppc-405/bin/sbox-powerpc-405-linux-gnu-c++filt
/scratchbox/compilers/ppc-405/bin/sbox-powerpc-405-linux-gnu-cc
/scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-addr2line
/scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-ar
/scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-as
/scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-cpp
/scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-g++
/scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-gcc
/scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-gccbug
/scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-gcov
/scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-ld /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-nm /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-objcopy /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-objdump /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-ranlib /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-readelf /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-size /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-strings /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-strip

>cat /scratchbox/compilers/ppc-405/compiler-name
ppc-405:/scratchbox/compilers/ppc-405:powerpc:linux:glibc:ppc

>cat /scratchbox/compilers/ppc-405/target_setup.sh

#!/bin/sh (-)

target=$1

mkdir -p $target/lib
mkdir -p $target/usr/lib
mkdir -p $target/usr/include
mkdir -p $target/usr/bin

cp -af /scratchbox/compilers/ppc-405/lib/*                 $target/lib/
cp -af /scratchbox/compilers/ppc-405/powerpc-405-linux-gnu/lib/*  $target/lib/
cp -af /scratchbox/compilers/ppc-405/powerpc-405-linux-gnu/lib/libstdc++* $target/usr/lib/

find /scratchbox/compilers/ppc-405/usr/ -mindepth 1 -maxdepth 1 -not -name libexec -exec cp -af {} $target/usr/ \;

cp -af /scratchbox/compilers/ppc-405/include/* $target/usr/include/

ln -sf /bin/cpp $target/lib/
ln -sf /bin/cc  $target/usr/bin/

chmod +x $target/lib/ld-*.so 

>cp /scratchbox/compilers/ppc-405/lib/gcc/powerpc-405-linux-gnu/3.4.4/specs /scratchbox/compilers/ppc-405/gcc.specs


[sbox-[HOST]~]> sb-conf se powerpc
sb-conf sh
Compiler: ppc-405 Devkits: none CPU-transparency: qemu-ppc


Reading specs from /scratchbox/compilers/ppc-405/lib/gcc/powerpc-405-linux-gnu/3.4.4/specs
Reading specs from /scratchbox/compilers/ppc-405/gcc.specs

Configured with: /home/wangji/crosstool-0.38/build/powerpc-405-linux-gnu/gcc-3.4.4-glibc-2.3.5/gcc-3.4.4/configure --target=powerpc-405-linux-gnu --host=i386-host_pc-linux-gnu --prefix=/scratchbox/compilers/ppc-405 --with-cpu=405 --enable-cxx-flags=-mcpu=405 --with-headers=/scratchbox/compilers/ppc-405/powerpc-405-linux-gnu/include --with-local-prefix=/scratchbox/compilers/ppc-405/powerpc-405-linux-gnu --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long 
Thread model: posix
gcc version 3.4.4

make all-am make[1]: Entering directory `/home/wangji/hello-world' if gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.c; \ then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fi gcc -g -O2 -o hello main.o make[1]: Leaving directory `/home/wangji/hello-world'


hello: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not stripped


[sbox-powerpc: ~/hello-world]>qemu-ppc hello
/lib/ld.so.1: No such file or directory


[sbox-powerpc: ~/hello-world] > qemu-ppc hello
Hello World!


buld tools for cputransparency and rootfs


cp -r fakeroot /scratchbox/compilers/ppc-405/lib/gcc/powerpc-405-linux-gnu/3.4.4/include/
make sbrshd

sbrshd: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not stripped
copy sbrshd to TARGET/usr/sbin


 ./configure --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib/libfakeroot --program-suffix=-tcp --with-ipc=tcp --with-dbformat=path --build=i686-linux  &&make install
  ../configure --prefix=/usr --mandir=/usr/share/man --program-suffix=-tcp 
 cd fake  && ../configure --prefix=/usr --mandir=/usr/share/man --program-suffix=-tcp --build=i686-linux  && make install
 



/scratchbox/users/wangji/home/wangji/busybox-1.01/archival/libipkg/args.c:63: warning: passing arg 1 of `bb_xasprintf' from incompatible pointer type /scratchbox/users/wangji/home/wangji/busybox-1.01/archival/libipkg/args.c:63: error: void value not ignored as it ought to be make: *** [/scratchbox/users/wangji/home/wangji/busybox-1.01/archival/libipkg/args.o] Erreur 1 wangji@laixa:/scratchbox/users/wangji/home/wangji/busybox-1.01$

have fun wangji 03-03-2006


/!\ End of edit conflict


last edited 2006-09-08 12:17:25 by IlkkaPoutanen