FOX Board G20 technical documentation Buy

Compiling Linux Kernel 4.19 LTS for the FOX Board G20

This article illustrates how to generate a bootable Linux Kernel image for the FOX Board G20 SBC

Step-by-step Kernel cross-compilation procedure:

This article has been tested on:

  • Ubuntu 18.04.4 Linux PC Intel/64bit
  • Raspberry Pi 4 Raspbian Buster Lite
  • Debian 10 Linux PC Intel/64bit

On Ubuntu or Debian Linux PCs

On Raspberry Pi

The toolchain (gcc, g++, etc) required to compile the Linux Kernel is already installed by default on Raspbian Buster. Install just these few packages:

sudo apt update
sudo apt install bc bison libssl-dev

It is possible to use the Raspberry Pi native gcc compiler so remove:

CROSS_COMPILE=arm-linux-gnueabihf-

from the command provided below

Download the kernel sources from Kernel.org

Open a terminal on your Linux PC and download the Linux Kernel sources from the main stream repository:

wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.19.209.tar.xz

Extract the Kernel sources from the compressed file by typing:

tar xvfJ linux-4.19.209.tar.xz

Move inside the new folder:

cd linux-4.19.209

Download a kernel configuration example

Download this file:

inside the kernel arch/arm/configs/ directory by typing:

wget https://www.acmesystems.it/www/foxg20_compile_kernel_4_19/foxg20_defconfig -O arch/arm/configs/foxg20_defconfig

then launch this command:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- foxg20_defconfig

Customize the default Linux Kernel configuration:

If you need to customize the Kernel configuration or you just want to take a look around the Kernel setup type:

make ARCH=arm menuconfig

and navigate inside the Kernel configuration using the arrow keys and following the help provided by the menuconfig interface.

Create a defconfig of your own Kernel configuration (optional)

make ARCH=arm savedefconfig

The file defconfig contains your configuration. You could rename and copy it in arch/arm/configs/

cp defconfig arch/arm/configs/my_defconfig

Download a device tree example

Download this file:

inside the kernel arch/arm/boot/dts directory by typing:

wget https://www.acmesystems.it/www/foxg20_compile_kernel_4_19/acme-foxg20.dts -O arch/arm/boot/dts/acme-foxg20.dts

Generate the Device Tree Blob file (.dtb)

Now compile the device tree file requested by your board by selecting one of the following commands:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- acme-foxg20.dtb

Compile the Kernel image

Compile the Linux Kernel sources and generate the binary compressed image file to save in the first partition of microSD card.

make -j8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage
...
Image arch/arm/boot/zImage is ready

Install the u-boot-tools

sudo apt update
sudo apt install u-boot-tools

Then create a unique binary file with the kernel image and the device tree blob in a unique file

cat arch/arm/boot/zImage arch/arm/boot/dts/acme-foxg20.dtb > zImage_dtb 

Generate uboot uImage requested by the AcmeBoot program saved on FOX Board serial flash to boot:

mkimage -A arm -O linux -C none -T kernel -a 20008000 -e 20008000 -n linux-4.19.209 -d zImage_dtb uImage

And copy this file on the fir microSD partition:

cp uImage /media/$USER/BOOT

Compile the Kernel modules

The image generated contains the Linux Kernel and all the built-in device drivers (option [*] in menuconfig) compiled with it.

Al the drivers compiled as external modules (option [M] in menuconfig) need to be compiled and saved in the rootfs /lib directory on the second partition of the microSD. We didn't use any [M] flag in our defconfig so this procedure is not requested but. in case you add something. these are the commands to use to compile them:

make modules -j8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
make modules_install INSTALL_MOD_PATH=./modules ARCH=arm

Sergio Tanzilli
Systems designer, webmaster of www.acmesystems.it and founder of Acme Systems srl

Personal email: tanzilli@acmesystems.it
Web pages: https://www.acmesystems.it --- https://www.acmestudio.it
Github repositories: https://github.com/tanzilli --- https://github.com/acmesystems
Telegram group dedicated to the Acme Systems boards: https://t.me/acmesystemssrl

Home page FOX Board G20 technical documentation Buy