Rooting the Samsung Alpha 5 (sm500fu) using Linux

TWRP

The time finally came when I needed to fiddle with my phone. You may wonder what on earth can be done with phone? Most are now sealed mono-units and even with a terminal emulator App the commands for Linux (which is underneath Android) don’t work….or do they?

As we know from Linux we need to invoke the magic word ‘sudo’ or ‘su’ to enable commands to run or to bring us the information we’re requesting, the same is true for Android but how do we do this? Typing SU into a suitable App won’t get us anywhere because an out-of-the-box phone is not ‘rooted’. To us in the Linux world we understand this meaning, to be root, in the Microsoft realm it’s called ‘administrator’. This in it’s self is the fundamental difference between Linux and Windows. On a Linux OS we’re always outside root, or as a ‘guest’ for Windows, however most windows PC’s run as admin all the time and hence the ease with which they can be hacked or infected.

So to get this mythical root access we’ll need to change some of the code of Android, we’re going to exploit a security bug in Lollipop to give us this root access. This is normally easily done by flashing (writing) a custom recovery which contains a suitable patch to grant root. Recovery is a bootable menu which allows you to load new software, to do a factory wipe or repair your OS – hence recovery. I’ll be using a modified TWRP from TheWhisp on XDA, others are ClockworkMod and Philz-recovery. Now I mentioned ‘this is normally easily done’ but some manufactures such as Sony, Asus and HTC ‘bootlock’ their phones and that’s a whole different hurdle to overcome in another post, in the case of Samsung they have a clever trick to make this hard, the stock Samsung ROM sees that the system folders have been modified and overwrites them to stock at boot rendering your hard work useless! Buggers!

Well that’s fine and dandy but I want root access, I want to remove all that bloatware that Samsung thinks I’ll need, I want to fiddle with my brand new phone and make it mine! We’re going to be rooting a Samsung Alpha 5 (SM500FU) using Linux (so no Odin) but the overall process remains similar for any Android device, you will need to read up on specific tricks or software needed for your device, the XDA forums are a great source. So let’s start:

The first thing is to read up fully on your device, there may be issues like bootloops that can be easily avoided, patches to solve issues and of course the latest revisions. For the Alpha5 we know about the OS overwriting the recovery.img, that as of 10th Dec 2015 our modified TWRP won’t give us root, WHAT?! but that’s the point of all this! Yes, but thanks to Chainfire we can flash superSu from our shiney new custom recovery to gain it….don’t worry.

First charge your phone to 100% just good practice. We’re going to need Heimdall (Odin for Linux) and I run it from the command line as it’s quicker and simpler, I compiled mine from GIT (source) to get V1.4.1:

 sudo apt-get install git

apt-get install build-essential cmake zlib1g-dev qt5-default libusb-1.0-0-dev libgl1-mesa-glx libgl1-mesa-dev

git clone git://github.com/Benjamin-Dobell/Heimdall.git

mkdir -p Heimdall/build

cd Heimdall/build

cmake -DCMAKE_BUILD_TYPE=Release ..

make

sudo cp bin/* /usr/local/bin

And finally to check it works: sudo heimdall-frontend which we can close now we know it’s all working.

Now we need the correct recovery image which will be a .tar file, I got mine HERE, put it somewhere you can find it again. If the file ends ‘.tar.md5’ rename it without the ‘.md5’ so that Archive manager can open it. Now extract the recovery.img and open a terminal in the folder which contains the recovery.img We now need the SuperSu.zip file from HERE, this file needs to be copied onto your external sdcard, don’t put it in a folder just straight onto the card on it’s own. Once that’s done power-off your phone and unplug the USB.

Thanks to the Alpha5 and Heimdall both being picky the following is the way I got my PC/Heimdall/Alpha5 to talk to each other. This seems to work regardless of which USB I was plugged into:

With our terminal still open in the folder with our recovery.img in:

sudo heimdall detect this will return that no device can be found or detected and is a final check that Heimdall is available.

Connect your phone. Press and keep holding the Volume-down+Home+Power buttons all at the same time until the phone vibrates, then release all the buttons and you will enter a screen warning you that you’re up to no good, ignore this and press Volume-up to enter ‘download mode’, now in the terminal:

heimdall flash –RECOVERY recovery.img –no-reboot

And WAIT………………….there should be an output in the terminal saying things like ‘downloading PIT file’, if successful it will end by saying it’s reattached the kernel and returns you to command prompt (the :~$ sign). On the phone there will be a progress bar moving across the screen, wait until it’s finished moving and then I like to wait a little longer to make sure the write has been completed before doing:

Press and hold the Volume-up+Home+Power buttons without releasing until the phone buzzes and enters our spanking new custom recovery. At this point and after several hours there was much cheering and rejoicing……….Do a full backup. Really, do a full backup!

Now at last for the point of the exercise, Root access. Still in recovery go to ‘install from zip’ and open up your external sdcard and select the SuperSu.zip file, hit install or with TWRP ‘swipe to confirm’ and hey presto root! Now reboot system to start deleting all those annoying apps you never wanted, well actually the first thing you’ll need is a superuser app to grant and manage root access, I use this one.

Now the caveats – If you’re going attempt to root your phone I’d like to assume you know you’re way around basic computing. Read up. It worked with my phone (SM500FU running stock 5.0 Lollipop) and desktop (debian based latest), yours will be different. Be prepared that when it all goes wrong (it will at some point) you will be in a world of hurt, but don’t panic, stop and google without touching your phone. During this process I ended up for a while with no recovery at all! Couldn’t find anything or anyone else who’d had the same, but I calmly retraced my steps, compiled Heimdall from source and through trail and error got Heimdall to ‘talk’ to my phone again resulting in the process above and a happy rooted phone.

At some point I’ll flash a custom ROM and will write and tell y’all about it, happy flashing!

Advertisements

Finger prints on my gadgets

handprint-crop

It’s something almost all of us have, a touch screen device. Almost all mobile phones now have a touch interface of some description that we daily poke at with our grubby fingers. Even if your fingers are particularly clean right now they are still producing sweat and oils which get all over the screens of our devices each and every time we glide our finger over them.

Most middle to high end phones (Samsung S series, iphone etc) have a factory applied oleophobic coating, a mixture of chemical compounds which repel oil, they decrease the amount of fingerprints visible on the screen. This coating doesn’t stop them altogether, but it reduces the amount and makes wiping them off far easier.

All well and good then? Yes, for a bit. This oleophobic coating is just a coating applied to the screen after manufacture, it doesn’t last forever, Gorilla Glass or Dragontrail it wears off dependant on the use your screen sees. My trusty rooted Samsung S2 came with this coating, I can now see that the center of the screen (which has taken a beating from my digit) attracts more fingerprints than the outer edges of the screen as the oleophobic coating has been worn off.

I’m not obsessed about having a perfectly clean screen, but I also don’t like the smeared look! I also don’t like screen protectors, why have super-tough glass covered by a bit of plastic……………. There is a Japanese company which is now making an oleophobic coating which can be applied to any glass touch screen. Made by Fusso it can last between 3-6 months, but it’s not cheap, at about $25 per kit. Another online ‘tip’ is to coat your screen with Rain-X, however Rain-X is hydrophobic, or H2O repellent, it’ll keep the rain off at least!

As ever I want it NOW, I want it better and I want it cheaper. This issue is not directly linked to my good old S2, but for my new Xperia Z1 Compact which comes with a crappy piece of plastic over my Dragontrail screen. Yes i’m aware that this ‘crappy piece of plastic’ is actually an anti-shatter film (ASF), but really Sony? (I hear the Z2 is finally free of an ASF on top of the screen at last). If I drop my phone from high enough it’s going to get bust, most likely the screen, with or without the ASF it’s a $200 repair. So now thats off and I have a nice clean Dragontrail screen which feels great, it’s getting covered in fingerprints, there’s no oleophobic coating…………

To find a solution without paying $25 we need to know what makes a good oleophobic coating. Well we need a/or a composition of compounds that are not soluble in Lipids, or fats. If the compound is not soluble in our chosen solvent (or liquid) it will naturally be phobic to it, or repel it. The cheapest is water (we all know oil and water don’t mix), fine for my Z1 to be drenched in water but not my S2! Fluorocarbons are the next (basically Fluorine and Carbon combined), great……….where do I get those then? Actually they are probably in your kitchen right now, it’s almost a household name, it might have helped you cook today, Teflon. Teflon is a Fluoropolymer, or a solid version of Fluorocarbon, that’s why your bacon doesn’t stick to the frying pan. As a long lasting polymer applying this involves some chemistry and high heat which is not very DIY, or phone friendly. An easier solution would be to buy Teflon as a wax or liquid thats easy to apply, well there are products used on skis and snowboards which contain Fluorocarbon, or liquid Teflon. These are $10-$15, but I think theres a cheaper way – PTFE tape. Polytetrafluoroethylene to be exact, this is used mostly in plumbing to wrap around threaded joints to stop leaks. So we have Fluorene bound as a polymer with ethylene (a hydrocarbon) to form a soft pliable tape, Teflon-tape! (Except ‘Teflon’ is owned by Dupont who don’t make tapes, hence why it’s called PTFE tape not Teflon-tape)

So the process:

Make sure your screen is really clean, having brought a roll of PTFE tape for about 50c, rip a length off and wrap it around your finger, now gently rub the tape over the screen always in the same direction, keep changing through 45 degrees. This will leave streaks and bits of PTFE tape on the screen which is what we want, it’s leaving an extremely thin layer of fluorocarbon behind. Now a light squirt of cleaner gently removing it then a buff-up using a microfibre cloth. Keep repeating to slowly build the layers up, an almost free oleophobic coating!

Fingerprints are now drastically reduced on my ‘naked’ Z1 Compact, those that do get on are easily cleaned by breathing on the screen and wiping it. Feel free to comment especially if you have a great finger smudge removing tip!

EDIT: In my ongoing search for cheap oleophobic coatings i’ve also discovered silicone based water proofing spray (such as Fabsil) to work rather well, it’s far quicker to apply than PTFE tape. Simply spray a small amount onto a cloth, wipe over the screen, leave for a bit then polish off using a microfibre cloth.

Image here