Remove All Ads from XDA

 View Poll Results: Is this tutorial Helpful?

2 Vote(s)
0 Vote(s)
May be
0 Vote(s)

[Tutorial] Creating adb script to flash ROM

150 posts
Thanks Meter: 112
Post Reply Email Thread
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 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:


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

  • 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:
TITLE [YOUR ROM NAME] by [Dev_Name] [Version 1.0]
mode con:cols=100 lines=40
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!
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:
 [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:
 [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                ----------ROM INSTALLED SUCCESSFULLY------------
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 Please be patient till device reboot!
ECHO                         --------------------------------------------------------
ECHO                     -----------------------THANK YOU------------------------
ECHO                         --------------------------------------------------------
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 - [Click for QR Code] (173.5 KB, 80 views)
The Following 7 Users Say Thank You to utsavkoju For This Useful Post: [ View ] Gift utsavkoju Ad-Free
Post Reply Subscribe to Thread

adb script, custom rom, rom building

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes