Rebuilding the Certified Ubuntu for AMD ARM Devices Linux Kernel from Source
This page describes the steps to download the source code files for the Linux kernel used in the Certified Ubuntu for AMD ARM devices 20.04 LTS release.
The following steps are also applicable to 22.04 - use jammy
where focal
is referenced below.
Table of Contents
- 1 Introduction
- 2 Configure the Build Environment
- 3 Clone the Linux Kernel Source Code
- 4 Configure the Build Environment
- 5 Edit the Linux Kernel Configuration
- 6 Build the Linux Kernel
- 7 Install the Linux Kernel Packages
- 8 Upgrading & Downgrading the Linux Kernel Image
- 9 Build the Kernel (Advanced)
- 9.1 Rebase Kernel
- 9.1.1 Interactive Rebase
- 9.1.2 Ours/Theirs Rebase
- 9.2 Configure the Kernel
- 9.3 Build the Kernel Packages
- 9.1 Rebase Kernel
Introduction
The Certified Ubuntu for 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 AMD ARM Devices kernel.
This wiki page documents how to clone the AMD-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
.
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
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.
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
In order to get started, first clone the source code.
After cloning the source code, switch to the latest tag. To check for the latest tag, look at the Git history with
To check out a specific tag, name it explicitly.
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
Also, export the dpkg
variables required for packaging Debian packages for the target (arm64) architecture
Finally, if compiling in a cross-compilation environment set the CROSS_COMPILE
variable
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.
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.
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.
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
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.
Build the Kernel (Advanced)
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
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.
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.
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.
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.
Clean and configure the build environment.
Configure the kernel. Required if you made an OVERRIDES
file.
Hit <return> on the keyboard to enter the config menu. Then from the config menu click <exit>.
Build the Kernel Packages
Build the kernel, but skip the modules, config and abi checks since we have made significant changes.
Install the packages and reboot.
© Copyright 2019 - 2022 Xilinx Inc. Privacy Policy