High-Level Synthesis for FPGA Online Courses

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

[code language="c"]

apt-get install gcc-arm-linux-gnueabihf

[/code]

2- Download the kernel from Xilinx Github site as follows

[code language="c"]

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

[/code]

3- Set environment variables

[code language="c"]

export ARCH=arm

export CROSS_COMPILE=arm-linux-gnueabihf-

[/code]

4- Generate the config file

[code language="c"]

make ARCH=arm xilinx_zynq_defconfig

[/code]

5- Edit the .config file

[code language="c"]

gedit .config

[/code]

6- Change the following options

To increase the contiguous memory allocation:

[code language="c"]

CONFIG_CMA_SIZE_MBYTES=512
[/code]

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

[code language="c"]

CONFIG_FORCE_MAX_ZONEORDER=15 

[/code]

7- Compile the kernel

[code language="c"]
make ARCH=arm UIMAGE_LOADADDR=0x8000 uImage
[/code]

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

[code language="c"]
make zynq-zc702.dtb
[/code]

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

[code language="c"]
dtc -I dtb -O dts -o zynq-zc702.dts  zynq-zc702.dtb
[/code]

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

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

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

[code language="c"]
make modules –j2
make modules_install
[/code]

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

High-Level Synthesis for FPGA Online Courses

One thought on “How to compile Xilinx Linux Kernel for zynq”
  1. Hello blogger, i must say you have very interesting articles here.

    Your page can go viral. You need initial traffic
    only. How to get it? Search for; Mertiso’s tips go viral

Leave a Reply