I am posting this in the hope it may help others who find themselves in a similar position to myself.
I have recently upgraded my mobile ‘phone (from a Motorola Moto X4) to a Moto G7 plus. I chose this particular phone because I like Motorolas. I like the fact that they are relatively cheap for a well specced device. I like the fact that they are (usually) easy to reflash with lineageos, and I like the fact that Motorola is quite supportive of that process and gives you some assistance in doing so. Of course the more paranoid of the tin hat brigade might see that support (from a Chinese manufacturer) as somewhat suspect, but that aside, I much prefer my ‘phones to be Google free and all of my past mobiles have been reflashed to either lineageos or its predecessor CyanogenMod.
I chose the G7 plus based on its specification, price, and the availability of an image for lineageos 18.1 (effectively Android 11). At the time of writing this post, later Moto Gs (the G8, G9 and G10) are not supported by lineageos. In theory, my X4 should have been capable of being reflashed to 18.1, but my earlier (three) attempts last year to upgrade it to 17.1 all failed and ended with the phone stuck in a boot loop and I had to revert to 16.0. I was not, therefore, prepared to attempt a jump to 18.1 without the fallback of a separate phone if all went wrong. The X4 is now four years old and I figured I could afford the (modest) cost of a newer model so plumped for the G7. The plus variant is very well specced indeed for a low to mid range phone and certainly meets my modest requirements (messaging, phone calls and a pretty good camera).
I have successfully flashed all three of my earlier Motorolas (and a couple of Samsung devices) in the past so I’m reasonably confident (and experienced) in the process. Besides, the lineageos wiki gives plenty of advice and further help is available on the lineageos subreddit to those who may need it. This time, I needed it.
All went well in the beginning. I already had adb and fastboot loaded on my desktop so I went through the process on the phone of:
- unlocking developer options.
- turning on USB debugging (in developer options).
- turning on oem unlocking. (NOTE however that this option WILL be disabled (greyed out) unless your phone is connected to the ‘net over wifi. I suspect that the ‘phone calls home to Motorola when this option is applied. This has never been the case with any previous Moto G I have flashed in the past.
- turning on “rooted debugging” to allow running android debugging as root (this is not mentioned in the lineagos wiki page but turns out to be necessary in my experience).
Then, having connected the phone to my PC with a USB cable I ran “adb reboot bootloader” and sure enough, the phone rebooted into fastboot mode. Note however, that in multiple subsequent attempts I found it much more consistently successful to boot using the hardware option (with the device powered off, simultaneously holding volume down + power buttons).
With the phone in fastboot mode I could verify that it was found with “fastboot devices” which would successfully report the device ID. Hereafter, however, everything went wrong.
At this stage you need to contact Motorola support to get an unlock code before you can flash a new ROM. Once you are signed in (if you have a motorola account) the support page instructs you to get the device id by typing “fastboot oem get_unlock_data”. The response to this command is supposed to be of the form:
$ fastboot oem get_unlock_data
(bootloader) 0A40040192024205#4C4D3556313230
(bootloader) 30373731363031303332323239#BD00
(bootloader) 8A672BA4746C2CE02328A2AC0C39F95
(bootloader) 1A3E5#1F53280002000000000000000
(bootloader) 0000000
Motorola instructs you to concatenate the five lines of output data (without any of the “bootloader” headers and with no spaces) into one continuous string and paste that string into a field on the web page. If your device can be unlocked, you will then be emailed the unlock code which you can apply to your phone.
My big problem here was the complete failure of the command “fastboot oem get_unlock_data”. No matter how many times I rebooted into fastboot mode that last command would simply hang with no response. I tried waiting for several minutes, I checked the phone boot log (which recorded the command as having successfully been received) but nothing happened. Without the unlock code, you can go no further, so I spent a few (less than happy) hours searching various on-line fora for answers. Try searching for “fastboot oem get_unlock_data hangs on moto g7” to see queries from lots of people with similar problems (though of course you may find references to this post after publication). The best hints I got were at the XDA developers site which pointed to a possible hardware problem – not enouraging.
So – I tried all of the following in various combinations:
- deleting the version of adb/fastboot supplied by my distro’s repository and installing the latest version from Google (probably good advice since the repository version looked to be very out of date);
- switching the USB cable between USB 2 and USB 3 ports;
- changing the USB cable entirely.
All to no avail.
Eventually I tried a completely different PC running a completely different distro (coincidentally a distro entirely free of systemd which I have been experimenting with because I loathe and detest systemd and its vampire squid like attempts to take over the entire linux system) and bingo, it worked. I sucessfully received the unlock code and could move on to reflashing the phone as outlined on the lineageos wiki page.
Now I cannot be sure what was wrong, or why the change of PC should have made any difference, there are too many variables at play here. The second PC runs an AMD processor, not Intel so it has a completely different architecture from the motherboard up. It runs a version of linux without systemd (which I may move to entirely when I have finished my testing), and it runs a completely different kernel (version 5.10.0-5mx-amd64 rather than 5.4.0-73-generic) so it is probably unfair to blame systemd – but I’m going to anyway. It gives me one more reason to hate it.
I don’t like not knowing why something fails, whilst trying something else works without finding out exactly what is wrong, because that leaves me with an itch I can’t scratch. But if you are faced with a similar problem (and searching suggests that this is not an uncommon problem with the G7 models) then please do try a different distro on a different machine. Preferably one without systemd.
One final point. Following the flash of 18.1 to my new phone, I successfully flashed my older X4 to the same version – with no problem whatsoever.
Go figure.