Compiling Linux Kernel 3.16.1

This article illustrates how to generate a bootable Linux Kernel image usable on the following Acme Systems SoM:

Hardware requirements:

  • a PC with Ubuntu Linux (tested with version 14.10) 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-3.16.1.tar.xz
...

Move inside the new folder:

~$ cd linux-3.16.1
~/linux-3.16.1$

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

Set the basic Kernel configuration

Arietta

Download acme-arietta_defconfig in arch/arm/configs then type to use it:

~/linux-3.16.1$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-arietta_defconfig
...
# configuration written to .config

Aria

Download acme-aria_defconfig in arch/arm/configs then type to use it:

~/linux-3.16.1$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-aria_defconfig
...
# configuration written to .config

Customize the default Linux Kernel configuration:

If you need to customize the Kernel configuration or just taking a look to the drivers and features activated type:

~/linux-3.16.1$ make ARCH=arm menuconfig

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

Compile the Device Tree Blob file

Aria

Download acme-aria.dts in arch/arm/boot/dts then type to use it:

~/linux-3.16.1$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-aria.dtb
...

Arietta

Download acme-arietta.dts in arch/arm/boot/dts then type to use it:

~/linux-3.16.1$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- acme-arietta.dtb
...

Compile the Kernel image

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

Aria

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

Arietta

~/linux-3.16.1$ 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-3.16.1$ make modules -j8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
...
~/linux-3.16.1$ make modules_install INSTALL_MOD_PATH=./modules ARCH=arm
...

Copy the boot files into the first microSD partition

Method 1 - Direct write on microSD

Insert a formatted microSD in your Linux PC and copy on it the files directly:

Write the Linux Kernel image and Device tree blog files in the first microSD partition:

Aria

~/linux-3.16.1$ cp arch/arm/boot/dts/acme-aria.dtb /media/$USER/KERNEL/at91-ariag25.dtb
~/linux-3.16.1$ cp arch/arm/boot/uImage /media/$USER/KERNEL/image.bin

Arietta

~/linux-3.16.1$ cp arch/arm/boot/dts/acme-arietta.dtb /media/$USER/KERNEL
~/linux-3.16.1$ cp arch/arm/boot/zImage /media/$USER/KERNEL

Write the Kernel modules in the rootfs (second microSD partition):

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

Method 2 - Remote writing via ssh

Use this method if you have a working board accessible via LAN

Write the Linux Kernel image and Device tree blog files in the first microSD partition:

Aria

~/linux-3.16.1$ scp arch/arm/boot/dts/acme-aria.dtb root@ariag25.local:/media/mmc_p1/at91-ariag25.dtb
~/linux-3.16.1$ scp arch/arm/boot/uImage root@ariag25.local:/media/mmc_p1/image.bin

Arietta

~/linux-3.16.1$ scp arch/arm/boot/dts/acme-arietta.dtb root@192.168.10.10:/boot
~/linux-3.16.1$ scp arch/arm/boot/zImage root@192.168.10.10:/boot

Write the Kernel modules in the rootfs (second microSD partition):

Aria

~/linux-3.16.1$ rsync -avc modules/lib/. root@ariag25.local:/lib/.

Arietta

~/linux-3.16.1$ rsync -avc modules/lib/. root@192.168.10.10:/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

Related links