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.gz
which contains:- The kernel
- The kernel modules
- The kernel firmware
- Overlays
config.txt
if available in the sourcescmdline.txt
if available in the sourcesdt-blob.bin
ifdt-blob.dts
is 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
defconfig
or usingall*config
. The default is to configure usingbcm2709_defconfig
- To override the default
defconfig
setDEFCONFIG
to thedefconfig
's name and make sure thedefconfig
is made available at the correct path. For exampleDEFCONFIG=my_defconfig
withmy_defconfig
being available atarch/arm/configs/my_defconfig
' - To configure using
all*config
setALLCONFIG
to one of the allconfig optionsallyesconfig
,allmodconfig
,allnoconfig
orrandconfig
. To override which config is used as the starting point setKCONFIG_ALLCONFIG
to 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 theMAKEFLAGS
environment 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: