RaspberryPi2 - notro/rpi-build GitHub Wiki
Single builds
By default, rpi-build
will build a kernel suitable for the Pi1 (original A, B, A+, and B+ models). If all you want is a card that will run only on these devices, then the standard instructions are fine.
If you want to build a kernel that will only run on the Pi2, then you simply need to redefine LINUX_DEFCONFIG
before you build. If you don't want to modify any build scripts, you can simply do this on the command line:
# build a Pi2 kernel
LINUX_DEFCONFIG=bcm2709_defconfig rpi-build releasename build
(Where releasename
is replaced with whatever release you have defined in your Rakefile
.) You can add clean
or any of the other standard options as needed.
If you're doing this regularly (eg. you only have a Pi2), then you can simplify this process either by creating a shell script that runs the above or by adding the following into your Rakefile
release:
ENV['LINUX_DEFCONFIG'] = 'bcm2709_defconfig'
(Conversely, if you want to force building a Pi1 kernel even if the default changes in the future, you can use bcmrpi_defconfig
instead.)
Multiple builds
If you're interested in creating a card that works on both Pi1 and Pi2 (like the standard kernels), then you need to perform the kernel build twice. As long as you haven't locked in a single LINUX_DEFCONFIG
as shown above, you can do this with the following script:
#!/bin/bash -e
: ${WORKDIR6:=workdir6}
: ${WORKDIR7:=workdir7}
: ${WORKDIR:=workdir}
WORKDIR="$WORKDIR6" LINUX_DEFCONFIG=bcmrpi_defconfig rpi-build "$@" build
WORKDIR="$WORKDIR7" LINUX_DEFCONFIG=bcm2709_defconfig rpi-build "$@" build
echo "$WORKDIR6 + $WORKDIR7 => $WORKDIR"
rm -rf "$WORKDIR"
mkdir -p "$WORKDIR/out"
cp -r "$WORKDIR7/out/"* "$WORKDIR/out/"
cp "$WORKDIR7/"*.{variable,target} "$WORKDIR/"
cp "$WORKDIR6/out/"{*.img,*.dtb,Module.symvers} "$WORKDIR/out/"
cp -r "$WORKDIR6/out/modules/"* "$WORKDIR/out/modules/"
cp "$WORKDIR6/out/extra/"* "$WORKDIR/out/extra/"
echo "Build complete, ready to install."
If you create this as a script called rpi-build67
and chmod +x
it, you can then run it like so:
./rpi-build67 releasename clean
(Or omit clean
if you want an incremental build. As before, replace releasename
with the name from your Rakefile
. You can also add use[x]
and other option parameters as you'd normally expect; just omit the final target from the normal command, as this always uses build
.)
By default, this will build the Pi1 kernel in workdir6
, the Pi2 kernel in workdir7
, and then create a merged workdir
that contains both of them. You can then install this on a Pi with the normal command:
SSHIP=ip SSHPASS=pass rpi-build releasename install
You can override the directory names used by rpi-build67
(or whatever you want to call it) via the environment as you'd expect.