Welcome! Log In Create A New Profile

Advanced

Cross compiling

Posted by gnexus 
Cross compiling
June 20, 2012 12:18PM
This post applies to any ARM sources you are cross-compiling. Not just Debian. Not just GNU (it applies for Android also).
It mostly applies to the ARMv7 SoC. That means it doesn't really apply to Kirkwood.
That also means it doesn't really apply to much of anything here. . .

But the information here is relevant for ANYTHING you are cross-compiling for ARM. So if you are reading this thread it is probably relevant to what you are doing.

I like compiling natively on the device, if it makes sense. It is cleaner to do, and it should help to optimize the code a bit if you are compiling on the correct hardware for the intended project. But sometimes it doesn't make sense. I was recently trying to build a kernel on my Dockstar. Compiling the kernel works fine on it, although it is slow and takes about a day. But when I tried to clone a git kernel the Dockstar just crumbled. It was never able to sync the sources. So I decided to cross-compile.

Previously I was using an ARM toolchain from the Fedora ARM project. But now it seems that their toolchain is gone for some reason (Debian people are lucky , you can get a toolchain from apt). So I did what I did previously and downloaded a toolchain from CodeSourcery(direct link -get it while you can if you need it since Mentor now requires registration).

The kernel built fine. But then while trying to figure out how to make an Initrd when cross-compiling I saw a post where the person had an error due to the lack of VFP(hardware floating point) in the CodeSourcery toolchain. It turns out that CodeSourcery makes you pay for a toolchain that has VFP support.

VFP(hardware floating point) is only helpful or needed for ARMv7 on up. So it doesn't apply to the Kirkwood SoC in the plugs. But it will be a big issue in the future and if you are compiling for a newer SoC. Anyway the reason for this post is to point out that ARM toolchains and compliation platforms vary a lot. To get the proper performance and avoid bugs you need to choose the correct toolchain or platform. It doesn't really matter much on small projects like an unlinked binary or Uboot. But if you are building something bigger like a kernel then you either need to compile natively on the correct platform, or cross-compile with an optimized toolchain for your platform.

That means don't build ARMv7 projects on kirkwood. Use hard-float if possible. Also, say you had a faster ARM platform, such as a new phone or tablet, and you wanted to compile something for a plug using kirkwood on it since the newer device was faster. Be aware that the output would likely FAIL to run on kirkwood since it is ARMv5 not ARMv7. You would need to use the proper flags if compiling natively for a earlier platform. Here is a nice page with more information on Building a Hard-float ARM Toolchain.

Have fun compiling, and please release your code or patches for others to use.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: