Mind Dump, Tech And Life Blog
written by Ivan Alenko
published under license CC4-BY
posted in category Systems Software / LineageOS
posted at 07. Sep '23
last updated at 13. Feb '24

Howto Upgrade LineageOS From 19.1 to 20.0

Recently I upgraded Oneplus 6 and Xperia XZ2 Compact from LineageOS 19.1 to 20.0 (Android 12 -> Android 13).

OnePlus went pretty smooth, there is even an upgrade guide to upgrade the firmware in the docs.

I will describe upgrade process on Xperia XZ2 Compact, because I had to upgrade boot partition this time too.

UPDATE 2024-02-13: Much more detailed preparation and Gapps sections.

See previous parts if you have an older version:

I like LineageOS 20.0 (Android 13), while icons are larger, scrolling is faster and less microstuttery (maybe I have twisted perception from 90 Hz displays about the ideal speed, but is is definitely snappier)

Preparation

Let’s describe also the tools, because I had to download the latest one.

Learn Button Combination to fastboot and recovery

Remember or write down how to go to fastboot and recovery modes, just to prevent panic when stuff does not work as it should:

  • fastboot (bootloader, the first boot stage - fastboot devices - volume up + connect usb cable = blue LED light, empty black screen (is different across devices, OnePlus 6 has white background with 3 menu items)
  • recovery (the second boot stage) - adb devices - power + volume down (don’t hold it more than couple of seconds, otherwise phone will restart once gets to recovery)


LineageOS 20.0 Recovery

Download Android platform tools

Download adb and fastboot from https://developer.android.com/tools/releases/platform-tools. The documentation recommends https://wiki.lineageos.org/devices/xz2c/install#booting-a-custom-recovery-using-fastboot using > 31.0.2. I downloaded latest one (v34), because I thought I bricked my phone flashing new recovery, but actually all was good.

Save somewhere and unpack and you will see platform-tools directory with adb and fastboot inside.

Alternatively install Android development tools from the software repository.

Add user to plugdev group

To use adb and fastboot user have to be in plugdev group (https://developer.android.com/studio/run/device).

usermod -aG plugdev <myuser>.

This command will add user to plugdev group (as a secondary group). Log out to greeter and log in again or restart the computer to have the operating system to refresh groups of user.

Install udev rules

Udev rules are necessary to access hardware as a regular user, I don’t know details and also I have no idea why it is required also for root user.

Android documentation recommends installing android-sdk-platform-tools-common with:

apt-get install android-sdk-platform-tools-common

but this package is not available, thanks the license not being compatible with Debian.

So you will end up installing whole development tools anyways:

apt-get install google-android-platform-tools-installer

which means adb and fastboot will be installed too in addition to udev rules.

Allow USB Debugging

ON THE PHONE - allow developer mode and USB debugging.

Enable developer mode:

  • go to the last item in “Settings” - “Information about phone”
  • press 7 (or more?) times on the last item “Build number”

Then allow USB debugging:

  • go to “Settings” - “System” - “Developer Options”
  • and turn on “USB Debugging” switch.

The category names are approximate, I translated them from Slovak language.

Backup Data

You shouldn’t lose anything, but you should backup all data you can. Yeah, without root forget about backing up applications, application data and stuff like SMS.

Applications and data will be preserved (until something goes really wrong and you get like bootloop).

Other Notes

  • I run adb and fastboot as root, but in theory a regular user in plugdev could work too
  • commands do not show the whole directory path since it was too long
  • do it only if you accept the risk of losing the phone
  • you need a USB cable and PC (Linux/Mac/Windows)

Upgrade Sony Firmware

New device drivers cannot hurt, right?

I know Lineage 20.0 is Android 13 and binaries are for Android 12, but they work. It used to be almost impossible in Gingerbread 2.3 and KitKat 4.4 era.

root@rapthalia:~/platform-tools# ./adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
BH902KDKCU      unauthorized
# authorize it on the phone
root@rapthalia:~/platform-tools# ./adb reboot fastboot
root@rapthalia:~/platform-tools# ./fastboot devices
BH902KDKCU      fastboot

root@rapthalia:~/platform-tools# ./fastboot flash oem ~/lineage/SW_binaries_for_Xperia_Android_12_4.19_v3a_tama.img
Sending 'oem' (314068 KB)                          OKAY [  1.245s]
Writing 'oem'                                      OKAY [ 14.389s]
Finished. Total time: 15.651s

Upgrade Bootloader

I had to upgrade the bootloader (Lineage recovery), because I got this error while flashing new ROM:

E: Package is for product xz2c but expected H8324
root@rapthalia:~/lineage/platform-tools# ./fastboot devices
BH902KDKCU       fastboot

root@rapthalia:~/lineage/platform-tools# ./fastboot flash boot ~/lineage/xz2c/boot.img
Sending 'boot_a' (65536 KB)                        OKAY [  0.252s]
Writing 'boot_a'                                   OKAY [  1.415s]
Finished. Total time: 1.686s

Here I kind of panicked and thought I fucked up the boot partition since all I saw was Sony logo for minutes and downloaded latest platform tools and flashed boot partition like 7 more times - classic method used when I handled bootloop couple of years ago. Just for your information it always flashed to boot_a and copy partitions script is not usable in bootloader. It requires to be applied in the recovery.

I still don’t know if it would boot into Android, probably not since I saw Sony logo for minutes. I hold volume down and power for couple of seconds and then wait for like 2 minutes until the phone got into the recovery. Yay!

And this concludes the new bootloader.

If you see this, you are not in fastboot, but somewhere in boot process limbo:

root@rapthalia:~/lineage/platform-tools# ./fastboot devices
????????????     XFL

root@rapthalia:~/lineage/platform-tools# ./fastboot flash boot ~/lineage/xz2c/boot.img
Warning: skip copying boot_a image avb footer (boot_a partition size: 0, boot_a image size: 67108864).
Sending 'boot_a' (65536 KB)                        OKAY [  0.604s]
Writing 'boot_a'                                   FAILED (remote: 'Command not authenticated')
fastboot: error: Command failed

Turn off the phone, hold volume up and connect the USB cable.

Upgrade LineageOS

And now the main part.

  • PC: download ROM from here - https://download.lineageos.org/devices/xz2c/builds
  • Phone: go to the recovery mode, connect with PC via USB
  • PC: always allow machine (PC) by fingerprint, adb devices shows the phone
  • Phone: In recovery selecty “Apply update” -> “Apply from ADB” - this will allow adb sideload command
root@rapthalia:~/lineage/platform-tools# ./adb sideload ../xz2c/lineage-20.0-20240103-nightly-xz2c-signed.zip 
Total xfer: 1.00x
root@rapthalia:~/lineage/platform-tools#
  • (Optional) Phone: Install Google Apps. You want to have this if you depend on some banking applications or applications which use push notifications or use Google Play Services. It is riddiculous how many applications will fail if this API is not available. You can survive without push notifications, but in case of Wise for example, you cannot approve a transaction, but can browse in the application.

    Instructions: reboot to recovery again, do not boot into the system, otherwise you will have to do factory reset in recovery and try again. Again enable sideload mode with selecting “Apply update” -> “Apply from ADB”. Download Google Apps ZIP from https://wiki.lineageos.org/gapps - choose LineageOS 20 ARM64 version.

damonrapthalia:~/projects/lineage$ adb sideload MindTheGapps-13.0.0-arm64-20231025_200931.zip
serving: 'MindTheGapps-13.0.0-arm64-20231025_200931.zip'  (~47%) 
  • (Optional) Phone: microG (Google Play Services free reimplementation) - I’ll fill in sometimes
  • (Optional) Phone: maybe you want Magisk too to mask custom ROM, but you will have to do your own research. Never worked properly in my case.
  • and then restart and all is good

Enjoy!

Add Comment