Sat 26 May 2018

Filed under Android

Tags android linux kernel gentoo


To run LXC, we need a kernel that has the options required by LXC on. This article shows how to build an Android kernel that has the required options on, built by Gentoo's latest stable cross-compile toolchain built by crossdev.

Install Cross-Compile Toolchain

We'll use crossdev, a set of wrapper scripts that provides cross-compilation capability to Portage. The following instructions assume that the workstation is a Gentoo machine.

First, install sys-devel/crossdev:

emerge -av sys-devel/crossdev

Install the latest stable toolchain:

crossdev --stable -t aarch64-unknown-linux-gnu

Clone the kernel sources and compile

The kernel source repository for Nexus 6P with my patches for compiling with GCC 6 as well as LXC-enabled config is at KireinaHoro/android_kernel_huawei_angler. Clone this repository and compile the kernel:

git clone
cd android_kernel_huawei_angler
make sharkbait_angler_defconfig
make -j8

The target kernel image will be available at arch/arm64/Image.gz-dtb. Copy this to the preinit repository to continue following Starting Android in LXC to build the preinit boot.img.


Linux kernel's make savedefconfig doesn't really save a working defconfig, at least it's not the case for Android kernels. When changes are made to .config (via make menuconfig or so), copy .config back to arch/arm64/configs instead of relying on the savedefconfig target, otherwise you may encounter problems such as missing drivers or things that should be built-in turned out to be built as a module.

GCC 6 support was accomplished by introducing compiler-gcc6.h from SaberMod/android-kernel-lge-hammerhead on GitLab. A few fixes regarding the static inline behavior change since GCC 6 has been made to make the source compile without problem. Warning checks in was disabled as well.


Sat 05 May 2018

Filed under Gentoo

Tags gentoo linux virtualization

The story

After struggling with HiDPI issues on native GNU/Linux and battery life issues on macOS, I resorted to using Windows 10 as the main operating system on my laptop. Though there's WSL, it's not running Gentoo and has a severely degraded performance. As crossdev is really easy to …

Read More

Fri 04 May 2018

Filed under GSoC 2018

Tags android gentoo gsoc linux


This week was about getting the Gentoo stage3 to work on Android (as a subsystem of Android currently), and replacing init located in the initramfs, which was part of the boot.img that was used to boot the system. To ease the process of compiling for a different architecture …

Read More

Personal details (portrait, CV) © Pengcheng Xu All Rights Reserved; articles licensed under CC BY-SA 4.0.
Powered by Pelican, Bootstrap, and NixOS. Icons by Font Awesome. Generated from 9c526f2.