VAR-SOM-AM43 Yocto Krogoth Build Linux out of tree

From Variscite Wiki

1 Downloading source code

First, clone the git repository to a local directory, as follows:

$ mkdir ~/varsomam43
$ cd ~/varsomam43
$ git clone
$ cd VAR-SOM-AMx3-Kernel-4-x
$ git checkout var-som-AMx3-sdk-linux-03.01.00

2 Setup Toolchain path

$ export PATH=/opt/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf/bin:$PATH

3 Cleaning the Kernel Sources

Prior to compiling the Linux kernel make sure that the kernel sources are clean.

NOTE:The next step will delete any saved .config file in the kernel tree as well as the generated object files. If you have done a previous configuration and do not wish to lose your configuration file you should save a copy of the configuration file before proceeding.

The command to clean the kernel is:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mrproper

4 Configuring the Kernel

Before compiling the Linux kernel it needs to be configured to select which components will become part of the kernel image:

4.1 Using Default Configurations

To build the defualt configuration for the VAR-SOM-AM43:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am437x_defconfig

4.2 Customizing the Configuration

For configuring the kernel run:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Once the configuration window is open you can select which kernel components will be included in the build. Exiting the configuration will save your selections to a file in the root of the kernel tree called .config.

5 Compiling the Kernel

Once the kernel has been configured compile kernel:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage LOADADDR=0x80200000

This will result in a kernel image file being created in the arch/arm/boot/ directory called zImage. This file can be used by u-boot to boot your device.

If you selected any components of the kernel to be built as dynamic modules you must issue an additional command to compile those modules. The command is:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules

This will result in .ko (kernel object) files being placed in the kernel tree. These .ko files are the dynamic kernel modules. The next section will cover how to install these modules.

6 Building the VAR-SOM-AM43 device tree

To build the VAR-SOM-AM43 device tree (dtb image), please use the following command line:

for Ethernet + Wifi SOMs
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- var-som-am43.dtb
for dual Ethernet SOMs:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- var-som-am43-eth1.dtb

The dtb images will be located in: arch/arm/boot/dts/

7 Replace bootable SD-Card's kernel

In order to install the newly created kernel to the SD-Card, please follow the instructions below:
1) Plug in the bootable SD-Card created above to a Linux host PC
2) Mount the second partition, which holds the system's file system as /media/rootfs.
3) Install by executing the following commands:

$ sudo cp arch/arm/boot/zImage /media/rootfs/boot
$ sudo cp arch/arm/boot/dts/var-som-am43.dtb /media/rootfs/boot
$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules_install INSTALL_MOD_PATH=/media/rootfs 
$ sync
$ sudo umount /media/boot
$ sudo umount /media/rootfs
$ sudo umount /media/user