Powered By Blogger

30 January 2011

Unlocking my Nexus S - on Ubuntu

WARNING - unlocking will wipe your user data - settings, apps, all the stuff you lovingly created "just so" on your groovy new phone. If you have not done so already, back it up all that good stuff with one of the many backup tools out there and/or create a google account to ensure all your useful data (contacts, email, etc) are safely sync'd to the cloud.

I have used these instructions on Ubuntu 10 and 11, they probably work on earlier versions (why haven't you upgraded?!) but make use of google and the man pages to see what "bumps in the road" you may hit.

I assume you have previously installed adb as part of the Android SDK - note it has moved to platform-tools now

Get fastboot from http://android-dls.com/files/linux/fastboot

Connect phone to Ubuntu via USB cable

su

lsusb

will show a list including these identities  - but, oddly, no description/name information, it may be another set of values entirely, I noticed it sometimes appeared as one of these two:
:
:
Bus 001 Device 044: ID 18d1:4e22
Bus 001 Device 044: ID 18d1:4e20
:
:

I now know 18d1:4e22 is the identity when android has booted, and 18d1:4e20 is the identity when in the boot loader. Doh!

Now edit this information a rules file:

vi /etc/udev/rules.d/51-android.rules 

Many posts suggested differing prefixes 70, 90 instead of 51, but it seemed to make no odds - man udev to explore options

Edit in two lines :

SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", ATTRS{idProduct}=="4e22", MODE="0666", OWNER="user", GROUP="plugdev"

SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", ATTRS{idProduct}=="4e20", MODE="0666", OWNER="user", GROUP="plugdev"

Replace user with your uid.


plugdev is a group of which you need to have membership - type groups from command line, as your uid, to see what groups you have - man groups for help

18d1  - vendor id from lsusb
4e22/4020 - product id from lsusb

Other vendor codes are documented here

Now ensure correct perms on the rules file we made earlier:

chmod a+rx /etc/udev/rules.d/51-android.rules 

Restart adb server as root - I made a simple init.d service to make adb daemon restart easier but the 
basic commands (if running as root and in the directory where you installed adb) will be:

./adb kill-server
./adb start-server

output something like:

* daemon not running. starting it now on port 5037 *
* daemon started successfully *

then try 

./adb devices

should get something like:

List of devices attached 
3931B6CB90EC00EC device

if you get output like:

List of devices attached
????????????    no permissions 

you need to check the permissions on the rules file are like:

-rwxr-xr-x 1 root root   111 2011-01-30 15:50 /etc/udev/rules.d/51-android.rules

and that you started the adb server as root

so now we can set the phone to the bootloader and try to run fastboot - this one you can do as your own user id

./adb reboot bootloader 

should give a basic screen with an android logo and some details about the phone, version etc 
and some choices that can be actioned via the hard keys. Should be saying FASTBOOT MODE at the top of the screen.

as root issue:

./fastboot devices

should see:

3931B6CB90EC00EC fastboot

if nothing happens you have configured incorrectly, and no results will return.

Now you can unlock, do this as root:

./fastboot oem unlock

The phone will prompt you to check this is really what you want, and then will do you bidding.

Reboot the phone and set it up as require.

If you subsequently reboot to the bootloader you will see the lock state as:

LOCK STATE - UNLOCKED






No comments:

Post a Comment