Barebones Linux on Barreleye G1

Following up on the previous article, this post will be building a similar barebones Linux for the POWER8-based OpenPOWER Barreleye system.

For this round, I will be building the system on a freshly kicked x86_64 Ubuntu 16.04 VM to capture all dependencies needed to follow the same steps.



Cross Compiling Linux

To get things started I will pull in the various dependencies needed to build the system.

  1. sudo apt install -y build-essential gcc-powerpc64le-linux-gnu libssl-dev bc
sudo apt install -y build-essential gcc-powerpc64le-linux-gnu libssl-dev bc

With these dependencies in place, I’ll create a new directory to work out of and pull down the kernel the same way as the last post. A minor difference is today the latest stable version is 4.13.1, so I’ll be rolling with that version.

  1. mkdir barebones-ppc64le
  2. cd barebones-ppc64le/
  3. wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.13.1.tar.xz
  4. tar xf linux-4.13.1.tar.xz
  5. cd linux-4.13.1/
mkdir barebones-ppc64le
cd barebones-ppc64le/
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.13.1.tar.xz
tar xf linux-4.13.1.tar.xz
cd linux-4.13.1/

Next I setup some environment variables to prepare for cross compilation.

  1. export ARCH=powerpc
  2. export CROSS_COMPILE=/usr/bin/powerpc64le-linux-gnu-
export ARCH=powerpc
export CROSS_COMPILE=/usr/bin/powerpc64le-linux-gnu-

The next big step is to configure the kernel. For this platform, I have not yet had success using one of the default configs that comes with the kernel source tree. The good news is that the OpenPOWER firmware of this platform is Linux based and open source. The kernel configuration from the firmware build repo is a known good configuration for this exact system, so that gives me assurance it will work pretty well.

I’ll download the skiroot kernel config, run the kernels make oldconfig to get the kernel build happy with the configuration (piping yes '' to make to accept the default answers to its many questions), and build the kernel using the number of threads returned to me by nproc.

  1. wget https://raw.githubusercontent.com/open-power/op-build/master/openpower/configs/linux/skiroot_defconfig -O .config
  2. yes '' | make oldconfig
  3. make -j`nproc`
  4. cp vmlinux ..
  5. cd ..
wget https://raw.githubusercontent.com/open-power/op-build/master/openpower/configs/linux/skiroot_defconfig -O .config
yes '' | make oldconfig
make -j`nproc`
cp vmlinux ..
cd ..

Building initramfs and Testing

Building the initramfs is also nearly identical to the previous post, just using the cross compiler instead of the default. This is the program that will be my init process.

  1. #include <stdio.h>
  2. #include <unistd.h>
  3. int main() {
  4. while (1) {
  5. printf("Hello from the land of Barreleye\n");
  6. sleep(1);
  7. }
  8. }
#include <stdio.h>
#include <unistd.h>
int main() {
  while (1) {
    printf("Hello from the land of Barreleye\n");
    sleep(1);
  }
}

And the steps I used to compile and pack into my initramfs

  1. powerpc64le-linux-gnu-gcc -o init -static test.c
  2. echo init | cpio -o --format=newc > initramfs
powerpc64le-linux-gnu-gcc -o init -static test.c
echo init | cpio -o --format=newc > initramfs

With that all done, I will upload it to a webserver I have in our lab and boot up my Barreleye system to Petitboot, the firmware stacks primary interface. I’ll exit to a shell, wget the kernel and initramfs and kexec load and execute!

Since I’m connecting into the system from home to the BMC console the interface is a wee bit slow to respond to input, but it does the trick.

All looks good! Please feel free to comment or leave any questions you may have.

Save

Leave a Reply