Acqua technical documentation Buy

Compiling Linux Kernel 4.19.x LTS for Acqua

This article illustrates how to generate a bootable class='acmetable' Linux Kernel image for Acqua SOM starting from the source files available on the Microchip Linux4Sam git repository. This image can be used with Debian or Buildroot rootfs.

Prerequisite

A Linux PC in required to cross compile the Kernel image.

This procedure has been tested on:

  • Ubuntu 18.04.4 LTS (amd64)
  • Debian Buster 10 (amd64)

Using an Intel PC is required to install these packages

It is advisable to have a Debug Port Interface like DPI or USB-3V-SER to check the error messages during the kernel bootstrap

Step-by-step Kernel cross-compilation procedure:

Here we will illustrate how to compile the source available on the Microchip website site and repository:

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

wget https://github.com/linux4sam/linux-at91/archive/linux-4.19-at91.zip

Extract the Kernel sources from the compressed file by typing:

unzip linux-4.19-at91.zip

Move inside the new folder:

cd linux-at91-linux-4.19-at91

Create with git a new branch of Linux Kernel sources called acme to keep a trace of any changes from the Kernel mainline.

Install git on your PC:

sudo apt update
sudo apt install git

Create a local git repository and the new branch acme:

git init; git add .; git commit -m "linux-4.19-at91"; 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 few bug fixes:

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

and apply it by typing:

patch -p1 < linux-4.19.x.patch

Set the defconfig:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- acme-acqua_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/my_defconfig

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-acqua.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

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

Copy the boot files into the first microSD partition

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

Write the Linux Kernel image and the device tree blob in the first microSD partition:

sudo cp arch/arm/boot/zImage /media/$USER/boot
sudo cp arch/arm/boot/dts/acme-acqua.dtb /media/$USER/boot/at91-sama5d3_acqua.dtb

Write the Linux Kernel modules inside the second microSD partition:

sudo rsync -avc modules/lib/. /media/$USER/rootfs/lib/.

After the first boot

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

depmod -a

Usefull commands

If you want to create a patch with the changes you have made on the vanilla Linux kernel use these commands:

git checkout acme
git diff master > acme.patch

To revert a patch applied type:

patch -p1 -R < ../acme.patch

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

Home page Acqua technical documentation Buy