Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

Info

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

Table of Contents

Table of Contents
excludeTable of Contents

Introduction

The Certified Ubuntu for Xilinx AMD ARM 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 AMD ARM Devices kernel.

This wiki page documents how to clone the XilinxAMD-specific Linux kernel tree for ARM devices 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.

...

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

Code Block
languagebash
$ sudo apt-get build-dep linux

...

Note

Native Build: Recommend having at least 8 GB of free space on your SD card or use an external HDD Using the Certified Ubuntu on Xilinx Devices image with a SATA hard disk

...

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

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

The gcc-aarch64-linux-gnu package is only required when cross compiling the kernel.

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

...

Code Block
$ 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.

...

Code Block
$ export CROSS_COMPILE=aarch64-linux-gnu-

Edit the Linux Kernel Configuration

First lets make a quick edit to distinguish our kernel build from the binaries installed from Canonical. Here we just added the +local to the version in the changelog to distinguish it from the running kernel.

Code Block
languagebash
$ fakeroot debian/rules clean
$ vi debian.zynqmp/changelog
linux-xilinx-zynqmp (5.4.0-1017.20+local) focal; urgency=medium

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.

...

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.

Code Block
$ fakeroot debian/rules clean
$ do_tools=false fakeroot debian/rules binary

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

If you are making changes to the configuration that may impact modules and/or the abi, then you may need to skip those checks as shown below.

Code Block
languagebash
$ do_tools=false skipmodule=true skipconfig=true skipabi=true fakeroot debian/rules binary

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.

...

After installing the kernel update packages, reboot the system

Code Block
$ sudo reboot
Info

If cross-compiling the kernel, you can “scp” the Debian packages to the target and install them.

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.

Info

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.

Build the Kernel (Advanced)

Note

This section is EXPERIMENTAL and intended for advanced kernel developers.

This section shows how to rebase the Xilinx branch against the mainline Ubuntu branch. This way you can upgrade the kernel and pick up the required commits to support Xilinx devices.

Rebase Kernel

Code Block
languagebash
$ git clone git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/focal
$ git remote add xlnx git://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-xilinx-zynqmp/+git/focal
$ git fetch --tags xlnx
$ git checkout -b Ubuntu-xilinx-zynqmp-5.4.0-1017.20.rebase Ubuntu-xilinx-zynqmp-5.4.0-1017.20

...

Info

OPTIONAL: Find number of commits in <c1> that aren’t reachable from <c2> you may use git rev-list --count <c1>..<c2>

Code Block
languagebash
$ git rev-list --count Ubuntu-5.4.0-98.111..Ubuntu-xilinx-zynqmp-5.4.0-1017.20

Interactive Rebase

The recommended rebase process is to manually go through each commit using the interactive mode and keep only the commits related to AMD platforms.

Code Block
languagebash
git rebase -i Ubuntu-5.4.0-98.111

...

Make any changes to the rebase commands or commits if needed from the menu. Then hit Ctrl-X to exit the menu and start rebasing against “Ubuntu-xilinx-zynqmp-5.4.0-1017.20”. Here you will need to address each conflict individually before you can proceed.

Ours/Theirs Rebase

We will take the lazy approach to resolving conflicts by using the ours/theirs strategy. Here we will use the “theirs” strategy, which is saying that we will automatically accept the changes in the feature branch (Ubuntu-xilinx-zynqmp-5.4.0-1017.20) when there is a conflict.

Code Block
languagebash
$ git rebase -Xtheirs Ubuntu-5.4.0-98.111

This will rebase without any conflicts. However, the gadget driver does not resolve properly. If you were to try to build the kernel as this point, you will get a compiler error flagging the gadget driver. So we will checkout the entire driver from the base branch (Ubuntu-5.4.0-98.111) as shown below using the “ours” option.

Code Block
languagebash
$ git checkout --ours drivers/usb/dwc3/gadget.c
$ git commit -a -m'usb: dwc3: gadget: keep driver commits from ubuntu branch'

NOTE: We chose the base branch because the gadget driver has more recent commits.

Configure the Kernel

Recommend modifying the debian.zynqmp/changelog to add a local version, +rebase, to the upstream kernel version. This will help distinguish the rebased kernel packages from the upstream kernel.

Code Block
languagebash
$ fakeroot debian/rules clean
$ vi debian.zynqmp/changelog
linux (5.4.0-91.102+rebase) focal; urgency=medium
Info

OPTIONAL: You may manually populate the config fragment file OVERRIDES, which will override any of the default kernel configs.

Code Block
languagebash
$ touch debian.zynqmp/config/OVERRIDES

Clean and configure the build environment.

Code Block
languagebash
$ fakeroot debian/rules clean

Configure the kernel. Required if you made an OVERRIDES file.

Code Block
languagebash
$ fakeroot debian/rules editconfigs

Hit <return> on the keyboard to enter the config menu. Then from the config menu click <exit>.

Build the Kernel Packages

Code Block
languagebash
$ fakeroot debian/rules clean

Build the kernel, but skip the modules, config and abi checks since we have made significant changes.

Code Block
languagebash
$ do_tools=false skipmodule=true skipconfig=true skipabi=true fakeroot debian/rules binary

Install the packages and reboot.

...