问题
I have installed all cross compile packages on my ubuntu system so far but am having a problem and need some help.
Processor : ARM926EJ-S rev 5 (v5l)
BogoMIPS : 184.72
Features : swp half thumb fastmult edsp java
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant : 0x0
CPU part : 0x926
CPU revision : 5
Cache type : write-back
Cache clean : cp15 c7 ops
Cache lockdown : format C
Cache format : Harvard
I size : 32768
I assoc : 4
I line length : 32
I sets : 256
D size : 32768
D assoc : 4
D line length : 32
D sets : 256
Hardware : MT7108
Revision : 0000
Serial : 0000000000000000
This is the target machine I need to cross compile for. What flags should I use when compiling?
回答1:
apt-cache search arm | grep ^gcc-
gives the following list,
- gcc-4.7-aarch64-linux-gnu - GNU C compiler
- gcc-4.7-arm-linux-gnueabi - GNU C compiler
- gcc-4.7-arm-linux-gnueabi-base - GCC, the GNU Compiler Collection (base package)
- gcc-4.7-arm-linux-gnueabihf - GNU C compiler
- gcc-4.7-arm-linux-gnueabihf-base - GCC, the GNU Compiler Collection (base package)
- gcc-4.7-multilib-arm-linux-gnueabi - GNU C compiler (multilib files)
- gcc-4.7-multilib-arm-linux-gnueabihf - GNU C compiler (multilib files)
- gcc-aarch64-linux-gnu - The GNU C compiler for arm64 architecture
- gcc-arm-linux-gnueabi - The GNU C compiler for armel architecture
- gcc-arm-linux-gnueabihf - The GNU C compiler for armhf architecture
You should install gcc-arm-linux-gnueabi which is an alias for gcc-4.7-arm-linux-gnueabi. gcc-4.7-multilib-arm-linux-gnueabi is also possible, but more complicated. Use the flags, -march=armv5te -mtune=arm926ej-s -msoft-float -mfloat-abi=soft
. You can do more tuning by specifying the --param NAME=VALUE
option to gcc
with parameters tuned to your systems memory sub-system timing.
You may not be able to use these gcc
versions as your Linux maybe compiled with OABI and/or be quite ancient compared to the one the compiler was built for. In some cases, the libc will call a newer Linux API, which may not be present. If the compiler/libc was not configured to be backwards compatible, then it may not work with your system. You can use crosstool-ng to create a custom compiler that is built to suit your system, but this is much more complex.
回答2:
You have an ARMv5
with no floating-point processor. It should have been enough with -march=armv5
and -mfloat-abi=soft
flags.
However if those flags doesn't work for you, I would suggest writing the smallest c application for testing the toolchain.
/* no includes */
int main(void) {
return 42;
}
and compiling it with most complete/strict flags
$arm-linux-gnueabi-gcc -Wall --static -O2 -marm -march=armv5 simple.c -o simple
after this, push simple
to target, run it then issue an echo $?
to verify if you would get 42
. If it works, try to see if you can get printf
working. If that one also works, you are pretty much set for everything. If printf
fails, easiest solution would be to find right toolchain for your target.
来源:https://stackoverflow.com/questions/17336236/cross-compile-from-linux-to-arm-elf-arm926ej-s-mt7108