Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,786,599 Members 38,534 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
Logseman
Old
(Last edited by Logseman; 22nd April 2012 at 02:45 AM.)
#1  
Logseman's Avatar
Senior Member - OP
Thanks Meter 637
Posts: 2,453
Join Date: Nov 2010
Location: Tenerife

 
DONATE TO ME
Default Xperia on Ubuntu (Udev rules, Flashtool, ADB&Fastboot)

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
Code:
lsusb
It will list you a boatload of devices, but only one of them is relevant to you right now:
Code:
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:
Code:
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:
Code:
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:
Code:
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:
Code:
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.

Flashtool

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:
Code:
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: http://developer.android.com/sdk/index.html

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
Code:
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:
Code:
# ADB and Fastboot direct link (this is a comment, so we remember what we did)
PATH=$PATH:/home/Path/to/SDK/platform-tools/
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 27 Users Say Thank You to Logseman For This Useful Post: [ Click to Expand ]
 
captain67
Old
#2  
captain67's Avatar
Senior Member
Thanks Meter 219
Posts: 1,067
Join Date: May 2011
Location: Aldergrove

 
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
Devices

LG Nexus 4 | Stock 4.2.2

Samsung Galaxy S II GT-i9100 | Wanamlite v14

Sony Ericsson Xperia PLAY | JokaWild 2.5 | DooMKernel v13 -Sold

Samsung Galaxy TAB 10.1 4G | Stock ICS -Sold

Firmware Collection for Xperia PLAY | Flashtool | JokaWild ROM | DooMKernel | SiyahKernel for GSII | CheckROM for GSII
 
williamwd
Old
#3  
Junior Member
Thanks Meter 0
Posts: 3
Join Date: Feb 2012
Location: Santa Maria

 
DONATE TO ME
don't forget to install de dependencies:
Code:
sudo apt-get install libusb-1.0
on 64 systems, you need 32bits libraries, so run:
Code:
sudo apt-get install ia32-libs
 
MilkyJoePD
Old
#4  
MilkyJoePD's Avatar
Senior Member
Thanks Meter 168
Posts: 905
Join Date: Oct 2011
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?
 
skeltonh
Old
#5  
skeltonh's Avatar
Member
Thanks Meter 7
Posts: 49
Join Date: Oct 2010
Location: Lewes, DE

 
DONATE TO ME
Default 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.
 
MilkyJoePD
Old
#6  
MilkyJoePD's Avatar
Senior Member
Thanks Meter 168
Posts: 905
Join Date: Oct 2011
Quote:
Originally Posted by skeltonh View Post
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
 
MilkyJoePD
Old
#7  
MilkyJoePD's Avatar
Senior Member
Thanks Meter 168
Posts: 905
Join Date: Oct 2011
Or can somebody can tell me what it means so I can Google it?

Sent from my R800i using XDA
 
IE-coRe
Old
#8  
IE-coRe's Avatar
Senior Member
Thanks Meter 178
Posts: 1,296
Join Date: Mar 2011
Location: Güstrow
I have a problem, when I try to use fastboot even in the platform-tools folder it says:
fastboot: command not found
Samsung M1 -> Motorola Defy->Xperia Play->Xperia Sola->HTC One!!

Running:
 
Logseman
Old
#9  
Logseman's Avatar
Senior Member - OP
Thanks Meter 637
Posts: 2,453
Join Date: Nov 2010
Location: Tenerife

 
DONATE TO ME
On what OS? If it's Linux, you have to add a Dotslash to execute the file.

Swypesation
 
JnkPanchal008
Old
#10  
Junior Member
Thanks Meter 1
Posts: 27
Join Date: Dec 2011
Location: Bengaluru
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.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Try to Keep Up with Just Swipe Game

Sometimes, the simplest of games are the ones that end up beingthe most addictive and end up consuming … more

MultiROM Ported to the Moto E

Few categoriesof Android development are as intrinsically interestingas the ability to boot into multiple … more

XDA Xposed Tuesday: How to Control Google Play Wake Locks – XDA Developer TV

Xposed Modules are usually pretty simple. There are a few … more

Make Text Entry More Efficient with Macro Text Expansion

One of the best things about the modern day smartphone is its ability to save us … more