terence427学习笔记

# Toolchain

To build binaries for the iPod you will need a special version of the GNU toolchain, where the compiler is configured as a cross compiler. This is used to generate binaries on your development machine which are executable on another platform, in this case the iPod. Since the iPod is an ARM based platform we need an ARM cross compiler. Fortunately there are pre-built versions of the cross compiler available for Linux, OS X, and Windows (via Cygwin). If you need to customize the toolchain, you'll have to build it yourself.

 Table of contents [hide]

## Installing a pre-built toolchain

There are two versions of the toolchain: 2.95 and 3.4.3. They contain different versions of the compiler (gcc). While the kernel needs to be built with 2.95, many other apps need to be built with the newer version.

#### Note about installing both toolchains

These two toolchains can coexist on the same system, but you may need to remove the compatibility symlinks from the newer toolchain once you have installed it (Note: this applies only to Linux systems - for Mac OS X see the note further down):

rm -f /usr/local/arm-uclinux-tools2/bin/arm-elf-*


If you do this, be sure you set the HOST appropriately for each toolchain you want to use: arm-elf for 2.95, and arm-uclinux-elf for 3.4.3.

### For the kernel (2.95 toolchain)

The arm-elf 2.95 toolchain is not for applications. This toolchain has several problems, namely:

• C++ support is passable at best.
• No i18n support.
• Cannot handle constructs like anonymous structures.

The new version, arm-uclinux-elf 3.4.3, fixes all these issues (and is much more modern). Unfortunately, the Linux 2.4 kernel source doesn't quite agree with 3.4.3 so you need to apply this patch (http://www.so2.sys-techs.com/ipod/linux/iPL_2.4.32-ipod2_arm-uclinux-elf.patch) to the kernel source before you compile the kernel for the iPod.

If you are using a pre-compiled kernel (e.g. from a nightly build), you can skip this section.

#### Linux on x86

Download:

http://www.uclinux.org/pub/uClinux/arm-elf-tools/arm-elf-tools-20030314.sh

Install the toolchain as root user:

sudo ./arm-elf-tools-20030314.sh

If you get the error message 'tail: cannot open +43' for reading: No such file or directory' when installing, change line 39 from:

tail +${SKIP}${SCRIPT} | gunzip | tar xvf -

to:

tail -n+${SKIP}${SCRIPT} | gunzip | tar xvf -

#### Mac OS X on PPC

(Note: works only on PowerPC Macs, not on Intel Macs)

Download and run the installer:

http://prdownloads.sourceforge.net/ipodlinux/arm_elf_stl.pkg.tar?download

Note: If you should later install the 3.4.3 toolchain as well, the "arm-elf"-files in /usr/local/bin will get replaced with the new toolchain commands, meaning that you then cannot build the kernel with the 2.95 toolchain any more. While the 2.95 installer also creates its own private directory /usr/local/arm-elf/bin, it does miss out on placing a few needed files into that dir (e.g. objcopy is missing there). So I suggest you issue this command in Terminal after having used the above installer in order to preserve all tools of the 2.95 toolchain (this will then later allow you to refer to these copies to build the kernel):

cp /usr/local/bin/arm-elf-* /usr/local/arm-elf/bin

#### Cygwin on Windows on x86

Download the zip file:

http://prdownloads.sourceforge.net/ipodlinux/arm-elf-gcc.zip?download

It contains the entire folder hierarchy (/usr/local/...), so you need to extract this to your Cygwin root directory, making sure you do not replace the contents of existing directories but add the new files into them. Be advised that some people have reported instability in this toolchain.

See also: Using Cygwin

#### Other Systems

You must build the toolchain from source. See below for instructions.

### For applications (3.4.3 toolchain)

For applications, you can use the more modern 3.4.3 arm-uclinux-elf toolchain; its advantages are above. If you are running a Linux or OS X system on x86 or PowerPC, then you can just download the toolchain in binary form. The x86 toolchain also works on AMD64 systems provided you have IA-32 compatibility libraries installed; this is the default on most AMD64 Linux distributions (on Gentoo, emerge emul-linux-x86-baselibs).

Note: you only need the first of the three files for a standard installation. The others are for development purposes.

The files you need are:

The toolchain is hardcoded to live in /usr/local/. You can extract it there by executing all three files as root:

# sh ./arm-uclinux-elf-tools-base-gcc3.4.3-20050722.sh
# sh ./arm-uclinux-elf-tools-c++-gcc3.4.3-20050722.sh
# sh ./arm-uclinux-elf-tools-gdb-20050722.sh


If you get an error like, tail: cannot open +43' for reading: No such file or directory, you need to change the line from

tail +${SKIP}${SCRIPT} | bunzip2 | tar xvf -

to

tail -n+${SKIP}${SCRIPT} | bunzip2 | tar xvf -

With a command like

# nano --nonewlines --noconvert arm-uclinux-elf-tools-base-gcc3.4.3-20050722.sh


Or, you may corrupt the file.

For the Cygwin one, you should do

# tar -C / -xvjf arm-uclinux-tools-cygwin-20060116.tar.bz2


If you are getting file not found errors from the cygwain tar then try appending another .tar to the end of above. For example:

# tar -C / -xvjf arm-uclinux-tools-cygwin-20060116.tar.bz2.tar


## Building your own toolchain

This is not recommended. It is far too easy to royally screw things up. Unless you have a really good reason not to, please stick with the prebuilt toolchains.
Also, these instructions are out of date - they're for 2.95.

Go to [1] (http://sourceforge.net/project/shownotes.php?release_id=226054). Go get the file build-uclinux-tools.sh (http://uclinux.org/pub/uClinux/arm-elf-tools/tools-20030314/build-uclinux-tools.sh)". This is a shell script which will do the build for you later, but it also contains notes about the prerequisites. Get all the files you need. You also need to get and configure the uClinux sources - see how to do that in Kernel Building. Follow all steps until the 'make' step, instead, do only a 'make dep'. You're done here.

When you have everything in place, edit build-uclinux-tools.sh (the 'edit' section). Put in the correct name for the uClinux source dir. If you want to install the toolchain in a different directory (e.g. /opt/arm-elf), put in a line like

PREFIX=/opt/arm-elf
PATH="${PREFIX}/bin:$PATH"; export PATH


Now you can run build-uclinux-tools.sh.

If the script complains that it can't write to $PREFIX, create$PREFIX manually.

mkdir /opt/arm-elf


If you get an error from patch saying some file is locked in Perforce, you should set an environ var 'POSIXLY_CORRECT' to work around that, or unset your P4PORT env.

export POSIXLY_CORRECT=1
OR
export P4PORT=


If you get an error from patch saying that it can't find the file gcc-uclinux-elf.mak, add a line

touch STLport-4.5.3/src/gcc-uclinux-elf.mak


before

${PATCH} -p0 < STLport-4.5.3.patch  ## Setup your build environment Normally your cross compiler will be installed in /usr/local/arm-uclinux-tools2/bin so you need to include that in your PATH. (The OS X version installs in /usr/local/arm-uclinux-tools/bin, modify appropriately) % export PATH=/usr/local/arm-uclinux-tools/bin:$PATH


The Cygwin toolchain installs in /usr/local/arm-uclinux-elf-tools/bin instead, so your PATH-supplementing line should be something like

% export PATH=/usr/local/arm-uclinux-elf-tools/bin:\$PATH


### Debian / Ubuntu issues

On Ubuntu Linux (and possibly other Debian-based systems), attempting to run these tools under sudo (for example, in 'make install' steps) will fail with 'command not found', even when the above directory is in your path. This is because Debian's sudo package is compiled with the --with-secure-path option, which causes it to use a hard-coded path instead of your actual one.

The only known 'proper' fix is to recompile your own copy of sudo. As a workaround, you can add symlinks to the arm-uclinux tools to /usr/local/bin with this command:

sudo ln -s /usr/local/arm-uclinux-tools2/bin/arm-uclinux-elf-* /usr/local/bin/


#### uclinux toolchain

2011-05-25 21:52:00

#### 如何交叉编译 uClinux 内核

2009年03月25日 6.87MB 下载

#### 交叉编译uclinux内核

2009年08月01日 7.28MB 下载

#### uClinux交叉编译综合文档。

2008-03-18 20:35:00

#### uClinux编译方法(uClinux-dist-20041215.tar.gz+S3C44B0X)

2007-05-10 23:46:00

#### uClinux的一些点

2008-01-23 15:16:00

#### STM32F429I-DISCO ucLinux 开发环境搭建

2017-11-20 11:58:19

#### uClinux源代码

2014年09月07日 9.5MB 下载

#### uClinux学习笔记之三 uClinux驱动开发初步

2008-08-26 19:20:00

#### uClinux

2018-02-23 17:07:45