Goal Compile Xilinx Linux kernel to be run on Zynq along with the Ubuntu
Approach Cross compilation on Ubuntu
Benefits Having control on different feature of Linux Kernel
Credit This work has been done under the ENPOWER project (funded by EPSRC) at University of Bristol.

Compiling the Xilinx Linux kernel for Ubuntu OS has three main parts:

  • Compiling the kernel
  • Compiling the devicetree
  • Install the kernel module on the SD-card

Compiling the kernel

1- Install ARM toolchain


apt-get install gcc-arm-linux-gnueabihf

2- Download the kernel from Xilinx Github site as follows


git clone https://github.com/Xilinx/linux-xlnx.git

3- Set environment variables


export ARCH=arm

export CROSS_COMPILE=arm-linux-gnueabihf-

4- Generate the config file


make ARCH=arm xilinx_zynq_defconfig

5- Edit the .config file


gedit .config

6- Change the following options

To increase the contiguous memory allocation:


CONFIG_CMA_SIZE_MBYTES=512

to be able to allocate larger memory for hardware When set to 12, the maximum is 8MB; 13 gives 16MB, etc.


CONFIG_FORCE_MAX_ZONEORDER=15 

7- Compile the kernel

make ARCH=arm UIMAGE_LOADADDR=0x8000 uImage

8- Transfer the uImage to the BOOT partition in the SD-card
9- Zip the whole kernel directory and transfer that to /usr/src folder in the root partition in the SD-card (This is for writing and developing kernel modules)

 

Compiling the devicetree

1- Generate the zynq-zc702.dtb by

make zynq-zc702.dtb

2- In a tmp folder convert this devicetree binary file into the source file by

dtc -I dtb -O dts -o zynq-zc702.dts  zynq-zc702.dtb

3- Edit the zynq-zc702.dts and change the bootargs line as follows

bootargs = "console=ttyPS0,115200 root=/dev/mmcblk0p2 rw earlyprintk rootfstype=ext4 rootwait devtmpfs.mount=0";

Install the kernel module on the SD-card

1- Unzip the kernel

2- Get the Linux kernel version by running “uname –r”

3- Change the Linux source folder name to the Linux kernel version

4- Go to the kernel src folder and run these two commands

make modules –j2
make modules_install

5- If it is necessary go to the /lib/module directory in the Zynq board add a software link to the Linux modules considering the Linux kernel version obtained by “uname –r”

The screenshots for two versions of Ubuntu 12.11 and 14.04 with Linux kernel 4.6.0:

zynq-linux-ubuntu-12-11

zynq-linux-ubuntu-14-04