- Notifications
You must be signed in to change notification settings - Fork0
Docker image for Linux kernel cross-compilation
License
0xor0ne/docker-linux-kernel-builder
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Docker image for cross-compiling the Linux kernel.
Check therequirements before proceeding.
Put the archives containing the Linux Kernel source code and the toolchain inthefiles directory.
Here is an example showing how to download Linux Kernel 3.15.37 fromkernel.org and a toolchain provided byBootlin for arm64 architecture.
curl --output files/kernel.tar.xz https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.37.tar.xz curl --output files/toolchain.tar.bz2 https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/tarballs/aarch64--glibc--stable-2021.11-1.tar.bz2
See thedocumentation for more examples and anautomated way to download both the Kernel source code and the toolchain.
Edit fileconfig.env and modify the following variables:
- LK_ARCHIVE_NAME: name of the archive containing the Linux Kernel source codeplaced in
filesdirectory; - TC_ARCHIVE_NAME: name of the archive containing the toolchain placed in
filesdirectory; - LK_ARCH: name of the target architecture (must match the used toolchain).Examples are
arm,arm64andmips
Building the Docker image is a two steps process. At first, a permanent volumecontaining both the toolchain and the kernel source code must becreated with:
./scripts/docker_create_volume.sh
Then, the actual Docker image can be built with:
./scripts/docker_build.sh
It is possible to invoke any available make target on the kernel source code byusing the scriptscripts/make.sh. For example, the following command willprint the kernel make help message:
./scripts/make.shhelpNOTE: the first time the container is executed it will take more time because ascript will take care of extracting the kernel source code and the toolchaincontained in the permanent volume.
The kernel can be configured as usual. Here are a few examples:
- Use the default configuration for the target architecture:
./scripts/make.sh defconfig
- Configure the kernel manually using a menu based program:
./scripts/make.sh menuconfig
- Use an existing configuration: save the existing configuration in
shared/.configand then run:
./scripts/make_olddefconfig.sh
- Configure the tiniest possible kernel for the target architecture (with thisconfiguration kernel modules are usually disabled):
./scripts/make.sh tinyconfig
Build the kernel with:
./scripts/make_all_install_retrieve.sh
at the end of the build process, the output artifacts will be placed inshared/install. Here you will find the kernel image (vmlinux), the symboltable (System.map), the used configuration, the kernel headers (inincludedirectory) and the kernel modules (inlib directory).
The kernel build directory can be cleaned as usual using theclean target orthemrproper target (for removing also the configuration file). E.g.,
./scripts/make.sh mrproper
In order to start from scratch (remove the permanent volume, the Dockerimage and the content ofshared directory), you can remove everything with:
./scripts/docker_remove_all.sh
- Add script for building out-of-tree kernel modules;
- Add support for building Busybox for quick testing in Qemu;
- Add support forbuilding the kernel with CLANG;
- Add support for building experimental Rust based kernel modules.
About
Docker image for Linux kernel cross-compilation
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.