Compiling Linux Kernel 4.9.124

This article illustrates how to generate a bootable Linux Kernel image for RoadRunner D2, Acqua A5, Aria G25, Arietta G25 and FOX G20 boards

Notes, info, changelog, sources and links related to this version

  • This procedure has been tested on Linux Ubuntu version 18.04
  • The latest Linux Kernel version we tried writing this article is 4.9.124
  • It is advisable to have a Debug Port Interface or similar during the kernel bootstrap
  • Before following this step by step procedure install these packages

Step-by-step Kernel cross-compilation procedure:

Open a terminal on your Linux PC and download the Linux Kernel sources:

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

Extract the Kernel sources from the compressed file by typing:

tar xvfJ linux-4.9.124.tar.xz

Move inside the just created new folder:

cd linux-4.9.124

At this point I suggest to create a your own personal branch of Linux Kernel sources with git to keep a trace of any changes from the Kernel mainline using these commands.

git init; git add .; git commit -m "Linux vanilla"; git branch acme; git checkout acme

Download the Acme Systems patch for this Kernel version. It add just the Acme boards defconfig, device trees and small fewbug fixes:

wget https://raw.githubusercontent.com/AcmeSystems/acmepatches/master/linux-4.9.patch

and apply it by typing:

patch -p1 < linux-4.9.patch

Then select from the following list the right Linux configuration for your board by typing one of these commands:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- acme-roadrunner_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- acme-acqua_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-arietta_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-xterm-01_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-aria_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-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

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/myboard_defconfig

Generate the Device Tree Blob file (.dtb)

Now compile the device tree file requested by your board by selecting the right command from the following list:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- acme-roadrunner-bertad2.dtb
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- acme-acqua.dtb
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-arietta.dtb
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-xterm-01.dtb
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-aria.dtb
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- 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.

Roadrunner, Acqua

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

Aria, Arietta, Fox Board G25

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

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:

Roadrunner, Acqua

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

Aria, Arietta, Fox Board G25

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

Copy the boot files into the first microSD partition

Insert a microSD formatted microSD with the boot loader and the rootfs contents already created in your Linux PC and copy on it the files directly:

Write the Linux Kernel image, the Device tree blog files in the first microSD partition and uncompress the modules in /modules/lib directory inside the second microSD partition:

RoadRunner on Berta D2 board

cp arch/arm/boot/dts/acme-roadrunner-bertad2.dtb /media/$USER/BOOT/acme-roadrunner.dtb
cp arch/arm/boot/zImage /media/$USER/BOOT
sudo rsync -avc modules/lib/. /media/$USER/rootfs/lib/.

Acqua A5

cp arch/arm/boot/dts/acme-acqua.dtb /media/$USER/BOOT/at91-sama5d3_acqua.dtb
cp arch/arm/boot/zImage /media/$USER/BOOT
sudo rsync -avc modules/lib/. /media/$USER/rootfs/lib/.

Arietta G25

cp arch/arm/boot/dts/acme-arietta.dtb /media/$USER/BOOT/acme-arietta.dtb
cp arch/arm/boot/zImage /media/$USER/BOOT
sudo rsync -avc modules/lib/. /media/$USER/rootfs/lib/.

Arietta G25 on XTERM-01 board

cp arch/arm/boot/dts/acme-xterm-01.dtb /media/$USER/BOOT/acme-arietta.dtb
cp arch/arm/boot/zImage /media/$USER/BOOT
sudo rsync -avc modules/lib/. /media/$USER/rootfs/lib/.

Aria G25

cp arch/arm/boot/dts/acme-aria.dtb /media/$USER/BOOT/at91-ariag25.dtb
cp arch/arm/boot/zImage /media/$USER/BOOT
sudo rsync -avc modules/lib/. /media/$USER/rootfs/lib/.

FOX Board G20

cat arch/arm/boot/zImage arch/arm/boot/dts/acme-foxg20.dtb > /media/$USER/BOOT/uImage
sudo rsync -avc modules/lib/. /media/$USER/rootfs/lib/.

Remote writing via ssh

Use this method if you have a working board accessible via LAN, WiFi or USB

Write the Linux Kernel image, the Device tree blog files in the first microSD partition and uncompress the modules in /modules/lib directory inside the second microSD partition:

RoadRunner on Berta D2 board

scp arch/arm/boot/dts/acme-roadrunner-bertad2.dtb root@[ip_address]:/boot/acme-roadrunner.dtb   
scp arch/arm/boot/zImage root@[ip_address]:/boot
rsync -avc modules/lib/. root@[ip_address]:/lib/.

Acqua A5

scp arch/arm/boot/dts/acme-acqua.dtb root@[ip_address]:/boot/at91-sama5d3_acqua.dtb
scp arch/arm/boot/zImage root@[ip_address]:/boot
rsync -avc modules/lib/. root@[ip_address]:/lib/.

Arietta G25

scp arch/arm/boot/dts/acme-arietta.dtb root@192.168.10.10:/boot/acme-arietta.dtb
scp arch/arm/boot/zImage root@192.168.10.10:/boot
rsync -avc modules/lib/. root@192.168.10.10:/lib/.

Arietta G25 with XTERM-01

scp arch/arm/boot/dts/acme-xterm-01.dtb root@192.168.10.10:/boot/acme-arietta.dtb
scp arch/arm/boot/zImage root@192.168.10.10:/boot
rsync -avc modules/lib/. root@192.168.10.10:/lib/.

Aria G25

scp arch/arm/boot/dts/acme-aria.dtb root@[ip_address]:/boot/at91-ariag25.dtb
scp arch/arm/boot/zImage root@[ip_address]:/boot
rsync -avc modules/lib/. root@[ip_address]:/lib/.

FOX Board G20

cat arch/arm/boot/zImage arch/arm/boot/dts/acme-foxg20.dtb > uImage
scp uImage root@[ip_address]:/boot
rsync -avc modules/lib/. root@[ip_address]:/lib/.

If this command doesn't work verify if rsync in installed on your board. Use apt-get install rsync.

After the first boot

At the first access to the board command line update the module dependencies by typing this command:

depmod -a

Links

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