Xperia on Ubuntu (Udev rules, Flashtool, ADB&Fastboot)

2,513 posts
Thanks Meter: 655
Post Reply Email Thread
This is a thread written to try and get poor MilkyJoePD up and running with his Ubuntu build, but it should be of help to anyone.

First of all, what you need:

1) Any version of Ubuntu from 10.04 onwards, with superuser access. The upcoming LTS Ubuntu 12.04 will be a great idea when it comes out, as it'll be maintained for 5 years (so the instructions to install it there will be valid for all that time).
2) Your Xperia Play (or any Xperia phone actually).
3) A Micro USB cable to connect it.
4) An open mind about terminal emulators. They're useful because they allow you to do things quickly and cleanly, if you just know their syntax.

What will we be doing in this thread: we'll set up our Xperia Play so that it gets recognized properly by Ubuntu. In addition, we'll set up ADB and Flashtool, which are programs with which our Xperia Play can interact. Lastly, we'll cover how to summon the "adb" and "fastboot" commands from any point in the terminal, by adding them to the $PATH variable.

Setting up the Xperia phone: udev rules

Android devices don't need specific drivers to work in Linux: you can plug an Android phone and it will be recognised as a flash drive. However, if we want deeper levels of interaction, such as the ones which ADB, Fastboot and Flashtool provide, we have to set up udev rules. Long story short, udev rules allow us to give the proper permissions that these modes require without having to function as superuser the whole time (an undesirable state of things in Ubuntu). Much more about them can be found here for the curious minds out there.

But let's not get lost. We want to set up udev rules, so we'll do it. First of all, we need to know the following: a device connected while it functions normally is not "seen" as the same device when it's connected in the Flash or Fastboot modes. In order to identify it, we can run "lsusb" which lists all of the ports, and connected devices, in our computer.

So, let's connect a Xperia phone which is turned on. We don't have to mount the sdcard as a flash drive, just plug it in. Once you have done that, open a terminal and type
It will list you a boatload of devices, but only one of them is relevant to you right now:
Bus 00x Device 00y: ID 0fce:aaaa Sony Ericsson blah blah
The device is identified with two alphanumeric chains. The first one is the vendor ID, and the second one is the Product ID, which are the identificators we're going to use for the udev rules later on.
Let's switch off our phone, and plug it in "Flash" mode (hold the Back button while you connect it). Run "lsusb" again in the terminal again, and you'll find:
Bus 00x Device 00y: ID 0fce:bbbb Sony Ericsson blah blah
The Vendor ID is the same (0fce) for all Sony Ericsson devices, but the Product ID is different, as you can see. This is consistent with the idea that it's identified as "another" device.
The last part would be plugging the phone in Fastboot mode, holding the Search key while we plug the phone. Typing "lsusb" in the terminal again will give us:
Bus 00x Device 00y: ID 0fce:cccc Sony Ericsson blah blah
Which is, as we know already, a different Product ID.

Now that we have the device ID needed for the udev rules, we can write them. The most expedite way is to write in that lovely terminal:
sudo gedit /etc/udev/rules.d/99-android.rules
That means, we'll use the standard text editor (gedit) to create the file 99-android.rules in the /etc/udev/rules.d folder. If we visit said folder we'll find other udev rules created already, but they're not interesting for our task. Notice that we ask for superuser permissions with "sudo" as we need them to write or modify udev rules. Once we have put our password we'll find an empty text file. And now we just copy-paste the following syntax:
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0fce″, ATTRS{idProduct}==”aaaa″, MODE=”0666″
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0fce″, ATTRS{idProduct}==”bbbb″, MODE=”0666″
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0fce″, ATTRS{idProduct}==”cccc″, MODE=”0666″
In human language, this means "Give the devices that are connected through USB and which have the mentioned ID codes the permissions 0666 (read/write access), which need root access".

Once we've filled the gaps, we just save the file. After we close it, we have to type in the terminal "sudo restart udev" and we've taken care of that part. Rebooting the computer has the same effect, but it's a bit of overkill, really.


With the udev rules fixed, we can go to the next step, which would be using Flashtool. It is necessary to mention that unlike the Windows version, Flashtool doesn't need any installation of any kind in Linux, you just run the program (the file called Flashtool) and you're set. You have to download the Flashtool folder, uncompress it and run the program. The folder is compressed in .7z format: Ubuntu doesn't manage 7z packages "out of the box", but that's no problem: go to your terminal, type:
sudo apt-get install p7zip-full
and that should take care of it. If you're not familiar with that command, "apt-get install" is the way to install packages from your existing repositories in Debian/Ubuntu; installing software in Ubuntu requires superuser access, as I'm sure you know. p7zip-full is a package which adds 7zip support to the archive manager of Ubuntu.

I won't cover how to use Flashtool, since I already did so in this post. While I made the tutorial for an older version of Flashtool, the base functions are exactly the same as before.

Optional: ADB and Fastboot; setting them in $PATH

OK, now we're going to the stronger stuff: if you want to do a bit more than restoring official ROMs and flashing kernels you'll do well in using the ADB and Fastboot programs. They're part of the platform tools of the Android SDK. You can download the latest Android SDK here:

Once you've downloaded and uncompressed the Linux version of the SDK, go to the "tools" folder and run the "android" file (you need to mark it as executable first, in the properties). That file is the Android SDK Manager. Once it's running, you only need to install the SDK Platform Tools package. The rest are not necessary for our purposes.

Once you install the package, you'll notice that the folder where you unpacked the SDK is bigger. You'll find there the "platform-tools" folder, which contains adb and fastboot. You can run them from a terminal, but that requires you to have your terminal running in the exact folder where your /<Path/to/SDK> directory lies. This can get old really quickly if you use ADB and/or Fastboot frequently, so we'll do a trick that will allow us to summon them from any folder: we'll add them to our PATH variable.

In order to do this, we need to open a new terminal. It will start in our home directory. There is a file called .bashrc in our home folder that we need to tweak, so let's go to it. You don't see it normally, as it's hidden. All files which begin with a . in Linux will be hidden by default. You can see them in Nautilus by pressing Ctrl+H, and in a terminal by typing "ls -a". At any rate, this file is hidden because you usually don't need to touch it, but we'll do it here.

In our terminal, we write
gedit .bashrc
Again, gedit is the standard text editor in Ubuntu.

We see a lot of stuff we don't need to touch. We just need to go to the final line, after the word "fi" and write below:
# ADB and Fastboot direct link (this is a comment, so we remember what we did)
export PATH
We save the modified file, close any terminal we had left open, and now we can use adb and fastboot directly from any folder. Just connect your device with debug mode on for example, and type "adb devices": you should see the ADB identificator of your device.

And with that, I cover the installation guide of Xperia phones in the Ubuntu environment. I hope it's useful to everyone, particularly to MilkyJoePD who has inspired me to write it. If I've missed something I should have mentioned, by all means say it.
The Following 36 Users Say Thank You to Logseman For This Useful Post: [ View ] Gift Logseman Ad-Free
22nd April 2012, 08:08 PM |#2  
captain67's Avatar
Senior Member
Flag Aldergrove
Thanks Meter: 223
Donate to Me
Haven't used Ubuntu for a while but I'm taking note of this for later. Thank you for the info.

Sent from a Galaxy far, far away
26th April 2012, 05:06 AM |#3  
Junior Member
Flag Santa Maria
Thanks Meter: 0
Donate to Me
don't forget to install de dependencies:
sudo apt-get install libusb-1.0
on 64 systems, you need 32bits libraries, so run:
sudo apt-get install ia32-libs
25th May 2012, 09:03 PM |#4  
MilkyJoePD's Avatar
Senior Member
Thanks Meter: 190
With the news of Sony not releasing ICS, I decided to try again to get fastboot working.

While installing the dependencies, I get this:

W: Duplicate sources.list entry cdrom://Ubuntu 11.10 _Oneiric Ocelot_ - Release i386 (20111012)/ oneiric/main i386 Packages (/var/lib/apt/lists/Ubuntu%2011.10%20%5fOneiric%20Ocelot%5f%20-%20Release%20i386%20(20111012)_dists_oneiric_main_ binary-i386_Packages)
W: Duplicate sources.list entry cdrom://Ubuntu 11.10 _Oneiric Ocelot_ - Release i386 (20111012)/ oneiric/restricted i386 Packages (/var/lib/apt/lists/Ubuntu%2011.10%20%5fOneiric%20Ocelot%5f%20-%20Release%20i386%20(20111012)_dists_oneiric_restr icted_binary-i386_Packages)
W: You may want to run apt-get update to correct these problems

Where do I go from here?
1st June 2012, 12:57 PM |#5  
skeltonh's Avatar
Senior Member
Flag New Castle, PA
Thanks Meter: 13
Donate to Me
Remove CD-ROM reference from sources
Edit your sources and comment-out / turn off the references for the installation disk (CDROM/DVD). It should be the first thing you turn of after any install anyway. In my humble opinion.

Then run

sudo apt-get update
sudo apt-get -f install

this should resolve any pending issues and get you running.
4th June 2012, 02:56 PM |#6  
MilkyJoePD's Avatar
Senior Member
Thanks Meter: 190
Originally Posted by skeltonh

Edit your sources and comment-out / turn off the references for the installation disk (CDROM/DVD).

How do I do that?

Sent from my R800i using XDA
5th June 2012, 01:36 PM |#7  
MilkyJoePD's Avatar
Senior Member
Thanks Meter: 190
Or can somebody can tell me what it means so I can Google it?

Sent from my R800i using XDA
11th June 2012, 09:30 AM |#8  
IE-coRe's Avatar
Senior Member
Flag Güstrow
Thanks Meter: 182
I have a problem, when I try to use fastboot even in the platform-tools folder it says:
fastboot: command not found
12th June 2012, 09:12 PM |#9  
Logseman's Avatar
OP Senior Member
Flag Tenerife
Thanks Meter: 655
Donate to Me
On what OS? If it's Linux, you have to add a Dotslash to execute the file.

26th June 2012, 06:08 PM |#10  
Flag Bengaluru
Thanks Meter: 2
I have created udev rules as said above, but flashtool still says 'Add udev rules'.

What I am missing here. I'm using Ubuntu 12.04.
Any help is appreciated.
26th June 2012, 06:54 PM |#11  
Dexxmor's Avatar
Senior Member
Flag near munich
Thanks Meter: 712
Donate to Me
You must start flashtool with root acces
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes