View on GitHub


Porting the upstream Linux kernel to the LG Nexus 5 phone (msm8974).

This page describes the current development efforts to port the upstream Linux Kernel to the LG Nexus 5 (hammerhead) phone. This work benefits other devices that use the Qualcomm msm8974 System on Chip (SoC) such as the Fairphone 2, OnePlus One, Samsung Galaxy S5, Sony Xperia Z1, Sony Xperia Z2 tablets, and current devices that use some of the same IP blocks within newer Qualcomm SoCs.

The factory kernel image is based on the upstream Linux 3.4 kernel that was released in May 2012, and adds almost 2 million lines of code on top of the upstream kernel. This factory image is abandoned and no longer receives security updates. The goal is to eventually get all of the major components working upstream so that the phone will work with the latest upstream kernel. These patches will eventually appear in the Android kernels as they rebase their kernels onto newer upstream LTS kernel releases.

Hardware status

The following components work upstream without any additional patches: display, backlight, touchscreen, USB, WiFi, charger, gyroscope / accelerometer, magnetometer, temperature / humidity / barometer, proximity / ambient light sensor (ALS), serial console, battery.

My linux tree on GitHub contains work-in-progress patches that adds support for the GPU, modem, bluetooth, and vibrator. See my v5.5 patch series cover letter that gives a high-level overview of the status of those patches.

I have work in progress patches available below to get the external display over HDMI and the IOMMU, where the latter is the last piece that’s needed to support the GPU upstream. The hardware isn’t fully working yet with these patches.

See the TODO list for information about other components and links to some out-of-tree patches.

Note that the kernel command line arguments msm.allow_vram_carveout msm.vram=48m must be passed used in order for the display to work properly. These options are present in my build-kernel script.

Phone user space

I’ve been running postmarketOS on the phone. Follow the instructions on their Nexus 5 page that describes how to install it. Here’s my pmbootstrap.cfg config file. Once that’s installed, see my build-kernel script for how to build and boot a custom kernel into a postmarketOS userspace.

A serial console can be obtained through the headphone jack and requires building a custom cable as described on this page. You will want to make a cable if you plan to do any development work.

External GPIO Example

See the script for the source code to the GTK+ application controlling the external LEDs in the image above. The phone is running XFCE4 and postmarketOS on an upstream Linux kernel. This Tiny OTG USB adapter is used on that video.

Upstream contribution summary

The following is a summary of my upstream Linux kernel contributions as part of this project:



Note that the ones with a short git SHA at the beginning are in the mainline kernel, the ones marked Queued are in linux-next, and the others are labeled either Pending or Needs work.

Other resources


Brian Masney: Email, Linked In, GitHub