Adventures in Android land - Part 2

Almost exactly two years ago I tried to make an android app. This time I tried installing Android operating system on an Android phone.

A few years ago we bought a new flagship LG phone for my mother for Christmas. She already had a cheap Android phone, which I bough her a couple of years earlier, which she liked and used a lot. It however had a small screen and was very slow and sluggish, so this Christmas we scrambled and after much research bought the best phone I could find, the LG G2, which still today is pretty damn good.
Years went by and the phone started to act weird, and one day it would not start. So she bought a new one and give me the LG G2.
I took a quick look at it, and sure it didn't start. After the phone laying on my desk a few weeks I tried too hook it into a USB and lo and behold it booted! It seems it had just ran out of battery :P. I asked my mother if she wanted it back but as she had bought a new one I could keep it.

Installing LineageOS

Last week I needed to test out an Android app, but it couldn't be installed on the LG because the Android version was too old ...
I wanted to upgrade the phone anyway, so I made some research and figured out LineageOS Android Distribution was the best bet. And there where plenty of guides on the web on how to install it.

Getting root

In order to install a new operating system on a smartphone it first have to be "rooted". Rooted means that you get root access, which means you can run commands not as a regular user but as the super user, or Administrator (Windows) or root (Linux/Unix). The root privilege is needed to run commands that can alter and possible damage the system itself, which is probably why mobile manufacturers wont allow it. Example of commands that need root is altering hard drive partitions, creating new users, and upgrading the operating system.

Getting root from being a regular user requires some hacking. Some mobile manufacturers have a hardware switch or secret command for it, but most try to make it hard, and sometimes it's impossible to get root.
There are however many guides and tools on the web, especially for the popular LG G2 flagship model.

The Android scene looks very much like the software scene in the old days, with amateur hackers. Which is nice!
But the worst part is that there is no support whatsoever from the vendors: the phone manufacturers, or Google that develops the Android software.
There are however a wealth of information and "home made" tools available on community forums. Only problem is half of the tools doesn't work, or no longer exist for download.
After trying a bunch of tools I finally found one that got me root access. I could finally do dangerous stuff on my mobile!

Re-flashing the recovery rom

The recovery tool you get with the phone will just reset everything to factory settings, which is a very nice feature to have if you mess up.
There are however software that is more powerful, such as TWRP, which allows you to do a bunch of more stuff, like making backups or installing a new operating system.

Flashing the recovery room was tricky, mostly because of secure boot, so I also needed to mess with the boot system in order to get TWRP to work.
After trying a bunch of tools I finally found an .apk Android app (AutoRec) that would do it.

To make the phone boot into the recovery rom/mode I needed to hit a combination of hardware buttons during restart:
On the LG G2 you have to hit volume down + power, then wait for the LG logo, release, and push volume down + power again until you get the recovery screen.

Flashing LineageOS

Once in TWRP recovery mode - installing LineageOS was pretty straight forward. First make a backup of your old system. Then clear the old system, and finally install the new OS.

I'm now a few hours into the process and was very excited to boot the new OS for the first time ... But it didn't boot ! ...

More researching

I spend some more hours researching and reading tutorials on the web. And learned about:

I tried many, many times to flash back to stock software from official LG tool, plus a bunch of other tools - via Download mode, but nothing worked!
Installing LineageOS also seems to have messed with the boot loader so I couldn't get into recovery mode nor the system, so couldn't use adb.
But I found a tool to flash boot via USB_bulk, which got me into TWRP recovery again.
There I tried to install another version of LineageOS which also did not work. I then repeated the process and tried to install the nightly build of LineageOS again, but it didn't work this time either.
So I finally recovered from backup via TWRP ... But after installing the backup I couldn't boot the phone! (never trust backups - always test your backups!)

Now I only had access to Fastboot. I however found a tool that extracted each partition/rom from LG stock firmware. And I then used Fastboot to flash each of the partition/roms using Fastboot.
But during the flashing of the last image file: the system image - I got a error message that the image was too big! Apparently I could only flash 700 or so MB while the system is a whopping 1.4 GB! ... I guess the developers thought that a system could never get that big.


After flashing all the partitions/roms, but failed the system rom, I rebooted, which was stupid. I read that the LG G2 was un-brickable, so maybe I should feel proud instead of sad ? Because now I also broke Fastboot and can't do shit. The phone is now fully "bricked", which means it's as useful as a brick.
I found a guide on how to get it into USB_bulk mode by disassembling the phone, removing a bunch of components and short-circuiting some capacitors ...
After spending two full days on it I gave up for now. Maybe if it runs out of battery the capacitors will also discharge and it will put itself into USB_bulk mode so I don't have to mess with the hardware. But the problem still remains, how the hell am I going to get the phone into a working state !?

The state of mobile Operating Systems rant

Mobile phone's low level systems such as operating system and drivers are a mess. Most drivers are closed source and interfaces are not well documented. That's probably why not much exist in the form of Operating System's except Android.

If I ever make my own mobile phone I'll use a one card PC like the Raspberry, then plug usb speakers, mic, GSM/3G/4G modem into it and hook up with a nice touch display and chassi.
Then let it run Linux with a custom GUI shell. Apps would be web apps via Electron/nw.js or Browser. Or Native Linux x86 (or most likely arm).

Written by May 16, 2018.

Follow me via RSS:   RSS https://z├Ą (copy to feed-reader)
or Github:   Github