[Xperia Play Q&A, Help & Troubleshooting] Logseman:
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

lsusb

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.

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:

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

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)
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.