[How to] Make a script to auto-flash nandroid backups - G1 Android Development

The idea is pretty simple really. All you will need is the notepad application on Windows. When applying it, make sure to put all contents of your backup into the folder that also contains fastboot.
Open that up and copy and paste this into notepad, filling in correct information where appropriate.
(my first line would be desktop\phone\g1\fastboot)
cd C:\ -location of your fastboot folder-
fastboot flash system system.img
fastboot flash userdata data.img
fastboot flash boot boot.img
fastboot reboot
exit
Now hit file>save and in the save window where it selects the file type, select "all files". Now, name the script anything you like, but make sure it ends with a .bat . For example "script.bat". Once you are done, hit save, and the script is ready!
To use, have your files in the fastboot folder, your G1 booted into fastboot mode, and double click on the script.

that's great, i just created a similar one for linux today, i was switching between the 1.5 build and JF a few times because of a few things and was comparing and so i wrote the same script

Related

idea for dualbooting android builds... somewhat

alrighty, basically im lazy and want someone else to do this for me.
heres my idea:
you install rc33 or whatever you want, make a nandroid backup of it, rename the folder to OS1. this folder contains your boot.img data.img and so on
then install or place a nandroid backup of another build into a folder called OS2..
then you would be able to boot into the modified recovery mode, which would have the selection to run a script, which then asks which OS to flash, 1 or 2, you press 1 or 2 wait for it to flash and reboot, a little hacky way to get a dual boot...
now who wants to repack a recovery image for me?
good idea would be worth a try , too bad im not up to par for the job , but id like to see it done
i'll give this a shot tomorrow and see what happens, not really feeling like doing it now. and i'm not gonna do it via rebuilding the recovery.img, just gonna make a script that does it for me from the recovery terminal. i'm quite lazy as well and i already have a script that runs the fastboot commands from my computer script to flash from one build to another, in theory it shouldn't be too hard to get the script terminal reaady and do that.
tubaking182 said:
i'll give this a shot tomorrow and see what happens, not really feeling like doing it now. and i'm not gonna do it via rebuilding the recovery.img, just gonna make a script that does it for me from the recovery terminal. i'm quite lazy as well and i already have a script that runs the fastboot commands from my computer script to flash from one build to another, in theory it shouldn't be too hard to get the script terminal reaady and do that.
Click to expand...
Click to collapse
I have a .bat file that I use to flash back and forth from Windows.
To RC33
cd C:\Android\
@echo off
echo :::Instructions:::
echo You must have:
echo system.img
echo data.img
echo boot.img
echo installed in the "C:\Android" directory
echo then enable fastboot on device before proceeding
pause
fastboot flash system system.img
fastboot flash userdata data.img
fastboot flash boot boot.img
fastboot reboot
Click to expand...
Click to collapse
To 502H
cd C:\Android\502H\
@echo off
echo :::Instructions:::
echo You must have:
echo system.img
echo data.img
echo boot.img
echo installed in the "C:\Android\502H" directory
echo then enable fastboot on device before proceeding
pause
fastboot flash system system.img
fastboot flash userdata data.img
fastboot flash boot boot.img
fastboot reboot
Click to expand...
Click to collapse
Pretty simple. I have them stored to my desktop. I save my nandroid backups to the appropriate file and just double click. No problem. I just wish there was a script that I can use to reboot into HARDSPL mode (someone tell me if there is).
keatonreckard:
This is the worst idea i've heard so far...
FLASH has a limited life-time, and rewriting the whole system at every boot is a BAD idea.
If you want to dual-boot, you should look into making your own init-system, adding the ability to load another system (From SD).
Binary100100:
"adb reboot bootloader"
there might be a simpler way: change the kernel command so it mounts somewhere in sdcard as root. not sure how to do this without a computer though.
Hey binary, with your phone plugged into your comp pull up you cmd and type adb shell reboot bootloader, the phone will boot right into fastboot mode making it easy to continue the script
just to clarify...i meant a script that is store locally on the device in the recovery image... so then you dont need a computer at all... you can already do this, you just have to type in the commands from the recovery console...i just wanted an easier way to do it
Binary100100 said:
I have a .bat file that I use to flash back and forth from Windows.
To RC33
To 502H
Pretty simple. I have them stored to my desktop. I save my nandroid backups to the appropriate file and just double click. No problem. I just wish there was a script that I can use to reboot into HARDSPL mode (someone tell me if there is).
Click to expand...
Click to collapse
To flash back and forth from windows? You've been running Windows Mobile on the Dream? I must be missing something.
Joushou said:
keatonreckard:
This is the worst idea i've heard so far...
FLASH has a limited life-time, and rewriting the whole system at every boot is a BAD idea.
If you want to dual-boot, you should look into making your own init-system, adding the ability to load another system (From SD).
Binary100100:
"adb reboot bootloader"
Click to expand...
Click to collapse
not flash at every boot...just so you can text out a build and if you dont like it go back to a stable one on the go....
again, im taking the lazy way out
Disregard! - My mind ran ahead of what this post was about and I posted something regarding a slightly different idea!
I don't know about re-installing Nandroid backups...
But, if one wanted to be able to run two different installs...
Seems to me an easier way about doing this would be to have a modified SPL. It could have the option of selecting an update file...
For example, one could put two files on their sd card - update1.zip and update2.zip. The SPL could have one of the following options:
1) reboot into recovery mode - select "alt-s" - then you would have an option to select 1 or 2.
2) have an additional "Alt- " option.
"Alt-s" - runs update1.zip
"Alt-?" - runs update2.zip. (dev could pick the additional letter)
I think this would be great! No reteaching of anyone how to use the process. And, one could leave the primary use-able update.zip as "update1.zip" and use the other as the version being tried out. It wouldn't be a Nandroid back up... But, with the new "nowipe" builds it should work well.
My $.02 worth.
Joushou said:
keatonreckard:
This is the worst idea i've heard so far...
FLASH has a limited life-time, and rewriting the whole system at every boot is a BAD idea.
If you want to dual-boot, you should look into making your own init-system, adding the ability to load another system (From SD).
Binary100100:
"adb reboot bootloader"
Click to expand...
Click to collapse
To be fair, that limited life-time is something like 1,000,000 writes, which would take about... oh... a year straight of constantly rebooting your phone(assuming it takes 30 seconds per reboot)
EDIT: and that assumes re-writing the whole system every time you boot, which I don't think he means since he's saying its in the recovery image.
hmmm....
I know that from the alt+x console you can do this....
mount sdcard
echo "boot-recovery
--update_package=SDCARD:build1/update.zip" > /cache/recovery/command
reboot recovery
so if you wanted 2 builds available (I would think you would need a wipe for 2 completely different builds) but....
make 2 folders in on your sdcard
build1
build2
place a copy of the update.zip from each build you want to boot in the folder
make a script like this
Code:
echo "boot-recovery
--update_package=SDCARD:"$"/update.zip" > /cache/recovery/command
reboot recovery
save the script to the sdcard directory
then when you start your phone you could
1. type "mount sdcard" (no quotes)
2. type "sh sdcard/script.sh build1" (for build 1 located in /sdcard/build1/update.zip)
3. type "sh sdcard/script.sh build2" (for build 2 located in /sdcard/build2/update.zip)
problem would be when wipes are needed. But if you have 2 solid builds and don't need to wipe when swapping it should work.
Just need a way to make a script or bootloader that could run either one of these.
Cannot see another way around it since the OS is loaded into phone ROM/RAM
of course if your build supports the reboot command from the OS then you could just make a script to run when you want to reload the other build. Then you could skip the recovery console.
@beagz - Ha, forgot about that script. Yes, to switch between say, the DudesG build and Haykuro's H build one could write a script like that in Gscript and change back and forth when a new build comes out.
Like now... One could run Dudes G build and try out Haykuro's new ADP1.5 build.
But, I do believe your right about going back to a JF33 build - would need to wipe...
Gimpeh said:
To flash back and forth from windows? You've been running Windows Mobile on the Dream? I must be missing something.
Click to expand...
Click to collapse
Nah.. I was referring to using a bat file on my Windows computer to switch between 1.1 to 1.5 back to 1.1 by just executing the bat.
Now that i know that "adb reboot bootloader" will work it can be completely automated!
... but will it default to fastboot? Hmmm...
tubaking182 said:
Hey binary, with your phone plugged into your comp pull up you cmd and type adb shell reboot bootloader, the phone will boot right into fastboot mode making it easy to continue the script
Click to expand...
Click to collapse
Thanks! But is this going to put the phone in FASTBOOT mode? I'm trying to make this completely automatic if it's possible. Simply keep your latest and greatest backup .img's in a certain directory on your computer and EXECUTE!
Take a shower or whatever... come back and VOILA! Your previous backup.
The method that I've come up with thus far is pretty simple... but you just can't execute and walk away. You still need to enable FASTBOOT at the least on the bootloader. Although I haven't tried messing with it lately. I have my phone just like I want it.
Now that the Official ADP1.5 is out let's get to work on Mulitouch, themes, etc!
Wow this seems crazy but it just might work. Lol.
bat file to automatically restore backups using Windows!
So all you need to do is...
Open notepad, copy and paste the quoted text below, edit the top line of this bat file to the directory of your backups (I used "c:\android" for an example), save as .bat and double click. Wait and your done. Just watch it happen automatically.
Also if you decide to change that directory on the top line also use the directory on the 14th line. Your done. Easy restore to a backup.
HINT! Make a couple of these with a variety of directories on the top to change what backup your want to flash back to.
Example: c:\android\rc33; c:\android\501h; c:\android\adp15; etc
cd C:\android
color A
cls
@echo off
echo.
echo :::Instructions:::
echo.
echo You must have:
echo.
echo system.img
echo data.img
echo boot.img
echo.
echo installed in the "c:\android" directory
echo.
pause
cls
color b
echo.
echo.
echo.
echo Now restoring:
echo.
echo system.img
echo data.img
echo boot.img
echo.
echo to your device.
color c
echo.
echo DO NOT TURN OFF OR UNPLUG YOUR DEVICE DURING THIS PROCESS!!!
@adb shell reboot bootloader
@fastboot flash system system.img
@fastboot flash userdata data.img
@fastboot flash boot boot.img
@fastboot reboot
Click to expand...
Click to collapse
I've tested it and it works beautifully!
Hope it helps!
Thanks to everyone that pointed out the command "adb shell reboot bootloader"
This post is noob friendly.
OR
Use this script below for it to prompt for the location of your backups.
color A
cls
@echo off
echo.
echo :::Instructions:::
echo.
echo Enter directory of nandroid backups that you would like to restore...
set /p flash=path:
cd %flash%
cls
color b
echo.
echo.
echo.
echo Now restoring:
echo.
echo system.img
echo data.img
echo boot.img
echo.
echo to your device.
color c
echo.
echo DO NOT TURN OFF OR UNPLUG YOUR DEVICE DURING THIS PROCESS!!!
@adb shell reboot bootloader
@fastboot flash system system.img
@fastboot flash userdata data.img
@fastboot flash boot boot.img
@fastboot reboot
Click to expand...
Click to collapse
This one is even more noob friendly... but it's not as fast because it requires you to enter the location of your backups.
I hope it helps someone out there. It helps me.
[email protected]:
The average lifetime of flash is 100.000 writes, and flash isn't delivered 100% intact, they're usually delivered with faulty blocks (Depending on where you get it, blah blah blah).
That should change your numbers a bit (A month i believe?)
And, sure, he is using the update-zip, so it's not written to the same pages every time.
But still, it's a bad idea (Other than wearing stuff down, it will also be very slow ).
To dual-boot, modifying the init-system so it could choose from different android-runtimes would be way faster/cooler...
If possible, this would be pretty damn useful. Using a stable build while being able to tinker with experimental builds. Would definitly cut down on the constant flashing back and forth.

one S stuck

my friend have one s then he flash it with recovery for "one X " after that the phone wont boot only stuck on "hTC this build is for development purposes only do ...etc" and every time i reboot it it gives me the same message
also it says **TAMPERED** whats that mean ?
Ouch. You should have followed the directions to flashing recovery for the One S not X. But I guess you know that now. Tampered means the sky is going to swallow you up in 24 hours. I'd find cover.
Lolz...jk. tampered. Modded. Unlocked bootloader....don't worry about it. As far as getting out of your situation. Go to the Q&A section.
Sent back in time to find Marty.
boot into bootloader and flash the correct recovery..
after that flash a different ROM after doing a full factory reset. You should be fine
azzledazzle said:
boot into bootloader and flash the correct recovery..
after that flash a different ROM after doing a full factory reset. You should be fine
Click to expand...
Click to collapse
i flash the correct recovery and i tried factory reset it didnt work
flash a different ROM then, Chances are if the old owner flash recovery for a One X, he probably flashed a ROM for the One X too !
first off, let someone ok this before you do it as the one s may be different with erasing system than my N1 is, since it has no actual sdcard
you could also try
fastboot erase system
fastboot -w
before doing any fastboot flashing of recovery then rom
maybe even fastboot erase recovery after fastboot -w
have everything on one s sdcard before doing this
without a system wipe, sometimes old rom remnants are left behind and not overwritten when new rom flashes. also one time I had to erase system before recovery would flash
You have various options, depending on your current state, which is always tough to judge if not having the actual device.
You can
1. push system.img and boot.img via bootloader
Start the 1.53 RUU and then look in TEMP folder in a folder with current date, then in the subfolder you find rom.zip. Copy that to another place outside of TEMP.
Now unzip with winrar and copy system.img and boot.img to fastboot folder along with a proper custom recovery
Now flash the 3 images with
fastboot flash boot boot_signed.img
fastboot flash system system.img
fastboot flash recovery r2-modaco-recovery-clockwork-touch-ville.img
Here`s the custom recovery for you - http://minus.com/mIA3OFkYq/4
Now reboot with
fastboot reboot
OR
2. Restore my clean stock nandroid backup
Part 1 - add clockworkmod folder (in case you don`t have them yet)
Boote in recovery and in cmd navigate to fastboot folder
Now type:
adb shell
then
mkdir /sdcard/clockworkmod
then
mkdir /sdcard/clockworkmod/backup
then
mkdir /sdcard/clockworkmod/backup/stockbackup
Now we have the empty folders.
Part 2 - Nandroid push and restore
Now we push the single parts of my backup in clockworkmod/backup folder. Navigate to your fastboot folder in cmd and type:
adb push .android_secure.vfat.tar /sdcard/clockworkmod/backup/stockbackup
adb push boot.img /sdcard/clockworkmod/backup/stockbackup
adb push cache.ext4.tar /sdcard/clockworkmod/backup/stockbackup
adb push data.ext4.tar /sdcard/clockworkmod/backup/stockbackup
adb push nandroid.md5 /sdcard/clockworkmod/backup/stockbackup
adb push recovery.img /sdcard/clockworkmod/backup/stockbackup
adb push system.ext4.tar /sdcard/clockworkmod/backup/stockbackup
Now we have everything in sdcard/clockworkmod/backup/stockbackup
Now you can restore that backup in recovery.
http://minus.com/mquC9WDG6/4
Tip: If you are sure your data partition is fine, you can leave out the data.ext4.tar, but make sure you also delete the md5 of data.ext4.tar before in nandroid.md5. That way you would restore wiithout having data loss
good process and "command" info, even if you don't need to do all of it
especially for folks not real familiar with fastboot/adb
hope OP gets it working

Universal Android Flasher

From now on, Android rom can be easy to pack. You don't need to worry about the permissions of the files or the symlinks anymore.
What does this package do:
1. Automatically find and recognize the img with patterned name in the same folder of this package.
2. Automatically wipe and flash the system partition when system.img is found.
3. Automatically flash the addon pack without wiping the system partition when addon.*.img is found.
4. Automatically backup efs and efs_gsm partition, on Samsung Duo sim card phones.
5. Be able to flash the unmountable partitions like boot, recovery, modem, etc.
How to pack:
1. Make you rom on on the Phone or Linux. On the Phone? Yes, you can test your patches on your phone.
2. No matter on the Phone or on Linux, cd /system/ or cd <your system folder>, check the permissions and symlinks. Usually I don't check cause I modify directly on a system I dumped from my phone. Yes a dump of system partition is a good idea.
3. You have two optitions: 1. Use the modified dumped system partition dump as system.img. This usually generate a big img to flash, but will flash faster. 2. If you use extracted folder or want to use small files, cd to the system folder in shell and make the folder to a tarball with the command: 'tar --lzma -cf <your tar file> * .[!.]*'. Why use * .[!.]*? This will put the .* files and folders in the tarball.
4. Then rename the dumped image or the tarball to system.img and put it in the same folder of the FLASHER.
5. Want to make an addon? Just make the name like addon.<your name>.img. Don't for get the permissions and ownership of the files and folders.
Future plan:
1. Make a packer/dumper for the system partition.
Github:
https://github.com/maxfu/universal_android_flasher
I will edit this post and post some pictures later.

How to unpack and repack boot.img full guide by Jai Sharma

How to unpack and repack boot.img
For Windows user
1. Download CarlivImageKitchen from here http://forum.xda-developers.com/attachment.php?attachmentid=3798926&d=1467275078
all credit goes to bluefirebird http://forum.xda-developers.com/member.php?u=5186178
2. extract it using 7zip or similar program
3.. Put your boot.img in boot-resources folder
4. Double click carlive batch file
now select B and Enter
Now choose your boot.img and enter
5. To unpack it type 1 and Enter
that's it. now you can find extract boot.img in boot folder. type enter for continue and keep this window open if you want to repack it again after
making change in boot folder
edit your files in boot folder and for repacking it again keep reading
Repacking
type 2 for repacking
now you can find you new boot.img in output folder
For Linux user
i am using ubuntu as my linux machine
1. Download Boot.img Tool from here https://github.com/jsharma44/bootimg-tools
2. cd bootimgtools
Type following in terminal
./unpackbootimg -i "boot.img path"
For example
./unpackbootimg -i /home/user/Desktop/boot.img
find your files in bootimgtools
I hope you like it. Please visit my website http://azodik.com/ for more interesting guide
Thank You
Extracting boot.img from your device
Extracting boot.img from your device
What we need
1. A rooted phone
2. Enable Usb Debugging in Developer Mode
3. ADB command knowldge
connect your phone via usb cable ensure that usb debugging is enabled
open terminal and type adb devices
if it is showing your device’s serial no than we are ready to go
C. type
adb shell
su
ls -l /dev/block/platform/mtk-msdc.0/11230000.msdc0/by-name
please note this command may vary by device to device. What we are doing here we want to know partition scheme of your device.
note down block name of /boot partition
example it will be like boot -> /dev/block/mmcblk0p7
d. type this
dd if=/dev/block/mmcblk0p7 of=/sdcard/boot.img
now boot.img succesfully transfered to your SD card Copy it to your Desktop
How To Extract System Folder From Android device
1. Connect your phone to computer with USB debugging enabled
2. Type following command to check
adb devices
if it is showing your device's serial no then go to step 3. If not then make sure drivers are installed for your device.
3. To pull system folder use following command
adb pull system
it will pull system folder to your current adb directory. If you want to pull it to some specific directory use following command
adb pull system "output directory"
Example
1. adb pull /system C:/Users/user_name/Desktop/ (For Windows)
2.adb pull /system /home/user/Desktop (for linux)
Your link to Windows zip is no longer there. Getting a 410 error
ianmb said:
Your link to Windows zip is no longer there. Getting a 410 error
Click to expand...
Click to collapse
link updated..Please check now. Thanks for pointing out it
jai44 said:
How to unpack and repack boot.img
For Windows user
1. Download CarlivImageKitchen from here http://forum.xda-developers.com/attachment.php?attachmentid=3798926&d=1467275078
all credit goes to bluefirebird http://forum.xda-developers.com/member.php?u=5186178
2. extract it using 7zip or similar program
3.. Put your boot.img in boot-resources folder
4. Double click carlive batch file
now select B and Enter
Now choose your boot.img and enter
5. To unpack it type 1 and Enter
that's it. now you can find extract boot.img in boot folder. type enter for continue and keep this window open if you want to repack it again after
making change in boot folder
edit your files in boot folder and for repacking it again keep reading
Repacking
type 2 for repacking
now you can find you new boot.img in output folder
For Linux user
i am using ubuntu as my linux machine
1. Download Boot.img Tool from here https://github.com/jsharma44/bootimg-tools
2. cd bootimgtools
Type following in terminal
./unpackbootimg -i "boot.img path"
For example
./unpackbootimg -i /home/user/Desktop/boot.img
find your files in bootimgtools
I hope you like it. Please visit my website http://azodik.com/ for more interesting guide
Thank You
Click to expand...
Click to collapse
Your link no longer exists. I want to download the software to Windows. I would love for you to update the link. Thank you!

How to set zram swappiness for budget Android device

Today I'm gonna write on how to set zram swappiness for budget Android device which have zram built in it. This method does not requires rooting but involves boot.img editing and requires flashing.
What you need is:
1. Boot.img file extracted from the ROM file package or just dumped from your rooted device.
2. ADB tools installed.
3. Bootimg.exe tool (Download from the attachment here)
4. Notepad++
5. Patience
Here's how to do it:
1. Create one empty folder and place both boot.img and bootimg.exe tool in one place and then, Ctrl+right click to open CMD/PowerShell in the folder. If you're using PowerShell, run the command cmd after launching.
2. Run the command bootimg.exe --unpack-bootimg boot.img to extract the boot.img file.
3. Go to initrd folder and open up init.rc or init.[device-chipset-name].rc with Notepad++ and find the code snippet that are usually like this below (Press Ctrl+F and key-in the keyword swap or swappiness for quick search):
on property:ro.config.zram.support=true
setprop sys.vm.swappiness 80
write /proc/sys/vm/page-cluster 0
start zram
4. After finding the code snippet inside the init.rc or equivalent file, edit the setprop sys.vm.swappiness line and edit the default value to 100 which stands for aggressive swap mode. Then save the file.
5. Next, you have to repack the boot.img file back by running the command bootimg.exe --repack-bootimg and the file boot-new.img created.
6. Flash your device with boot-new.img via fastboot with command fastboot flash boot boot-new.img and boot the device.

Categories

Resources