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
View Poll Results: Is this tutorial Helpful?
Yes 1 100.00%
No 0 0%
May be 0 0%
Voters: 1. You may not vote on this poll

Post Reply

[Tutorial] Creating adb script to flash ROM

OP utsavkoju

4th March 2014, 07:42 AM   |  #1  
OP Senior Member
Flag bhaktapur
Thanks Meter: 106
 
140 posts
Join Date:Joined: Nov 2010
Donate to Me
More
Dear all

I know there are numbers of you who want to start developing for our XL. There are numbers of way to flashROM. Either you can flash your ROM via system.img or ROM.zip etc etc. And here are we to explore creating rom via adb script. The earlier two ROM flashing mean require you to have unlocked bootloader but adb script ROM can be flashed on L/UL mobile devices. Lets get started with:

Quote:

NOTE: The phone needs to be rooted to flash adb script. For your assistance I will attach a ROM template along with this post.

Preparation
  • Please create two folders inside your working folder with name [Your ROM Name] and [Your ROM Name_PC].
  • Copy all your system files/folder inside your [Your ROM Name] folder.
    Please avoid creating folder within folder to avoid confusion. For example: if you are adding ringtones in your ROM consider creating folder inside [Your ROM Name] with name ringtones instead of creating folder structure like media/audio/ringtones.
  • In [Your ROM Name_PC] folder create a folder with name adb and copy adb.exe, AdbWinApi.dll and AdbWinUsbApi.dll inside it from your android sdk. If you are using my template then you can skip this step as i have already included adb folder inside [Your ROM Name_PC]

Scripting ADB Flasher
1. Create a new text file and rename it as Setup.bat. Remember to remove .txt extension and replace it with .bat extension.[LIST=2] [*]Right Click on Setup.bat and click Edit. The file will open in notepad.
2. Copy Following lines of Code and paste it in your Setup.bat file.
HTML Code:
 [MENTION=279333]ECHO[/MENTION] off
TITLE [YOUR ROM NAME] by [Dev_Name] [Version 1.0]
COLOR 70
mode con:cols=100 lines=40
ECHO.
Pause 
ECHO Waiting For Device.....


 [MENTION=302893]adb[/MENTION]\adb wait-for-device

 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'stop'"
ECHO Getting System access.....
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'mount -o rw,remount /system/ /system/'"
This will mount system folder with read write privilege.
3. Before flashing your apks and other stuff you need to make sure you remove corresponding stuffs from the system. I have listed generic folders inside the code below please add/delete lines as per your application preferences.
HTML Code:
ECHO Removing system files
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/app/*.odex'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/app/*.apk'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/fonts/*.ttf'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/framework/*.jar'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/framework/*.apk'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/framework/*.odex'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/media/audio/ringtones/*.ogg'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/media/audio/alarms/*.ogg'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/media/audio/notifications/*.ogg'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/media/audio/ui/*.ogg'"
ECHO System files removed successfully!
ECHO.
4. Copy each and every content of each folder you want to flash in corresponding folders of the system. Below is the sample code please consider adding/deleting as per your preferences.
HTML Code:
ECHO COPYING FILES.....
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/framework/* /system/framework/'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/app/* /system/app/'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/fonts/* /system/fonts/'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/media/* /system/media/'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/ringtones/* /system/media/audio/ringtones/'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/alarms/* /system/media/audio/alarms/'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/notifications/* /system/media/audio/notifications/'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/ui/* /system/media/audio/ui/'"
5. After you have copied all your files/folders into the system you need to add permission in case of framework and apps and any other folders requiring special permission. Below is the sample code please consider adding/deleting as per your preferences.
HTML Code:
ECHO SETTING PERMISSION.....
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'chown 0.0 /system/framework/*.jar'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'chmod 0644 /system/framework/*.jar'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'chown 0.0 /system/framework/*.apk'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'chmod 0644 /system/framework/*.apk'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'chown 0.0 /system/app/*.apk'"
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'chmod 0644 /system/app/*.apk'"
6. We are almost done now. Please consider copying following codes and adding them at the end of your script to remount system as read-only and rebooting the mobile device.
HTML Code:
ECHO.
ECHO                         --------------------------------------------------------
ECHO                ----------ROM INSTALLED SUCCESSFULLY------------
ECHO                         --------------------------------------------------------
ECHO.
 [MENTION=302893]adb[/MENTION]\adb shell "su -c 'mount -o ro,remount /system/ /system/'"
ECHO Rebooting System
 [MENTION=302893]adb[/MENTION]\adb reboot
ECHO.
ECHO Please be patient till device reboot!
ECHO.
ECHO.
ECHO                         --------------------------------------------------------
ECHO                     -----------------------THANK YOU------------------------
ECHO                         --------------------------------------------------------
ECHO.
pause
7. Now zip both [Your ROM Name] and [Your ROM Name_PC] folders and upload them to the file sharing sites of your convenience.

If all goes well you will have a superb ROM to share here at XDA. Please find the attached template along with this post.

If you like this tutorial please press thanx at the bottom of the post.

Have a happy time porting.

CREDITS will be highly appreciated.
Attached Files
File Type: zip template.zip - [Click for QR Code] (173.5 KB, 28 views)
Last edited by utsavkoju; 4th March 2014 at 08:49 AM.
The Following 7 Users Say Thank You to utsavkoju For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Tags
adb script, custom rom, rom building
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes