Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

Nandroid v2.0 - Full NAND backup and restore tool (tried and tested!)

OP infernix

16th December 2008, 12:41 AM   |  #1  
OP Member
Thanks Meter: 53
 
95 posts
Join Date:Joined: Oct 2007
* What is Nandroid Backup v2.0?
Nandroid Backup is a set of tools and a script that will enable anyone who has root on their G1 and has the engineering/dev spl bootloader [1] (or has a dev phone) + a recovery image with busybox and adbd running as root [2] to make full system backups. These can then be restored using the fastboot [3] commandline tool and your phone in SPL/bootloader mode (hold camera + power). This allows you to create regular backups of your entire phones NAND flash so that you can restore a backup when something breaks. Its backup method works on a level that allows you to completely break, wipe or corrupt any or all partitions and still restore the phone to a working state within a few minutes. This works great for those who use their G1 for normal activities but also want to test their ideas which might break the phone, or when not having an extra G1 to keep purely as a development phone.

* Requirements for use
- Android G1 phone in recovery mode with busybox installed, including appropriate symlinks to at least tar and md5sum, as well as 'adb shell' support running as root. I recommend using JesusFreke US RC30 or UK RC8 v1.2 recovery image. You can flash the RC30 v1.2 recovery.img on your G1 if you don't want to bother constructing your own image. Of course you are free to use your own recovery image and it will work if you set it up correctly.
- dump_image-arm and mkyaffs2image|mkyaffs2image-$ARCH compiled in the current dir, as well as root on a linux/mac (POSIX) machine for constructing system and data images. root is required because the uid, gid and file permissions need to be preserved while extracting and creating the yaffs2 images. You are free to run the script as a normal user and then run the appropriate commands yourself as root; the commands are printed when you run the script as a regular user.

If you don't trust the provided binaries, you are free to compile them yourself. The source for the tools are included. For dump_image, edit nandtools/android-imagetools/Makefile so that you use the proper cross compiling gcc. For mkyaffs2img, just running make in tartools/yaffs2/utils/ should give you a binary. You are on your own in getting stuff compiled, but it should be easy to figure out from the Makefile.

* How to use this (the easy part)
Just boot your phone in recovery mode with the correct recovery.img (one that has adb shell as root + busybox installed with symlinks to tar, md5sum etc) and connect it to your pc/laptop/server. Then run the nandroid.sh script. If something is wrong or missing, it will tell you.

* What about restore?
If you have the dev phone or have root on the G1 and flashed the engineering/dev bootloader, then you can power on your phone while holding camera to get into the bootloader/SPL. It should then show some androids on skateboards (if not, you don't have the engineering/dev bootloader). Plug in your USB cable and push back until it says FASTBOOT instead of Serial0. Now you can fire up fastboot flash {partition} {file.img}.
Fastboot itself is part of the android SDK. If you download and compile your own mydroid build, it should sit in mydroid/out/host/linux-x86/bin/fastboot Perhaps in a future version I'll include a restore script, but for now I don't see the need.
One tip, if you are in fastboot mode on your phone and 'fastboot devices' doesn't show anything, try as root. You might need to edit your udev setup to allow your user to access the phone's usb device (which is different from the one you're in when in recovery or normal boot).

* Where's the source?
Sources are included. They are copies of the Android sources with various changes mostly made by Brainaid.
Everything in the zip is also also available through subversion:

svn co http://svn.infernix.net/nandroid/

Note that I DO NOT recommend checking out the latest revision unless you know damn well what you are doing. No guarantees if you play with fire. At the very least do diff against the latest released version.

* Credits
Bash script hacked together by infernix.
dump_image adapted from flash_image and extended by Brainaid.
Original mtdutils source and mkyaffs2image source by Google.

[1] http://forum.xda-developers.com/showthread.php?t=455860
[2] http://forum.xda-developers.com/showthread.php?t=443713
[3] http://www.gotontheinter.net/fastboot


DOWNLOAD HERE or:
wget http://dx.infernix.net/nandroid-2.0.zip
Attached Files
File Type: zip nandroid-2.0.zip - [Click for QR Code] (942.7 KB, 76775 views)
Last edited by infernix; 16th December 2008 at 05:28 AM.
The Following 12 Users Say Thank You to infernix For This Useful Post: [ View ]
16th December 2008, 12:41 AM   |  #2  
OP Member
Thanks Meter: 53
 
95 posts
Join Date:Joined: Oct 2007
Lightbulb Nandroid v2.0 - Full NAND backup and restore tool (tried and tested!)
Originally Posted by trmacdonal

How to Restore your phone on a Windows PC using a Nandroid backup

I am going to assume you already have a Nandroid backup created on your SD card using JF 1.31's recovery Alt-B feature. The backup will create a folder called nandroid on your SD.

What you need:
The Android SDK:
Fastboot Windows Binary in this post:http://forum.xda-developers.com/show...53&postcount=1
From your Nandroid backup you need three files:
data.img
system.img
boot.img

Steps to restore your phone
1) Put the files Adb and AdbWinApi.dll from the tools folder in the Android SDK into C:\WINDOWS\System32 folder on your PC. Substitute the correct drive letter if windows is not installed on you C: drive
2) Put the Windows Fastboot.exe into the C:\WINDOWS\System32 folder on your PC
3) Create a folder on the C: drive of your PC called android. The path should be C:\Android.
4) Copy the Nandroid backup files data.img, system.img, and boot.img from your SD card to the folder called Android you created by mounting your SD card as removable disk.
5) Unplug the USB cord and power off your phone
6) Power up your phone by holding CAMERA+POWER, you should see three androids on skateboards. If you don't see this go install the Engineering boot loader
7) Plug the USB cord back into your phone and press back. The screen on your phone should say fastboot.
8) Make sure your pc is using the correct driver. Open the device manager on your pc. It is helpfull to have all other USB storage devices besides your phone unplugged for this part. Look for a USB Mass Storage device in the list of the USB devices. Right click on it and update the driver. Pick the option to browse for a driver on your pc. The driver is located in the Android SDK your downloaded in the folder called usb_driver. If this is done right you will now see a device called HTC Dream
9) Press start, go to run and type cmd (If you are on Vista just type cmd in the search box and hit enter). The command prompt will pop up.
10) Type cd C:\android
then enter the following commands:

fastboot flash system system.img
it will say Sending, then writing and say OKAY if it was successful
then type
fastboot flash userdata data.img
wait for the second OKAY and type
fastboot flash boot boot.img
wait for the second OKAY and type
fastboot reboot

Your phone should now be restored exactly as you had it when it was backed up.
Last edited by neoobs; 1st March 2009 at 07:43 AM.
The Following 2 Users Say Thank You to infernix For This Useful Post: [ View ]
16th December 2008, 03:47 AM   |  #3  
Junior Member
Thanks Meter: 0
 
27 posts
Join Date:Joined: Nov 2008
This sounds great! I just recently used the other script to make a backup, but this sounds like it's been a bit more polished

I attempted to compile the yaffs2 utils under OS X 10.5 and I encountered a problem during linking:

ln -s ../yaffs_ecc.c yaffs_ecc.c
gcc -c -I/usr/include -I.. -O2 -Wall -DCONFIG_YAFFS_UTIL -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline -static yaffs_ecc.c -o yaffs_ecc.o
gcc -c -I/usr/include -I.. -O2 -Wall -DCONFIG_YAFFS_UTIL -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline -static mkyaffsimage.c -o mkyaffsimage.o
mkyaffsimage.c:120: warning: ‘yaffs_CalcNameSum’ defined but not used
gcc -o mkyaffsimage yaffs_ecc.o mkyaffsimage.o
ld: absolute addressing (perhaps -mdynamic-no-pic) used in _process_directory from mkyaffsimage.o not allowed in slidable image
collect2: ld returned 1 exit status
make: *** [mkyaffsimage] Error 1


Any thoughts? I'm heading off to google to figure out what a 'slidable image' is.

-jwb
16th December 2008, 04:30 AM   |  #4  
OP Member
Thanks Meter: 53
 
95 posts
Join Date:Joined: Oct 2007
No idea, and I don't have access to a mac. You could change the makefile and skip compiling of mkyaffsimage, you only need mkyaffs2image, but you'll probably get similar errors.
16th December 2008, 05:47 AM   |  #5  
Junior Member
Thanks Meter: 0
 
27 posts
Join Date:Joined: Nov 2008
Quote:
Originally Posted by infernix

No idea, and I don't have access to a mac. You could change the makefile and skip compiling of mkyaffsimage, you only need mkyaffs2image, but you'll probably get similar errors.

Google seems to imply its a common issue, possibly solved in a later XCode rev.. We'll see how that pans out.
16th December 2008, 02:36 PM   |  #6  
brocktice's Avatar
Member
Thanks Meter: 0
 
70 posts
Join Date:Joined: Nov 2008
mkyaffs2image on mac
It built just fine for me when I did the whole mydroid build. It's in out/host/darwin-x86/bin.

Is there some way to mount the yaffs2 image, though? Does one need to do the kernel patch etc on a linux box and then use loop?
17th December 2008, 06:49 PM   |  #7  
Member
Thanks Meter: 1
 
69 posts
Join Date:Joined: May 2006
More
Wow this a awesome. Thanks for all the hard work everyone.
17th December 2008, 07:49 PM   |  #8  
Senior Member
Flag Huntington Beach
Thanks Meter: 0
 
176 posts
Join Date:Joined: Jul 2007
More
you are are ridiculous.....ly good!

so you telling me if we have root and jf's modified rc30 v1.2 and be brick our phone, there's another quarter in your pocket after you die (game over) and you can start a whole new game?

hbguy
17th December 2008, 10:49 PM   |  #9  
OP Member
Thanks Meter: 53
 
95 posts
Join Date:Joined: Oct 2007
Quote:
Originally Posted by hbguy

so you telling me if we have root and jf's modified rc30 v1.2 and be brick our phone, there's another quarter in your pocket after you die (game over) and you can start a whole new game?

If you have flashed the engineering bootloader (the androids on skateboards appear when powering on your phone while holding camera button), yes.
18th December 2008, 08:26 AM   |  #10  
Senior Member
Flag Huntington Beach
Thanks Meter: 0
 
176 posts
Join Date:Joined: Jul 2007
More
haha very nice ::borat voice::

P.S. For the borat fans out there, he is making a new movie, insider info baby

hbguy!

Post Reply Subscribe to Thread

Tags
android, backup, flash, nand, t-mobile g1
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes