Open Devices

For some of the Xperia™ devices, we provide Android™ Open Source Project (AOSP) device configurations on GitHub. This means that the software will be open for you as a developer to use and contribute to. This is a way for us to support the open Android community, and it is also a tool for us to facilitate and verify contributions to AOSP.

How to manually build the Linux kernel for 64 bit devices

1. Unlock the boot loader

All the work on building and compiling a kernel is based on you having unlocked the boot loader of your device. Instructions on how to do this can be found in our new and improved unlocking boot loader pages. Please remember that this is only for advanced kernel developers. We recommend standard users not to unlock the boot loader, as it is not needed.

Note: There is no turning back after unlocking the boot loader. You may void the warranty of your device, and you will not be able to revert it back to a locked and original state again.

2. Download a cross compiler

A cross compiler is used to build ARM binaries on a different architecture, such as x86. This allows you to compile the kernel into a format that the device can run. We recommend the use of the GCC 4.8 cross compiler provided in the Android Open Source Project.Download the GCC 4.8 cross compiler using the following commands:

mkdir /android && cd /android
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/

Note: Any ARM cross compiler capable of compiling Linux kernels can be used, such as CodeSourcery Lite, and Linaro.

3. Export the cross compiler

The cross compiler needs to be exported to specify which compiler to be used by the build system.Export the GCC 4.8 cross compiler using the following command:

export CROSS_COMPILE=/android/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-

Note: In case of using another cross compiler than GCC 4.8, replace /android/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin/arm-eabi- with the correct search path of the cross compiler of your choice.

4. Download the kernel source from GitHub

The Sony kernel sources for flagship devices are available on the SonyXperiaDev GitHub. More sources for other devices will be added over time. Download by entering:

git clone https://github.com/sonyxperiadev/kernel
cd kernel
git branch -r
git checkout 

5. Identify your device’s config file name

In order to configure the kernel, you need first to identify your device’s config file name. Please note that only devices featured in the Sony GitHub release and Sony GitHub unified kernels are shown here.

Device

Config name

Device

Xperia X

Config name

aosp_loire_suzu_defconfig

Device

Xperia X Compact

Config name

aosp_loire_kugo_defconfig

Device

Xperia X Performance

Config name

aosp_tone_dora_defconfig

Device

Xperia XZ

Config name

aosp_tone_kagura_defconfig

Device

Xperia Z5 Premium

Config name

aosp_kitakami_suzuran_defconfig

Device

Xperia Z5 Compact

Config name

aosp_kitakami_satsuki_defconfig

Device

Xperia Z5

Config name

aosp_kitakami_sumire_defconfig

Device

Xperia Z4 Tablet

Config name

aosp_kitakami_karin_defconfig, aosp_kitakami_karin_windy_defconfig

Device

Xperia Z3+

Config name

aosp_kitakami_ivy_defconfig

6. Configure the kernel

Configure the kernel is a required step before building it. Kernel drivers can be turned on or off, or be built as modules. This has to be configured in order for the kernel to function as desired. Configure the kernel by entering:

make ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE <device_defconfig>

Note: Replace with the device config file name identified in Step 5.

7. Build the kernel and needed modules

When building the kernel a compressed kernel image file is created and placed in the default target arch/arm/boot/zImage on your computer. To start the build, enter:

make ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE -j <cpu_thread_number>

Note: The should correspond to your host architecture. In case of errors, replace with the numeral 1 for easy debugging.

8. Copy needed binaries to your Android repository

For building a new boot image with the compiled kernel, the kernel binary “arch/arm64/boot/Image.gz-dtb” has to be renamed “kernel-” and placed in the device/sony/common-kernel folder.

Note: Please note that this is a kernel binary with an appended dtb and there is no need to copy the .dtb separately. Wireless drivers are built into the kernel and there is no kernel module for them.

For environment setup instructions, see the AOSP build instructions. To generate the images enter the following commands:

source build/envsetup.sh && lunch

When prompted, pick the number corresponding to your device in the list displayed and press enter. To start the build, type:

make -j <insert the cpu thread number of your computer> bootimage

Note: The build will take some minutes to complete.Next

9. Download the Fastboot protocol

Fastboot is a diagnostic protocol included in the Android SDK. Make sure you have the Android SDK installed before proceeding. Fastboot will be used to modify the flash file system on your device via a USB connection from the computer. If you unlocked your boot loader in Step 1, you will already have Fastbootinstalled.

10. Flash the boot image file

Use the Fastboot protocol to flash the boot image file to your phone or tablet. Enter the following command:

fastboot flash boot out/target/product/<device>/boot.img

When prompted to connect your device, first make sure that your device is turned off. Then, hold down the Volume Up button and connect the device to your computer with a USB cable. Your device’s notification light should shine blue to confirm it’s in Fastboot mode.

When the flashing is completed, reboot your device by entering:

fastboot reboot

You have now gone through the process of how to download a Sony kernel source, and then how to build and flash the kernel to your device. However, we have not gone into detail on how to modify the kernel itself. For more details, we recommend you to deep dive into forums and websites such as XDA Developers and XDA University, where there are many skilled people sharing their knowledge.