HOWTO cross-compile the Linux kernel for the Libre Computer AML-S805X "La Frite"

This is a quick guide / HOWTO cross-compile the Linux kernel for the Libre Computer AML-S805X "La Frite".
The following works for me (YMMV). Also note that since I don't have the board yet, I cannot test the compiled kernel.

Basic steps

  • Install Ubuntu 18.04 on your laptop, PC or workstation, and customize to taste (note that the following instructions should work fine with any other recent Linux distribution, with very few changes).
  • Create a new directory under your home directory and call it for example "Amlogic". Alternatively, create a partition with label Amlogic and mount it (it will be mounted under /media/<username>/Amlogic), then change the group for the mount point to adm and set group write permissions.
  • Inside <path>/Amlogic, create folders u-boot_dev and kernel_dev for u-boot and kernel development purposes respectively.
  • Install the cross-compilation toolchain, git and a few more tools:
> sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
> sudo apt-get install build-essential autoconf libtool cmake pkg-config git python-dev swig3.0 libpcre3-dev nodejs-dev gawk wget diffstat bison flex libssl-dev
  • We won't be using the following packages immediately, but it's good to have them installed just in case:
> sudo apt-get install device-tree-compiler libncurses5-dev

Getting the Linux kernel and/or u-boot

  • Since both u-boot and the Linux kernel are on GitHub, it's a good idea to create an account and fork both.
  • OK, now let's see if we can clone the latest version of the Linux kernel (4.19 as I write these lines) to our local hard disk.
> cd .../Amlogic/kernel_dev/
> git clone<your_github_username>/linux.git (this will take some time, as it represents about 2.2 GB to download)
> cd linux
> git checkout v4.19
> head -n 6 ./Makefile (make sure it says "People's Front" somewhere and we are good!)
  • Let's make sure we can cross-compile the kernel and see how long it takes:
> make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- distclean
> make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig

At this point we have generated a default ARM 64-bit (aarch64) .config kernel configuration file. You may want to further edit/fine-tune this kernel configuration file for the "La Frite", or you may skip that step and compile the kernel, modules and device tree blob with the following command:
> time make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j4 Image modules amlogic/meson-gxl-s805x-p241.dtb

On my old and trusty Thinkpad T420 compiling the kernel took 25m51s.