Editing Cross Compiling
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
=Cross Compiling= | =Cross Compiling= | ||
This page shows how to cross compile for CellBE/ppc64 | This page shows how to cross compile for CellBE/ppc64 | ||
Line 11: | Line 10: | ||
Client: http://www.gentoo.org/doc/en/cross-compiling-distcc.xml (Because it's much better written than anything I could do) | Client: http://www.gentoo.org/doc/en/cross-compiling-distcc.xml (Because it's much better written than anything I could do) | ||
== | == Ubuntu/Debian == | ||
=== | ===Creating a cross compiler toolchain=== | ||
Install required packages | |||
<pre> | |||
sudo apt-get install build-essential gawk bison flex automake libtool cvs lzma ncurses-dev texinfo patch g++ gcj | |||
</pre> | |||
Create directories and compile crosstool | |||
<pre> | |||
Create directories and compile crosstool | |||
mkdir /home/user/crosstool | mkdir /home/user/crosstool | ||
mkdir /home/user/kernel | mkdir /home/user/kernel | ||
mkdir -p /home/user/toolchain/powerpc | mkdir -p /home/user/toolchain/powerpc | ||
tar xvjf crosstool-ng-1.10.0.tar.bz2 | |||
cd crosstool-ng | cd crosstool-ng-1.10.0/ | ||
./configure --prefix=/home/user/crosstool | ./configure --prefix=/home/user/crosstool/ | ||
make && make install | make && make install | ||
</ | </pre> | ||
* /home/user/crosstool-ng/ -> ''' | * /home/user/crosstool-ng-1.10.0/ -> '''crostool-ng sources''' | ||
* /home/user/crosstool/ -> '''Crosstool install directory with binaries''' | * /home/user/crosstool/ -> '''Crosstool install directory with binaries''' | ||
* /home/user/toolchain/ -> '''Directory where the binary will be installed''' | * /home/user/toolchain/ -> '''Directory where the binary will be installed''' | ||
Line 69: | Line 37: | ||
* /home/user/kernel -> '''Place were graf_chokolo's linux kernel tarball will be saved''' | * /home/user/kernel -> '''Place were graf_chokolo's linux kernel tarball will be saved''' | ||
Add the enviromental variable to bash | |||
<pre> | <pre> | ||
sudo gedit /etc/bash.bashrc | |||
</pre> | </pre> | ||
Add the following lines at the end of the file | |||
"export PATH="${PATH}:/home/user/crosstool/bin/" | |||
"export PATH="${PATH}:/home/user/x-tools/powerpc64-unknown-linux-gnu/bin/" | |||
Download graf_chokolo's kernel | Download graf_chokolo's kernel | ||
<pre> | |||
cd /home/user/kernel | cd /home/user/kernel | ||
wget -O linux-2.6.tar.gz http://git.dukio.com/gitweb.cgi?p=linux-2.6\;a=snapshot\;h=HEAD\;sf=tgz | |||
</pre> | |||
</ | |||
Copy the sample configuration file and modify it | Copy the sample configuration file and modify it | ||
<pre> | |||
cp /home/ | cp /home/usr/crosstool/lib/ct-ng-1.10.0/samples/powerpc64-unknown-linux-gnu/* /home/usr/toolchain/powerpc/ | ||
cd /home/ | cd /home/usr/toolchain/powerpc/ | ||
mv crosstool.config .config | mv crosstool.config .config | ||
cd /home/ | cd /home/usr/toolchain/powerpc/ | ||
ct-ng menuconfig | ct-ng menuconfig | ||
</ | </pre> | ||
I've added graf_chokolos kernel | I've added graf_chokolos kernel | ||
*Operating System -> Linux Kernel version -> custom tarball | *Operating System -> Linux Kernel version -> custom tarball | ||
Line 131: | Line 74: | ||
---- | ---- | ||
Start from scratch and configure the toolchain the way you want | Start from scratch and configure the toolchain the way you want | ||
<pre> | |||
cd /home/user/toolchain/powerppc/ | cd /home/user/toolchain/powerppc/ | ||
ct-ng menuconfig | ct-ng menuconfig | ||
</ | </pre> | ||
Compile ppc64 toolchain | Compile ppc64 toolchain | ||
<pre> | |||
unset LD_LIBRARY_PATH LIBRARY_PATH CPATH | unset LD_LIBRARY_PATH LIBRARY_PATH CPATH | ||
export LD_LIBRARY_PATH LIBRARY_PATH CPATH | export LD_LIBRARY_PATH LIBRARY_PATH CPATH | ||
ct-ng build | ct-ng build | ||
</ | </pre> | ||
'''Wait for some time until it finishes compiling''' | '''Wait for some time until it finishes compiling''' | ||
Line 150: | Line 92: | ||
===Testing if your toolchain works properly=== | ===Testing if your toolchain works properly=== | ||
<pre> | |||
export PATH="${PATH}:/home/user/x-tools/powerpc64-unknown-linux-gnu/bin/" | export PATH="${PATH}:/home/user/x-tools/powerpc64-unknown-linux-gnu/bin/" | ||
powerpc64-unknown-linux-gnuspe-gcc test.c -o test | powerpc64-unknown-linux-gnuspe-gcc test.c -o test | ||
</ | </pre> | ||
More info: http://www.ibm.com/developerworks/linux/tutorials/l-embedded-distro/section3.html | More info: http://www.ibm.com/developerworks/linux/tutorials/l-embedded-distro/section3.html | ||
Line 161: | Line 102: | ||
Download openssl sources | Download openssl sources | ||
<pre> | |||
wget http://www.openssl.org/source/openssl-0.9.8g.tar.gz | |||
</pre> | |||
unpack the sources | unpack the sources | ||
<pre> | |||
tar xvjf openssl-0.9.8g.tar.gz | |||
</pre> | |||
Go to openssl source path | Go to openssl source path | ||
<pre> | |||
cd openssl-0.9.8g/ | |||
</pre> | |||
Change the following lines in the Makefile | Change the following lines in the Makefile | ||
<pre> | <pre> | ||
INSTALLTOP= | INSTALLTOP=/x-tools/powerpc64-unknown-linux-gnu/powerpc64-unknown-linux-gnu/sysroot/usr | ||
OPENSSLDIR= | OPENSSLDIR=/x-tools/powerpc64-unknown-linux-gnu/powerpc64-unknown-linux-gnu/sysroot/usru | ||
CC= powerpc64-unknown-linux-gnu-gcc | CC= powerpc64-unknown-linux-gnu-gcc | ||
AR= | AR=xpowerpc64-unknown-linux-gnu-ar $(ARFLAGS) r | ||
RANLIB= powerpc64-unknown-linux-gnu-ranlib | RANLIB= powerpc64-unknown-linux-gnu-ranlib | ||
</pre> | </pre> | ||
Finally | Finally | ||
<pre> | |||
make | |||
</pre> | |||
===Cross compiling graf_chokolo's tools=== | ===Cross compiling graf_chokolo's tools=== | ||
Make sure you have a working toolchain and openssl installed | Make sure you have a working toolchain and openssl installed | ||
Comment the current compiler and add your cross compiler in our case "powerpc64-unknown-linux-gnu-gcc" | Comment the current compiler and add your cross compiler in our case "powerpc64-unknown-linux-gnu-gcc" | ||
<pre> | <pre> | ||
Line 194: | Line 142: | ||
</pre> | </pre> | ||
finally | |||
<pre> | |||
make | |||
</pre> | |||
you can find graf_chokolo tools and scripts here | |||
http://git.dukio.com/gitweb.cgi | |||
===Compiling graf_chokolo's kernel=== | |||
Set the following environmental variables | |||
If you haven't already | |||
<pre> | |||
export | |||
</pre> | |||
the cross compile environmental variables | |||
<pre> | |||
CROSS_COMPILE=powerpc64-unknown-linux-gnu- | |||
ARCH=powerpc | |||
</pre> | |||
</ | |||
Finally | |||
<pre> | |||
make | |||
</pre> | |||
< | |||