Buildroot Toolchain

To conveniently obtain and build a compiler having a particular version, particularly a cross-compiler, the Buildroot software can be used.

Finding Compiler Support

Although Buildroot provides a relatively convenient way of making a compiler or toolchain, the versions supported will evolve from one release to the next, meaning that Buildroot retires support for older compilers over time. Where an older compiler version is required, it is necessary to check the release notes to find suitable Buildroot versions.

For example, to find a version of Buildroot that still supports GCC 4.x, needed for the legacy U-Boot for the A10 and A20, a search through the release notes using "gcc 4" will indicate versions that removed support for specific GCC versions. Usually, the versions retaining support can be deduced: if a Buildroot version removed support for a GCC version, typically in a "release candidate", then a previous version will presumably have support for that GCC version. For GCC 4.x, Buildroot 2019.08-rc1 removed support for GCC 4.9, so it is conceivable that Buildroot 2019.05.3 still has such support.

It is arguably better to choose a later Buildroot version supporting a particular GCC version than the one introducing such support. Otherwise, issues such as this one affecting the GCC 4 build process can be experienced.

There may be a more reliable summary of toolchain support in Buildroot which, if discovered, may be added here.

Building the Toolchain

First, check the requirements in the Buildroot manual. You may need to install additional packages like rsync besides the usual development tools needed for building software.

Here is a tested recipe for obtaining, configuring and building a GCC 4.9 toolchain for the A20:

git clone git://git.buildroot.net/buildroot
cd buildroot
git checkout 2018.08.4
make menuconfig

In the menu, the following settings were inspected/changed:

Target options
  Target Architecture (ARM (little endian))
  Target Binary Format (ELF)
  Target Architecture Variant (cortex-A7)
  Target ABI (EABIhf)
  Floating point strategy (NEON/VFPv4)
  ARM instruction set (ARM)

Toolchain
  GCC compiler Version (gcc 4.9.x)

To build the toolchain, run...

make toolchain

To speed things up on modern hardware, use -j <processes> for parallel builds, as is typical for the use of make. For example:

make -j8 toolchain

Configuration Specifics

When configuring the toolchain, the "Target Architecture Variant" and "Floating point strategy" are likely to be crucial.

For the A10, it appears that the following might be appropriate:

  Target Architecture Variant (cortex-A7)
  Floating point strategy (NEON)

For the A20 (as shown above):

  Target Architecture Variant (cortex-A7)
  Floating point strategy (NEON/VFPv4)

The Buildroot help suggests that the safest option likely to be applicable for "Floating point strategy" is as follows:

  Floating point strategy (VFPv3-D16)

Using the Toolchain

The built toolchain should reside in output/host/bin within the buildroot top-level directory. Setting the PATH environment variable to reference this toolchain should then allow the tools to be used.

Note that Buildroot cross-tools tend to use different prefixes to other cross-tools, so that GCC will be called one of the following things:

  • arm-buildroot-linux-uclibcgnueabihf-gcc
  • arm-linux-gcc

Meanwhile, a Debian cross-GCC will be called arm-linux-gnueabihf-gcc instead. This influences the invocations needed to compile software such as U-Boot and Linux.