Noob-friendly guide to get from vanilla to lineage

Search This thread

xstasi

New member
Mar 4, 2019
1
2
This is a step-by-step guide that will get you to a fully working lineageos on your sony xa2 ultra, starting from a device that was just purchased.

I used Linux, but everything should be more than doable on Windows as well.

Make sure you have:

  • A copy of platform-tools from google (ubuntu's version works to some extent, i had to use binaries from both). You need:
    • fastboot
    • adb
  • The TWRP image for XA2 ultra: twrp-3.2.3-0-discovery.img
  • A working copy of xperifirm. If you're on Linux set a light UI theme, or it won't work. Also
    Code:
    export TERM=xterm
    before launching it.
  • A working copy of newflasher. You can build it on linux by typing
    Code:
    make newflasher.x64
    newflasher.x64 will be the name of the binary.
  • A fresh lineageos build for your phone (from now on referred to as lineage.zip)
  • A build of gapps, if you want them

The first thing you have to do is to

Unlock your bootloader

Preliminary operations:

  1. Start your phone
  2. Connect to the internet (3g or wifi)
  3. Go to Settings > System > Device info, tap "Build number" until developer mode is active
  4. Go back, open developer options
  5. Tick USB Debugging and OEM Unlock
  6. Open the phone dialer and type
    Code:
    *#*#7378423#*#*
    this will open the service menu. It could take a few seconds.
  7. Go to Service info
  8. Enter 'Model info', write down the string (e.g. H4213) somewhere
  9. Go back and enter 'Configuration'.
  10. Check that "Bootloader unlockable" is 'yes', if it's not you can't proceed.
  11. Write down the IMEI code. If it's a dual sim, you need to write down the "Sub1" one.
  12. Go here, select the device and paste the IMEI that you wrote down
  13. Write down the unlock code

Put phone in fastboot mode and unlock the bootloader:

  1. Shut down the phone completely, unplug the USB cable if plugged
  2. Hold VolumeUp, plug USB cable
  3. Phone should power on, press Power if it doesn't
  4. Wait until you have a fixed blue light on the led
  5. You are now in fastboot mode
  6. Code:
    fastboot oem unlock xxxxx
    where xxxxx is the unlock code that you obtained from the previous step

Flash an updated firmware

First you need to obtain the latest firmware for your device:

  1. Run xperifirm
  2. Open Sony XA2 discovery
  3. Select whatever you wrote down from the 'Model info' section of the service menu
  4. Download whatever firmware has the highest build number

If you're on Linux xperifirm will fail to unpack the firmware. You can work around it by entering the firmware directory on a shell and running:
Code:
for i in FILE_* ; do unzip $i ; done
unzip boot.zip -d boot

Remove a bunch of files, you can copy/paste this string after 'rm' or delete them manually:
Code:
kernel_X-FLASH-ALL-18AE_0x00.hash kernel_X-FLASH-ALL-18AE.sin persist_X-FLASH-ALL-18AE_0x00.hash persist_X-FLASH-ALL-18AE.sin system_other_X-FLASH-ALL-18AE_0x00.hash system_other_X-FLASH-ALL-18AE.sin system_other_X-FLASH-ALL-9B8D_0x00.hash system_X-FLASH-ALL-18AE_0x00.hash system_X-FLASH-ALL-18AE.sin system_X-FLASH-ALL-9B8D_0x00.hash userdata_X-FLASH-CUST-18AE.sin vendor_X-FLASH-ALL-18AE_0x00.hash vendor_X-FLASH-ALL-18AE.sin vendor_X-FLASH-ALL-9B8D_0x00.hash

Put your phone in flashing mode.

  1. Shut down the phone completely, unplug the USB cable if plugged
  2. Hold VolumeDown, plug USB cable
  3. Phone should power on, press Power if it doesn't
  4. Wait until you have a fixed green light on the led
  5. You are now in flashing mode

Run
Code:
newflasher
(or newflasher.x64 if you built it yourself) from the directory where you have the remaining firmware files. It could ask you whether to dump the TA section, feel free to answer 'n'.

Go back in fastboot mode, and run:

Code:
fastboot set_active other

Then rerun the last list (go to flashing mode, run newflasher).

If 'other' doesn't work, run "fastboot getvar current-slot" in fastboot mode and then use either 'a' or 'b' instead of 'other' - whatever is not the one returned by getvar.

Flash lineage

Boot into TWRP:

  • Put your phone in fastboot mode (see above)
  • Code:
    fastboot boot twrp-3.2.3-0-discovery.img
  • You are now in TWRP

When I first tried this my phone kept power cycling. If this happens to you too, here is how to fix it:

  1. Hold VolUp and let it power cycle until it goes into fastboot mode again (fixed blue led)
  2. Code:
    fastboot -w
  3. Try booting into TWRP again

Flash lineage:

  1. On TWRP go to advanced, enable sideload
  2. On your computer run:
    Code:
    adb sideload lineage.zip

It should start flashing by itself, if it doesn't, make it.

If you want to also flash gapps, repeat steps from 'Boot into TWRP' and flash the gapps zip file.

Reboot your phone into fastboot one last time, and run
Code:
fastboot -w
.

Reboot with
Code:
fastboot reboot
.

Congratulations, you're now running lineage!
 
Last edited:

AlaskaLinuxUser

Senior Member
Oct 23, 2015
1,946
4,079
Fairbanks
thealaskalinuxuser.wordpress.com
Thanks @xstasi for the write up. However, I have a question.

After flashing the firmware with newflasher the first time, I then went to download mode, found I was on "b" so I set it to the "a" slot. But after powering down, now my phone will not do anything. I can't get back into the flash mode, or fastboot mode. No matter what I press, when I plug in the USB cord, the light blinks green several times but never goes solid. Any advice on how to fix this?
 

voidling42

Member
Jan 28, 2012
5
0
N00b question:
The automatically generated lineageos installation instructions recommend backing up the "trim area partition" as it contains "the" DRM keys:
https://wiki.lineageos.org/devices/discovery/install#unlocking-the-bootloader
There seems to be a tool on XDA for this: https://forum.xda-developers.com/crossdevice-dev/sony/universal-dirtycow-based-ta-backup-t3514236

Why do I need to bother with that? What would I need the DRM keys for? Does it make a difference when running lineage? Or reverting back to stock?

BR
 

ultenhiemer

Member
Mar 30, 2018
24
6
West Midlands, UK
N00b question:
The automatically generated lineageos installation instructions recommend backing up the "trim area partition" as it contains "the" DRM keys:
https://wiki.lineageos.org/devices/discovery/install#unlocking-the-bootloader
There seems to be a tool on XDA for this: https://forum.xda-developers.com/crossdevice-dev/sony/universal-dirtycow-based-ta-backup-t3514236

Why do I need to bother with that? What would I need the DRM keys for? Does it make a difference when running lineage? Or reverting back to stock?

BR

You backup the TA Partition once you've booted into TWRP. Theres a section where you can backup the TA Partition through there... Unfortunately it isn't mentioned here.

---------- Post added at 04:22 AM ---------- Previous post was at 04:20 AM ----------

Hmmm, I would have recommended the 'Minimal Adb and Fastboot' instead of the 'platform-tools' from Google. Less bloaty, quicker installation and same instructions as above. All thats needed is the twrp.img in the same folder where the 'Minimal Adb and Fastboot' is installed and voila!

You never mentioned the Add On SU, to add rooting capability into Lineage itself rather than third party apps, activated from the developer options once flashed.

I know GApps are a rather personal preference from person to person. But I'd personally recommend installing the Aroma package from Open GApps. Whilst it is essentially the Super package (Where it has all the Google Apps), Aroma unlike Super has a GUI where you can select what Google Apps you do and don't want installed from it. So you can add as much or as little as you need to. further on, It also has extra really useful features; before installing you can tell if you want Aroma to replace the Lineage apps with the Google versions (Such as Gallery, Camera, Contacts and Messaging... etc), because normally it will just overwrite them anyway. Finally, the most useful feature before installing GApps, is that you get the option to uninstall Lineage features. There's only 3 options (LineageOS Recorder, LineageOS Setup Wizard and LineageOS Updater), the rest dont really apply to Lineage. At the very least I'd recommend uninstalling the LineageOS Setup Wizard (But I usually uninstall all 3). I say that because Aroma also installs a Google setup wizard, thats much more useful than the Lineage one, particularly if you're updating Lineage and have previously made a backup with Google and want to quickly reinstall all your apps and settings, rather than reinstalling them one by one.
 

ilCactuss

Member
Nov 30, 2014
10
4
25
Albiate
Hello guys,
I found some differences with other Newflash guides:
- you do not delete *.ta files in main folder and in boot folder;
- you delete kernel_* files instead of boot_* files in main folder;
I can't tell if those different steps make any difference, anyway.

You should mention that DRM keys are lost with bootloader unlock and that TA partition should be backup up via TWRP before flashing lineage.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    This is a step-by-step guide that will get you to a fully working lineageos on your sony xa2 ultra, starting from a device that was just purchased.

    I used Linux, but everything should be more than doable on Windows as well.

    Make sure you have:

    • A copy of platform-tools from google (ubuntu's version works to some extent, i had to use binaries from both). You need:
      • fastboot
      • adb
    • The TWRP image for XA2 ultra: twrp-3.2.3-0-discovery.img
    • A working copy of xperifirm. If you're on Linux set a light UI theme, or it won't work. Also
      Code:
      export TERM=xterm
      before launching it.
    • A working copy of newflasher. You can build it on linux by typing
      Code:
      make newflasher.x64
      newflasher.x64 will be the name of the binary.
    • A fresh lineageos build for your phone (from now on referred to as lineage.zip)
    • A build of gapps, if you want them

    The first thing you have to do is to

    Unlock your bootloader

    Preliminary operations:

    1. Start your phone
    2. Connect to the internet (3g or wifi)
    3. Go to Settings > System > Device info, tap "Build number" until developer mode is active
    4. Go back, open developer options
    5. Tick USB Debugging and OEM Unlock
    6. Open the phone dialer and type
      Code:
      *#*#7378423#*#*
      this will open the service menu. It could take a few seconds.
    7. Go to Service info
    8. Enter 'Model info', write down the string (e.g. H4213) somewhere
    9. Go back and enter 'Configuration'.
    10. Check that "Bootloader unlockable" is 'yes', if it's not you can't proceed.
    11. Write down the IMEI code. If it's a dual sim, you need to write down the "Sub1" one.
    12. Go here, select the device and paste the IMEI that you wrote down
    13. Write down the unlock code

    Put phone in fastboot mode and unlock the bootloader:

    1. Shut down the phone completely, unplug the USB cable if plugged
    2. Hold VolumeUp, plug USB cable
    3. Phone should power on, press Power if it doesn't
    4. Wait until you have a fixed blue light on the led
    5. You are now in fastboot mode
    6. Code:
      fastboot oem unlock xxxxx
      where xxxxx is the unlock code that you obtained from the previous step

    Flash an updated firmware

    First you need to obtain the latest firmware for your device:

    1. Run xperifirm
    2. Open Sony XA2 discovery
    3. Select whatever you wrote down from the 'Model info' section of the service menu
    4. Download whatever firmware has the highest build number

    If you're on Linux xperifirm will fail to unpack the firmware. You can work around it by entering the firmware directory on a shell and running:
    Code:
    for i in FILE_* ; do unzip $i ; done
    unzip boot.zip -d boot

    Remove a bunch of files, you can copy/paste this string after 'rm' or delete them manually:
    Code:
    kernel_X-FLASH-ALL-18AE_0x00.hash kernel_X-FLASH-ALL-18AE.sin persist_X-FLASH-ALL-18AE_0x00.hash persist_X-FLASH-ALL-18AE.sin system_other_X-FLASH-ALL-18AE_0x00.hash system_other_X-FLASH-ALL-18AE.sin system_other_X-FLASH-ALL-9B8D_0x00.hash system_X-FLASH-ALL-18AE_0x00.hash system_X-FLASH-ALL-18AE.sin system_X-FLASH-ALL-9B8D_0x00.hash userdata_X-FLASH-CUST-18AE.sin vendor_X-FLASH-ALL-18AE_0x00.hash vendor_X-FLASH-ALL-18AE.sin vendor_X-FLASH-ALL-9B8D_0x00.hash

    Put your phone in flashing mode.

    1. Shut down the phone completely, unplug the USB cable if plugged
    2. Hold VolumeDown, plug USB cable
    3. Phone should power on, press Power if it doesn't
    4. Wait until you have a fixed green light on the led
    5. You are now in flashing mode

    Run
    Code:
    newflasher
    (or newflasher.x64 if you built it yourself) from the directory where you have the remaining firmware files. It could ask you whether to dump the TA section, feel free to answer 'n'.

    Go back in fastboot mode, and run:

    Code:
    fastboot set_active other

    Then rerun the last list (go to flashing mode, run newflasher).

    If 'other' doesn't work, run "fastboot getvar current-slot" in fastboot mode and then use either 'a' or 'b' instead of 'other' - whatever is not the one returned by getvar.

    Flash lineage

    Boot into TWRP:

    • Put your phone in fastboot mode (see above)
    • Code:
      fastboot boot twrp-3.2.3-0-discovery.img
    • You are now in TWRP

    When I first tried this my phone kept power cycling. If this happens to you too, here is how to fix it:

    1. Hold VolUp and let it power cycle until it goes into fastboot mode again (fixed blue led)
    2. Code:
      fastboot -w
    3. Try booting into TWRP again

    Flash lineage:

    1. On TWRP go to advanced, enable sideload
    2. On your computer run:
      Code:
      adb sideload lineage.zip

    It should start flashing by itself, if it doesn't, make it.

    If you want to also flash gapps, repeat steps from 'Boot into TWRP' and flash the gapps zip file.

    Reboot your phone into fastboot one last time, and run
    Code:
    fastboot -w
    .

    Reboot with
    Code:
    fastboot reboot
    .

    Congratulations, you're now running lineage!
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone