Didj crosstool-NG Build Environment

From eLinux.org
Jump to: navigation, search

Background

I have used these instructions in the past to successfully build uclibc eabi toolchains for Didj. They are based on instructions I originally found at http://blog.leshak.ru/english/pages/how-to-build-cross-toolchain-arm-uclibc-eabi-using-crosstool-ng/

(That site was not responding as of this writing).

Prerequisites

build-essential
bison
flex
texinfo or makeinfo (if you can't apt-get makeinfo try texinfo)
automake
libtool
cvs
ncurses (libncurses5-dev)


Download and unpack crosstool-NG (latest version 1.7.1 as of 17 July 2010)

 cd ~
 wget http://ymorin.is-a-geek.org/download/crosstool-ng/crosstool-ng-1.7.1.tar.bz2
 tar -xjvf crosstool-ng-1.7.1.tar.bz2
 cd crosstool-ng-1.7.1

Configure and install

 ./configure --prefix=$HOME/ctng
 make
 make install

Add the path to the ct-ng

 export PATH=$PATH:$HOME/ctng/bin

Create a temporary folder for the assembly of the package

 cd ~
 mkdir toolchain-build
 cd toolchain-build

Copy preconfigured config files

 cp ../ctng/lib/ct-ng-1.7.1/samples/arm-unknown-linux-uclibcgnueabi/* .
 mv crosstool.config .config

If necessary, you can change the configuration (but it usually works fine without changes)

ct-ng menuconfig

You can usually just change the path to the cross-toolchain

nano .config


Configure CT_PREFIX_DIR to change the path to the cross-toolchain

this section previously told you to use the following as the prefix dir, unfortunately it causes issues, such as permission denied errors depending on how the user has their machine setup:

CT_PREFIX_DIR="/opt/ctng"

It has now been tested and the following should allow you to install the toolchain without issues:

#CHANGE THIS
CT_PREFIX_DIR="${HOME}/x-tools/${CT_TARGET}"
# TO THIS
CT_PREFIX_DIR="${HOME}/ctng/${CT_TARGET}"

if you look at Configure and install we use the $HOME/ctng folder, we should probably use $HOME/x-tools then we wouldn't need to edit the .config file at all.

Run the compilation, get a coffee - have lunch, etc. (after “.” you can specify the number of concurrently running tasks. Set it to equal the number of CPU cores in your system)

ct-ng build.4

An example log of a successful compilation: (There is one more step after this finishes)

 $ ct-ng build.4
 [INFO ]  Build started 20090406.091909
 [INFO ]  Checking environment sanity
 [INFO ]  Building environment variables
 [WARN ]  Directory '/home/dev/src' does not exist. Will not save downloaded tarballs to local storage.
 [EXTRA]  Preparing working directories
 [WARN ]  You did not specify the build system. That's OK, I can guess...
 [EXTRA]  Installing user-supplied crosstool-NG configuration
 [EXTRA]  =================================================================
 [EXTRA]  Dumping internal crosstool-NG configuration
 [EXTRA]    Building a toolchain for:
 [EXTRA]      build  = i486-linux-gnu
 [EXTRA]      host   = i486-linux-gnu
 [EXTRA]      target = arm-unknown-linux-uclibcgnueabi
 [EXTRA]  Dumping internal crosstool-NG configuration: done in 0.06s (at 00:01)
 [INFO ]  =================================================================
 [INFO ]  Retrieving needed toolchain components' tarballs
 [EXTRA]    Retrieving 'linux-2.6.26.8'
 [EXTRA]    Retrieving 'gmp-4.2.4'
 [EXTRA]    Retrieving 'mpfr-2.3.2'
 [EXTRA]    Retrieving 'binutils-2.19'
 [EXTRA]    Retrieving 'gcc-4.3.2'
 [EXTRA]    Retrieving 'uClibc-0.9.30'
 [EXTRA]    Retrieving 'libelf-0.8.10'
 [EXTRA]    Retrieving 'sstrip'
 [EXTRA]    Retrieving 'dmalloc-5.5.2'
 [EXTRA]    Retrieving 'duma_2_5_14'
 [EXTRA]    Retrieving 'gdb-6.8'
 [EXTRA]    Retrieving 'ncurses-5.6'
 [EXTRA]    Retrieving 'ltrace_0.5.orig'
 [EXTRA]    Retrieving 'strace-4.5.17'
 [INFO ]  Retrieving needed toolchain components' tarballs: done in 762.14s (at 12:43)
 [INFO ]  =================================================================
 [INFO ]  Extracting and patching toolchain components
 [EXTRA]    Extracting and patching 'linux-2.6.26.8'
 [EXTRA]    Extracting and patching 'gmp-4.2.4'
 [EXTRA]    Extracting and patching 'mpfr-2.3.2'
 [EXTRA]    Extracting and patching 'binutils-2.19'
 [EXTRA]    Extracting and patching 'gcc-4.3.2'
 [EXTRA]    Extracting and patching 'uClibc-0.9.30'
 [EXTRA]    Extracting and patching 'libelf-0.8.10'
 [EXTRA]    Extracting and patching 'dmalloc-5.5.2'
 [EXTRA]    Extracting and patching 'duma-2_5_14'
 [EXTRA]    Extracting and patching 'gdb-6.8'
 [EXTRA]    Extracting and patching 'ncurses-5.6'
 [EXTRA]    Extracting and patching 'ltrace-0.5'
 [EXTRA]    Extracting and patching 'strace-4.5.17'
 [INFO ]  Extracting and patching toolchain components: done in 98.05s (at 14:21)
 [INFO ]  =================================================================
 [INFO ]  Checking C library configuration
 [EXTRA]    Munging uClibc configuration
 [INFO ]  Checking C library configuration: done in 0.14s (at 14:21)
 [INFO ]  =================================================================
 [INFO ]  Installing kernel headers
 [EXTRA]    Installing kernel headers
 [EXTRA]    Checking installed headers
 [INFO ]  Installing kernel headers: done in 20.49s (at 14:42)
 [INFO ]  =================================================================
 [INFO ]  Installing GMP
 [EXTRA]    Configuring GMP
 [EXTRA]    Building GMP
 [EXTRA]    Checking GMP
 [EXTRA]    Installing GMP
 [INFO ]  Installing GMP: done in 39.33s (at 15:21)
 [INFO ]  =================================================================
 [INFO ]  Installing MPFR
 [EXTRA]    Configuring MPFR
 [EXTRA]    Building MPFR
 [EXTRA]    Checking MPFR
 [EXTRA]    Installing MPFR
 [INFO ]  Installing MPFR: done in 35.88s (at 15:57)
 [INFO ]  =================================================================
 [INFO ]  Installing binutils
 [EXTRA]    Configuring binutils
 [EXTRA]    Building binutils
 [EXTRA]    Installing binutils
 [INFO ]  Installing binutils: done in 34.51s (at 16:31)
 [INFO ]  =================================================================
 [INFO ]  Installing C library headers
 [EXTRA]    Copying sources to build dir
 [EXTRA]    Applying configuration
 [EXTRA]    Building headers
 [EXTRA]    Installing headers
 [INFO ]  Installing C library headers: done in 6.29s (at 16:38)
 [INFO ]  =================================================================
 [INFO ]  Installing static core C compiler
 [EXTRA]    Configuring static core C compiler
 [EXTRA]    Building static core C compiler
 [EXTRA]    Installing static core C compiler
 [INFO ]  Installing static core C compiler: done in 92.64s (at 18:10)
 [INFO ]  =================================================================
 [INFO ]  Installing C library
 [EXTRA]    Copying sources to build dir
 [EXTRA]    Applying configuration
 [EXTRA]    Building C library
 [EXTRA]    Installing C library
 [INFO ]  Installing C library: done in 76.73s (at 19:27)
 [INFO ]  =================================================================
 [INFO ]  Installing final compiler
 [EXTRA]    Configuring final compiler
 [EXTRA]    Building final compiler
 [EXTRA]    Installing final compiler
 [INFO ]  Installing final compiler: done in 1408.53s (at 42:56)
 [INFO ]  =================================================================
 [INFO ]  Finishing C library
 [EXTRA]    Copying sources to build dir
 [EXTRA]    Applying configuration
 [EXTRA]    Installing C library host utils
 [INFO ]  Finishing C library: done in 7.85s (at 43:04)
 [INFO ]  =================================================================
 [INFO ]  Installing GMP for the target
 [EXTRA]    Configuring GMP
 [EXTRA]    Building GMP
 [EXTRA]    Installing GMP
 [INFO ]  Installing GMP for the target: done in 27.50s (at 43:31)
 [INFO ]  =================================================================
 [INFO ]  Installing MPFR for the target
 [EXTRA]    Configuring MPFR
 [EXTRA]    Building MPFR
 [EXTRA]    Installing MPFR
 [INFO ]  Installing MPFR for the target: done in 12.29s (at 43:44)
 [INFO ]  =================================================================
 [INFO ]  Installing binutils for target
 [EXTRA]    Configuring binutils for target
 [EXTRA]    Building binutils' libraries (libiberty bfd) for target
 [EXTRA]    Installing binutils' libraries (libiberty bfd) for target
 [INFO ]  Installing binutils for target: done in 46.33s (at 44:30)
 [INFO ]  =================================================================
 [INFO ]  Installing libelf
 [EXTRA]    Configuring libelf
 [EXTRA]    Building libelf
 [EXTRA]    Installing libelf
 [INFO ]  Installing libelf: done in 10.04s (at 44:40)
 [INFO ]  =================================================================
 [INFO ]  Installing sstrip
 [EXTRA]    Building sstrip
 [EXTRA]    Installing sstrip
 [INFO ]  Installing sstrip: done in 0.17s (at 44:40)
 [INFO ]  =================================================================
 [INFO ]  Installing dmalloc
 [EXTRA]    Configuring dmalloc
 [EXTRA]    Building dmalloc
 [EXTRA]    Installing dmalloc
 [INFO ]  Installing dmalloc: done in 6.88s (at 44:47)
 [INFO ]  =================================================================
 [INFO ]  Installing D.U.M.A.
 [EXTRA]    Copying sources
 [EXTRA]    Building libraries 'libduma.a libduma.so.0.0.0'
 [EXTRA]    Installing libraries 'libduma.a libduma.so.0.0.0'
 [EXTRA]    Installing shared library link
 [EXTRA]    Installing wrapper script
 [INFO ]  Installing D.U.M.A.: done in 1.72s (at 44:49)
 [INFO ]  =================================================================
 [INFO ]  Installing cross-gdb
 [EXTRA]    Configuring cross-gdb
 [EXTRA]    Building cross-gdb
 [EXTRA]    Installing cross-gdb
 [INFO ]  Installing cross-gdb: done in 90.94s (at 46:20)
 [INFO ]  =================================================================
 [INFO ]  Installing native gdb
 [INFO ]    =================================================================
 [INFO ]    Installing ncurses library
 [EXTRA]      Configuring ncurses
 [EXTRA]      Building ncurses
 [EXTRA]      Installing ncurses
 [INFO ]    Installing ncurses library: done in 61.44s (at 47:21)
 [EXTRA]    Configuring native gdb
 [EXTRA]    Building native gdb
 [EXTRA]    Installing native gdb
 [INFO ]  Installing native gdb: done in 170.15s (at 49:10)
 [INFO ]  =================================================================
 [INFO ]  Installing gdbserver
 [EXTRA]    Configuring gdbserver
 [EXTRA]    Building gdbserver
 [EXTRA]    Installing gdbserver
 [INFO ]  Installing gdbserver: done in 5.70s (at 49:16)
 [INFO ]  =================================================================
 [INFO ]  Installing ltrace
 [EXTRA]    Copying sources to build dir
 [EXTRA]    Configuring ltrace
 [EXTRA]    Building ltrace
 [EXTRA]    Installing ltrace
 [INFO ]  Installing ltrace: done in 5.10s (at 49:21)
 [INFO ]  =================================================================
 [INFO ]  Installing strace
 [EXTRA]    Configuring strace
 [EXTRA]    Building strace
 [EXTRA]    Installing strace
 [INFO ]  Installing strace: done in 15.81s (at 49:37)
 [INFO ]  =================================================================
 [EXTRA]  Installing the populate helper
 [EXTRA]  Creating toolchain aliases
 [INFO ]  Removing installed documentation
 [INFO ]  Build completed at 20090406.100846
 [INFO ]  (elapsed: 49:36.55)
 [INFO ]  Finishing installation (may take a few seconds)...
 [49:37] $

Last step: Create a file named 'crosscompile' with the contents below (edit accordingly for your directory structure). Whenever you want to compile anything for the device, enter 'source crosscompile' first to set the environment variables. compiling for didj, edit the export PROJECT_PATH= line to where you unpacked your kernel sources, use:

 export ARCH=arm
 export CC=arm-unknown-linux-uclibcgnueabi-gcc
 export CXX=arm-unknown-linux-uclibcgnueabi-gcc
 export CROSS_COMPILE=arm-unknown-linux-uclibcgnueabi-
 export PATH=$PATH:$HOME/ctng/bin:$HOME/ctng/arm-unknown-linux-uclibcgnueabi/bin
 export PROJECT_PATH=[YOUR PATH TO THE SOURCE TREE]/Didj-Linux-4222-20090422-1236
 export TARGET_MACH=LF_LF1000
 export ROOTFS_PATH=${PROJECT_PATH}/Didj-Linux-4222-20090422-1236/target/didj-rootfs
 export RELEASE_PATH=${PROJECT_PATH}/Didj-Linux-4222-20090422-1236/target/release
 export TFTP_PATH=${PROJECT_PATH}/Didj-Linux-4222-20090422-1236/target/tftp
 export EROOTFS_PATH=${PROJECT_PATH}/Didj-Linux-4222-20090422-1236/target/erootfs.stage

Compiling for Explorer, use the following, if you edit the export PROJECT_PATH line it will change all of the other target path dirs for you:

 export ARCH=arm
 export CC=arm-unknown-linux-uclibcgnueabi-gcc
 export CXX=arm-unknown-linux-uclibcgnueabi-gcc
 export CROSS_COMPILE=arm-unknown-linux-uclibcgnueabi-
 export PATH=$PATH:${HOME}/ctng/bin:${HOME}/ctng/arm-unknown-linux-uclibcgnueabi/bin
 export PROJECT_PATH=[YOUR PATH TO THE SOURCE TREE]/LX-Linux-6905-20100610-0915
 export TARGET_MACH=LF_TS_LF1000
 export ROOTFS_PATH=${PROJECT_PATH}/LX-Linux-6905-20100610-0915/target/rootfs
 export RELEASE_PATH=${PROJECT_PATH}/LX-Linux-6905-20100610-0915/target/release
 export TFTP_PATH=${PROJECT_PATH}/LX-Linux-6905-20100610-0915/target/tftp
 export EROOTFS_PATH=${PROJECT_PATH}/LX-Linux-6905-20100610-0915/target/erootfs.stage

The PROJECT_PATH will be the folder that you unpack the source to, so if I unpacked the explorer kernel sources in my $HOME dir that would be:

PROJECT_PATH=/home/reggie/LX-Linux-6905-20100610-0915

Create the directories for the rootfs of your shiny new kernel

You should also create the directories to save any tears later if a config file can't find a directory it needs so after running the crosscompile script for the first time do the following:

mkdir $PROJECT_PATH/target $TFTP_PATH $ROOTFS_PATH $EROOTFS_PATH $RELEASE_PATH

These are the various directories that the Leapfrog sources expect to put things in according to the different scripts that are available for us to use.

For instance, the make_rootfs.sh file in the Didj kernel sources ($PROJECT_PATH/scripts dir) will eventually make you a kernel and a whole rootfs and place it all in the $ROOTFS_PATH folder, from there you could mount your $ROOTFS_PATH as an NFS share as if it were actually on the Didj/Explorer (a tutorial for this will be along shortly....)


Once you've made your folders you should be set to compile your own apps. If you want to compile a kernel you need to edit the makefile in the kernel source dir ($PROJECT_PATH/linux-2.6/ for the explorer, $PROJECT_PATH/linux-2.6.20-lf1000 for the Didj) and comment out the CROSS_COMPILE= line with a #:

#CROSS_COMPILE = arm-linux-

once thats done you should be able to make a kernel for yourself, enter the kernel source dir and execute:

make lf1000_ts_defconfig

This will build a stock Explorer kernel for you, of course feel free to do a make menuconfig after the initial make above.


on the Leapster Explorer you may well want to test the new kernel non destructively via usb, see the Testing Kernels via USB Boot tutorial for more details.