출처: http://antonmelser.org/open-source/backup-install-restore-adp1.html


안드로이드 개발폰(ADP1)에서 백업,설치,복구 하는 방법


주의: 이 지침서는 안드로이드 개발폰에서만 적용되고 G1 폰이나 다른 안드로이드 단말기에서는 지원이 안됨

제 1장 필요한 도구 준비하기

1. 안드로이드 소스 컴파일

    다음 링크를 참조: http://source.android.com/download

우분투에서 설치 방법

$ sudo apt-get install git-core gnupg sun-java6-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

여러분의 홈 디렉토리에 ~/bin 디렉토리가 있고 패스에 포함되어 있는지 확인
$ cd ~
$ mkdir bin
$ echo $PATH
(if it's not then add it to .bashrc then $ source .bashrc)

Download the repo script and make sure it is executable:
$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo

Ok, now we have the tools, we need to get  the source. And don't worry, this takes a LONG time - it's over 2GB, so unless you have a fibre link, you're in for a very long wait.

$ mkdir mydroid
$ cd mydroid
$ repo init -u git://android.git.kernel.org/platform/manifest.git

If it asks you for things, then answer as you like - they don't need to be true (except maybe a valid google address) but to be honest you're not risking much... then

$ repo sync
(this is what takes the time)

When that finally finishes there are a few binary-only files you need to copy from the phone. Here are the instructions copied from here:

  1. (we've already done step 1)
  2. download local_manifest.xml here
  3. put local_manifest.xml in the .repo directory (next to the main manifest.xml)
  4. repo sync (to download the three new projects)
  5. in vendor/htc/dream/ there is a script that must be run (from that directory) to extract some proprietary binaries from your device.*
  6. create a buildspec.mk at the top of your source tree and add TARGET_PRODUCT:=htc_dream to it
  7. (we do this straight after)

$ make 

  시간이 많이 걸리니 낮잠 때려도 좋을듯


이 과정이 끝나면 여러가지 이미지들과 유용한 툴(fastboot)이 같이 생성된다.


2. 안드로이드 SDK 설치할 것: (나중에 다 필요함)
    
    참고 http://developer.android.com/sdk/1.5_r3/index.html

3. 수정된 recovery.img를 받을 것

    참고: http://forum.xda-developers.com/showthread.php?t=466174

    ADP1 버전을 받을 것


제 2장 ADB1 의 설치된 파일 백업하기


4. ADP1을 fastboot모드로 설정하기



Backup/install/restore Android on an Android Developer Phone 1 (ADP1)
I bought and ADP1 on the 4th of January, and was keen as mustard to compile the latest and greatest from source. Having read around the place that it wasn't particularly stable or useable, I naturally wanted to be able to restore the default settings to get back a useable phone. So I head over to source.android.com looking for instructions. Great, they've got instructions for building for the dream (ADP1 hardware) but absolutely NOTHING for backup or restore. So I thought, oh well, Google Is My Friend... but no, on this occasion, Google was not my friend.

I found multitudes of info, mainly from the excellent xda-developers forum but came across something very frustrating - instructions for modding/cracking (+ doing what I wanted) the T-Mobile G1, with not so helpful "works with the ADP1" tacked on for good measure. All the info was there but it was all but clear what I needed to do, as I ALREADY have root access, and no OTA (Over The Air, took me a while!) updates were going to de-root me. I wanted to install/change the absolute minimum - after all, I paid over 400€ (I'm living in France, around 560$), and it's a developer phone - why should I have to install recovery.img/update.zip/? What's more, there werre always infuriating: "Step 4. Click here and follow instructions", only to find a "Step 3. Click here for instructions" in the second list, and so on! So I finally posted on android-discuss, and the very helpful lbcoder provided me with great instructions. His original instructions are here but here I will be augmenting them with explanations - my goal here is to provide clear and concise instructions for people who have an ADP1 and want to test it out and revert and are sick of having to sift though t-mobile-g1-specific crap. I also got quite a bit of knowledge from the posts made by Koush, including here.

A final word of warning  -

IF YOU HAVE A T-MOBILE G1 OR ANY OTHER SIMLOCKED VERSION THESE INSTRUCTIONS ARE NOT FOR YOU.

That felt good! So here goes... These instructions worked for me - YMMV. I am running a fairly standard Debian Lenny x86 (on an Athlon X2, which is x64, but anyway) but these instructions should be ok for any recent debian-based system. You should be fairly knowledgeable about linux and happy with the command line. These instructions may not work for non-debian systems, probably won't for Mac, and DEFINITELY won't work for windows. I am not interested in either of the later systems, so don't ask for help for those systems.  I'll try to do as much hand-holding as possible but if you're not comfortable with linux or the CL, then I can't help. You shouldn't need ANY android-specific knowledge - if you know linux and things aren't clear, I'll update the article. You should also have had a bit of a play with the stock install of the phone and know how to set it up and turn it off... I intend updating this article with more explanations of the various parts of android internals as I learn more, so stop back and have a look if you haven't become a guru in the meantime.

Standard disclaimer: I will be in no way, shape, or form be held responsible if the instructions don't work for you or brick your phone!

The backup will be smaller if you get rid of all the pictures/movies/music/random apps you have installed, so get rid of as much as possible (you can always put it back later...).

Part A - downloading the necessary files/programmes/code.

1. Get the android source and compile.
Here is an abbreviation of the instructions mentioned here.The linked site (android) has more explanation.

$ sudo apt-get install git-core gnupg sun-java6-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

Make sure you have a ~/bin directory in your home directory, and check to be sure that this bin directory is in your path:
$ cd ~
$ mkdir bin
$ echo $PATH
(if it's not then add it to .bashrc then $ source .bashrc)

Download the repo script and make sure it is executable:
$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo

Ok, now we have the tools, we need to get  the source. And don't worry, this takes a LONG time - it's over 2GB, so unless you have a fibre link, you're in for a very long wait.

$ mkdir mydroid
$ cd mydroid
$ repo init -u git://android.git.kernel.org/platform/manifest.git

If it asks you for things, then answer as you like - they don't need to be true (except maybe a valid google address) but to be honest you're not risking much... then

$ repo sync
(this is what takes the time)

When that finally finishes there are a few binary-only files you need to copy from the phone. Here are the instructions copied from here:

  1. (we've already done step 1)
  2. download local_manifest.xml here
  3. put local_manifest.xml in the .repo directory (next to the main manifest.xml)
  4. repo sync (to download the three new projects)
  5. in vendor/htc/dream/ there is a script that must be run (from that directory) to extract some proprietary binaries from your device.*
  6. create a buildspec.mk at the top of your source tree and add TARGET_PRODUCT:=htc_dream to it
  7. (we do this straight after)

$ make 
(this could also take hours)

Both of the very long commands are quicker for subsequent update/compiles, but still take an age. The compile also generates a tool that we will be using quite a bit (in mydroid/out/host/linux-x86/bin/) - fastboot. This wee gem lets you do lots of cool stuff but more on that later.

2. Get the android sdk.
The sdk has some very useful tools for interacting with a running android system, and that includes your new ADP1 phone. Download it from here. Extract to somewhere useful. I've seen a lot that the tools directory of the SDK needs to be in your $PATH, but haven't actually found that to be true - it can't hurt though.

3. Get your hands on JF's (JesusFreak) modified recovery.img. Calm down! I know it's an xda-developers link but it's just for the download (1GB goes very quickly when you post 30MB files...), the only thing you need to read is for finding the link for the ADP1 version. http://forum.xda-developers.com/showthread.php?t=466174. Download the ADP1 version! If he has already updated the post and the version has changed (and you want to follow these instructions to the word, but subsequent versions are probably better) then drop me a line and I'll post the file here. You need to extract the archive (and remember where you put it) - recovery.img is at data/recovery.img.

Part B - Backing up your phone. 
Ok, so that was easy - we've done nothing unusual, it's all standard linux stuff. Now we get to plug in the phone... 
Before you start getting worried, the xda-developers file we downloaded is NOT going to be installed to the phone. We use it like you would a livecd (or SystemRescueCD, or whatever). It boots us to a minimal, non-running system in memory so we can backup without having all those temp files (think /proc, /dev, etc.). This is done with help from the fastboot binary we compiled in step 1.

4. Start your ADP1 in fastboot mode: From power off, hold the camera button while turning on (keep your finger on the camera button, then press on), this will get you into a mode that says "serial0" with androids on skateboards. Plug in the USB (wait for a bit) and press the "back" button. It should now be in fastboot mode, and instead of "serial0" it will say "fastboot". Try the back button a few more times (and wait a few seconds in between) if you don't see fastboot straight away.

5. From your computer, run the command "fastboot boot recovery.img". This will send recovery.img to your ADP1 WITHOUT writing it and will cause it to boot. For me (and others on debian-based systems, as I've read), fastboot doesn't work unless you're root (something to do with standard permissions on USB devices mounted automatically). Now cd into the data directory you got from the JF download in step 3. Presuming your username is "me", and you put the android source in ~/mydroid you should execute something like:
$ sudo /home/me/mydroid/out/host/linux-x86/bin/fastboot boot recovery.img

As sudo is broken on debian, you'll need to put the full path in each time (putting it in your path, even if you are in the sudo group it doesn't work).

6. When the recovery.img has finished booting, it presents a menu, one of which is to create a backup. The backup will be written to the sdcard in the /nandroid/ directory. It should tell you the backup was successful. You should now reboot your phone (another menu option), and mount it, so you can copy the backup to your computer (or like me also to some online storage!). 

Part C - Installing from the compiled source.
You have already compiled all the necessary image files, so here we go...

7. get to where the installable images were created

$ cd ~/mydroid/out/target/product/dream

8. Boot your phone to fastboot, like we did in Part B, 4. You should then execute the following commands and get similar output (the file sizes will change):

me@debian:~/mydroid/out/target/product/dream$ sudo /home/me/mydroid/out/host/linux-x86/bin/fastboot flash system system.img
sending 'system' (51086 KB)... OKAY
writing 'system'... OKAY
me@debian:~/mydroid/out/target/product/dream$ sudo /home/me/mydroid/out/host/linux-x86/bin/fastboot flash boot boot.img
sending 'boot' (1418 KB)... OKAY
writing 'boot'... OKAY
me@debian:~/mydroid/out/target/product/dream$ sudo /home/me/mydroid/out/host/linux-x86/bin/fastboot flash userdata userdata.img
sending 'userdata' (2 KB)... OKAY
writing 'userdata'... OKAY
me@debian:~/mydroid/out/target/product/dream$ sudo fastboot reboot

You should now be booting to a source-compiled system! You'll need to rerun the registering process (which you've already done) but you can now do it at a later time than first boot.

9. Have a play, on 2009-01-25 there we still lots of things broken and/or missing. I've seen lots of talk of a "cupcake" release being pushed to T-Mobile users some time before the end of Feb. but with the state of the source, I can't imagine how...

Part D - Reverting to your stock image.

10. So now you want to get back to what you had before. First thing you need to do is get to where your backups are, let's say they are in /home/me/HT848GZ40218/20090121-1931, though you will have something slightly different (the date, for sure, the machine name maybe):

$ cd  ~/HT848GZ40218/20090121-1931

 Now simply execute the same commands you did to install the source (output from fastboot omitted, if you don't get output, IT DIDN'T WORK):

$ sudo /home/me/mydroid/out/host/linux-x86/bin/fastboot flash system system.img
$ sudo /home/me/mydroid/out/host/linux-x86/bin/fastboot flash boot boot.img
$ sudo /home/me/mydroid/out/host/linux-x86/bin/fastboot flash userdata userdata.img
$ sudo /home/me/mydroid/out/host/linux-x86/bin/fastboot reboot

The data image could be called data.img and not userdata.img. If that is the case, then just change the .img filename and not the partition to flash - it still needs to be $... flash userdata data.img.

 You should now have everything restored to normal. It may not be EXACTLY like it was before but all my apps and config were restored and working, and that's all I cared about.You can also use these instructions to try out other people's images/compiling. I tried out this (which didn't work for me), and this (which did, and was pretty good). Simply extract the archives and run the "fastboot flash system system.img", etc.Then fastboot reboot, play, and revert to your stock backup.

Feel free to drop me a line (in About Me) if you find any errors (or take real offense to my blatant plagiarism!) in this document...

Random advice/comments:

1. I had the google apps (gmail, contacts, calendar) stop syncing at one point. It seemed to happen when I went out of my provider's area (from France to Spain) with no roaming. Rebooting the phone solved this.

2. I've had a few emails from people commenting on their experiences and would like to thank everyone for their input on the article. One in particular gave some comments on getting a build to work properly. I initially thought about posting the comments but then realised it would be a mistake... We're at the bleeding edge of android development here, and one commit could render the advice useless. I DO definitely think that if you are having any problems with building and/or modules functioning (or not), then always search for the latest google groups posts by JBQ. He's a googler, and seems to be interested in making life for us ADP1 owners interesting by both committing code to get things to work, and providing advice and workarounds.

3. Now you can install the (almost, see article) Official upgrade from Google! See here for instructions!

Posted by kevino
,