Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the correct options for an ARM cross compiler with crosstool-NG

I am trying to build a cross compiler to target the processor running on my NAS box using crosstool-NG.

The NAS box is a ZyXEL NSA210, there is an example dmesg output, the /proc/cpuinfo is:

Processor       : ARM926EJ-S rev 5 (v5l)
BogoMIPS        : 183.09
Features        : swp half thumb fastmult edsp java
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant     : 0x0
CPU part        : 0x926
CPU revision    : 5
...
Hardware        : Oxsemi NAS
Revision        : 0000
Serial          : 00000d51caab2d00

The options on the target options page, the flag and my current settings in ():

  • Target Architecture (arm)
  • Use the MMU (yes)
  • Endianness (Little endian)
  • Bitness (32-bit)
  • Default instruction set mode (arm)
  • Use EABI (yes)
  • Architecture level --with-arch= ()
  • Emit assembly for CPU --with-cpu= ()
  • Tune for CPU ()
  • Use specific FPU ()
  • Floating point (software)
  • Target CFLAGS ()
  • Target LDFLAGS ()

I've been trying various combinations in the 'Architecture level' and 'Emit assembly for CPU', such as arm926ej-s, armv5l, armv5tej, but I don't know which option goes where.

I've set the Target OS to bare-metal as crosstool-NG doesn't have the version of Linux used on the box.

Also, once the toolchain is built do I need to pass the same options again to the compilers.

So far by attempts have just produced the Illegal instruction message.

Edit

If anyone could point me towards an article on setting up an ARM GCC toolchain with explicit reference of how to find out the correct parameters, that would answer my question.

like image 469
Silas Parker Avatar asked Apr 20 '12 21:04

Silas Parker


People also ask

How do you use an ARM cross-compiler?

Install gcc-arm-linux-gnueabi and binutils-arm-linux-gnueabi packages, and then just use arm-linux-gnueabi-gcc instead of gcc for compilation. This brings in the complete cross-compile environment, including binutils. On Ubuntu 13.10 you get gcc-4.7 for 'gnueabi' and gcc-4.8 for 'gnueabihf'.

What is cross-compilation for ARM?

What is cross compilation for ARM? A cross-compiler is one that compiles binaries for architectures other than its own, such as compiling ARM binaries on a Intel's x86 processor. A “cross compiler” executes in one environment and generates code for another.

What is a cross-compiler toolchain?

A cross toolchain refers to the compiler, linker, and target's C library that executes on the host (x86 or x86_64) but generates code for the ARM architecture. The C library is used for linking compiled code to create the target application.

What are the components of toolchain?

The major components of a toolchain include, but aren't limited to, a compiler, an assembler, and a linker. The compiler is responsible for parsing source files written in a high-level programming language, such as C. The files are first translated into an intermediate language, used internally to the compiler.


1 Answers

Try one of these

--with-arch=armv5te
--with-tune=arm926ej-s

or

--with-cpu=arm926ej-s

(there's no point in having both).

Otherwise your options look fine.

If it still doesn't work then you need to look at the libraries and headers. If you want to use dynamically linked libraries then you'll need to have ones that match those on the target, version wise and name wise. If you want to use static linking, or copy your own shared libraries onto the target (in a non-standard place, perhaps, which would need extra config), you should be fine.

Either way, you'll need your kernel headers to match. You can probably just download some contemporary kernel headers from kernel.org.

like image 90
ams Avatar answered Oct 02 '22 22:10

ams