HOWTO compile the Linux kernel for the "La Frite" on the "Le Potato"

This is a quick guide / HOWTO natively compile the Linux kernel for the "La Frite" on the "Le Potato", or on the "La Frite" itself, or on any other ARM 64-bit SBC. Note that natively compiling the Linux kernel on any ARM 64-bit SBC will take much longer (as much as 4x to 20x longer) than cross-compiling on your laptop, PC or workstation, so the question is, why would you want to do that in the first place, apart from the fun? Well, it validates the entire toolchain on your SBC and it also shows the SBC capabilities.

The following works for me, using an Amlogic S905 Android TV Box on which I am booting Ubuntu Linux 18.04 from an SD card (YMMV). Also note that since I don't have the "La Frite" yet, I cannot test the compiled kernel.

  • Install AArch64 Ubuntu 18.04 on your "Le Potato" or other SBC, and customize to taste. Note that the following instructions should work fine with any other recent AArch64 Linux distribution, with very few changes. Also please note that Raspbian is not an ARM 64-bit (AArch64) Linux distribution.
  • 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 compilation toolchain, git and a few more tools:
> 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
  • 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
  • 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 / SD card.
> cd .../Amlogic/kernel_dev/
> git clone --depth 1 --branch v4.19<your-git-username>/linux.git (this will take some time, as it represents about 150MB 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 compile the kernel and see how long it takes:
> make distclean
> make 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 -j4 Image modules amlogic/meson-gxl-s805x-p241.dtb

On my S905-based Android TV Box with 1GB RAM running Linux on an SD card, it took 80m17s. That is more than 3x longer than on my old and trusty Thinkpad T420 (which has an i5-2540M @ 2.60GHz and 8GB RAM).
I checked the SoC temperature at the end of the compilation job and it had reached 81C (measured using the on-die temperature sensor available at /sys/devices/virtual/thermal/thermal_zone0/temp). Idle temperature is around 42C.

Note that one way to speed up the compilation of the Linux kernel or any other large software package is to use distcc.