Linaro Embedded Toolchain on Ubuntu 64-Bit: Tips and Tricks for Successful Cross-Compilation
One can choose any Linux distribution (like Fedora, SUSE, Debian) for development. A 64-bit install is preferred as you might want to use the machine also for OpenEmbedded work. Cross-compiling certain packages requires the larger address space available. Also, the latest cross toolchains from Linaro are provided only for 64-bit hosts.Should you choose Ubuntu, use the bash shell instead of dash. (Google for 'ubuntu bash update-alternatives')
Linaro embedded toolchain on Ubuntu 64-Bit
Beginning with image 2.7b2, as part of our OpenEmbedded Morty update we transitioned to using version 6.2 of the gcc compiler. Linaro releases well tested binary toolchains which can be used to cross-compile software for our modules (choose gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf.tar.xz):
Beginning with image V2.6, as part of our OpenEmbedded Jethro update we transitioned to using version 5.2 of the gcc compiler. Linaro releases well tested binary toolchains which can be used to cross-compile software for our modules (choose gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf.tar.xz):
A toolchain is a set of distinct software development tools that are linked (or chained) together by specific stages such as GCC, binutils and glibc (a portion of the GNU Toolchain). Optionally, a toolchain may contain other tools such as a debugger or a compiler for a specific programming language, such as C++. Quite often, the toolchain used for embedded development is a cross toolchain, or more commonly known as a cross compiler. All the programs (like GCC) run on a host system of a specific architecture (such as x86), but they produce binary code (executables) to run on a different architecture (for example, ARM). This is called cross compilation and is the typical way of building embedded software. It is possible to compile natively, running GCC on your target. Before searching for a prebuilt toolchain or building your own, it's worth checking to see if one is included with your target hardware's Board Support Package (BSP) if you have one.
The second major component of a toolchain is the compiler. In the embedded Linux, the only realistic solution today is GCC, the GNU Compiler Collection. Nowadays, as input, it not only supports C, but also C++, Java, Fortran, Objective-C and Ada. As output, it supports a very wide range of architectures.
As you can see on this link, there are multiple cross toolchains available for different host machines such as Windows and Linux. Furthermore, they are available for both 32-bit and 64-bit machines of Windows and Linux operating system based host machines. The name of the toolchain is arm-linux-gnueabihf. Here, arm-linux-gnueabihf stands for Linux GNU toolchain for ARM with hard float.
Although, Linaro provides toolchains for windows and Linux based systems. But it is recommended to use a Linux based host machine for embedded linux development. Because it is mandatory to have a Linux based host machine (Ubuntu, Fedora etc) to compile the Linux source code, to compile the U-Boot source code, to compile the busy box, etc.
We are not planning to release x86_64 Windows hosted toolchain for now as 32-bit version covers both systems.With your changes to build scripts users are able to generate 64-bit hosted toolchain. Cheers!
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.
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).
This guide is the first part of a Linux version of the guide we previously wrote dealing with setting up an embedded software toolchain within Eclipse. This guide is targeted at readers who need to set up a GCC toolchain within a vanilla Eclipse installation. This guide is written with embedded software development for MCU and SoCs in mind but can be used with any GCC toolchain regardless of the intended target. Note that there are many combinations of Eclipse versions, plugins and supporting tools that can be used to successfully build C and C++ applications using the GCC toolchain, this document is the recommended way by JBLopen but readers are free to modify their development environment to suit their needs.
The availability of this port is the culmination of a broad architecture enablement program carried out by Linaro, ARM and the ARM partnership. ARM partners now have access to a 64-bit and 32-bit AOSP file system, together with a broad range of supporting material including the ARMv8 Fast Models, open source toolchain from Linaro and supporting documentation.
In many of my previous blogs/posts i have used a few cross tools to compile Linux kernel as well as many packages for ARM based platforms. I have used only pre compiled cross toolchains provided by either CodeSourcery or linaro to achieve that. Officially too, i follow the same principle as in many ways this is the easiest way to create binaries which needs to run on the target platform. Some times these are not bleeding edge but they are sufficient for most of the needs of the embedded devices.
The second challenge was that Wachendorff provided a toolchain with 32-bit tools and a 32-bit Ubuntu 10.10. As Ubuntu 10.10 is not supported any more, I wanted to use at least the lastest 64-bit Ubuntu with long-term support (v14.04) or best the very latest 64-bit Ubuntu (v15.10). Unfortunately, the 32-bit versions of the gcc compilers do not simply run on a 64-bit system. This can be solved by installing some libraries including the standard C and C++ libraries on the 64-bit Ubuntu development machine. I describe the installation of the toolchain and root file system in the section Setting Up the Development Environment.
For all embedded Linux developers, cross-compilation toolchains are part of the basic tool set, as they allow to build code for a specific CPU architecture and debug it. Until a few years ago, CodeSourcery was providing a lot of high quality pre-compiled toolchains for a wide range of architectures, but has progressively stopped doing so. Linaro provides some freely available toolchains, but only targetting ARM and AArch64. kernel.org has a set of pre-built toolchains for a wider range of architectures, but they are bare metal toolchains (cannot build Linux userspace programs) and updated infrequently.
The toolchains are built with Buildroot, but can be used for any purpose: build a Linux kernel or bootloader, as a pre-built toolchain for your favorite embedded Linux build system, etc. The toolchains are available in tarballs, together with licensing information and instructions on how to rebuild the toolchain if needed.
This is when Buildroot and Yocto Project comes in the picture. With these solutions one can build a completely customizable embedded Linux system. These build systems provide the rootfs, toolchains, kernel, bootloader and a great number of installable packages. Everything is compiled from scratch using cross compilation. Both are very actively developed and maintained projects, and they are widely used in the industry by companies like Intel, Juniper, Xilinx, Texas Instruments etc. Both have great documentation and online training courses. Both are Free Software: Buildroot is released under GNU GPL version 2 (or later), Yocto is a mix of MIT and GPLv2.