This page will describe how you can build the scratchbox foreign toolchain. If you plan to compile additional packages, you can either follow these instuctions, or skip this step. The toolchain will then be downloaded automatically when you install scratchbox.

Install scratchbox development environment

Use the hfp utility to setup an initial scratchbox development environment. Invoking “hfp sb-install-dev” will download and extract the following packages:
– scratchbox-core-1.0.22-i386
– scratchbox-libs-1.0.22-i386
– scratchbox-devkit-debian-1.0.12-i386
– scratchbox-devkit-doctools-1.0.15-i386
– scratchbox-devkit-perl-1.0.5-i386
– scratchbox-toolchain-host-gcc-1.0.22-i386

After that, the folders /scratchbox/compilers and /scratchbox/device_tools will be chowned to the current user, and the user will be added to scratchbox.

hv@scratchbox:~
$ hfp sb-install-dev
scratchbox-core-1.0.22-i386.tar.gz downloaded (46M)
sudo tar zxf scratchbox-core-1.0.22-i386.tar.gz -C /
scratchbox-libs-1.0.22-i386.tar.gz downloaded (14M)
sudo tar zxf scratchbox-libs-1.0.22-i386.tar.gz -C /
scratchbox-devkit-debian-1.0.12-i386.tar.gz downloaded (7.1M)
sudo tar zxf scratchbox-devkit-debian-1.0.12-i386.tar.gz -C /
scratchbox-devkit-doctools-1.0.15-i386.tar.gz downloaded (132M)
sudo tar zxf scratchbox-devkit-doctools-1.0.15-i386.tar.gz -C /
scratchbox-devkit-perl-1.0.5-i386.tar.gz downloaded (940K)
sudo tar zxf scratchbox-devkit-perl-1.0.5-i386.tar.gz -C /
scratchbox-toolchain-host-gcc-1.0.22-i386.tar.gz downloaded (4.2M)
sudo tar zxf scratchbox-toolchain-host-gcc-1.0.22-i386.tar.gz -C /
sudo /scratchbox/run_me_first.sh
sudo /scratchbox/sbin/sbox_adduser hv
sudo chown -R hv:hv /scratchbox/compilers
sudo mkdir /scratchbox/device_tools
sudo chown -R hv:hv /scratchbox/device_tools

You should logout and login again before you can use scratchbox

If the last line is displayed, you cannot start scratchbox until you’ve logged in again.

Create foreign toolchain

We’re going to use the toolchain provided by buildroot and configure it for scratchbox. Start by downloading and compiling the latest version

hv@scratchbox:~
$ hfp download http://buildroot.uclibc.org/downloads/buildroot-2010.11.tar.bz2
buildroot-2010.11.tar.bz2 downloaded

hv@scratchbox:~
$ tar jxf downloads/buildroot-2010.11.tar.bz2

hv@scratchbox:~
$ ln -s buildroot-2010.11 buildroot

hv@scratchbox:~
$ cd buildroot

hv@scratchbox:~/buildroot
$ make menuconfig

Now, make the following changes to the configuration of buildroot:

Target Architecture : arm
Target Architecture Variant : arm926t
Build options:
  Download dir: $(HOME)/downloads
  Toolchain and header file location: /scratchbox/compilers/arm-gcc4.3-uclibc0.9.31
Toolchain:
  Kernel Headers:  Linux 2.6 (manually specified version) 
  linux version: 2.6.24.4
  [*] Enable large files
  [*] Enable IPv6
  [*] Enable toolchain locale/i18n support
  [*] Enable stack protection support
  [*] Build/instal c++ compiler and libstdc++
Package selection for the target
  [ ] BusyBox  
Target filesystem options:
  [ ] ext2 root filesystem

After the initial build is ready, we make a small change to the configuration of uClibc (to enable the toolchain to be used by scratchbox 2):

hv@scratchbox:~/buildroot
$ make

hv@scratchbox:~/buildroot
$ make uclibc-menuconfig
General library settings:
  [*] Support global constructors and destructors

Now, rebuild the toolchain. After the toolchain has been created, we have to create some symbolic links to make the toolchain suitable for scratchbox.

hv@scratchbox:~/buildroot
$ make

hv@scratchbox:~/buildroot
$ cd /scratchbox/compilers/arm-gcc4.3-uclibc0.9.31

hv@scratchbox:/scratchbox/compilers/arm-gcc4.3-uclibc0.9.31
$ rmdir bin

hv@scratchbox:/scratchbox/compilers/arm-gcc4.3-uclibc0.9.31
$ ln -s usr/bin bin

hv@scratchbox:/scratchbox/compilers/arm-gcc4.3-uclibc0.9.31
$ ln -s usr/include include

hv@scratchbox:/scratchbox/compilers/arm-gcc4.3-uclibc0.9.31
$ ln -s usr/arm-unknown-linux-uclibcgnueabi .

hv@scratchbox:/scratchbox/compilers/arm-gcc4.3-uclibc0.9.31/bin
$ cd usr/include

hv@scratchbox:/scratchbox/compilers/arm-gcc4.3-uclibc0.9.31/usr/include
$ ln -s ../arm-unknown-linux-uclibcgnueabi/include/c++ c++

hv@scratchbox:/scratchbox/compilers/arm-gcc4.3-uclibc0.9.31/usr/include
$ cd

Configuring scratchbox

Log in to scratchbox. If you can’t login, try logging out and in again. Maybe you haven’t been added to the sbox group yet.

hv@scratchbox:~
$ /scratchbox/login
You dont have active target in scratchbox chroot.
Please create one by running "sb-menu" before continuing


Welcome to Scratchbox, the cross-compilation toolkit!

Use 'sb-menu' to change your compilation target.
See /scratchbox/doc/ for documentation.

[sbox-NO-TARGET: ~] > sb-conf st HOST -c host-gcc -d -perl:debian-etch:doctools -t none
[sbox-NO-TARGET: ~] > sb-conf in HOST -e -d
[sbox-NO-TARGET: ~] > sb-conf se HOST
[sbox-HOST: ~] > darcs get --set-scripts-executable http://scratchbox.org/repos/1.0/sb-toolchain-extras
[sbox-HOST: ~] > cd sb-toolchain-extras/device_tools/gdb
[sbox-HOST: ~/.../gdb] > vi Makefile
GARNAME = gdb
GARVERSION = 7.0.1
CATEGORIES = device_tools

PATCHLEVEL = 2
DISTFILES = $(GARNAME)_$(GARVERSION).orig.tar.gz \
            $(GARNAME)_$(GARVERSION)-$(PATCHLEVEL).debian.tar.gz

Change the marked code segments

[sbox-HOST: ~/.../gdb]  > cd ../gdbserver
[sbox-HOST: ~/.../gdb]  > vi Makefile
GARNAME = gdb
GARVERSION = 7.0.1
CATEGORIES = device_tools

PATCHLEVEL = 2
DISTFILES = $(GARNAME)_$(GARVERSION).orig.tar.gz \
            $(GARNAME)_$(GARVERSION)-$(PATCHLEVEL).debian.tar.gz

Change the marked code segments

[sbox-HOST: ~/.../gdbserver]  > cd ../../meta/alien-tc
[sbox-HOST: ~/.../alien-tc]  > vi arm-gcc4.3-uclibc0.9.31.conf
COMPILER_NAME = arm-gcc4.3-uclibc0.9.31
COMPILER_PACKAGE = scratchbox-toolchain-arm-gcc4.3-uclibc0.9.31
ALIEN_TC = yes

CC_VER = 4.3
CC_GCCVER = 4.3.5
CC_FULLVER = 4:$(CC_GCCVER)
CC_DEBIAN_DIR = gcc-3.4-debian

ARCH = arm
SUB_ARCH = $(ARCH)
VENDOR = unknown-
TOOLCHAIN_PREFIX_END = uclibcgnueabi-
TARGET_END = -uclibcgnueabi

BINUTILS_FULLVER = 2.20.1.20100303

HEADERS_DIR = $(COMPILER_DIR)/usr/include
LINUX_HEADERS_SUBDIRS = linux asm asm-generic
LINUX_HEADERS_VER = 2.6.24.4

LIBC_FILES_BINS = usr/arm-unknown-linux-uclibcgnueabi/target_utils
LIBC_FILES_LIBS = lib usr/lib
CHECKSUM_FILE   = ../../$(CONFIG:.conf=.checksums)

Enter the text above and save the file

[sbox-HOST: ~/.../alien-tc]  > cd ../..
[sbox-HOST: ~/sb-toolchain-extras]  > make CONFIG=meta/alien-tc/arm-gcc4.3-uclibc0.9.31.conf -C meta/alien-tc all-sums
[sbox-HOST: ~/sb-toolchain-extras]  > cd device_tools/gdbserver
[sbox-HOST: ~/.../gdbserver]  > make patch
[sbox-HOST: ~/.../gdbserver] > cd work/gdb-7.0.1/gdb/gdbserver
[sbox-HOST: ~/.../gdbserver]  > vi +20 linux-low.h
#ifdef HAVE_THREAD_DB_H
#include <thread_db.h>
#endif

#include <stdint.h>
#define HAVE_UINTPTR_T
#include "../gdb_thread_db.h"

#include "gdb_proc_service.h"

#ifdef HAVE_LINUX_REGSETS

Change the marked segments

[sbox-HOST: ~/.../gdbserver]  > cd ~/sb-toolchain-extras
[sbox-HOST: ~/sb-toolchain-extras]  > make CONFIG=meta/alien-tc/arm-gcc4.3-uclibc0.9.31.conf -C meta/alien-tc
[sbox-HOST: ~/sb-toolchain-extras]  > make CONFIG=meta/alien-tc/arm-gcc4.3-uclibc0.9.31.conf tarball
[sbox-HOST: ~/sb-toolchain-extras]  > cd
[sbox-HOST: ~]  > ls
sb-toolchain-extras
scratchbox-toolchain-arm-gcc4.3-uclibc0.9.31-1.0.22-i386.tar.gz

Cleanup

Now, we should logout off scratchbox

[sbox-HOST: ~]  > exit
logout

hv@scratchbox:~
$ rm -rf ~/buildroot-2010.11

hv@scratchbox:~
$ rm ~/buildroot

hv@scratchbox:~
$ cp /scratchbox/users/$(id -un)/home/$(id -un)/scratchbox-toolchain-arm-gcc4.3-uclibc0.9.31-1.0.22-i386.tar.gz ~/downloads

hv@scratchbox:~
$ hfp sb-remove
sudo /scratchbox/sbin/sbox_ctl stop
Stopping Scratchbox: umount, binfmt_misc.
sudo rm -rf /scratchbox
scratchbox removed

Links

Scratchbox: homepage
Scratchbox: toolchains
Scratchbox: foreign toolchains