📄 arm_linux.html
字号:
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>一步一步的制作arm-linux交叉编译环境</title>
</head><body>
<p align="center"> </p>
<p align="center"><b><font size="6">一步一步的制作arm-linux交叉编译环境</font></b></p>
<p> </p>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="462">
<tbody><tr>
<td width="788" height="269">
<p style="line-height: 150%;">Gavin Li
<a href="http://65.54.244.250/cgi-bin/linkrd?_lang=EN&lah=09c9ba9f5247413a7810f22cff42fcad&lat=1055095776&hm___action=http%3a%2f%2fembedded%2ehomeunix%2eorg" target="_blank">http://embdev.gotdns.org</a>
Sunday, June 08, 2003<br>
</p><hr>
<p style="line-height: 150%;">我们使用以下版本的文件为例子建立arm-linux
交叉编译环境:
</p><ul>
<li>
<p style="line-height: 150%;">binutils-2.11.gz
</p></li><li>
<p style="line-height: 150%;">gcc-2.95.3.gz
</p></li><li>
<p style="line-height: 150%;">glibc-2.2.3.gz
</p></li><li>
<p style="line-height: 150%;">glibc-linuxthreads-2.2.3.tar.gz
</p></li><li>
<p style="line-height: 150%;">linux-2.4.5.gz
</p></li><li>
<p style="line-height: 150%;">patch-2.4.5-rmk7.gz
# linux kernel patch
</p></li></ul>
<p style="line-height: 150%;">我们的工作路径是:
</p><pre style="line-height: 150%;">~ -- +------- tars --+----- SourceDir
| \----- BuildDir
\------ armtools
</pre>
<table id="Table1" border="1" cellpadding="1" cellspacing="1" width="100%">
<tbody>
<tr>
<td align="left" bgcolor="#00cccc">
<p style="line-height: 150%;">tars</p>
</td>
<td align="left" bgcolor="#00cccc">
<p style="line-height: 150%;">在这里放我们的下载来的 .tar.gz
文件</p>
</td>
</tr>
<tr>
<td align="left" bgcolor="#00cccc">
<p style="line-height: 150%;">SourceDir</p>
</td>
<td align="left" bgcolor="#00cccc">
<p style="line-height: 150%;">这个临时目录放我们解压缩后的源文件</p>
</td>
</tr>
<tr>
<td align="left" bgcolor="#00cccc">
<p style="line-height: 150%;">BuildDir</p>
</td>
<td align="left" bgcolor="#00cccc">
<p style="line-height: 150%;">我们在这里编译</p>
</td>
</tr>
<tr>
<td align="left" bgcolor="#00cccc">
<p style="line-height: 150%;">armtools</p>
</td>
<td align="left" bgcolor="#00cccc">
<p style="line-height: 150%;">把arm-linux
交叉编译环境的安装在这里</p>
</td>
</tr>
</tbody>
</table>
<ol>
<li>
<p style="line-height: 150%;">安装linux 的头文件
</p><p style="line-height: 150%;">
</p><ul>
<li>
<p style="line-height: 150%;">解压缩,打补丁<code>
</code></p><pre style="line-height: 150%;">cd ~/tars/SourceDir
tar -zxf ../linux-2.4.5.tar.gz
cd linux
zcat ../../patch-2.4.5-rmk7.gz | patch -p1
</pre>
</li><li>
<p style="line-height: 150%;">修改 Makefile 建议先删除 .config
文件, 否这以后会遇到麻烦。<br>
将Makefile中ARCH := ......改为:ARCH=arm #<br>
执行一下 make clean<br>
</p></li><li>
<p style="line-height: 150%;">建立连接
</p><p style="line-height: 150%;">
</p><ul>
<li>
<p style="line-height: 150%;">如果是LART板子<code>
</code></p><pre style="line-height: 150%;">make ARCH=arm lart_config
cd include/asm-arm
rm -f arch proc
ln -s arch-sa1100 arch
ln -s proc-armv proc
</pre>
</li><li>
<p style="line-height: 150%;">如果是clps711x的CPU<code>
</code></p><pre style="line-height: 150%;">cd include/asm-arm
rm -f arch proc
ln -s arch-clps711x arch
ln -s proc-armv proc
</pre>
</li><li>
<p style="line-height: 150%;">为你自己的板子定制:<code>
</code></p><pre style="line-height: 150%;">make ARCH=arm menuconfig
make dep
</pre>
</li>
</ul>
</li><li>
<p style="line-height: 150%;">拷贝头文件<code>
</code></p><pre style="line-height: 150%;">cp -dR include/linux ~/armtools/arm-linux/include
cp -dR include/asm-arm ~/armtools/arm-linux/include/asm
</pre>
</li>
</ul>
</li><li>
<p style="line-height: 150%;">编译安装binutils
</p><p style="line-height: 150%;">
</p><ul>
<li>
<p style="line-height: 150%;">解压缩<code>
</code></p><pre style="line-height: 150%;">cd ~/tars/SourceDir
tar -zxf ../binutils-2.11.gz
</pre>
</li><li>
<p style="line-height: 150%;">编译<code>
</code></p><pre style="line-height: 150%;">cd ~/tars/BuildDir
mkdir binutils
cd binutils
../../SourceDir/binutils-2.11/configure --target=arm-linux --prefix=~/armtools
make all install
</pre>
</li>
</ul>
</li><li>
<p style="line-height: 150%;">编译安装gcc 的c 编译器
</p><p style="line-height: 150%;">
</p><ul>
<li>
<p style="line-height: 150%;">解压缩<code>
</code></p><pre style="line-height: 150%;">cd ~/tars/SourceDir
tar -zxf ../gcc-2.95.3.tar.gz
</pre>
</li><li>
<p style="line-height: 150%;">修改gcc 的t-linux 文件在t-linux文件中的TARGET_LIBGCC2_CFLAGS上加上__gthr_posix_h
inhibit_libc<br>
<code>
</code></p><pre style="line-height: 150%;">cd gcc-2.95.3/ gcc/config/arm
mv t-linux t-linux-orig
sed 's/TARGET_LIBGCC2_CFLAGS =/TARGET_LIBGCC2_CFLAGS = -D__gthr_posix_h -Dinhibit_libc/' < t-linux-orig > t-linux-core
cp ./t-linux-core ./t-linux
</pre>
</li><li>
<p style="line-height: 150%;">编译<code>
</code></p><pre style="line-height: 150%;">cd ~/tars/BuildDir
mkdir gcc-core
cd gcc-core
../../SourceDir/gcc-2.95.3/configure \
--target=arm-linux \
--prefix=~/armtools \
--enable-languages=c \
--with-local-prefix=~/armtools/arm-linux \
--without-headers \
--with-newlib \
--disable-shared
make all install
</pre>
</li>
</ul>
</li><li>
<p style="line-height: 150%;">编译安装 glibc
</p><p style="line-height: 150%;">
</p><ul>
<li>
<p style="line-height: 150%;">解压缩<code>
</code></p><pre style="line-height: 150%;">cd ~/tars/SourceDir
tar -zxf ../glibc-2.2.3.tar.gz
cd glibc-2.2.3
tar -zxf ../../glibc-linuxthreads-2.2.3.tar.gz
</pre>
</li><li>
<p style="line-height: 150%;">编译<code>
</code></p><pre style="line-height: 150%;">cd ~/tars/BuildDir
mkdir glibc
cd glibc
CC=arm-linux-gcc AR=arm-linux-ar RANLIB=arm-linux-ranlib \
../../SourceDir/glibc-2.2.3/configure \
--host=arm-linux \
--prefix=~/armtools/arm-linux \
--enable-add-ons \
--with-headers=~armtools/arm-linux/include
make all install
</pre>
</li>
</ul>
</li><li>
<p style="line-height: 150%;">编译安装gcc 的c, c++ 编译器
</p><p style="line-height: 150%;">
</p><ul>
<li>
<p style="line-height: 150%;">恢复t-linux 文件<code>
</code></p><pre style="line-height: 150%;">cd ~/tars/BuildDir
mkdir gcc
cd gcc
cp ../../SourceDir/gcc-2.95.3/gcc/config/arm/t-linux-orig \
../../SourceDir/gcc-2.95.3/gcc/config/arm/t-linux
</pre>
</li><li>
<p style="line-height: 150%;">编译<code>
</code></p><pre style="line-height: 150%;">../../SourceDir/gcc-2.95.3/configure \
--target=arm-linux \
--prefix=~/armtools \
--enable-languages=c,c++ \
--with-local-prefix=~armtools/arm-linux
make all install
</pre>
</li>
</ul>
</li>
</ol>
<p style="line-height: 150%;"><br>
<b>注:</b> 如果你是第一次制作arm-linux
交叉编译环境,强烈建议你用本文所使用的各个程序的版本。如果用其它版本,按照本文的方法可能会在编译的时候出问题,因为我没有时间去测试各个版本的组合。
</p></td>
</tr>
</tbody></table>
</center>
</div>
<p style="line-height: 150%;"> </p>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -