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: | ||
[[Category: | [[Category:Linux]] | ||
=Cross Compiling= | =Cross Compiling= | ||
Line 18: | Line 18: | ||
To know how many cores you have available use : | To know how many cores you have available use : | ||
<pre> | |||
grep -c '^processor' /proc/cpuinfo | |||
</pre> | |||
This will be used later on while building the toolchain ct-ng build.#number of cores and while compiling export CONCURRENCY_LEVEL=#number of cores. | This will be used later on while building the toolchain ct-ng build.#number of cores and while compiling export CONCURRENCY_LEVEL=#number of cores. | ||
Line 24: | Line 26: | ||
Example for a quadcore system : | Example for a quadcore system : | ||
<pre> | |||
ct-ng build.4 | ct-ng build.4 | ||
CONCURRENCY_LEVEL=4 | CONCURRENCY_LEVEL=4 | ||
</ | </pre> | ||
Line 33: | Line 35: | ||
Install required packages : | Install required packages : | ||
<pre> | |||
sudo apt-get install build-essential gawk bison flex automake libtool cvs lzma ncurses-dev texinfo patch g++ gcj mercurial git-core | |||
</pre> | |||
Add the enviromental variable to bash : | Add the enviromental variable to bash : | ||
<pre> | |||
sudo vi /etc/bash.bashrc | |||
or | or | ||
vi /home/user/.bashrc | |||
</pre> | |||
Add the following lines at the end of the file : | Add the following lines at the end of the file : | ||
export PATH="${PATH}:/home/user/crosstool/bin/" | export PATH="${PATH}:/home/user/crosstool/bin/" | ||
export PATH="${PATH}:/home/user/x-tools/powerpc64-unknown-linux-gnu/bin/" | export PATH="${PATH}:/home/user/x-tools/powerpc64-unknown-linux-gnu/bin/" | ||
export CONCURRENCY_LEVEL=#number | export CONCURRENCY_LEVEL=#number | ||
Create directories and compile crosstool : | Create directories and compile crosstool : | ||
<pre> | |||
mkdir /home/user/crosstool | mkdir /home/user/crosstool | ||
mkdir /home/user/kernel | mkdir /home/user/kernel | ||
Line 58: | Line 68: | ||
hg clone http://crosstool-ng.org/hg/crosstool-ng | hg clone http://crosstool-ng.org/hg/crosstool-ng | ||
cd crosstool-ng | cd crosstool-ng | ||
./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/ -> '''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 98: | Line 108: | ||
Go to that directory and apply the patch : | Go to that directory and apply the patch : | ||
<pre> | |||
cd /home/user/crosstool/lib/ct-ng-yourcrosstoolversion/scripts/build | cd /home/user/crosstool/lib/ct-ng-yourcrosstoolversion/scripts/build | ||
patch < important.patch | patch < important.patch | ||
</ | </pre> | ||
===Creating a cross compiler toolchain for ppc64=== | ===Creating a cross compiler toolchain for ppc64=== | ||
Line 107: | Line 117: | ||
Download graf_chokolo's kernel : | Download graf_chokolo's kernel : | ||
<pre> | |||
cd /home/user/kernel | cd /home/user/kernel | ||
git clone git://git.gitbrew.org/ps3/ps3linux/linux-2.6.git | git clone git://git.gitbrew.org/ps3/ps3linux/linux-2.6.git | ||
tar -zcvf linux-2.6.tar.gz linux-2.6/ | tar -zcvf linux-2.6.tar.gz linux-2.6/ | ||
</ | </pre> | ||
Copy the sample configuration file and modify it : | Copy the sample configuration file and modify it : | ||
<pre> | |||
cp /home/user/crosstool/lib/ct-ng-yourcrosstoolversion/samples/powerpc64-unknown-linux-gnu/* /home/user/toolchain/powerpc/ | cp /home/user/crosstool/lib/ct-ng-yourcrosstoolversion/samples/powerpc64-unknown-linux-gnu/* /home/user/toolchain/powerpc/ | ||
cd /home/user/toolchain/powerpc/ | cd /home/user/toolchain/powerpc/ | ||
Line 121: | Line 131: | ||
cd /home/user/toolchain/powerpc/ | cd /home/user/toolchain/powerpc/ | ||
ct-ng menuconfig | ct-ng menuconfig | ||
</ | </pre> | ||
I've added graf_chokolos kernel : | I've added graf_chokolos kernel : | ||
Line 133: | Line 143: | ||
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.#number | ct-ng build.#number | ||
</ | </pre> | ||
'''Wait for some time until it finishes compiling''' | '''Wait for some time until it finishes compiling''' | ||
Line 150: | Line 160: | ||
===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 170: | ||
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 -zxvf 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 : | ||
Line 180: | Line 197: | ||
Finally : | Finally : | ||
<pre> | |||
make | |||
</pre> | |||
===Cross compiling graf_chokolo's tools=== | ===Cross compiling graf_chokolo's tools=== | ||
Line 196: | Line 215: | ||
Finally : | Finally : | ||
<pre> | |||
make | |||
</pre> | |||
You can find graf_chokolo tools and scripts here : | You can find graf_chokolo tools and scripts here : | ||
Line 205: | Line 226: | ||
Go to the directory where you saved your kernel, untar it and go to the kernel source directory : | Go to the directory where you saved your kernel, untar it and go to the kernel source directory : | ||
<pre> | |||
cd /home/user/kernel | cd /home/user/kernel | ||
tar xfvz linux-2.6.tar.gz | tar xfvz linux-2.6.tar.gz | ||
cd linux-2.6 | cd linux-2.6 | ||
</ | </pre> | ||
It is a good measure to clean the source directory : | It is a good measure to clean the source directory : | ||
<pre> | |||
make clean | make clean | ||
make-kpkg clean | make-kpkg clean | ||
</ | </pre> | ||
Export set ARCH=powerpc | Export set ARCH=powerpc | ||
And set the right number of concurrent jobs to be done this is used to improve the building time : | And set the right number of concurrent jobs to be done this is used to improve the building time : | ||
<pre> | |||
export ARCH=powerpc | export ARCH=powerpc | ||
export CONCURRENCY_LEVEL=4 | export CONCURRENCY_LEVEL=4 | ||
</ | </pre> | ||
Use graf_chokolo config file : | Use graf_chokolo config file : | ||
<pre> | |||
cp ps3_linux_config .config | cp ps3_linux_config .config | ||
make oldconfig | make oldconfig | ||
</ | </pre> | ||
You can customize your by using make menuconfig. | You can customize your by using make menuconfig. | ||
Line 235: | Line 260: | ||
Now lets compile and package our kernel : | Now lets compile and package our kernel : | ||
<pre> | |||
make-kpkg --arch=powerpc --cross-compile=powerpc64-unknown-linux-gnu- --rootcmd=fakeroot --initrd --append-to-version=-graf kernel_image kernel_source kernel_headers | |||
</pre> | |||