Building an AutoSD image that includes a custom kernel¶
On a native AArch64 architecture system, you can compile a custom version of the OS kernel and then build a version of the AutoSD operating system (OS) image that includes the customized kernel. You can then install and run the customized AutoSD OS in either a virtualized environment or on an ARM board.
Note
Cross-compilation is unsupported for kernel customizations.
You must compile custom kernels on AArch64 hardware that is running a supported Linux host. See Getting Started on Linux, Sample OSBuild manifests, and Packaging applications with RPM for more information about software and hardware requirements for AArch systems.
The overall process consists of the following general steps:
-
Customize the kernel source, compile a new kernel, and build RPM files.
-
Build a custom AutoSD OS image and run it in a virtual environment.
-
Build a custom AutoSD OS image and run it on physical hardware.
Compile a customized AutoSD kernel and build new RPM files¶
On a supported Linux host system running on AArch64 hardware, compile a customized kernel and modules from the CentOS Stream 9 kernel source code.
Note
This procedure assumes that you are using a CentOS Stream 9 host running on ARM hardware. If you use a different host system, some steps in this procedure might not work.
Prerequisites
- You are running CentOS Stream 9 on AArch64 hardware. See Packaging applications with RPM for more information about software and hardware requirements.
Procedure
-
Install the tools and dependencies necessary to compile the kernel:
-
Clone the CentOS Stream automotive kernel source code Git repository to a local directory of your choice:
-
Go to the
centos-stream-9
directory that contains the source code: -
Add to or modify the kernel source code according to your requirements.
Important
You must stage and commit your changes in Git, or the
make
command will not pick up the changes and build them into the RPM packages. -
Generate the RPM workspace, which includes the kernel spec file, for the build:
-
Install the dependencies necessary to build the kernel RPM files:
-
Compile the custom kernel and build the RPM files. The following example uses
_mykernel
as the custom string to be appended to the new versions of the RPM file names:By appending a custom string, you can differentiate your custom build from the standard version.
Important
The custom version string must consist of alphanumeric characters plus any of the following optional separators:
.
,_
,+
,~
, and^
. The string cannot contain spaces or certain other characters, such as hyphens (-
). If the string contains illegal characters, the build will fail.See the “Spec file format” RPM documentation for more information about using the
~
and^
separators in version strings.
After a successful build, RPM files are installed to the following directory: ./redhat/rpm/RPMS/aarch64/
.
Build an AutoSD image with a custom kernel and run it in a virtual environment¶
After you create your custom kernel RPM files, you can build a custom AutoSD image that includes the files and will run in a QEMU virtual machine.
Prerequisites
-
You have successfully built RPM package files that contain kernel customizations.
-
You have installed QEMU.
Procedure
-
Go to your home directory:
-
If you have not done so already, install the OSBuild utility:
-
Recursively clone the sample-images Gitlab repository:
-
Go to the
automotive-image-builder
directory: -
Deploy the custom kernel RPM files:
-
If you have not done so already, install the createrepo utility:
-
Create a new directory to use as a local RPM repository:
-
Copy your RPM files to the new directory:
-
Initialize the directory as an RPM package repository:
-
-
To build an OS image in
.qcow
format to run in a QEMU virtual environment, run theautomotive-image-builder
script, substituting your values for the RPM repo directory location and the kernel version name:./automotive-image-builder build --distro cs9 --mode package --target qemu \ --export qcow2 ~/sample-images/images/developer.mpp.yml my-custom-kernel.qcow2 \ --define 'extra_repos=[{"id":"kernel","baseurl":"file:///<absolute-path-to-my_repo-directory>"}]' \ --define 'kernel_version="5.14.0-515.464_mykernel.el9iv"'
Note
-
The value for
kernel_version
should match the name of your custom kernel. You can find the name in the~/centos-stream-9/redhat/rpm/RPMS/aarch64/
directory, which contains your custom built RPM files. -
The value for
baseurl
can be any valid URL to an RPM repository that contains your custom kernel RPM files.
-
-
Run the image:
-
After the image boots in QEMU, log in as
root
using the passwordpassword
. -
Verify that your packaged software is present in your image by running the following command and verifying that the custom kernel name is returned:
Important
If you build multiple images, run dnf clean all
between builds to clear the build artifacts and reset the DNF cache.
Build an AutoSD image with a custom kernel and run it on physical hardware¶
You can create an OS image in a specific format to install on specific physical hardware.
Prerequisites
-
You have recursively cloned the sample-images repository.
-
You are running an AArch64 system with Internet access.
-
You have successfully built RPM package files that contain kernel customizations.
Procedure
-
If you have not done so already, install Podman:
-
Go to the
automotive-image-builder
directory: -
Deploy the custom kernel RPM files:
-
If you have not done so already, install the createrepo utility:
-
Create a new directory to use as a local RPM repository:
-
Copy your RPM files to the new directory:
-
Initialize the directory as an RPM package repository:
-
-
Identify the image format appropriate for installation on your board:
-
Identify the appropriate hardware target for your board:
-
Build the image, specifying the appropriate target and the export file format and substituting your values for the RPM repo directory location and the kernel version name:
./automotive-image-builder --container build --distro autosd --mode package \ --target <target> --export <export_image_format> ~/sample-images/images/developer.mpp.yml my-custom-kernel.img \ --define 'extra_repos=[{"id":"kernel","baseurl":"file:///<absolute-path-to-my_repo-directory>"}]' \ --define 'kernel_version="5.14.0-515.464_mykernel.el9iv"'
Note
-
The value for
kernel_version
should match the name of your custom kernel. You can find the name in the~/centos-stream-9/redhat/rpm/RPMS/aarch64/
directory, which contains your custom built RPM files. -
The value for
baseurl
can be any valid URL to an RPM repository that contains your custom kernel RPM files.
-
-
Follow the relevant procedure in the “Provisioning hardware” section to flash the OS image to your board.
-
After the image boots, log in as
root
using the passwordpassword
. -
Verify that your packaged software is present in your image by running the following command and verifying that the custom kernel name is returned:
Note
If you build multiple images, run dnf clean all
between builds to clear the build artifacts and reset the DNF cache.
Additional resources
-
See Building an AutoSD image for more information about options available for building OS images.