As of commit 2aff5ba6
in the op-build tree, we're able to easily replace the kernel in an OpenPower firmware image.
This commit adds a new partition (called BOOTKERNEL
) to the PNOR image, which provides the petitboot bootloader environment. Since it's now in its own partition, we can replace the image with a custom build. Here's a little guide to doing that, using an example of using a separate branch of op-build that provides a little-endian kernel.
You can check if your currently-running firmware has this BOOTKERNEL
partition by running pflash -i
on the BMC. It should list BOOTKERNEL
in the partition table listing:
# pflash -i Flash info: ----------- Name = Micron N25Qx512Ax Total size = 64MB Erase granule = 4KB Partitions: ----------- ID=00 part 00000000..00001000 (actual=00001000) ID=01 HBEL 00008000..0002c000 (actual=00024000) [...] ID=11 HBRT 00949000..00ca9000 (actual=00360000) ID=12 PAYLOAD 00ca9000..00da9000 (actual=00100000) ID=13 BOOTKERNEL 00da9000..01ca9000 (actual=00f00000) ID=14 ATTR_TMP 01ca9000..01cb1000 (actual=00008000) ID=15 ATTR_PERM 01cb1000..01cb9000 (actual=00008000) [...] #
If your partition table does not contain a BOOTKERNEL
partition, you'll need to upgrade to a more recent PNOR image to proceed.
First (if you don't have one already), grab a suitable version of op-build. In this example, we'll use my le
branch, which has little-endian support:
git clone --recursive git://github.com/jk-ozlabs/op-build.git
cd op-build
git checkout -b le origin/le
git submodule update
Then, prepare our environment and configure for the relevant platform - in this case, habanero
:
. op-build-env op-build habanero_defconfig
If you'd like to change any of the kernel config (for example, to add or remove drivers), you can do that now, using the 'linux-menuconfig
' target. This is only necessary if you wish to make changes. Otherwise, the default kernel config will work.
op-build linux-menuconfig
Next, we build just the userspace and kernel parts of the firmware image, by specifying the linux26-rebuild-with-initramfs
build target:
op-build linux26-rebuild-with-initramfs
If you're using a fresh op-build tree, this will take a little while, as it downloads and builds a toolchain, userspace and kernel. Once that's complete, you'll have a built kernel image in the output tree:
output/build/images/zImage.epapr
Transfer this file to the BMC, and flash using pflash
. We specify the -P <PARTITION>
argument to write to a single PNOR partition:
pflash -P BOOTKERNEL -e -p /tmp/zImage.epapr
And that's it! The next boot will use your newly-build kernel in the petitboot bootloader environment.
Out-of-tree kernel builds
If you'd like to replace the kernel from op-build with one from your own external source tree, you have two options. Either point op-build at your own tree, or build you own kernel using the initramfs that op-build has produced.
For the former, you can override certain op-build variables to reference a separate source. For example, to use an external git tree:
op-build LINUX_SITE=git://github.com/jk-ozlabs/linux LINUX_VERSION=v3.19
See Customising OpenPower firmware for other examples of using external sources in op-build.
The latter option involves doing a completely out-of-op-build build of a kernel, but referencing the initramfs created by op-build (which is in output/images/rootfs.cpio.xz
). From your kernel source directory, add CONFIG_INITRAMFS_SOURCE
argument, specifying the relevant initramfs. For example:
make O=obj ARCH=powerpc \ CONFIG_INITRAMFS_SOURCE=../op-build/output/images/rootfs.cpio.xz
during the compilation I got following error: checking for suffix of object files... + rm -f conftest.o conftest.obj + ac_try='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' + case "(($ac_try" in + ac_try_echo='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' + eval 'ac_try_echo="$as_me:2764: $CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5"' ++ ac_try_echo='configure:2764: /root/kernel3/op-build/output/host/usr/bin/powerpc64le-buildroot-linux-gnu-gcc -c -O2 conftest.c >&5' + echo 'ac_try_echo=configure:2764: /root/kernel3/op-build/output/host/usr/bin/powerpc64le-buildroot-linux-gnu-gcc -c -O2 conftest.c >&5' ac_try_echo=configure:2764: /root/kernel3/op-build/output/host/usr/bin/powerpc64le-buildroot-linux-gnu-gcc -c -O2 conftest.c >&5 + cat -n conftest.c 1 / confdefs.h / 2 #define PACKAGE_NAME "GNU C Library" 3 #define PACKAGE_TARNAME "glibc" 4 #define PACKAGE_VERSION "(see version.h)" 5 #define PACKAGE_STRING "GNU C Library (see version.h)" 6 #define PACKAGE_BUGREPORT "http://sourceware.org/bugzilla/" 7 #define PACKAGE_URL "http://www.gnu.org/software/glibc/" 8 #define PKGVERSION "(Buildroot) " 9 #define REPORT_BUGS_TO "http://www.gnu.org/software/libc/bugs.html" 10 / end confdefs.h. / 11
12 int 13 main () 14 { 15
16 ; 17 return 0; 18 } + cp conftest.c /tmp/cft.c + printf '%s\n' 'configure:2764: /root/kernel3/op-build/output/host/usr/bin/powerpc64le-buildroot-linux-gnu-gcc -c -O2 conftest.c >&5' + ac_status=127 + printf '%s\n' 'configure:2771: $? = 127' + test 127 = 0 + printf '%s\n' 'configure: failed program was:' + sed 's/^/| /' conftest.c + set +x configure: error: in
/root/kernel3/op-build/output/build/glibc-2.19/build': configure: error: cannot compute suffix of object files: cannot compile See
config.log' for more details