How to compile i.MX6 Linux Kernel 3.15 and 3.16

Content


Thank you very much to Robert Nelson. Robert ported the Linux Kernel 3.15 and Kernel 3.16 for the iMX6 Rex. You can find more information at Robert's Wiki: iMX6 Rex Board Debian Image webpage.

On this page, you will find step-by-step instructions to build iMX6 Rex Kernel 3.15. Please note we have tested only Kernel version 3.15. The kernel 3.16 has a bug and HDMI will not work without additional tweaking.

Setup a host computer

1. Download and install Ubuntu 12.04 LTS. You can use a Virtual machine - we normally use vMware Player.
2. Run updates on the fresh installed Ubuntu. Go to Update manager (via Dash Home on the top right corner or via terminal use command update-manager). Check for updates first and then Install Updates. Restart the machine.

Download the kernel source files

1. Clone the iMX6 Rex Robert's github repositories to your machine. (Note: You may need to be registered on github)
# cd
# git clone https://github.com/RobertCNelson/imx-devel.git
# cd imx-devel/
2. Checkout the branch of Kernel 3.15:
# git checkout origin/v3.15.x-rex -b v3.15.x-rex
3. Create a rootfs directory:
# mkdir /media/rootfs

Compile kernel and copy it on an SD card

1. Always be sure you have the latest source code (follow these instructions). To compile the kernel run following script:
# ./build_kernel.sh
2. After the build is ready you need to install the uImage on your SD card. You can use also prepared Kernel 3.15. Note: This kernel was compiled with command line using 1GB memory and booting from device sda1 (usually hard disk).

Plug in an SD card and follow these steps to setup the card. List the block devices and look where the SD card is located (in this example it is mapped as /dev/sdb1):
# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0    50G  0 disk 
├─sda1   8:1    0    49G  0 part /
├─sda2   8:2    0     1K  0 part 
└─sda5   8:5    0  1021M  0 part [SWAP]
sdb      8:16   1   7.4G  0 disk 
└─sdb1   8:17   1   7.4G  0 part 
sr0     11:0    1  1024M  0 rom  
sr1     11:1    1  1024M  0 rom 
3. Mount the device
# sudo mount /dev/sdb1 /media/rootfs/
4. Prepare a blank file which is required to copy the uImage to the SD card:
# sudo touch /media/rootfs/uEnv.txt
5. According to where the SD card is mapped update the file:
# sudo nano system.sh
On the bottom of the file there is one uncommented line. Update it with the location of the SD card. Do not use the name of the partition, use the name of the device:
MMC=/dev/sdb
6. Run the script for creating the uImage. Use the correct one according to your module version - e.g. for Module Pro (Quad CPU, 2GB Memory) run:
# ./tools/install_kernel_quad_2gb.sh 

Copy the Debian filesystem

1. Download the Debian filesystem for iMX6 Rex created by Sam Nazarko:
# wget http://www.imx6rex.com/imx6-rex-debian.tar.gz -P ~
2. Untar the package to the SD card:
# cd /media/rootfs/
# tar -pxvzf ~/imx6-rex-debian.tar.gz
3. Reset the password (don't forget, you re still working on the SD card plugged in the host machine):
# sudo nano /media/rootfs/etc/passwd
On the first line remove the x after the first colon. The line will then look like this:
root::0:0:root:/root:/bin/bash
4. umount SD card
# umount /media/rootfs/
Now you can move SD card to your iMX6 Rex board.
4. Boot up and update the password. Login as a "root"
# passwd
Done. Now you have your Kernel 3.15 and Debian file system running :)

Get the latest source code / update command line

1. If you need to pull the latest commits from github and reset you local changes manually use these commands. Note: You may want to backup your local changes before you delete them.
# git fetch --all
# git reset --hard origin/v3.15.x-rex
# git pull origin v3.15.x-rex
2. Because the new kernel cannot pass the parameters set in u-boot they need to be compiled directly into the kernel. Open defconfig file:
# sudo gedit patches/defconfig
Look for CONFIG_CMDLINE parameter. If you for example want to boot from hard drive you will change it to:
CONFIG_CMDLINE="console=ttymxc0,115200 root=/dev/sda1 rootwait video=HDMI-A-1:1024x768@60e"
  • Neeeraj

    HI i am getting following error
    ** File not found /boot/uEnv.txt **
    Checking if uenvcmd is set …
    Running default loadzimage …
    ** File not found /boot/zImage **
    Running default loaduimage …
    ** File not found /boot/uImage **

  • PPP

    I am trying to recompile kernel and I found that linaro removed http urls. Now it seems to be using https. Could you please fix the tutorial/files? I can’t go forward because of my limited knowledge of linux.