Goodbye Apple Goodbye Google

Having unlocked Xiaomi's Poco M3 phone, thereby enabling replacement of its operating system, it's time to take action and say goodbye to Google's Android and Apple's IOS phone operating systems forever. It's off to a brave new world of Ubuntu Touch....maybe.

For this user everything from here on is a learning exercise. Pretty much eveything you know about phones is now useless in this new private world. All those services which collect your private information that you've come to know and use now operate in a different way by different organizations that operate in a fundamentally different way.

Ubuntu Touch actually has quite a long history dating back to 2011. It was started by Canonical Ltd. and then later abandoned in 2017 due to a lack of market interest. The IP was then transferred to the UBports Foundation who maintain and grow it to this day.

At the heart of the foundation's philosophy is a notion not too far from that of the mutual insurance company. The concept of mutual insurance originated in England in the late 17th century to cover losses due to fire. Essentially the organisation is run, in large part, in the interests of its users, which is fundamentally different to Apple and Google. At least that's how it is for the time being. </philosophy>

Android -> Linux

What's the difference between Android and Linux?

Back in the day Android had to run on endless varieties of CPU architectures.  Many of these were Chinese in origin. Loongson produced CPUs based on the MIPS architecture (manufactured by the French/Italian STMicroelectronics group) which found their way into many cheap tablets and phones. All of them ran Android.

This led to a fundamental difference and diversion from Linux. Android programs are essentially run by a virtual machines. The Dalvik Virtual Machine is a program that takes code and does stuff in much the same way as the very first BASIC interprets did in the 70's. Whereas Linux programs run on bare metal (directly on the CPU), which in this case is the now famous ARM64 cpu. In Xiaomi Poco M3 case there are 8 such CPUs  which are coupled to 4GB of RAM and 128GB of flash storage. The result of running programs on bare metal is, arguably, that it's faster and takes less power. This was always the arguement against interpreters/software virtual machines.

The downside is that it's necessary to compile everything for each different type of CPU - which is why the DVM was invented, right. With the DVM programs are just "written once and run everywhere". The only thing that is recompiled is the DVM itself.

Now days, of course, ARM has won the CPU race pretty much as Intel did back in day for Personal Computers. There really isn't a need anymore for a Dalvik Virtual Machine that can run on every type of CPU that once existed. Technically Android is obsolete, not to mention infested with spyware.

What is being installed and what is not?

It turns out that Ubuntu Touch can be installed in two ways. The changeover from Android to Linux (which is the case with this phone) surprisingly does not involve replacing the the vendor's kernel. Whereas the Pinephone and similar friends actually runs a full Linux kernel installation. The technology to adapt Xiaomi's kernel to the task of running the Ubuntu Touch "OS" (or more accurately a distribution) comes from a middleware project named Halium.

Their technology adapts the original kernel complete with its often propietary drivers for secret cool hardware. An example of cool hardware is the fingerprint reader on the Poco M3. This hardware gadget makes for super convenient unlocking and even rivals Apple's IOS face recognition in usability for unlocking the phone. The really nice thing is that the Beijing Bureau of Public Security doesn't get to collect your biometric data (although because the driver for the fingerprint reader is a blob nobody can actually verify precisely what it does or does not do - but it's generally thought to be rendered safe).

So the cool thing here is that there is no Linux kernel driver for these pieces of the phone's hardware available in the public domain. So while you could technically compile the open source kernel from Xiaomi (which has been downloaded here at ElectricBrain) there are bits missing - like the fingerprint reader driver. Halium fixes this and so the fingerprint reader on this phone amazingly actually works! Furthermore this is a technical feat which leaves many a software engineer gobsmacked! Take this author's word for it, this is amazing. Halium explains this with the following diagram:

The net result is a hybrid of sorts

Limitations

The downside of the hybrid approach, at least at this time, is that upgrading the kernel is considered to be a complex operation. While feasible it is generally not done and the installer program won't help with the task. Essentially that means phone owners need to upgrade their phones with the very latest vendor operating system updates prior to embarking on the Ubuntu Touch installation process. This is because the running kernel will likely be the last one ever installed for the rest of the phone's life.

This clearly has it's own security risk profile.

Another limitation, which isn't anything the user can control, is that app developers find themselves having to contend with mutiple versions of the operating system kernel. The range of kernels that could be running underneath Ubuntu Touch could be quite wide. For example discussion on Telegram reveals very old Linux kernels as old as 3.4 while current kernels on the Pinephone run up to 5.11. Generally a Linux distribution doesn't backport to old kernels whereas app developers have to do all sorts of software gymnastics to remain backwards compatible.

Installation

The installation process is similar to other Android ROM images in that an installer is used to get things done. It's different to a conventional Linux operating system install, however, where the installer gathers components and installs the packages one by one. Here a complete image of the file system is dumped in to a partition. In fact if one attempts to use conventional apt-get and relatives it's quite likely the result will be to brick the phone. The support fora (i.e. forums) are full of people who tried the apt install route for a favourite package - which ended in tears.

Apps from the OpenStore (of which there are literally hundreds) are in a special format known as "Clicks". Clicks are an extended form of the standard "deb" format however they are able to take into account the subtleties of Ubuntu Touch environment. They can install and uninstall without bricking the phone/tablet. More on this later.

The UT (Ubuntu Touch) installer is called UBPorts Installer. It's downloadable from the official site https://devices.ubuntu-touch.io/ where it's important to locate the precise model of phone being targetted. For the Xiaomi Poco M3 a specific version of the installer is called for (and it's not the latest version at the time of writing). Post installation it was found that more stuff worked than is marked working on the official page. So much stuff works that it will make for endless articles in this Phone Adventures series. Even things that appeared broken were made to work! (like the SDCARD - this phone has a 128GB card fully operational).

Once the installer is downloaded for your operating system follow the on screen instructions. The documentation on the whole is very good quality. Plugging the phone in requires it to be booted in "fastboot" mode which brings up the following image (where it's not entirely clear what the PLA rabbit is planning on doing to the Android robot). Booting to fastboot from power-off is done by pressing the "volume down" key and the power button simultaneously and holding it until the images stays there for a couple of seconds (it seems to flash on and off and finally on again).

As this action was done on the ElectricBrain Lenovo notebook (which has been de-Microsoft-ized and) which now runs Kubuntu 21.04 (Hirsute Hippo) hence all the necessary drivers are just built in. For Windows users ensure the drivers mentioned on the unlocking page are installed before proceeding.

Various people report different issues with having the installer recognize the phone. The fora (i.e. forums) have lots and lots of help. The Telegram group https://t.me/WelcomePlus has almost 2,000 members, so someone is sure to be able to help with your issue. Here at ElectricBrain it just worked. (On the subject of Telegram groups, the main group for Ubuntu Touch is https://t.me/ubports which has almost 4000 members)

There was one slight issue while performing the install. The installer kept complaining that a certain key was not available. This turned out to be the AVB ( Android Verified Boot) complaining a certain partition did not have the expected checksum and didn't match a key. The answer was very very simple. Just wipe all user data so that the AVB won't check it. Ensure Wipe Userdata is selected on the first install after unlocking the phone.

The installer then sets about downloading 14 different things and loads them in to the phone. Finally control is passed over to the phone to do its "update OS" thing. This step can take a long time as in 10 minutes or more, so don't panic - just let it do its thing.

Finally the screen shall appear - your adventure begins!

(Note: The pic below is a screen grab and doesn't show the notch caused by the face camera - See last pic in Phone Adventures page - you can't see the top line from the Mail icon to the Bluetooth icon because of the camera)

and after loading lots of interesting new apps from the OpenStore: