Cross compiling from linux to ARM-ELF (ARM926EJ-S / MT7108)

I installed all cross-compiling packages on my ubuntu system, but I have problems 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 for which you need to cross-compile. What flags should I use when compiling?

+3
source share
2 answers

apt-cache search arm | grep ^gcc- 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 compilation (base package)
  • gcc-4.7-arm-linux-gnueabihf - GNU C compiler
  • gcc-4.7-arm-linux-gnueabihf-base - GCC, GNU compiler compilation (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 - GNU C compiler for arm64 architecture
  • gcc-arm-linux-gnueabi is the GNU C compiler for armature architecture.
  • gcc-arm-linux-gnueabihf is the GNU C compiler for armhf architecture.

You must 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 perform additional configuration by specifying the --param NAME=VALUE option on gcc with parameters configured to synchronize the system memory subsystem.

You may not be able to use these versions of gcc , since your Linux can be compiled with OABI and / or be quite ancient compared to the one for which the compiler was created. In some cases, libc will invoke a new Linux API, which may be missing. If the / libc compiler has not been configured for backward compatibility, 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 it is much more complicated.

+1
source

You have ARMv5 without a floating point processor. That should have been enough with the flags -march=armv5 and -mfloat-abi=soft .

However, if these flags do not work for you, I would suggest writing a small c application to test the tool chain.

 /* no includes */ int main(void) { return 42; } 

and compile it with the most complete / strict flags

 $arm-linux-gnueabi-gcc -Wall --static -O2 -marm -march=armv5 simple.c -o simple 

after that click simple to target, run it, then enter echo $? to check if you get 42 . If it works, try to see if printf can work. If this also works, you are pretty much tuned in to everything. If printf fails, the easiest solution is to find the right tool chain for your purpose.

+3
source

Source: https://habr.com/ru/post/1488681/


All Articles