Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Docker image for Linux kernel cross-compilation

License

NotificationsYou must be signed in to change notification settings

0xor0ne/docker-linux-kernel-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker image for cross-compiling the Linux kernel.

Check therequirements before proceeding.

Initial Setup

Linux kernel Source Code and Toolchain

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.

Variables Setup

Edit fileconfig.env and modify the following variables:

  • LK_ARCHIVE_NAME: name of the archive containing the Linux Kernel source codeplaced infiles directory;
  • TC_ARCHIVE_NAME: name of the archive containing the toolchain placed infiles directory;
  • LK_ARCH: name of the target architecture (must match the used toolchain).Examples arearm,arm64 andmips

Building the Docker Image

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

Configuring and Building the Linux Kernel

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.shhelp

NOTE: 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.

Configuration

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 inshared/.config and 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

Kernel Build

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).

Cleaning Kernel Build

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

Reset Docker Image and Volume

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

TODOs

  • 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

Stars

Watchers

Forks


[8]ページ先頭

©2009-2026 Movatter.jp