uclinux交叉编译、调试工具

Toolchain

From wikiPodLinux

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 <script type="text/javascript">showTocToggle("show","hide")</script>[hide]
[ edit]

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.

[ edit]
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.

[ edit]

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.

[ edit]
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 -
[ edit]
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
[ edit]
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

[ edit]
Other Systems

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

[ edit]

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
[ edit]

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
[ edit]

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 
[ edit]

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/
Retrieved from " http://ipodlinux.org/Toolchain"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值