Tuesday, July 26, 2016

The multitude of ROM for the Xiaomi phones

I recently got a Xiaomi Mi5 (android) phone. One of the reasons I picked this phone was that apparently Xiaomi follows "release early, release often" principle for the firmware (aka ROM) of their devices. Eventually, I didn't get disappointed. Not only do they release often updates for the phone, but you have choices on which ROM goes on your phone. It took me some time to find out all the different ROMs, so as a note to myself, and maybe to others, here is a summary.

Firstly, let's mention that Xiaomi's firmware is called MIUI, and although it's developed by them, MIUI is also available for other brands of android phones. On the MIUI website, you have the choice between two ROMs:
  • China: that's the one dedicated to the Chinese market (which cannot access anything related to Google due to the government policy). As the developers and main target customers are Chinese, it's the ROM the most often updated, and which receives the most attention.
  • Global: that's the one for the rest of the world. It's main advantage is that it comes with Google-ware installed instead of Chinese software. It's less often updated, but still you can expect a new version once every couple of months.
Actually, for each of these ROMs there are two channels:
  • Stable: That's the one most people should use.
  • Developer: That's were beta versions are available. On the Chinese ROM, you can expect new ROM at least every second week! (For the Global one, it's a bit more irregular).

Ok, so far, there are just 4 ROM versions available for download at any time. Now, where it gets more muddy, is that there are several ways to update you ROM (5 on my last count). To support all the ways, there are actually, three different formats for each ROM. So we bump to 12 ROMs. But wait, what if you want to try older versions for bug bisection or due to a regression? Of course, all the older versions are also present!

That's pretty much all for the official ROMs... but there are also some non-official but famous ROMs. As pretty much the whole MIUI ROM is open-source, people have been making derivative. In particular, there is the Xiaomi.eu Multilang ROM. They basically take the China ROM, and modify it themselves to make a ROM adapted for the European users. So it's pretty much the same as the Global ROM, excepted it might be slightly ahead in terms of version, and they claim they've added their own improvements. Note that because it's not an official ROM, the phone bootloader must be unlocked, and the update is done via some special bootloader extension (TWRP). In my experience, the difference is very tiny, and I feel it's not worth the trouble of having to unlock the bootloader and drop some security and ease of updates.

One very weird aspect of my phone is that when I got it, it still was running none of these ROMs. I got the phone from a small Dutch vendor doing imports from China, when the phone had just been released so that might explain a bit this, but I didn't feel comfortable running some ROM from absolutely unknown source. Basically, the ROM was claiming to be the unofficial Xiaomi.eu, but the bootloader was locked (so the ROM was signed a Xiaomi key ?!). Although it seemed to behave fine, one particulary troubling aspect was the standard updater would never find any update, and would crash when trying to update manually. Trying to update via the MI PCSuite would just show an error saying the device firmware is too old to be updated (how ironic...). After much looking here was how I could update the ROM to a standard Global version (without any data loss):
  1. Ask to have unlocking privileges on my Xiaomi account
  2. (Two weeks later) unlock the bootloader of my phone
  3. Flash the latest Global ROM using the fastboot method
  4. Relocked the bootloader (using these instructions)
Maybe I should have been more paranoid, and completely erase the data to make sure no code from the old ROM was left-over but I was happy not to restore all my data.