Putting LineageOS on a Samsung Galaxy S9 (SM-G960F/DS)

LineageOS on the Samsung Galaxy S9

Recently, a friend of mine wanted to get away from the stock software of their phone, and asked for my help to install LineageOS. There were several write-ups about how to do this, so I’m just sharing my experience of making this process work, in case it is useful to someone else.

First things first, LineageOS says that you need to be on the latest Android 10 firmware for this to work. So, after getting the phone, I turned on automatic updates under software update and had to go through 4 rounds of downloading and installing the updates. This took a while on a 10 Mbps internet connection, about 3 hours. But finally, it was up to date from Android 9 to now be Android 10 with the latest firmware.

During this time, I also downloaded the latest LineageOS nightly and recovery for the S9. As seen from their site.

Now with the latest firmware, I enabled developer options by clicking on about phone, and multiple taps of the build number to enable developer options. I looked in the developer options for the OEM unlock option, but it was no-where to be found. Interesting…. But, a quick search of XDA revealed that you have to wait 7 days after enabling the developer options before you can see the OEM unlock option. However, a user, named altai1963 had a neat post about disabling automatic time updates and changing the date to be a month ago and tricking the phone that more than 7 days had passed. So, I used it, and sure enough, it worked like a charm.

I did notice though, that I didn’t need to follow all of the steps they had done. All I did was uncheck auto date/time, and set the date back one month. Then the OEM unlock option became available under developer options. After I clicked on it, it asks if you want to wipe all of your data and proceed, to which I said yes. The phone rebooted to the Samsung logo for a while with a blue flashing notification light. After about 4 minutes, it said “Android wirt restarten” and then rebooted in (I believe) German.

Fortunately, Australian English was an option from the drop-down, as was Canadian English, so I went with my old friends the Aussies and clicked through the startup screens, choosing to skip setup of anything, since I was about to wipe it anyways to install LineageOS.

Now the fun begins….

I powered off the phone from the menu, and then held Volume down, the Bixby button, and Power button to power it on. Within a second, the screen was green with a download icon and lots of text, so I released all of the buttons, and per the on screen instructions, pressed volume up to allow changes.

Per LineageOS’s instructions, I tested that Heimdall (which was already installed on my Linux computer) was working and compatible with the phone:


$ heimdall print-pit
Heimdall v1.4.1

Copyright (c) 2010-2014 Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au/

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://www.glassechidna.com.au/donate/

Initialising connection...
Detecting device...
Claiming interface...
Setting up interface...

Initialising protocol...
Protocol initialisation successful.

Beginning session...

Some devices may take up to 2 minutes to respond.
Please be patient!

Session begun.

Downloading device's PIT file...
PIT file download successful.

Entry Count: 32
Unknown 1: 1598902083
Unknown 2: 844251476
Unknown 3: 21324
Unknown 4: 14665
Unknown 5: 12600
Unknown 6: 48
Unknown 7: 5
Unknown 8: 0


--- Entry #0 ---
Binary Type: 0 (AP)
Device Type: 8 (Unknown)
Identifier: 80
Attributes: 2 (STL Read-Only)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 0
Partition Block Count: 1024
File Offset (Obsolete): 1
File Size (Obsolete): 0
Partition Name: BOOTLOADER
Flash Filename: sboot.bin
FOTA Filename: 
----- Edited for breivety ------
--- Entry #31 ---
Binary Type: 0 (AP)
Device Type: 8 (Unknown)
Identifier: 25
Attributes: 5 (Read/Write)
Update Attributes: 5 (FOTA)
Partition Block Size/Offset: 1697152
Partition Block Count: 0
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: USERDATA
Flash Filename: userdata.img
FOTA Filename: remained

Ending session...
Rebooting device...
Releasing device interface...

And then the phone rebooted. So I shut down the phone again, and again went into download mode by pressing Volume down, the Bixby button, and Power button to power it on. Again, the screen was green with a download icon and lots of text, so I released all of the buttons, and per the on screen instructions, pressed volume up to allow changes.

Now from my computer terminal, I typed:

$ heimdall flash --RECOVERY ./lineage-17.1-20200615-recovery-starlte.img --no-reboot
Heimdall v1.4.1

Copyright (c) 2010-2014 Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au/

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://www.glassechidna.com.au/donate/

Initialising connection...
Detecting device...
Claiming interface...
Setting up interface...

Initialising protocol...
Protocol initialisation successful.

Beginning session...

Some devices may take up to 2 minutes to respond.
Please be patient!

Session begun.

Downloading device's PIT file...
PIT file download successful.

Uploading RECOVERY
100%
RECOVERY upload successful

Ending session...
Releasing device interface...

Now the phone showed a load bar across the screen. It was finished as soon as I saw it, so it was pretty fast. Then, I unplugged the USB cable, and per the instructions on the screen, held Volume Down and the Power button for 7 seconds to get out of download mode. As soon as it switched off, I held the Volume Up button with the Bixby button, and the Power button to go into recovery mode. This is important, because if you let it boot all the way into the stock ROM, it will wipe the recovery you just loaded. After a second or two, I could see the pink LineageOS recovery screen, and I plugged back in the USB cable to the computer.

On the phone, I used the volume keys and power button to select “Apply update” and “ADB sideload”. Then, on the computer terminal, I typed:

$ adb sideload ./lineage-17.1-20200615-nightly-starlte-signed.zip
serving: ‘./lineage-17.1-20200615-nightly-starlte-signed.zip’ (~17%)

To which it proceeded to 47%, and the phone screen had small white text at the bottom with status, eventually stating “script succeeded: result was [1.000000]” and giving me a prompt back on the phone screen and computer terminal.

At this point, I could install Magisk or Gapps, but in this case the owner of the phone wanted to install only LineageOS. So, I pressed the back arrow at the top of the phone screen, and tapped “Reboot System Now”. The phone rebooted and immediately showed me the LineageOS boot logo, and then a pop up asking me to wipe all encrypted data. I said yes, the phone rebooted to wipe the data, then rebooted back to LineageOS. Success!

One final note, when I started this process, the battery was at 100%, but by the time I finished, the battery was down to 67%, so be sure to fully charge the phone before you start this process, if you intend to follow along.

Linux – keep it simple.

Engineering Pie Build for the Sony Xperia XA2 Ultra!

So it’s been a rough start for me, stepping into the modern world with a modern phone that has a/b partitioning and was Android 8.0+. I’ve built dozens of roms for dozens of phones, some that were even unsupported, and to God be the glory, I was moderately successful, but these modern phones have been a different story. My first attempt with the Xperia XA2 Ultra ended up hard bricked. Then, I built a pie version of AOKP, which did boot, but would immediately crash after getting to the home screen.

Today, however, was off to a much better start. I successfully tested my engineering build of LineageOS 16.0 (pie) for my XA2 Ultra (discovery). Everything seems to work well, and you are welcome to try it out. Keep in mind, though, it is an engineering build as opposed to a user build. Also note that this is for the 50.1.x firmware variants.

Granted, a lineage build is already available, and most of the work was done by Luke. I like to compile a build on my own, though, to make sure my system is set up properly and that the source material does work before I get started on my own roms.

Now to get back to that AOKP build…. Or should I start on a Resurrection Remix build instead?

Linux – keep it simple.

Fixing my bricked Sony Xperia XA2 Ultra

a

The photo above is not a mirrored image, it is actually two distinct Sony Xperia XA2 Ultra phones.

Whether it is fishing or phones, it all has to start with a story. Unlike fishing, though, this phone story really does start out as a big whopper! I guess I should back track to the beginning….

I was researching a new phone for Mom, and found that the Xperia XA2 Ultra is a really, really great phone. Sure, there are reviewers that were not enthusiastic, and some that were ecstatic, but I really felt that this would be a great phone for my mom. And I think it is. In fact, I liked it so much, that I picked up a slightly used one for myself. All was well.

Then, I decided to ditch the stock rom and start working on some custom stuff, as usual. The first thing I needed to do was test a current custom rom someone else made to make sure things work, and that I understand what’s going on under the hood. That is where things went horribly wrong.

I was following a guide on XDA. Several users had a similar guide, so I figure it must be right. Unfortunately, it not only didn’t work, but following the guide to a “T” bricked my phone. Here’s where I got hung up:

1. Download latest firmware with XperiFirm.
NOTE: When using mono XperiFirm will fail to unpack the firmware, you can do it manually using following commands:

Code:
for f in FILE_*; do unzip $f; done
unzip boot.zip -d boot

2. Go to the directory where the firmware got downloaded to and remove following files:
– 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
3. Turn off your phone, hold vol dn and plug in the USB cable, the screen should be off and green LED lit.
4. Run Newflasher, it’ll flash entire FW to your current slot then unplug the USB cable and power on your phone.
5. Turn off your phone, hold vol up and plug in the USB cable, the screen should be off and blue LED lit.
6. Enter this command: `fastboot getvar current-slot`, it should return something like this:
current-slot: _b
Finished. Total time: 0.001s
7. Now switch to the opposite slot by entering command: `fastboot set_active a` if the current slot is `_b` or `fastboot set_active b` if its `_a`, you should see this:
Setting current slot to ‘a’…
OKAY [ 0.012s]
Finished. Total time: 0.014s
or
Setting current slot to ‘b’…
OKAY [ 0.012s]
Finished. Total time: 0.014s
8. Unplug usb cable and repeat steps: 3, 4
9. Profit?

At step 7, I was supposed to switch to the other slot. So I did, but when I unplugged the USB cable and repeat steps 3 and 4, it bricked the phone on the repeat of step 4. After that, it never booted up. All that happened when plugging it in or pressing any button combo was a triple blink of the green LED, and nothing else.

So, I made a post on the thread asking for help. But there was none to be found. Shortly after my post, others started posting as well. They all had the same issue. So, I take comfort in my misery loving company. Although I wish other’s phones had not also bricked, I was somewhat glad that I didn’t “mess up”, since several others following the instructions had the same results. What went wrong? I really don’t know.

The big question became, how do I fix it? I had about $100 invested in this useless paperweight, so I really wanted to turn a positive result. Thus enter ebay. I started bidding on phones with broken screens. I really just wanted to buy another main board, or motherboard for the phone, but I couldn’t find any suppliers. Eventually, I won a phone with a shattered screen.

The screen may have been shattered, but the phone still turned on and worked, so I simply disassembled the two phones (my brick and the one with the shattered screen) and swapped the main board! Now I had a working phone with the good screen, and I was back in business!

Next, I went about the process of installing Lineage 16 (pie) on the phone. According to the instructions, you have to update your phone to 50.1.A.13.123 to use this version of Lineage, but my phone was already 50.1.A.13.83, so I decided to try it as is, without updating the firmware. Praise God, it worked! So I was able to unlock the bootloader, boot TWRP, and flash LineageOS 16!

WARNING: This worked for me on software 50.1.A.13.83, but I don’t think it works if your software version is 50.2+! Try this at your own risk. I can’t promise that it won’t brick your phone.

Here’s what I did:

  • Went to Sony’s Unlock Bootloader section of their website and followed the specific instructions there to unlock the bootloader. You have to input your IMEI to generate a code that you use to unlock it in fastboot.
  • Downloaded TWRP for “discovery” (the nickname for XA2 Ultra).
  • Turned off my phone, held Volume up and plugged in the USB cable, which turned it on and put it in fastboot mode.
  • Typed fastboot boot ./twrp-3.2.3-0-discovery.img

fastboot boot ./twrp-3.2.3-0-discovery.img
downloading ‘boot.img’…
OKAY [ 1.431s]
booting…
OKAY [ 5.131s]
finished. total time: 6.562s

  • The phone rebooted into TWRP. I suggest making a backup at this point. I did, and copied it to my computer.
  • Download the latest LineageOS 16 (pie) rom for your XA2 Ultra. I used the 20190621 nightly, and it worked great for me.
  • Then, since I was ready to install LineageOS, select wipe, advanced, and wipe everything, then format data! Really important, if you don’t format data, you can’t boot lineageOS, as it will hang trying to unencrypt the data directory.
  • Still in TWRP, go to advanced, and select sideload.
  • On the computer, type:

adb sideload <name_of_lineage_zip.zip>

  • It will show a type of progress bar, and then will tell you when it is done. Don’t be alarmed if it “hangs” for a few minutes at the end, that was normal for me.
  • Reboot to system and enjoy LineageOS!

So, after a test run, I went back into TWRP, from fastboot, and flashed Magisk v19.3, and that worked great as well. I didn’t try Gapps, since I am actually going Gapp-less again. But that’s another post for another time….

Hopefully this was helpful for you. It was a lengthy process for me, and not optimal to say the least. If you do go this route, I will note that the Xperia XA2 ultra has been phenomenal for me. The battery life on Pie is incredible, the camera (that everyone loves or hates) is the best I’ve ever used, and I love it so far!

Linux – keep it simple.

Another example of a dirty fix….

[CODE] ninja: error: ‘/home/alaskalinuxuser/compile/build_lineageos/out/target/common/obj/APPS/ValidityService_intermediates/with-local/classes.dex’, needed by ‘/home/alaskalinuxuser/compile/build_lineageos/out/target/common/obj/APPS/ValidityService_intermediates/classes.dex’, missing and no known rule to make it make: *** [ninja_wrapper] Error 1 make: Leaving directory `/home/alaskalinuxuser/compile/build_lineageos’ [/CODE]

That was the error I received. I was trying to build LineageOS (the CyanogenMod replacement) for the TBLTEXX/TBLTETMO Samsung Galaxy Note Edge. There were several ways to fix this, but first let’s understand the problem a little better.

The isse is that the classes.dex file is missing from that location. What is it for? Well, in this case, it is for the ValidityService app. Note that it is under APPS, and ValidityService. Now you may ask, what does that do? Well, my limited understanding is that it is a nessessary component of the fingerprint sensor, for validating that you have the correct fingerprint.

So, what could we do to fix this? Well, we could edit the TBLTEXX device tree and remove the ValidityService folder, and remove the reference to it in the config files. That would definately solve the error issue, but then would prevent you from using the fingerprint sensor.

We could rifle through all of the files and see what is missing that needs to be built in order to make that work. This is the BEST option, but very time consuming.

Or, we could just copy the out/target/common/obj/APPS/ValidityService_intermediates folder from another sucessfull build, if we have one, which, as a matter of fact, I do, AOKP. So, I copied the folder over and continued with the build. No issues there! At least, not with the fingerprint sensor…. Now if I can only make a phone call with my cell phone.

Linux – keep it simple.