Building Linux

This document attempts to provide recipes for building different Linux kernel versions. Linux 3.4 was used to test the A10 and A20 boards, but it may now be considered "legacy" and would not be the basis for ongoing software support. However, it may still be useful for board testing.

Linux 3.4

Since the 3.4 kernel will suffer from similar compilation issues to those experienced in Building U-Boot, a Buildroot Toolchain may need to be prepared before attempting to build the Linux kernel itself.

A tested recipe with a GCC 4.9 cross-toolchain from Buildroot 2018.08.4, targeting the A20:

git clone https://github.com/linux-sunxi/linux-sunxi.git
cd linux-sunxi
ARCH=arm CROSS_COMPILE=arm-linux- make sun7i_defconfig
ARCH=arm CROSS_COMPILE=arm-linux- make uImage modules

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

ARCH=arm CROSS_COMPILE=arm-linux- make -j8 uImage modules

Note that Buildroot compilers tend to use their own naming, so it is arm-linux- and not arm-linux-gnueabihf- (as Debian uses) that needs to be used. However, if another compatible compiler is available with the Debian-style naming, then the CROSS_COMPILE setting should use that naming instead.

In the above, configuration for the A20 is selected using sun7i_defconfig. For the A10, sun4i_defconfig would be used instead.

Mainline

The mainline Linux kernel should be compatible with contemporary compiler versions, meaning that operating system distribution toolchains such as those provided by Debian should work. For Debian, installing the gcc-arm-linux-gnueabihf cross-toolchain should be sufficient.

Following more general guidance, a recipe for building the kernel with the Debian toolchain:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cd linux
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make sunxi_defconfig
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make zImage dtbs

Note that the arm-linux-gnueabihf- prefix was used to select the Debian cross-toolchain. Obviously, a different toolchain can be selected by modifying this value.

In the above, configuration for numerous Allwinner devices is selected using sunxi_defconfig.

Device Tree and Configuration

The boot page provides some device tree and configuration files for more recent kernels than the 3.4 kernel. These will probably need checking, updating and integrating into the above build process.

The sun7i-a20-eoma68-a20.dts file appears to be derived from Cubieboard 2 support whose hardware definition is found at arch/arm/boot/dts/sun7i-a20-cubieboard2.dts in the mainline kernel.

The eoma68-a20-4.7-config file appears to specify various settings that are now covered by the sunxi_defconfig file, together with lots of other settings that may be filled in by default.

Device Tree Overlays

Modern kernels should support device tree overlays which hopefully support the modularity requirements of the EOMA68 concept. Additional device tree files will be required for housings such as the microdesktop board, describing the peripherals that are made available when the computer card (on which the CPU is placed) is inserted into the appropriate socket on the housing.