[Android Software/Hacking General [Developers Only]] CdTDroiD:
Work in progress..

Now the purpose of this guide is only one, to guide you through “cooking” your own stock flashable ROM from a shipped ROM… That’s it. It’s not hard but it does help you start the journey of the real dev work. There are to many "Devs" around that just do something like this guide and copy files from other ROMs to theres, And this DOES NOT make you a Developer so please dont go posting stock deodexed ROMs everywhere and call yourself a Developer ;)

Before starting I’m going to assume you have setup the correct ADB Drivers for your device although not really needed to make a ROM, it does make it easier in the long run.

Once you run through this guide you will have a stock ROM with ROOT permissions, DeoDexed, Zipaligned, Busybox and init.d support. From there you can modify your ROM to your hearts content, all this is doing is making your base. The real Dev work is .smali editing, modifying .xmls making your own apps, etc... This guide will just help you to not rely on other members to release "Stock deodexed ROMs"​

ADB Short codes that may be helpful later:

Type these directly into your CMD window with your device plugged in.

adb reboot recovery = Reboots your phone straight into recovery mode

adb reboot = Reboots your phone

adb push = use this to push files to your phone, make sure you are in the folder with the file you want to push in CMD (Example, adb push c:\android\SystemUI.apk /system/app)

adb logcat = Tells you what your phone is doing.

adb remount = Remounts the partition specified (Example, adb remount /system)

Note 1:

When making a ROM the overall concept is the same for every device that runs CWM or any other custom recovery. The only main difference is extracting the files you need from the Shipped ROM​

Note 2:

It makes it easier to have a shortcut to your kitchen folder and any others you need in your favourites or dektop​

Part 1. Setting up the “Kitchen”

Go to THIS FAQ and choose the method you prefer to install on. If you are running Windows I recommend the Cygwin way. It’s easier and you don’t need to keep booting between Linux and Windows, You don’t even need Linux if you do it the Cygwin way. And please do get the pictorial guide HERE, it helps A LOT for “noobs” and don’t forget to install the Java JDK if you do Windows Option 1. Keep in mind that doing it on Ubuntu IS much faster.

NOW IF Cygwin is to difficult for you, just download Ubuntu and install it next to windows.

Part 2. Extracting the files you need.

There are a few different ways you can do this, the main ones are:

For HTC Devices

Get a RUU.exe from the internet for HTC Devices and extract the system.img and boot.img

Download the RUU and run it on Windows, proceed until you get to the screen with the picture of the phone, see bellow. – (No you don’t need to plug your phone in)

Open your Start Menu on Windows

In the Windows 7 search bar type %temp% and hit enter

In the folder that opens click in the search box in the top right corner and search ROM.zip

Drag ROM.zip to your desktop, open and extract system.img and boot.img to your desktop.

________________________________________________

For ANY Android Device (Or if you cant get them any other way)

Using a backup of a stock ROM, This way gives you the ability to make a ROM from pretty much any device that has CWM installed.

Taking the system.img and boot.img from the backup folder

________________________________________________

For Samsung Devices:

Extracting the following from a Samsung Shipped ROM

factoryfs.img (and optionally: cache.img, zImage, modem.bin)

TAR file containing factoryfs.img (optional: cache.img, zImage, modem.bin)

ZIP file containing factoryfs.img (optional: cache.img, zImage, modem.bin)

Any of these above methods can be used and the extracted files placed in the ORIGINAL_UPDATE folder of the kitchen in the next step. If your device is not compatible with these methods check the device list in this THREAD for more guides.

Part 3. Setting up the working folder.

Now we have the files needed to make our ROM let’s get to it!

Go to your kitchen folder then the original_update folder and place your files in It

Start the kitchen by starting Cygwin and typing cd kitchen then ./menu

Hit option “1. Setup working folder from ROM” press enter again

Select the option you want from the list e.g. “(1) system.img and boot.img”

Rename the folder if you wish but it doesn’t matter, hit enter

If you are working from system.img and boot.img you need to run through the extraction process in next step. Most new ROMs use an EXT4 file system so if you are unsure just hit option “2 – Run Ext2Explore (EXT3/EXT4)” and follow the instructions in the Cygwin window (If you are just using a .zip or .tar etc. you don’t need to do this step.)

When that’s finished hit “3 – I’m finished unpacking / abort”

Finally hit Y to see you working folder details once its run through the process.

Part 4. Add the options you want to add

A good thing to do now is, keep it simple. The kitchen is best to use only for making your ROM base, once you have the .zip file most customizing can be done from there unless you need to edit the boot.img etc. but we are not going to get into that in this guide.

Now, we are going to make a simple ROM base optimized for speed and functionality. Follow the next steps and by the end you will be ready to build the ROM.

The most obvious of all, we will add “ROOT Permissions”. So choose option 2.

Always stick with Chains method so hit option F, this won’t take long at all, wait for it to finish the press enter to continue.

Next add Busybox with option 3, hit Y to continue and enter when finished.

Most people disable boot sounds (option 4), I usually just do it later if I choose to.

Don’t worry about Zipaligning because we will do it when we build the ROM.

Next choose option 0 for advanced options.

If you ROM isn’t already DeoDexed choose option 11

If you wish you can backup both folders but I usually don’t bother.

Then select option B to Deodex BOTH folders, this one will take some time, on an HP Laptop core2duo with 4gig of RAM takes about 15 minutes.

Now add /data/app functionality so choose option 13 and select Y to continue, This allows you to move apps from the system folder to your /data/app folder before the install, which in turn allows the end user to uninstall the apps if they wish. This can ONLY be done with certain apps, like apps you get from the market.. YouTube, Google Maps, Twitter etc. DO NOT put dependent apps like SystemUI.apk etc in the /data/app folder.

Next add the Nano text editor on option 14

Next add Command Shell or “Bash” with option 15

Next add init.d support with option 17 to allow the running of init.d scripts, sometimes you may have to manually add the init.d folder to your ROM at the end or before build, either way it doesn’t matter.

Now we are ready to build the ROM and flash it. Understand that all these are optional, if you want to you can just deodex the ROM and go straight to option 99 and build the .zip file. This is just what I recommend you do

Next go to option 99 when you’re ready to build your ROM.

For now you will choose option 1 “Interactive Mode”

When it asks you to Zipalign your .apk’s you can now choose Y and it will quickly run through and Zipalign all the .apk’s in your build.

Once finished, it will start building you ROM.zip file this may take about 5-10 mins on a slow computer or if your CPU is busy already.

When that’s finished it will ask you to either continue with the updater-script or not, this is always a YES for you guys, so hit Y and move on.

Now we need to Sign our ROM, this is always a YES also

The final step is to either rename your ROM or not, it doesn’t matter if you do it now or just rename the .zip file later, so do what you wish and hit enter.

Congratulations you have made your first ROM! You can now backup your current setup in CWM and flash it from your SD-Card, be sure to do a full wipe if it’s the first time and install it.

Note 1:

Sometimes you may get an error and CWM wont flash it, USUALLY this is because the kitchen has screwed up the updater-script but this doesn’t often happen. If it does take one from another ROM on the SAME DEVICE (<< IMPORTANT) and add it to your ROM.​