2012-01-06 121 views
1

我正在做我的硕士论文,我在配置交叉编译器时遇到问题。我读过很多文章,常见问题解答,教程等,但我仍然认为我错过了一些东西,可能非常愚蠢和基础,但没有这些,我不能清楚地看到一切,而且我也不会使所有工作...所以请随时解释我的一切。让我们来解决这个问题。安装mips交叉编译器的问题

我正在使用SoClib设计具有许多MIPS和许多RAM的NoC,并且我想在每个RAM中加载不同的应用程序,以使每个MIPS只从一个RAM读取。我设法用非常简单的应用程序来做到这一点(比如hello word with interrupts ...),所以现在我试图实现一个JPEG解码器,以更强烈的方式使用MIPS。问题是我使用的交叉编译器找不到基本的stdio函数,所以无法编译mips的应用程序。所以基本上我没有设法安装一个完整的交叉编译器。

1)Let's开始与SoClib安装交叉编译: 这里有导向从来就跟着来安装它:http://www.soclib.fr/trac/dev/wiki/CrossCompiler 现在从什么从来就读这不是一个完整的交叉编译器。我只安装了第一阶段的gcc,可以为mips生成elf代码,但不能使用任何C函数。用那个,我应该编译一个C库来创建一个新的交叉编译器。所以这是正常的,它不工作,虽然这并不回答这个问题:为什么“Hello world”工作,如果它使用printf并包括stdio.h?答案应该是我已经看到SoClib的头文件stdio.h中实现了很少的功能(printf在那里),所以我不能在该编译器中使用标准的C库。 2)因为这个,我决定安装一个完整的交叉编译器,并且我已经阅读了很多指南,我只会发布我在练习中使用的两个: http://www.cse.iitb.ac.in/grc/gcc-workshop-11/downloads/slides/gccw11-config-build.pdf(从第108页开始)交叉编译问题) 它使用EGLIBC。唯一的区别是我用作目标“米勒精灵”。如果我理解正确,这种方法需要3阶段交叉编译器,因为eglibc不能用第一阶段交叉编译器完全编译。现在的问题是,我无法用第一阶段交叉编译器安装eglibc(它在第122页失败)。我附上了日志。我认为问题开始于它说:“mipsel-elf-gcc:错误:无法识别的选项'-V'”和“mipsel-elf-gcc:致命错误:没有输入文件编译终止”。似乎我有一些编译器的问题,并完成一个不支持的平台......但它应该工作,因为我已经复制eglibc/ports目录像指南所说...

3)我试过另一个指南,使用newlib而不是eglibc: http://www(dot)cygwin(dot)com/ml/crossgcc/2005-08/msg00114/l-cross-ltr.pdf 本指南仅创建2阶段交叉编译器。我认为这是因为newlib可以用第一阶段编译器完全编译......我是对的吗?无论如何,我遇到同样的问题。我无法编译newlib,并且出现类似的错误(附加日志)。

所以这是我的问题,在这里我提出了一些疑问,我试图解决它。

4)问题可能是目标= mipsel-elf吗?我从gnu文档中知道,配置gnu的名字应该是:cpu-manufacturer-os(或者cpu-manufacturer-kernel-os),但我读过mipsel-elf被接受。小精灵应该是因为我不想在我的NoC平台上加载操作系统,这里有第二个疑问......

5)问题是操作系统的问题吗?这些指南使用Linux内核头文件...也许有一个mipsel-elf目标我不应该配置binutils -with-sysroot?但听起来很奇怪......应该改变什么?

6)又一个可能是愚蠢的问题。 stdio和一般的C函数,不需要一个操作系统?因为所有这些问题都让我对基础知识产生怀疑......所以我应该能够用mipsel-elf交叉编译器运行JPEG解码C应用程序吧?

每一个考虑,建议和帮助将不胜感激。如果你有一些关于这些论点的文件,请让我知道,我想学习,并在这个领域变得更加自信。 感谢

eglibc日志:

configure:2426: $? = 0 
configure:2433: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -v >&5 
Using built-in specs. 
COLLECT_GCC=/home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc 
COLLECT_LTO_WRAPPER=/home/bertone/programmazione/crosscompiler/mips/install/libexec/gcc/mipsel-elf/4.6.2/lto-wrapper 
Target: mipsel-elf 
Configured with: ../../../../../Scaricati/src/gcc-4.6.2/configure --target=mipsel-elf --prefix=/home/bertone/programmazione/crosscompiler/mips/install --without-headers --with-newlib --disable-shared --disable-threads --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c --disable-werror 
Thread model: single 
gcc version 4.6.2 (GCC) 
configure:2437: $? = 0 
configure:2444: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -V >&5 
mipsel-elf-gcc: error: unrecognized option '-V' 
mipsel-elf-gcc: fatal error: no input files 
compilation terminated. 
configure:2448: $? = 1 
configure:2452: checking for suffix of object files 
configure:2478: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c conftest.c >&5 
configure:2482: $? = 0 
configure:2507: result: o 
configure:2511: checking whether we are using the GNU C compiler 
configure:2540: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c conftest.c >&5 
configure:2547: $? = 0 
configure:2564: result: yes 
configure:2573: checking whether /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc accepts -g 
configure:2603: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c -g conftest.c >&5 
configure:2610: $? = 0 
configure:2711: result: yes 
configure:2728: checking for /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc option to accept ISO C89 
configure:2802: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c -g -O2 conftest.c >&5 
conftest.c:9:19: fatal error: stdio.h: No such file or directory 
compilation terminated. 
configure:2809: $? = 1 
configure: failed program was: 
| /* confdefs.h. */ 
| #define PACKAGE_NAME "GNU C Library" 
| #define PACKAGE_TARNAME "glibc" 
| #define PACKAGE_VERSION "(see version.h)" 
| #define PACKAGE_STRING "GNU C Library (see version.h)" 
| #define PACKAGE_BUGREPORT "http://sourceware.org/bugzilla/" 
| /* end confdefs.h. */ 
| #include <stdarg.h> 
| #include <stdio.h> 
| #include <sys/types.h> 
| #include <sys/stat.h> 
| /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ 
| struct buf { int x; }; 
| FILE * (*rcsopen) (struct buf *, struct stat *, int); 
| static char *e (p, i) 
|  char **p; 
|  int i; 
| { 
| return p[i]; 
| } 
| static char *f (char * (*g) (char **, int), char **p, ...) 
| { 
| char *s; 
| va_list v; 
| va_start (v,p); 
| s = g (p, va_arg (v,int)); 
| va_end (v); 
| return s; 
| } 
| 
| /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has 
| function prototypes and stuff, but not '\xHH' hex character constants. 
| These don't provoke an error unfortunately, instead are silently treated 
| as 'x'. The following induces an error, until -std is added to get 
| proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an 
| array size at least. It's necessary to write '\x00'==0 to get something 
| that's true only with -std. */ 
| int osf4_cc_array ['\x00' == 0 ? 1 : -1]; 
| 
| /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters 
| inside strings and character constants. */ 
| #define FOO(x) 'x' 
| int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; 
| 
| int test (int i, double x); 
| struct s1 {int (*f) (int a);}; 
| struct s2 {int (*f) (double a);}; 
| int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); 
| int argc; 
| char **argv; 
| int 
| main() 
| { 
| return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; 
| ; 
| return 0; 
| } 
configure:2802: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -qlanglvl=extc89 -c -g -O2 conftest.c >&5 
mipsel-elf-gcc: error: unrecognized 

选项 '-qlanglvl = extc89选项' 配置:2809:$? = 1

NEWLIB登录

configure:4049: $? = 0 
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -v >&5 
Using built-in specs. 
COLLECT_GCC=/home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc 
COLLECT_LTO_WRAPPER=/home/bertone/programmazione/crosscompiler/mips/install/libexec/gcc/mipsel-elf/4.6.2/lto-wrapper 
Target: mipsel-elf 
Configured with: ../../../../../Scaricati/src/gcc-4.6.2/configure --target=mipsel-elf --prefix=/home/bertone/programmazione/crosscompiler/mips/install --without-headers --with-newlib --disable-shared --disable-threads --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c --disable-werror 
Thread model: single 
gcc version 4.6.2 (GCC) 
configure:4049: $? = 0 
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -V >&5 
mipsel-elf-gcc: error: unrecognized option '-V' 
mipsel-elf-gcc: fatal error: no input files 
compilation terminated. 
configure:4049: $? = 1 
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -qversion >&5 
mipsel-elf-gcc: error: unrecognized option '-qversion' 
mipsel-elf-gcc: fatal error: no input files 
compilation terminated. 
configure:4049: $? = 1 
configure:4069: checking for C compiler default output file name 
configure:4091: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc conftest.c >&5 
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crti.o: No such file or directory 
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtbegin.o: No such file or directory 
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find -lgcc 
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find -lgcc 
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtend.o: No such file or directory 
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtn.o: No such file or directory 
collect2: ld returned 1 exit status 
configure:4095: $? = 1 
configure:4132: result: 
configure: failed program was: 
| /* confdefs.h */ 
| #define PACKAGE_NAME "" 
| #define PACKAGE_TARNAME "" 
| #define PACKAGE_VERSION "" 
| #define PACKAGE_STRING "" 
| #define PACKAGE_BUGREPORT "" 
| #define PACKAGE_URL "" 
| /* end confdefs.h. */ 
| 
| int 
| main() 
| { 
| 
| ; 
| return 0; 
| } 
configure:4138: error: in `/home/bertone/programmazione/crosscompiler/mips/build/newlib': 
configure:4142: error: C compiler cannot create executables 

回答

0

首先,关闭,您是否需要这些stdio功能?

您可以替换这些stdio函数吗?例如,你真的真的需要一个printf(其中一个更痛苦的),或者你可能愿意用别的东西替换它们,也许string_display()和hex_display()函数可能很容易实现和库和系统独立。

这些文件I/O功能?我似乎记得一个流行的开源jpeg解码器想为你做文件I/O。实现一个fopen()有多难?(只返回任何有效的),一个fread,它跟踪一个包含在二进制文件中的常量数据的指针,并且执行mem copy和fwrite deal会跟踪数组中的指针,并执行mem副本。

我已经嵌入jpeg解码器,mp3等,使系统调用,都通过使用newlib(),这使得它更容易一点,但是现在非常痛苦的建立一个交叉编译器,并且还取代了系统调用具有不同的功能或通过实现这些功能的模拟。

如果您使用免费的codesourcery精简版(现在称为codebench或其他东西,因为它是导师图形,而不是codesourcery了),并用模拟的替换系统调用,你不必再与编译器混乱了。

我有一些非常简单的mips代码,但也有一些关于构建我所说的GNU交叉编译器的说明(如果你没有用于系统调用,C库调用,gcc库调用,自己实施一切)。

https://github.com/dwelch67/pic32_samples

它是不是从什么我建立一个完整的交叉编译一个远伸。 Gcc/gnu不太稳定,您可以从任何版本交叉编译任何版本并使其工作,同样,任何使用任何版本的主机上的任何版本的任何目标的交叉编译器都不稳定。有时一个目标版本的binutils + gcc + newlib恰好工作。例如,在这段时间/历史这个工作,无论是在Linux上,并与windows上的mingw。

http://www.dwelch.com/ipod/gccarm.txt

,但除非你使用虚拟机(VMware的,等等),并在其上安装一个老的Linux与旧足够建造系统,你将无法建立以上。

不久前,也许还是这个工作的现代化系统。它适用于手臂,但也可能适用于mips。

http://www.cowlark.com/2009-07-04-building-gcc/

我不认为我有任何贴有没有系统调用或模拟的系统调用在那里我可以把它们发布的地方使用的MP3和zlib和JPEG库的代码。如果你想使用zlib作为性能测试什么的,一个时间压缩或解压缩或两者mallocs很容易实现的东西像zlib的,不是一个通用的东西,而是一个控制的测试环境,在数据和数据输出。这同样适用于其他受控环境JPEG编码或解码,MP3编码或解码(他们是有损,所以你不能比较的输入到输出一定要验证系统产生正确的结果,但对已知的良好系统相比,校验或CRC很容易/结果)。

如果您检查newlib,我空出并更换后,你可以看到什么newlib沸腾标准输入输出要求下入文件,那么您需要执行每这些功能。我有一对夫妇至少有Dhrystone的实例非常简单,只是想一个printf http://www.dwelch.com/ipod/ http://www.dwelch.com/gba/dhry.htm在这里你可以看到我做了什么与newlib功能了网站,大多只是通过返回一个传递值来消除它们,并计算出newlib在输出到stdout时的行为。

或更换,由此导致一些仍然有效的复用功能的一些标准输入输出调用的一个例子。不是说它很漂亮,但你可以玩游戏。 https://github.com/dwelch67/stm32f4d/blob/master/adventure/

基本上我正在阅读的是,你已经确定了一个问题,但只追求一条路径,在编译器端解决它。当你可以通过创建一个抽象层或填充来解决它,或者完全删除违规代码或用较少的令人反感的代码替换它。如果您查看上述冒险游戏以及类似时代游戏帝国等的源代码,即使是小型的c编译器和已经移植过多次的其他代码,您也可以看到他们的确完成了这些,他们解决了这个问题,语言,非系统特定的调用,然后最后一英里是在一个或几个系统特定的地方实现这些调用。即使您要获得gcc + newlib或gcc + glibc交叉编译器,您仍然必须使用自己的代码将缺省stdio替换为操作系统层。 (这也是编译器的一面,也是一个庞大的抽象层,glibc,newlib等等,你仍然需要实现后端)。

0

为什么不直接下载免费的预建GCC Codesourcery Lite交叉编译器,MIPS工具链?

6) The stdio and generally C functions, doesn´t need an OS right?

通常,libc的转化标准输入输出调用到系统调用底层的操作系统,所以你需要有标准输入输出工作的OS。如果您的JPEG解码器应用程序没有调用任何需要操作系统的任何东西,它可以正常工作,但是您需要创建一种方法,以便从NoC中的每个单独的CPU获得结果到外部世界。