Linux Mint - Free and powerful

Friday, 19 July 2013

[How-to] Setting up MTP for Xperia ZL on Ubuntu - xda-developers

[How-to] Setting up MTP for Xperia ZL on Ubuntu - xda-developers:

'via Blog this'

XDA Developers Android and Mobile Development Forum
Hi all,

I've been tinkering around trying to get mtpfs to work properly and get mtp services working in Ubuntu for my Xperia ZL (Bell C6506 4.2.2 android)

Here's where I'm at so far:
Linux can recognize the device and automatically mounts it now.
Rhythmbox can detect it, but I haven't tested sync features, but I did notice it couldn't automatically detect my music libraries. It obviously doesn't autodetect their locations and is possibly only looking for them in a certain place. 
I'm also worried if I try to sync with rhythmbox, that it will erase data on the SD or worse, the internal. 

Don't give me credit for any of this, I pulled all my info from various sources online, mostly from webupd8.
My steps:
Create a directory that we can mount the device to. Open up a terminal and type:
Code:
sudo mkdir /media/xperiazl
I never had to use chmod, but if you wanna make sure permissions are right, do a quick google search on how to set permissions with chmod. I think it's more important if you have multiple users on the one computer, but I'm the only user on my PC.

Next, install go-mtpfs through the ppa provided by webupd8
go-mtpfs is a Ddebian package that manages the filesystem used by the mtp protocols. It should work on any Debian distro, but I only work in Ubuntu 13.04 so I haven't tested anything else.

Code:
sudo add-apt-repository ppa:webupd8team/unstable
sudo apt-get update
sudo apt-get install go-mtpfs
But go-mtpfs isn't enough on it's own, because it doesn't autmoatically detect the Xperia ZL (it is supposed to detect nexus devices, etc. automatically though)

Next you need to edit a script file in the udev folders, to tell linux how to recognize the phone; or theoretically any other MTP devices.
If you want to know about udev and the files you're editing, go to /etc/udev/rules.d/ and look for the readme document inside.

Code:
sudo gedit /etc/udev/rules.d/51-android.rules
I use the code below to set the parameters for recognizing the Xperia ZL, specifically while it's in MTP, with USB debugging enabled.
With debugging disabled you have a different product ID (labelled "ID_VENDOR_ID" in the code below). You could just duplicate the code and have two entries then, one for usb debugging on, one for when it's off. 

FOR NON C6506 / Xperia ZL device users:
When looking at the below code, notice the idVendor tag and the idProduct tag in the first unhashed line of code. These numbers are specific for the Xperia ZL (possibly specific to the C6506, I never looked into it). If you're setting up auto-mount for another device, use the following function in the terminal:

lsusb

lsusb gives you a readout of all the usb devices attached to your computer (that linux can detect). The readout looks kind of like this:

Bus 002 Device 055: ID 0fce:5189 Sony Ericsson Mobile Communications AB

That's the readout at this time for my Xperia ZL. The 0fce is meant to be handled by idVendor or ID_VENDOR. The 5189 is meant to be handled by idProduct or ID_VENDOR_ID. Again, remember that your idProduct or ID_VENDOR_ID is different when usb debugging is off / on. 

Ok, we're almost there! C6506 users, just copy the code below and replace YOUR_USERNAME with... well, your username.
All other users must replace the product ID and Vendor ID with their own device's values.

Code:
# Sony XperiaZL idProduct="0189" for usb debug off, and idProduct="5189" for usb debug on
SUBSYSTEM=="usb", SYSFS{idVendor}=="0fce", ATTR{idProduct}=="5189", MODE="0777" #MTP media, USB debug on

# Xperia ZL MTP mode under JB 4.2+ : automatic mount & unmount whel plugged (usb debug on & off)
SUBSYSTEM=="usb", ENV{ID_VENDOR}=="0fce", ENV{ID_VENDOR_ID}=="5189", ACTION=="add", RUN+="/usr/bin/sudo -b -u YOUR_USERNAME /usr/bin/go-mtpfs -allow-other=true /media/xperia"
You will often run into errors and other random problems if you try to mount with the screen off (or at lockscreen). If you're gonna do lots of file transfers, I suggest jumping into your phone's developer options and turning on "stay awake" so the screen stays on while it's charging. That'll prevent loss of permissions in the middle of a file sync.

If there are any linux experts, could you help point out any faults in my code? I'm pretty sure its all good actually and that all the rough edges are linux issues with mtp, since it's not supported as well as it could be. 

Anyways, thanks for reading, I know I'm not the best at teaching this but hopefully this helps someone else out who's been struggling with linux and MTP protocol.

1 comment :

  1. Hi.
    I'm from Brazil and can't make install this rom in my Xperia XL. Do you can send me the "step by step"?
    Great.

    ReplyDelete

Thank you for taking the time to comment. Your opinion is important and of value and we appreciate the positive feedback! If you are "Negative Nancy" then please do us, and humanity, a favor, and piss off.

Total Pageviews

Google+ Followers

Pages

Blog Archive

Popular Posts

Recent Comments

Rays Twitter feed

Ads

Web sites come and go and information is lost and therefore some pages are archived. @rayd123. Powered by Blogger.