Rebuilding the Certified Ubuntu for Xilinx Devices 20.04 LTS Kernel from Source

This page describes the steps to download the source code files for the Linux kernel used in the Certified Ubuntu for Xilinx Devices 20.04 LTS release.

The following steps are also applicable to 22.04 - use “jammy” where “focal” is referenced below.

Table of Contents

Introduction

The Certified Ubuntu for Xilinx Devices release provides a robust and stable Linux kernel image that covers many use cases. It is possible that a particular application may require a feature in the Linux kernel that is not enabled by default in the Certified Ubuntu for Xilinx Devices kernel.

This wiki page documents how to clone the Xilinx-specific Linux kernel tree from the Canonical Ubuntu servers and rebuild it using standard Debian best practices.

Configure the Build Environment

Before fetching the Linux kernel sources, first configure the build environment with tools such as git, Aarch64 gcc, and fakeroot.

First, configure the Ubuntu sources package repository for Ubuntu 20.04 LTS.

$ echo "deb-src http://archive.ubuntu.com/ubuntu focal main" | sudo tee -a /etc/apt/sources.list.d/focal.list

After configuring the new repository, update the apt metadata cache.

$ sudo apt-get update

Once the package repository is updated, configure all of the build dependencies for the Linux kernel

$ sudo apt-get build-dep linux

This process generates many files during the compilation process and can exhaust the amount of space available in the SD card. It is highly recommended to use a fixed disk. Please see https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/2136014855.

Once the Linux kernel build dependencies are configured, install the remaining tools required for the build process.

$ sudo apt-get install git fakeroot libncurses-dev gcc-aarch64-linux-gnu linux-tools-common

Clone the Linux Kernel Source Code

The Certified Ubuntu for Xilinx Devices Linux kernel repository can be found on Launchpad at https://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-xilinx-zynqmp/+git/focal

In order to get started, first clone the source code.

$ git clone https://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-xilinx-zynqmp/+git/focal

After cloning the source code, switch to the latest tag. To check for the latest tag, look at the Git history with

$ cd focal $ git tag

To check out a specific tag, name it explicitly.

$ git checkout Ubuntu-xilinx-zynqmp-5.4.0-1017.20

Configure the Build Environment

Prior to building the Linux kernel there are some environment variables that need to be set. Some are universal but others are only required if building in a cross-compile environment.

First, set the target architecture for the Linux kernel

$ export ARCH=arm64

Also, export the dpkg variables required for packaging Debian packages for the target (arm64) architecture

$ export $(dpkg-architecture -aarm64)

Finally, if compiling in a cross-compilation environment set the CROSS_COMPILE variable

$ export CROSS_COMPILE=aarch64-linux-gnu-

Edit the Linux Kernel Configuration

If the Linux kernel configuration requires modification the standard Linux kernel menuconfig can be accessed with the standard Debian editconfigs rule. This is the place in the process where new drivers, modules, or features of the Linux kernel can be enabled. If there are no edits required this section can be skipped.

$ fakeroot debian/rules clean $ fakeroot debian/rules editconfigs

After the kernel options have been configured, select <Exit> from the bottom menu and then proceed to build the kernel.

Build the Linux Kernel

To build the Linux kernel, use the standard Debian rules system with the binary target. The output of this process will be a series of standard .deb Debian packages.

$ fakeroot debian/rules clean $ fakeroot debian/rules binary

The generated .deb packages are located one directory higher than the Linux kernel source directory.

Install the Linux Kernel Packages

If the kernel was compiled on the target, installing the new kernel is simple. First, change to the directory where the build process placed the Debian packages and install them with the dpkg tool.

$ cd .. (or to wherever the .deb packages are located) $ sudo dpkg -i *.deb

If the kernel was compiled in a cross-compilation environment, first copy the .deb packages to some kind of external media such as a USB stick in order to transport them to the Ubuntu target machine. Alternatively, they can be placed in the FAT32 partition of the Ubuntu SD card (mounted at /boot/firmware in the running Ubuntu system). Then, they can be installed using the dpkg tool as described above.

After installing the kernel update packages, reboot the system

$ sudo reboot

Upgrading & Downgrading the Linux Kernel Image

If a newer or older version of the Linux kernel is required, the same process is appropriate. Simply, choose the appropriate tag and build using it.

NOTE: If a newer version of the Linux kernel appears in the package repositories, the Linux kernel image will be updated to it automatically. It may need to be rebuilt manually to re-enable special features from the kernel configuration above.

 

 

 

© Copyright 2019 - 2022 Xilinx Inc. Privacy Policy