Docker image to build a Raspberry Pi 3 kernel for the arm architecture
Building a kernel using the rpi3-kernel-builder Docker image works according to the following conventions. Configuration is done using environment variables:
- The kernel sources should be made available at
/workdir - The build will output to
/workdir/build - The output is a file called
<kernelversion>.tar.gzwhich contains:- The kernel
- The kernel modules
- The kernel firmware
- Overlays
config.txtif available in the sourcescmdline.txtif available in the sourcesdt-blob.binifdt-blob.dtsis available in the sources
- To apply patches to the kernel sources make the patches available at
PATCH_DIRS. This is a space separated array of paths. The patches need to have the extension.patch - The kernel can be configured using a
defconfigor usingall*config. The default is to configure usingbcm2709_defconfig- To override the default
defconfigsetDEFCONFIGto thedefconfig's name and make sure thedefconfigis made available at the correct path. For exampleDEFCONFIG=my_defconfigwithmy_defconfigbeing available atarch/arm/configs/my_defconfig' - To configure using
all*configsetALLCONFIGto one of the allconfig optionsallyesconfig,allmodconfig,allnoconfigorrandconfig. To override which config is used as the starting point setKCONFIG_ALLCONFIGto the path of the config file. For exampleALLCONFIG=/workdir/configs/myminimalconfig
- To override the default
- The amount of jobs used by make will default to the value returned by
nproc. To override this set theMAKEFLAGSenvironment variable. For exampleMAKEFLAGS=-j8.
# Checkout kernel sources
$ git clone --single-branch --branch rpi-4.14.y --depth 1 https://www.github.com/raspberrypi/linux
# Build a kernel archive using the docker image
# using a volume mount for the linux sources to /workdir
$ cd linux
$ docker run --rm -ti -v "${PWD}":/workdir simonvanderveldt/rpi3-kernel-builder
# When the build is done the kernel archive is available in the build directory
$ ls -ahl build/
total 28M
drwxr-xr-x 2 simon simon 6 Feb 3 23:21 .
drwxr-xr-x 5 simon simon 6 Feb 3 23:08 ..
-rw-r--r-- 1 root root 178K Feb 3 23:21 kernel-4.9.59-0.0.7-g8172bbc.sha256
-rw-r--r-- 1 root root 11M Feb 3 23:21 kernel-4.9.59-0.0.7-g8172bbc.tar.gz
Based on: