Kernel V4.4 _ Initial Steps - LGE-G5-G6-V20/msm8996_lge_kernel GitHub Wiki

Initial steps

The idea of building this wiki came in pretty late in the development cycle, so a few details on the steps that the V20 and G5 went through might be missing in this subsection.

History:

Initially the procedures were quite straightforward: Look for a good 4.4 caf kernel base to work on, then import the LGE-specific code and update whatever was in need of fixes. The first commit done to that base was this one, with the base being LA.UM.7.5.2.r1-03700-8x96.0.

For a list of what was done at the start, look here.

The LGE imports themselves were split into multiple commits due to the sheer amount of files touched by LGE, and some were still left out in order to have a cleaner kernel compared to 3.18. The vast majority of those commits were done right at the start, so you can refer to the link above for more info.

The fixes needed to build the kernel were nothing out of the ordinary, being mostly patches to usb/anx (ANX being the integrated chip that handles usb and provides HDMI-out support, among other things on both G5 and V20) and the ESS DAC on the V20 (ES9218, named ES9018 in the kernel CONFIGS, and being pretty similar to G6's ES9218P).

The V20 in special needed some extra UFS patches in its dtsi files in order to boot correctly. For a general reference on how it was done, look for the G6 section below, it faced a similar problem.

While dealing with the USB code, the phones would constantly get stuck in a loop where it wasn't possible to trigger a ramoops without manual intervention. A workaround to those situations was using a code to force a kernel panic when a USB cable was inserted, eventually reverted in the following commit: Remove smbcharger's usb insertion panic after the USB got stable enough to reliably allow the phones to boot.

Some cleanups were made in the dtsi files, which are now largely commonized and organized per device/subsystem. So the G5 for example has its files located in /arch/arm64/boot/dts/lge/g5/, and its global variant's specifics are located further in, on /h1_global/ for example. Previously many of those files were duplicated on each model's variant, with h1_global being located on arch/arm64/boot/dts/lge/msm8996-h1_global, with lots of files in common with other variants such as the US one for example.

Certain features were also disabled on the dtsi files to solve minor errors in the kernel's dmesg log, one of those being actuator@0 on the V20's camera files. Revisiting those dtsi files to re-enable and cleanup a few things after the kernel gets more stable is a good idea.

The current state on those two phones is comprised of usb working mostly fine but with certain states still not allowing the phone to charge while HDMI or OTG (or both) is being used, something that can be done in 3.18. ADB and charging also don't work correctly unless a mode different from PTP and "No data transfer" is selected.