Compiling Linux Kernel 4.1.11

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

Hardware requirements:

  • an Ubuntu 15.04 Linux PC to cross compile the Kernel
  • an Acme board with Atmel MPU inside
  • a microSD card
  • a Debug Port Interface

Software requirements

Step-by-step Kernel cross-compilation procedure:

Download and save in your home directory the Linux Kernel sources:

Extract the Kernel sources from the compressed file by typing:

~$ tar xvfJ linux-4.1.11.tar.xz
...

Move inside the new folder:

~$ cd linux-4.1.11
~/linux-4.1.11$

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

~/linux-4.1.11$ git init
~/linux-4.1.11$ git add .
~/linux-4.1.11$ git commit -m "Linux vanilla"
~/linux-4.1.11$ git branch acme
~/linux-4.1.11$ git checkout acme

Download this patch file from GitHub:

and apply it by typing:

~/linux-4.1.11$ patch -p1 < linux-4.1.11.patch

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

~/linux-4.1.11$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-acqua-a5_defconfig
~/linux-4.1.11$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-arietta-g25_defconfig
~/linux-4.1.11$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-aria-g25_defconfig
...
# configuration written to .config

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:

~/linux-4.1.11$ make ARCH=arm menuconfig

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

Generate the Device Tree Blob file (.dtb)

Now compile the the device tree file requested by your board by typing one of these commands:

~/linux-4.1.11$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-acqua-a5.dtb
~/linux-4.1.11$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-arietta-g25.dtb
~/linux-4.1.11$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-aria-g25.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.

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

On a mid-power PC the whole source compilation requires about 5 minutes.

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. To compile them type:

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

Copy the boot files into the first microSD partition

Direct write on microSD

Insert a formatted microSD 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:

Acqua

~/linux-4.1.11$ cp arch/arm/boot/dts/acme-acqua-a5.dtb /media/$USER/kernel/at91-sama5d3_acqua.dtb
~/linux-4.1.11$ cp arch/arm/boot/zImage /media/$USER/kernel
~/linux-4.1.11$ sudo rsync -avc modules/lib/. /media/$USER/rootfs/lib/.

Arietta

~/linux-4.1.11$ cp arch/arm/boot/dts/acme-arietta-g25.dtb /media/$USER/kernel/acme-arietta-g25
~/linux-4.1.11$ cp arch/arm/boot/zImage /media/$USER/kernel
~/linux-4.1.11$ sudo rsync -avc modules/lib/. /media/$USER/rootfs/lib/.

Aria

~/linux-4.1.11$ cp arch/arm/boot/dts/acme-aria-g25.dtb /media/$USER/kernel/at91-ariag25.dtb
~/linux-4.1.11$ cp arch/arm/boot/zImage /media/$USER/kernel
~/linux-4.1.11$ 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:

Acqua

~/linux-4.1.11$ scp arch/arm/boot/dts/acme-acqua-a5.dtb root@ip address:/boot/at91-sama5d3_acqua.dtb
~/linux-4.1.11$ scp arch/arm/boot/zImage root@ip address:/boot
~/linux-4.1.11$ rsync -avc modules/lib/. root@ip address:/lib/.

Arietta

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

Aria

~/linux-4.1.11$ scp arch/arm/boot/dts/acme-aria-g25.dtb root@ip address:/media/mmc_p1/at91-ariag25.dtb
~/linux-4.1.11$ scp arch/arm/boot/zImage root@ip address:/media/mmc_p1
~/linux-4.1.11$ 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