Documentation – Arm Developer. Sourcery™ CodeBench goes beyond just the compiler to provide developers with powerful open source, embedded C/C development tools to build, debug, analyze and optimize embedded software in complex heterogeneous architectures including Arm, IA32, MIPS and Power Architectures. CodeSourcery G Lite is a free, unsupported command-line version of Sourcery G sponsored by CodeSourcery's hardware partners that. Contains command-line tools, including the GNU C and C compilers, the GNU assembler and linker, C and C runtime libraries, and the GNU debugger. $endgroup$ – Kevin Vermeer Oct 1 '10 at 17:16.
- The Sourcery G Lite cross compiler suite is a free version of Sourcery G from CodeSourcery. There is a page for the GNU Toolchain for ARM Processors. Determine the version you need for your host/target combination.
- Sourcery CodeBench is a 32-bit application, but runs on 64-bit host systems with 32-bit host libraries. The information comes from the bottom of the web pages for specific target platforms. Here's the page for ARM GNU/Linux targets.
The toolchain is a set of binaries, system libraries and tools which allow you to build (in our case, cross-compile) u-boot and the kernel for a target platform. This will, to some limited extent, need to match the target rootfs. A large and incompatible change has taken place recently, through the Hard Float ABI. Now, two different debian and ubuntu ports are binary incompatible with each other.
|
Ubuntu
A complete cross toolchain is available as a package, just run:
The gcc cross compiler from the standard package in Ubuntu 16 may have a bug that manifests itself as the following error while compiling U-Boot:
Version of the compiler with the bug:
A suggested solution is to use the Linaro toolchain
Debian
Details on cross-development Toolchains for Debian are at the Debian Wiki.
Installing Cross Compiler and build utilities:
armhf
arm64
You might want additional tools for building a sunxi system that are not related to the cross-compiler:
Fedora
A complete cross toolchain is available as a package, just run:
Gentoo
The crossdev tool[1]is the standard way of dealing with crosscompilers in Gentoo. Command line options are used to specify any arbitrary mix of different versions of the kernel headers, glibc, binutils and gcc. You can also use the -S option instead (to pick whatever is considered to be stable at the moment), but in this case the crosscompiler will be also upgraded as part of the regular distribution updates, which might be a bit annoying.
ARM crosscompiler
Even though Gentoo normally uses armv7a-hardfloat-linux-gnueabi as the toolchain triplet on ARM, we can also use Debian alike arm-linux-gnueabihf variant in order to be able to use the compilation instructions from the linux-sunxi wiki as-is (without substituting the toolchain name).
ARM64 crosscompiler
Note: binutils =9999 (fetch sources from git) should be replaced with =2.26 as soon as binutils 2.26 is added to portage. Such new binutils version is necessary for having a Cortex-A53 erratum 843419 workaround.
OpenRISC crosscompiler
If you have one of the Allwinner SoC variants with an additional OpenRISC core (for example A31 and H3 have it), then you might want to also build an OpenRISC crosscompiler too:
Please note that the upstream GCC does not support OpenRISC yet, so the OpenRISC code is still brewing in https://github.com/openrisc/or1k-gcc.git and we can solve this problem by just providing a patch for GCC in the /etc/portage/patches directory.
- ↑The Gentoo website has undergone a major overhaul as of April 2015. While a backup of the old content is still available, it seems to have left the Gentoo Embedded Handbook in a non-functional state. You can still find a copy via archive.org. The wiki article on Raspberry Pi Cross building might also be helpful.
These standalone toolchains are big tarballs which come with everything you need.
Linaro toolchain
Download
Linaro has been very good at changing the location and availability of just about everything, making it very hard to keep a wiki up to date which refers to it. So the below download locations might be stale already.
Currently, the main selection page is here.
It lists the following toolchains:
When in doubt, try 4.9 first.
WARNING: Do not use the 4.8 gcc versions of the linaro toolchain to build legacy kernels (sunxi-3.4 etc.), those seem to have issues building the kernel. (TODO: Verify that this is still true today).
Usage


Take a gcc-linaro-<major>.<minor>-<year>.<month>.tar.xz file and untar it. You will find a bin directory in there. Temporarily add it to the environment you are building from:
no hardfloat?
Recent linaro toolchains are Hard Float (hf), this will be used throughout the wiki you see something like:
Replace arm-linux-gnueabihf- with arm-linux-gnueabi- if your are not using a hardfloat toolchain.
Code Sourcery
Another option is to install the Sourcery toolchain from Code Sourcery (now in Mentor Graphics). Download Code Sourcery G++ 2010 9-50https://sourcery.mentor.com/sgpp/lite/arm/portal/release1600 (official link, email registration required)
Direct link: https://netst.org/pub/linux/ARM/CodeSourcery/arm-2010.09-50-arm-none-linux-gnueabi.bin (unofficial link)
If you are using Ubuntu, you may need to switch to use bash shell (instead of dash shell)
It will now install CodeSourcery with a GUI installer
Follow default settings and do Next , Next, Next, etc…
It should install in: ~/CodeSourcery/ ( for example: /home/penguin/CodeSourcery/ )
Make sure the CodeSourcery binaries are added to your path (if your username is penguin, then this should be correct):
Bootlin
Bootlin also provices glibc / musl / uclibc based toolchains for building:
- Homepage (mentor.com)
- Direct download (mentor.com)
As some of you probably noticed a new category appeared in Download section - Software > bleeding-edge-toolchain - with some pretty huge files names in a way that implies these are bare-metal compilers for chips with ARM cores... 'On the market' we already have CodeSourcery (now known as Sourcery CodeBench), linaro, Yagarto, and - if you insist - there are also prehistoric GNUARM and WinARM packages, and probably some more which I don't know about (yet) - so why another one? You cannot even use a cool name for it, as Yet Another Gnu ARm TOolchain is already taken (;
Let's start with a bit of history. In the ancient times (which would be about 3-4 years ago [; ), when ARMs started to become really popular (with Cortex-M3 chips), the best choice for a toolchain was CodeSourcery - there were versions for Windows and Linux, package was updated regularly, developers from the company working on it were said to cooperate with ARM - full service, all you ever needed. Countless websites (including this one) recommend this toolchain as a good starting point.
But when first Cortex-M4 chips with integrated floating point unit appeared on the market a serious crack presented itself... When you enter arm-none-eabi-gcc -print-multi-lib in your shell you get something like that:
To cut things short, it means that this toolchain includes standard libraries (like libm.a with math functions) only for 'standard'ARM7 architecture (ARMv4, both ARM and THUMB mode), for Cortex-M0 (ARMv6-M, THUMB) and for Cortex-M3 (ARMv7-M, THUMB2). You could - of course - write code for Cortex-M4, with this toolchain, as ARMv7-ME is just an extension of ARMv7-M architecture, but you need to forget about using the FPU (Floating Point Unit) in most cases. If you're in a mood you could always use assembly language or use CMSIS functions, but basic stuff like:
would use 100% software algorithms instead of FPU-goodness... Additionally in 2010 CodeSourcery was purchased by Mentor Graphics and support for free Lite version becomes almost non-existent. Suggestions about adding FPU support for ARMv7-ME architecture are dismissed with information that it (and many more) is available in the paid version...
Fortunately at the same time (2010) linaro organization is started, consisting of ARM and a few of its biggest partners, with purpose to develop and support open-source tools for new chips with ARM cores. It is pretty obvious that main target of linaro are application processors with ARM Cortex-A core and systems like Linux and Android, but at the end of 2011 first version of package named GNU Tools for ARM Embedded Processors was published. Since then updated versions appear 3-4 times a year and include the most recent version of the compiler, coming from the branch targeting embedded microcontrollers (at that time - /branches/ARM/embedded-4_6-branch, currently - /branches/ARM/embedded-4_7-branch). As opposed to CodeSourcery package, this one included wide collection of libraries:
As you see this package supports 'classic' ARM7 (ARM, THUMB), Cortex-M (ARMv6-M, ARMv7-M, ARMv7-ME) and Cortex-R (ARMv7-R) - all of them with option to use hardware FPU.
Some of you probably stopped reading at this point and asked aloud 'what more do you want?'... Everything would be perfect with linaro packages if not one tiny problem - for unknown reasons compilation of any project lasts 3-4 times longer than in CodeSourcery...
At the same time - with no relation to the above - I needed to do some projects in C++ and exceptions that you couldn't really disable (against the rule that 'you don't pay for what you don't use') made me a bit annoyed. To completely get rid of them (because of memory size constraints in microcontrollers) you need to recompile the whole C and C++ standard library that is included in the compiler. (effects of a few compilations that I've done can be downloaded from Download > ARM > Various section - you can find there packages with just the libraries that have C++ exceptions disabled)
And lately, when working on another project, I needed to use new version of newlib library, because (with my help) it included a patch that drastically reduced stack use of fprintf() function. As the project was pretty huge, long compilation times started to really annoy me, so I decided to check whether utilization of 64-bit processor will significantly reduce the time of compilation.
Last experiment showed that use of 64-bit compiler doesn't change much when compared to 32-bit version (gain less than 10%), but the compilers 'produced' by me were several times faster than original linaro, reaching CodeSourcery's 'efficiency'. That is how bleeding-edge-toolchain concept was born.
Main assumptions are as follows:
- based on linaro packages,
- compiled with most recent compiler, modern mingw-w64 compiler is used for Windows,
- basic components (compiler, newlib, gdb and binutils) come directly from projects' repositories, most recent revisions are used,
- remaining components (libraries required for toolchain compilation) are in the most recent stable versions (unless documentation recommends a specific version),
- disabled C++ exceptions (I'm working on availability of both versions, selected with .specs files),
- all compiler libraries include debugging symbols (they are not stripped),
- newlib library with enabled reent-small option and disabled support for 64-bit variables in printf()/sprintf() type functions.
What is the gain of using such toolchain? I've run some extremely boring test which compared compilation time of 6 different projects, comparing 3 toolchain packages in the most recent versions (bleeding-edge-toolchain-130207 [32-bit], linaro - GCC ARM Embedded 4.7-2012-q4-major, CodeSourcery - Sourcery CodeBench Lite 2012.09-63) for both sequential and for parallel (2 jobs) compilation. Results are presented in the table below.
Code-sourcery-toolchain-arm-2011.03
| resulting executable size | number of source files | BET -j1 | BET -j2 | linaro -j1 | linaro -j2 | cs -j1 | cs -j2 | |
| p1 | 12kB | 29 | 12s | 8s | 48s | 27,5s | 12s | 8s |
| p2 | 17kB | 23 | 19s | 12s | 51,5s | 30,5s | 19,5s | 12s |
| p3 | 30kB | 39 | 17s | 11,5s | 62s | 36,5s | 16s | 11s |
| p4 | 60kB | 567 | 85,5s | 40,5s* | 96,5s | 42s* | 91s | 40s* |
| p5 | 100kB | 71 | 38,5s | 24s | 104,5s | 59,5s | -** | -** |
| p6 | 130kB (30kB)*** | 60 | 26,5s | 18s | 92s | 54,5s | 27s | 17s |
* - compilation done with tup build system, original Makefiles of this project are not usable for parallel compilation,
** - compilation is impossible because of incompatibility of project and compiler libraries (different options related to reentrancy)
*** - fonts and bitmaps occupy about 100kB, the project has about 30kB of code
Results are an average of two compilations. Each compilation was preceded with full 'cleaning' of the project (make clean). Number of source files takes into account only the files that were compiled (actually it's the number of resulting object files). Measurements were done with a script.
Codesourcery Arm Eabi Toolchain
As a reward for these tests I allowed myself for a small commentary.
Codesourcery Arm Toolchain 2009q1-203
- In theory CodeSourcery package has different version of compiler (4.7.2) than two others (4.7.3 prerelease).
- p4 project does not fit this comparison well because of its 567 source files - most of the time is probably wasted by computer on spawning new processes of compiler, so results for all 3 packages are comparable.
- Excluding p4 project mentioned above it can be said that compilation time when using bleeding-edge-toolchain is 2.5-4x shorter than with linaro.
- bleeding-edge-toolchain results are almost identical to CodeSourcery's.
- Close look at information available on linaro's website leads one to believe that the reason of long compilation may be use of really old system (Ubuntu-8.10) and tools for building it - probably for increased compatibility with older operating systems.
Codesourcery Arm Toolchain Windows
Because I've compiled the toolchain on 64-bit Linux system, I was unable to compile 32-bit version for Linux system, however the scripts included in each package will allow any user of such system to do the compilation on his/her own (; Maybe in future I'll be able to compile such version too - who knows, I'll keep trying (;
Codesourcery Arm Toolchain Download
So if you are as annoyed by long compilation times as I am, you should download and start using bleeding-edge-toolchain (; Comments are welcome, as usual (;
