buf

BE something YOU love and understand
posts - 94, comments - 35, trackbacks - 0, articles - 2
   :: 首页 :: 新随笔 :: 联系 ::  :: 管理

关于华硕的1073工具链...

Posted on 2012-02-07 23:57 buf 阅读(589) 评论(0)  编辑 收藏 引用 所属分类: Embedded Linux
最近几个月,空闲时间常在折腾基于RTD1073芯片的高清机DIY。刚开始的时候,很多东西只求得到需要的结果,其中的道理却不求甚解。这两天又在折腾libusb,终于把之前一些不太理解的地方梳理了一下,写在这里既是一份学习or折腾的记录,也分享给或许用得上的童鞋们。

总之,一切是从hdpfans上ccbcfan大虾转帖的《[转贴]1073DD播放机内核编译研究!(连载中...)》http://www.hdpfans.com/thread-3161-1-1.html开始的。追根溯源,找到了原文作者gouzhuang大牛的blog:http://www.cnitblog.com/gouzhuang/,这里有很多1073交叉编译相关的文章,写得非常清楚,对俺们这样的入门小白帮助极大,在此拜一下。

相关的交叉编译工具,似乎华硕的那个版本是广为流传了,下载以及安装的方法在gouzhuang的文章中都有详细讲解,这里我再做个进一步的说明:
1. OPlay_HDP-R1_GPL_SourceCode.zip解开以后有个1073_toolchain.tgz,解开这个tgz有两个文件夹:“Kernel Tools”和“AP Tools”。前者用于内核编译,后者用于用户程序编译(这样的说法不知有何根据,姑且根据文件夹的名字这样理解先)。

2. 安装“AP Tools”下的rpm后:
===工具链的可执行文件在/usr/local/bin/mipsel-linux-*:
root@debian:/home/paul# ls -l /usr/local/bin/mipsel-linux-*
-rwxr-xr-x 1 root root 530540 Feb 12  2004 /usr/local/bin/mipsel-linux-addr2line
-rwxr-xr-x 2 root root 506028 Feb 12  2004 /usr/local/bin/mipsel-linux-ar
-rwxr-xr-x 2 root root 795948 Feb 12  2004 /usr/local/bin/mipsel-linux-as
-rwxr-xr-x 2 root root  74060 Feb 12  2004 /usr/local/bin/mipsel-linux-c++
-rwxr-xr-x 1 root root  53580 Feb 12  2004 /usr/local/bin/mipsel-linux-c++filt
-rwxr-xr-x 1 root root  74092 Feb 12  2004 /usr/local/bin/mipsel-linux-cpp
-rwxr-xr-x 2 root root  74060 Feb 12  2004 /usr/local/bin/mipsel-linux-g++
-rwxr-xr-x 1 root root  72716 Feb 12  2004 /usr/local/bin/mipsel-linux-gcc
-rwxr-xr-x 2 root root 744140 Feb 12  2004 /usr/local/bin/mipsel-linux-ld
-rwxr-xr-x 2 root root 538924 Feb 12  2004 /usr/local/bin/mipsel-linux-nm
-rwxr-xr-x 1 root root 664460 Feb 12  2004 /usr/local/bin/mipsel-linux-objcopy
-rwxr-xr-x 1 root root 711180 Feb 12  2004 /usr/local/bin/mipsel-linux-objdump
-rwxr-xr-x 2 root root 506028 Feb 12  2004 /usr/local/bin/mipsel-linux-ranlib
-rwxr-xr-x 1 root root 159308 Feb 12  2004 /usr/local/bin/mipsel-linux-readelf
-rwxr-xr-x 1 root root 486156 Feb 12  2004 /usr/local/bin/mipsel-linux-size
-rwxr-xr-x 1 root root 486252 Feb 12  2004 /usr/local/bin/mipsel-linux-strings
-rwxr-xr-x 2 root root 664460 Feb 12  2004 /usr/local/bin/mipsel-linux-strip
===gcc版本为2.96:
root@debian:/home/paul# /usr/local/bin/mipsel-linux-gcc --version
2.96-sdelinuxmips-040127
===gcc include dir:
/usr/local/mipsel-linux/include        #这是从“AP Tools”文件夹下的inc_lib.tar.bz2释放出来的
===gcc link dir:
/usr/local/mipsel-linux/lib    #这是从“AP Tools”文件夹下的inc_lib.tar.bz2释放出来的
===对应的package为sdelinux:
root@debian:/home/paul# dpkg -l | grep sde
ii  sdelinux                             5.03.06-2                      SDE-MIPS targeted for MIPS Linux

3. 安装“Kernel Tools”下的mipsel-sdelinux-v6.03.01-1.i386.rpm后:
===工具链的可执行文件在/usr/bin/mipsel-linux-*:
root@debian:/home/paul# ls -l /usr/bin/mipsel-linux-*
-rwxr-xr-x 1 root root 602924 Nov 14  2005 /usr/bin/mipsel-linux-addr2line
-rwxr-xr-x 2 root root 574508 Nov 14  2005 /usr/bin/mipsel-linux-ar
-rwxr-xr-x 2 root root 948940 Nov 14  2005 /usr/bin/mipsel-linux-as
-rwxr-xr-x 1 root root  84716 Nov 14  2005 /usr/bin/mipsel-linux-cpp
-rwxr-xr-x 2 root root  83180 Nov 14  2005 /usr/bin/mipsel-linux-gcc
-rwxr-xr-x 2 root root  83180 Nov 14  2005 /usr/bin/mipsel-linux-gcc-3.4.4
-rwxr-xr-x 1 root root  21420 Nov 14  2005 /usr/bin/mipsel-linux-gcov
-rwxr-xr-x 2 root root 916364 Nov 14  2005 /usr/bin/mipsel-linux-ld
-rwxr-xr-x 2 root root 615244 Nov 14  2005 /usr/bin/mipsel-linux-nm
-rwxr-xr-x 1 root root 770060 Nov 14  2005 /usr/bin/mipsel-linux-objcopy
-rwxr-xr-x 1 root root 841132 Nov 14  2005 /usr/bin/mipsel-linux-objdump
-rwxr-xr-x 2 root root 574508 Nov 14  2005 /usr/bin/mipsel-linux-ranlib
-rwxr-xr-x 1 root root 221964 Nov 14  2005 /usr/bin/mipsel-linux-readelf
-rwxr-xr-x 1 root root 553100 Nov 14  2005 /usr/bin/mipsel-linux-size
-rwxr-xr-x 1 root root 553100 Nov 14  2005 /usr/bin/mipsel-linux-strings
-rwxr-xr-x 2 root root 770092 Nov 14  2005 /usr/bin/mipsel-linux-strip
===gcc版本为3.3.4:
root@debian:/home/paul# /usr/bin/mipsel-linux-gcc --version
mipsel-linux-gcc (GCC) 3.4.4 mipssde-6.03.01-20051114
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
===gcc include dir:
/usr/lib/gcc/mipsel-linux/3.4.4/include    # 问题是这个路径下只有几个.h文件,连stdio.h都没有
===gcc library dir:
/usr/lib/gcc/mipsel-linux/3.4.4                # 问题是这个路径下没有lib文件(*.so, *.a ...)
===对应的package为mipsel-linux-sdelinux:
root@debian:/home/paul# dpkg -l | grep sde
ii  mipsel-linux-sdelinux                6.03.01-2                      MIPS SDE combined cross-toolchain tree targeting MIPS Linux

注意:上述两套工具的可执行文件名称均为mipsel-linux-*,但却是两个不同的package,存放路径也不同。并且,sdelinux安装了g++(虽然后来发现没有编译c++程序需要的头文件),而mipsel-linux-sdelinux却没有安装g++。另外,已经看到mipsel-linux-sdelinux的include和link目录下缺少必要的文件,这套工具到目前为止啥也干不了。

4. 在“Kernel Tools”下还有一个toolchain_mipsel-6.03-6.i586.rpm,安装这个以后:
===工具链的可执行文件在 /usr/local/toolchain_mipsel/bin/mipsel-linux-*:
root@debian:/home/paul# ls /usr/local/toolchain_mipsel/bin/ -l
total 8652
-rwxr-xr-x 1 root root    814 Jul  3  2008 g++-uc
-rwxr-xr-x 1 root root  22164 Oct 13  2008 ldconfig
-rwxr-xr-x 1 root root   9628 Oct 13  2008 ldd
lrwxrwxrwx 1 root root     29 Feb  7 10:31 mipsel-linux-addr2line -> mipsel-linux-uclibc-addr2line
lrwxrwxrwx 1 root root     22 Feb  7 10:31 mipsel-linux-ar -> mipsel-linux-uclibc-ar
lrwxrwxrwx 1 root root     22 Feb  7 10:31 mipsel-linux-as -> mipsel-linux-uclibc-as
lrwxrwxrwx 1 root root     23 Feb  7 10:31 mipsel-linux-c++ -> mipsel-linux-uclibc-c++
lrwxrwxrwx 1 root root     22 Feb  7 10:31 mipsel-linux-cc -> mipsel-linux-uclibc-cc
lrwxrwxrwx 1 root root     27 Feb  7 10:31 mipsel-linux-c++filt -> mipsel-linux-uclibc-c++filt
lrwxrwxrwx 1 root root     23 Feb  7 10:31 mipsel-linux-cpp -> mipsel-linux-uclibc-cpp
lrwxrwxrwx 1 root root     23 Feb  7 10:31 mipsel-linux-g++ -> mipsel-linux-uclibc-g++
lrwxrwxrwx 1 root root     23 Feb  7 10:31 mipsel-linux-gcc -> mipsel-linux-uclibc-gcc
lrwxrwxrwx 1 root root     29 Feb  7 10:31 mipsel-linux-gcc-3.4.4 -> mipsel-linux-uclibc-gcc-3.4.4
lrwxrwxrwx 1 root root     26 Feb  7 10:31 mipsel-linux-gccbug -> mipsel-linux-uclibc-gccbug
lrwxrwxrwx 1 root root     24 Feb  7 10:31 mipsel-linux-gcov -> mipsel-linux-uclibc-gcov
lrwxrwxrwx 1 root root     22 Feb  7 10:31 mipsel-linux-ld -> mipsel-linux-uclibc-ld
lrwxrwxrwx 1 root root     28 Feb  7 10:31 mipsel-linux-ldconfig -> mipsel-linux-uclibc-ldconfig
lrwxrwxrwx 1 root root     23 Feb  7 10:31 mipsel-linux-ldd -> mipsel-linux-uclibc-ldd
lrwxrwxrwx 1 root root     22 Feb  7 10:31 mipsel-linux-nm -> mipsel-linux-uclibc-nm
lrwxrwxrwx 1 root root     27 Feb  7 10:31 mipsel-linux-objcopy -> mipsel-linux-uclibc-objcopy
lrwxrwxrwx 1 root root     27 Feb  7 10:31 mipsel-linux-objdump -> mipsel-linux-uclibc-objdump
lrwxrwxrwx 1 root root     26 Feb  7 10:31 mipsel-linux-ranlib -> mipsel-linux-uclibc-ranlib
lrwxrwxrwx 1 root root     27 Feb  7 10:31 mipsel-linux-readelf -> mipsel-linux-uclibc-readelf
lrwxrwxrwx 1 root root     24 Feb  7 10:31 mipsel-linux-size -> mipsel-linux-uclibc-size
lrwxrwxrwx 1 root root     27 Feb  7 10:31 mipsel-linux-strings -> mipsel-linux-uclibc-strings
lrwxrwxrwx 1 root root     25 Feb  7 10:31 mipsel-linux-strip -> mipsel-linux-uclibc-strip
-rwxr-xr-x 1 root root 588580 Oct 13  2008 mipsel-linux-uclibc-addr2line
-rwxr-xr-x 2 root root 563872 Oct 13  2008 mipsel-linux-uclibc-ar
-rwxr-xr-x 2 root root 901792 Oct 13  2008 mipsel-linux-uclibc-as
-rwxr-xr-x 2 root root  84576 Oct 13  2008 mipsel-linux-uclibc-c++
lrwxrwxrwx 1 root root      3 Feb  7 10:31 mipsel-linux-uclibc-cc -> gcc
-rwxr-xr-x 1 root root 588420 Oct 13  2008 mipsel-linux-uclibc-c++filt
-rwxr-xr-x 1 root root  80480 Oct 13  2008 mipsel-linux-uclibc-cpp
-rwxr-xr-x 2 root root  84576 Oct 13  2008 mipsel-linux-uclibc-g++
-rwxr-xr-x 2 root root  80480 Oct 13  2008 mipsel-linux-uclibc-gcc
-rwxr-xr-x 2 root root  80480 Oct 13  2008 mipsel-linux-uclibc-gcc-3.4.4
-rwxr-xr-x 1 root root  16038 Oct 13  2008 mipsel-linux-uclibc-gccbug
-rwxr-xr-x 1 root root  21936 Oct 13  2008 mipsel-linux-uclibc-gcov
-rwxr-xr-x 2 root root 869096 Oct 13  2008 mipsel-linux-uclibc-ld
lrwxrwxrwx 1 root root      8 Feb  7 10:31 mipsel-linux-uclibc-ldconfig -> ldconfig
lrwxrwxrwx 1 root root      3 Feb  7 10:31 mipsel-linux-uclibc-ldd -> ldd
-rwxr-xr-x 2 root root 601284 Oct 13  2008 mipsel-linux-uclibc-nm
-rwxr-xr-x 1 root root 741572 Oct 13  2008 mipsel-linux-uclibc-objcopy
-rwxr-xr-x 2 root root 798084 Oct 13  2008 mipsel-linux-uclibc-objdump
-rwxr-xr-x 2 root root 563872 Oct 13  2008 mipsel-linux-uclibc-ranlib
-rwxr-xr-x 1 root root 206984 Oct 13  2008 mipsel-linux-uclibc-readelf
-rwxr-xr-x 1 root root 547612 Oct 13  2008 mipsel-linux-uclibc-size
-rwxr-xr-x 1 root root 547612 Oct 13  2008 mipsel-linux-uclibc-strings
-rwxr-xr-x 2 root root 741604 Oct 13  2008 mipsel-linux-uclibc-strip
===gcc版本为3.3.4:
root@debian:/home/paul# /usr/local/toolchain_mipsel/bin/mipsel-linux-gcc --version
mipsel-linux-gcc (GCC) 3.4.4 mipssde-6.03.00-20051020
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
===include 和link dir分别为:
 /usr/local/toolchain_mipsel/include
  /usr/local/toolchain_mipsel/lib
===对应的package为toolchain-mipsel:
root@debian:/home/paul# dpkg -l|grep toolchain
ii  toolchain-mipsel                     6.03-7                         Toolchain targeted for mipsel linux

注意:和前面两套工具链相比, toolchain-mipsel较为完整,既有g++,也有编译c++程序时需要的头文件(include/c++/3.4.4/)和库文件。

这样看来,虽然尚不清楚以上三款工具链有何种联系,但至少知道使用sdelinux编译一般的C程序时没有问题的,编译C++程序则需要使用toolchain-mipsel,至于mipsel-linux-sdelinux的用法到这里还是个问号。

4. 查看gcc相关信息的一些有用命令:
gcc --version : 简要的版本信息
gcc -v : 编译gcc时的一些信息
gcc --print-search-dirs : 一些搜索路径
gcc -v xxx.c : 可以看到处理xxx.c时展开include时的搜索路径



又google了一番这些工具的出处,结果如下:
http://www.linux-mips.org/wiki/Toolchains#MIPS_SDE
这里提到MIPS Technologies UK公司提供用于MIPS平台开发的最可靠、高效的编译器。注意:Note that the pre-built cross-compiler is only suitable for building a Linux kernel, and cannot be used to create Linux applications or shared objects.然而作者又加上注解说:Note: We have been using the sde toolkit for both shared objects and applications. Maybe the issue was fixed?

http://www.linux-mips.org/wiki/MIPS_SDE_Installation
这里提供了MIPS SDE的安装方法,提到最新的SDE release为6.05.00,基于GCC3.4。遗憾的是,MIPS Technologies UK将相关软件从他们的FTP中移除了(NOTICE: All of the following instructions can no longer be followed as MIPS Technologies removed the sde-for-linux directory from their FTP site.)在http://imap.netfilter.org/pub/vendors/Conceptronic/MEDIAGIANT/toolchain/还可以找到SDE 6.05。这里明确说:The cross toolchain can only be used to cross compile a Linux/MIPS kernel, it cannot be used to build Linux/MIPS applications and shared libraries without some additional cross building infrastructure, such as listed in http://www.linux-mips.org/wiki/Toolchains. The Linux/386 cross toolchain is available as a single file, in RPM format。注意是单个rpm文件,即6.05不需要inc_libxxx.tar之类附加的头文件和库文件。(    sdelinux-5.03.06-1.i386.rpm需要inc_lib0808.tar.bz2)。

http://forum.xtreamer.net/mediawiki-1.15.1/index.php/Toolchain
这里提到了sdelinux_5.03.06的安装方法。
只有注册用户登录后才能发表评论。