This series of blog posts contains the following parts:

1. The bootloader U-Boot

2. The Kernel (This part)

3. Debian Root File System

4. Flashing with MFGTool in Windows

5.Creating an SDCard Image


Part 2: Kernel


In this part we will be creating the kernel, the device tree as well as the modules and kernel headers from the mainline source code.


The build environment will be the same as the one for building u-boot.

So if you didn´t already do that, then you should do "Step 1. Essentials and Compiler" from Part 1.


1. Get the source code


If you´re not already in the right folder, cd into the folder you will be saving the code.

You should already have one i f you followed Part 1 of this series.

In my case:


cd /home/riotboard/linux


And now we´ll get the code from Linus Torvalds original Linux repository.


git clone git://
cd linux



2. Compile the Kernel


Before compiling make sure the environment variables are set correctly. (As described in Part 1)

Also make sure the OUTPUT variable is set to the correct folder.


export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
export OUTPUT=/home/riotboard/linux/output


First write the config to compile the kernel for our RIoTBoard.

(We now can use the config that´s integrated into the mainline code.)


make imx_v6_v7_defconfig


If you need to change the config. Like activating support for specific drivers or similar, you can execute menuconfig to edit the config file with a dialog.

(This is optional)


make menuconfig


Now we can compile the Kernel

(Adjust the parameter j to the number of threads it should use. Most likely one for each CPU.)


make -j4 bzImage


Now in the folder arch/arm/boot we have the Kernel file zImage


Copy that file into our Output boot folder.


mkdir $OUTPUT/boot
cp arch/arm/boot/zImage $OUTPUT/boot/zImage


3. Device Tree Blob


Next we need the Device Tree Blob file.

With the following command all DTB files will be created. But we copy only the one we need.


make dtbs
cp arch/arm/boot/dts/imx6dl-riotboard.dtb $OUTPUT/boot/imx6dl-riotboard.dtb


4. Modules and Headers


Now we need to create the modules.

And then copy them into our output folder.


make modules -j4
make modules_install INSTALL_MOD_PATH=$OUTPUT


Now the same thing for the Kernel headers.

This is optional, but sometimes you´ll need them to compile additional drivers on the board for example.

So let´s integrate them too. They belong into the usr folder.


make headers_install INSTALL_HDR_PATH=$OUTPUT/usr


Last thing to do now is just to pack everything into a tarball and remove the unneeded folders.


tar cvzf linux-kernel.tgz boot lib usr
rm -rf boot lib usr


That´s it for this part.


In the next part we will be creating a debian root file system from scratch.


Continue with Step 3