Skip to content

Kernel Only Build Instructions for Helium reference platform

Michael Scott edited this page Oct 7, 2015 · 20 revisions

General Notes

This assumes user has followed the instructions to setup your reference device:
Getting Started with Helium

"~/helium-kernel-build" is used as the main directory for this setup per the export settings. Can be whatever you prefer, but must not be a relative path.

For internal use replace "git clone https://git-ara-mdk.linaro.org" with "git clone ssh://git@projectara-git.linaro.org".

Need the following packages installed (many of these are required during Getting Started setup):

$ sudo apt-get install gcc-4.8
$ sudo apt-get install gzip
$ sudo apt-get install cpio
$ sudo apt-get install git

1-Time Build Setup Instructions

STEP 1. make install dirs

$ export HKB_ROOT=~/helium-kernel-build
$ mkdir $HKB_ROOT
$ cd $HKB_ROOT
$ mkdir bin boot-files boot-files/ramdisk

STEP 2. copy split_bootimg.pl script to /bin

$ cd $HKB_ROOT/bin
$ wget http://www.enck.org/tools/split_bootimg_pl.txt
$ mv split_bootimg_pl.txt split_bootimg.pl
$ chmod 755 split_bootimg.pl

STEP 3. use a prebuilt Ara Android boot.img to extract the ramdisk

$ cd $HKB_ROOT/boot-files

# NOTE: download Ara Android Helium boot.img:
# http://releases-ara-mdk.linaro.org/ara_pxa1928-5.1.1-open/
# latest file is: ara_pxa1928-boot-lmy48p.img

$ wget -O boot.img http://releases-ara-mdk.linaro.org/ara_pxa1928-5.1.1-open/ara_pxa1928-boot-lmy48p.img

# NOTE: Using split_bootimg.pl from step #2 extract ramdisk
$ ../bin/split_bootimg.pl boot.img

# NOTE: Extract ramdisk for re-packing later
$ cd ramdisk
$ gzip -dc ../boot.img-ramdisk.gz | cpio -i

STEP 4. clone system/core for 1-time compile of "mkbootimg" / "mkbootfs"

# NOTE: confirm gcc is installed on host via "gcc --version"
$ cd $HKB_ROOT
$ git clone https://git-ara-mdk.linaro.org/platform/system/core.git -b projectara-5.1
$ cd core/libmincrypt/
$ gcc -c *.c -I../include
$ ar rcs libmincrypt.a *.o
$ cd ../mkbootimg
$ gcc mkbootimg.c -o mkbootimg -I../include ../libmincrypt/libmincrypt.a
$ mv mkbootimg ../../bin

STEP 5. clone aarch64-linux-android-4.8 for arm toolchain for lollipop-mr1-release

$ cd $HKB_ROOT
$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8 -b lollipop-mr1-release

STEP 6. clone greybus master

$ cd $HKB_ROOT
$ git clone https://github.com/projectara/greybus.git -b master

STEP 7. git clone pxa1928 kernel for Android

$ cd $HKB_ROOT
# To use the public kernel repo use the following command (for module developers, etc)
$ git clone https://git-ara-mdk.linaro.org/kernel/pxa1928.git -b projectara-5.1
# If you are an internal developer, use the next command instead
$ git clone ssh://git@projectara-git.linaro.org/marvell/vendor/marvell/ose/mrvl-3.10.git -b projectara-5.1 pxa1928

Testing Your Custom Kernel

PREPARE YOUR CURRENT SESSION

# You need to set the following export variables only once per window session:

# Make sure you export the root location of your kernel build.
# This can be a custom location, but make sure this is not a relative path.
# “cd $HKB_ROOT” should work from anywhere.
$ export HKB_ROOT=~/helium-kernel-build

$ export PATH=$HKB_ROOT/aarch64-linux-android-4.8/bin:$PATH
$ export CROSS_COMPILE=$HKB_ROOT/aarch64-linux-android-4.8/bin/aarch64-linux-android-
$ export KERNEL_DIR=$HKB_ROOT/pxa1928

STEP 1. make kernel Image

$ cd $HKB_ROOT
# NOTE: [OPTIONAL] you can erase the kernel-out directory for a clean start (if it exists)
$ rm -rf kernel-out

$ mkdir -p kernel-out
$ cd pxa1928
$ make ARCH=arm64 KCFLAGS="-fno-pic" O=../kernel-out defconfig
$ make -j8 ARCH=arm64 KCFLAGS="-fno-pic" O=../kernel-out Image
$ make -j8 ARCH=arm64 KCFLAGS="-fno-pic" O=../kernel-out pxa1928-helium.dtb
$ mv ../kernel-out/arch/arm64/boot/Image ../boot-files/Image
$ mv ../kernel-out/arch/arm64/boot/dts/pxa1928-helium.dtb ../boot-files/dtb

STEP 2: make greybus modules

$ cd $HKB_ROOT/greybus
$ make clean
$ make ARCH=arm64 KERNELDIR=../kernel-out EXTRA_CFLAGS+=-fno-pic
$ mv $HKB_ROOT/boot-files/ramdisk/lib/modules/galcore.ko $HKB_ROOT/boot-files/galcore.ko
$ sudo rm $HKB_ROOT/boot-files/ramdisk/lib/modules/*
# [if necessary enter su password]
$ mv $HKB_ROOT/boot-files/galcore.ko $HKB_ROOT/boot-files/ramdisk/lib/modules/galcore.ko
$ mv *.ko $HKB_ROOT/boot-files/ramdisk/lib/modules/
$ sudo chmod 644 $HKB_ROOT/boot-files/ramdisk/lib/modules/*
# [if necessary enter su password]
$ sudo chown root:root $HKB_ROOT/boot-files/ramdisk/lib/modules/*
$ sudo ${CROSS_COMPILE}strip --strip-unneeded $HKB_ROOT/boot-files/ramdisk/lib/modules/*
# [if necessary enter su password]

STEP 3: recombine ramdisk and boot.img for testing

$ cd $HKB_ROOT/boot-files/ramdisk
$ find . | cpio -o -H newc | gzip > ../ramdisk.gz
$ cd ..
$ ../bin/mkbootimg --kernel Image --ramdisk ramdisk.gz --base 0x01200000 \
--kernel_offset 0x00080000 --ramdisk_offset 0x01000000 --tags_offset 0x00000100 \
--cmdline "androidboot.selinux=permissive usbcore.autosuspend=-1 firmware_class.path=/data/firmware" \
--pagesize 2048 -o newboot.img

STEP 4: testing your custom "newboot.img" and dtb

$ cd $HKB_ROOT/boot-files/
# Follow these instructions to place your device in fastboot mode:
[[How to place Helium in fastboot mode|Getting-Started-with-the-Helium-reference-platform#how-to-place-helium-in-fastboot-mode]]

# flash the newboot.img and device tree binary to the device using fastboot
$ sudo fastboot flash dtb dtb
$ sudo fastboot flash boot newboot.img
$ sudo fastboot reboot