Since we're using buildroot for the OpenPower firmware build infrastructure, it's relatively straightforward to generate a standalone toolchain to build add-ons to the petitboot environment. This toolchain will allow you to cross-compile from your build host to an OpenPower host running the petitboot environment.
This is just a matter of using op-build's
toolchain target, and specifying the destination directory in the
BR2_HOST_DIR variable. For this example, we'll install into
sudo mkdir /opt/openpower/ sudo chown $USER /opt/openpower/ op-build BR2_HOST_DIR=/opt/openpower/ toolchain
After the build completes, you'll end up with a toolchain based in
Using the toolchain
If you add
/opt/openpower/usr/bin/ to your
PATH, you'll have the toolchain binaries available.
[jk@pecola ~]$ export PATH=/opt/openpower/usr/bin/:$PATH [jk@pecola ~]$ powerpc64le-buildroot-linux-gnu-gcc --version powerpc64le-buildroot-linux-gnu-gcc (Buildroot 2014.08-git-g80a2f83) 4.9.0 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Currently, this toolchain isn't relocatable, so you'll need to keep it in the original directory for tools to correctly locate other toolchain components.
OpenPower doesn't (yet) specify an ABI for the petitboot environment, so there are no guarantees that a petitboot plugin will be forwards- or backwards- compatible with other petitboot environments.
Because of this, if you use this toolchain to build binaries for a petitboot plugin, you'll need to either:
- ensure that your op-build version matches the one used for the target petitboot image; or
- provide all necessary libraries and dependencies in your distributed plugin archive.
We're working to address this though, by defining the ABI that will be regarded as stable across petitboot builds. Stay tuned for updates.
Using the toolchain for subsequent
Because op-build has a facility to use an external toolchain, you can re-use the toolchain build above for subsequent op-build invocations, where you want to build actual firmware binaries. If you're using multiple op-build trees, or are regularly building from scratch, this can save a lot of time as you don't need to continually rebuild the toolchain from source.
This is a matter of configuring your op-build tree to use an "External Toolchain", in the "Toolchain" screen of the menuconfig interface:
You'll need to set the toolchain path to the path you used for
BR2_HOST_DIR above, with
/usr appended. The other toolchain configuration parameters (kernel header series, libc type, features enabled) will need to match the parameters that were given in the initial toolchain build. However, the buildroot code will check that these match and print a helpful error message if there are any inconsistencies.
For the example toolchain built above, these are the full configuration parameters I used:
BR2_TOOLCHAIN=y BR2_TOOLCHAIN_USES_GLIBC=y BR2_TOOLCHAIN_EXTERNAL=y BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y BR2_TOOLCHAIN_EXTERNAL_PREINSTALLED=y BR2_TOOLCHAIN_EXTERNAL_PATH="/opt/openpower/usr/" BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="$(ARCH)-linux" BR2_TOOLCHAIN_EXTERNAL_PREFIX="$(ARCH)-linux" BR2_TOOLCHAIN_EXTERNAL_GLIBC=y BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_15=y BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y BR2_TOOLCHAIN_EXTERNAL_CXX=y BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS="" BR2_TOOLCHAIN_HAS_NATIVE_RPC=y BR2_TOOLCHAIN_HAS_THREADS=y BR2_TOOLCHAIN_HAS_THREADS_DEBUG=y BR2_TOOLCHAIN_HAS_THREADS_NPTL=y BR2_TOOLCHAIN_HAS_SHADOW_PASSWORDS=y BR2_TOOLCHAIN_HAS_SSP=y
Once that's done, anything you build using that op-build configuration will refer to the external toolchain, and use that for the general build process.