How to setup a development environment for nOobs, How to make a basic ROM from Samsung's stock firmware, how to setup and use the apktool, how to compile AOKP for the d2tmo (T-Mobile S3), how to port to an unsupported device for AOSP/CM/AOKP coming....
Table of contents
Setting up Linux and a developers environment how to for Linux - post 2
Android Kitchen how to for Linux - post 3
Apktool how to for Linux - post 4
Manually decompile and recompile smali, jar's and even apks' how to for Linux - post 4
How to compile AOKP for d2tmo (T-mobile S3) - post 5
How to cherry pick - post 5 Thanks to Midnight_Rider - post 5
How to compile a kernel for d2tmo (T-mobile S3) - post 6
Code:
#include
/*
* Your warranty is now void.
*
* I am not responsible for bricked devices, dead SD cards,
* thermonuclear war, or you getting fired because the alarm app failed. Please
* do some research if you have any concerns about features included in this ROM
* before flashing it! YOU are choosing to make these modifications, and if
* you point the finger at me for messing up your device, I will laugh at you.
*/
By using these guides you agree with the above terms!
Ok guys here is my setup that has successfully worked for me for over 2 years. You have to have a developer environment like this to move on to the "how to" build a basic ROM. Also again this guide is for Linux ( 64 bit is a must!!!) Here goes.
Personally I run Ubuntu 12.04 LTS and strongly suggest you use it as well if you plan on doing extensive development. Head over to Ubuntu and download it there. Download page
Now after you have downloaded Ubuntu (64 bit!) you need to install Linux.
Easiest way is to put in a blank DVD and click on the ISO(Ubuntu os) and burn the image on the DVD. You can also setup and burn it onto a thumb drive that is at least 4 gb. You will need to Google this if you want to go that way.
once you have burnt the image you will need to install, reboot your computer and watch the screen (make sure the DVD or thumb drive is in.) Most computers will say either hit "ESC" or F9 or F12 to pull up boot options.
Now select the option that say something about DVD/something,,,, this will bring up the options from within the boot disk. Select live boot. This will bring up Linux. Once it is up sign into your Wifi router because this is needed in the install.
Click on the Icon that says install Ubuntu. Install . . . and follow prompts. Very easy setup...
Congratulations you now have Linux installed.
Before anything you need to install right click terminal then reboot for it to effect. Do this now.
Code:
sudo apt-get install nautilus-open-terminal
Now head over to my github and download the developer setup package I have made for you guys. This way everything is in one place. I will try and keep the tools up to date as well. Download - https://github.com/jamison904/developer_setup
Once downloaded, extract. Then open the folder find andadb.sh. Right click it and go to permissions and mark this file executable. Now open termial and;
Code:
. andadb.sh
Now you will have a few options. BE CAREFUL :evil: not to do them all. Some we still will need to do manually and will cause issues if you do them :shock: here.
**********************************************************
Android ADB Installer 2.1
Main Menu
**********************************************************
1 - Resolve dependencies ( Run this first )
2 - Install Android SDK & Android NDK
3 - Install adb & fastboot
4 - Nautilus right-click to adb push support
5 - MTP Support for Galaxy Nexus <- Do not do!
6 - Create/update the 99-android.rules file
7 - Install aapt & apktool <- Do not do! NEED TO DO MANUALLY
8 - Install git-repo <- Do not do!
9 - Help and information
0 - Exit
*********************************************************
Enter selection:
once you are done with this step you are 90% done. You can now start playing with the Android Kitchen. I will make another thread to show you how to set up and use the apktool.
Update for java
The script above will install an outdated version of java. No worries, here is the fix.
- first you need to uninstall the current version of Java by copying and pasting this into the terminal:
This is a rough draft and I will clean it up and make it look pretty later... :cool:
OK guys this is a step by step "How to"
The goal is to teach you how to take a stock firmware from Samsung and convert it into a custom ROM that anyone can download and flash through a custom recovery like ClockWorksMod (CWM.)
- First off this guide is written for Linux. I am personally using Ubuntu 12.04 at the moment. I really don't believe Android development should be done on Windows so I will not be writing a Windows version of this guide. That being said, I don't have an issue with someone else writing one and using this to convert to as long as it is posted here!
- At this point I am going to assume you are running Linux and have some basic understanding of it. Now you will need to have Java and Android SDK installed. I have written a "HOW TO" above
- extract Samsung's firmware, then extract the .tar. Now move the boot.img, System.img and the cache.img to a folder called "original_update" inside the Android kitchen.
============================================================
Android Kitchen 0.223 - by dsixda (xda-developers.com)
============================================================
> MAIN MENU
1 - Set up working folder from ROM
2 - Add root permissions
3 - Add BusyBox
4 - Disable boot screen sounds
5 - Zipalign all *.apk files to optimize RAM usage
6 - Change wipe status of ROM
7 - Change name of ROM
8 - Show working folder information
0 - ADVANCED OPTIONS
00 - LEGACY OPTIONS (old and rarely used)
99 - Build ROM from working folder
The format for each ROM must be one of the following:
- system.img + optional boot.img/lib.img (e.g. stock ROM or Nandroid)
- ZIP file for a custom ROM (e.g. update.zip)
- ZIP file containing *.img (e.g. stock rom.zip)
- ZIP file containing shipped ROM in SYSTEM + BOOT folder format
- Working folder made with this kitchen (e.g. WORKING_old_rom)
Android OS version : 4.1.1
Device : d2tmo
Model : SGH-T999
ROM Name : JRO03L.T999UVDLJA
Rooted (Superuser.apk + su) : NO
Rooted (unsecured boot.img) : NO
BusyBox installed : NO
BusyBox run-parts support : NO
Apps2SD (Apps to EXT) enabled : NO
/data/app enabled : NO
Custom boot animation allowed : NO
Nano text editor installed : NO
Bash shell support : NO
/system/framework is deodexed : NO
/system/app is deodexed : NO
radio.img found : NO
ROM will wipe all data : NO
Android OS version : 4.1.1
Device : d2tmo
Model : SGH-T999
ROM Name : Hello World!
Rooted (Superuser.apk + su) : YES
Rooted (unsecured boot.img) : YES
BusyBox installed : YES
BusyBox run-parts support : NO
Apps2SD (Apps to EXT) enabled : NO
/data/app enabled : NO
Custom boot animation allowed : NO
Nano text editor installed : NO
Bash shell support : NO
/system/framework is deodexed : NO
/system/app is deodexed : NO
radio.img found : NO
ROM will wipe all data : NO
Now at this point after making your tweaks and changes, you will select option # 99. After that I am normally running after my daughter so I pick option # 2 which automates the zipping, signing, and naming process
Now very import before you flash!! Make sure you compare the blocks from my installer script and the one you have from the kitchen. Make sure that yours has this information and nothing else or you will end up with a soft brick or even a hard brick with no return!!
Code:
/dev/block/mmcblk0p14 - for system
/dev/block/mmcblk0p17 - for cache
/dev/block/mmcblk0p15 - for data
/dev/block/mmcblk0p7 - for the boot.img (kernel)
- Now open the terminal and navigate to the desktop. (or go to Ubuntu software center and search "right click terminal" and download it.
- No that you are in desktop in the terminal you need to give each of the three files root access.
- to do this you will need to chown -R and type the location of the file.:
Code:
chown -R
- The quickest and easiest way to type "chown -R " then the location (jamison904:jamison904) then drag and drop the file into the terminal. So it will look like this (also it will prompt you for your password.)
- Open the terminal in the same folder as the apps you want to mod. I normally take the app an the frameworks and place them in a folder on the desktop. I name it whatever the project is. i.e. "Toggles mod"
- now you will need add the framerork-res.apk and the twframework-res.apk to the apktool.
Code:
apktool if framework-res.apk <- enter, then
apktool if twframework-res.apk <- enter
Now you need to decompile the apk you are working on, lets say the SystemUI.apk
Code:
apktool d SystemUI.apk <- enter
At this point you will make your modifications. . . . then you will need to recompile the apk.
Code:
apktool b SystemUI <- enter
Now if all goes well you will have a new modded apk. One more step and you're done.
- Last you will need to open the archive of both the orignal apk and your new modded apk.
- Grab the META-INF folder and the original AndroidManifest.xml from the original apk and drag and drop both into your new modded apk then close the archive.
- I have attached a test zip for you to use. Just place the apk or jar where it goes. ie...SystemUI.apk goes into system/app and framework-res.apk goes into system/framework. Just double click the zip and go to the folder the apk or jar goes to and drag and drop it in then just close the archive. No signing needed this way.
Now make a new folder. I named mine smali. Place both into the new folder.
Next go to Ubuntu software center and download 7zip.
Lets use the android.policy.jar as an example for this part of the guide.
Take the android.policy.jar and place it into the new folder (smali)
double click on the android.policy.jar to open the archive. Then click on the class.dex and drag it and drop into the folder (smali)
Now for the fun part.
Right click and open terminal here inside the folder. (If you haven't got it yet please do. Go to Ubuntu software center and download right click terminal.)
Now you type this or copy and paste:
Code:
java -jar baksmali.jar -o classout/ classes.dex
this will decompile the class.dex to a folder named class. Make your changes then continue.
This will give you the output of new-classes.dex. If you get any errors or don't get a "new-classes.dex" then you had an error. Copy what the terminal says and paste it here and I will help you figure it out. If it is long please paste it over at pastebin.com and post a link here. Trying to keep it clean in here. Thanks!
You will want to copy the android.policy.jar and the new-classes.dex to a new folder inside the folder you have been working. I name this folder Test1. This way you don't overwrite the stock ones. Plus makes it easiser to keep track of what worked and what did not.
Now all you need to to is double click on the android.policy.jar to open the archive again. Now since you are in the Test1 folder rename new-classes.dex to
classes.dex. Last just drag classes.dex to the archive and drop it. It will add the new classes.dex to the archive. Once it is done close the archive and test to see if your chages worked.
I have attached a test zip for you to use. Just place the apk or jar where it goes. ie...SystemUI.apk goes into system/app and framework-res.apk goes into system/framework. Just double click the zip and go to the folder the apk or jar goes to and drag and drop it in then just close the archive. No signing needed this way.
This is a quick walk through to get you started compiling AOKP MR1 4.2.2 from source. I have made it super easy for you and anyone who can read will be able to do it. Again this is for Linux ( 64 bit is a must!!!!.) You will also need at least 50 gigs of free space. ( I would go as far as saying 100 gig but you can get by with 50.)
First you need to download my repo tool Download link
Once you have it download extract to your working folder. Then right click and open terminal here. Then:
DO NOT DO OPTION 1. This is older and will undo the version on Java you installed from above and is no longer the supported version of Java.
Now pick option # 2. This will install the required packages you will need to build.
Now pick number 10 - Sync AOKP Jellybean. This will make a folder called AOKP and will initiate the repo and download the source ( you can move this folder later.) Follow the on screen prompts and input your name ( Real name ) and a real email address. At this point go have a beer and wash the wife's car. This will take a while depending on your internet speed.
Now you will need to add the local manifest so it knows where to get the source for the kernel. Do a "Ctrl and h" to show hidden folders. Now open the . repo folder. Then do a right click and add new document. Rename the new document to local_manifest.xml then copy and paste the code below and then save it.
Now that you have the local manifest in the . repo folder you will need to download the kernel source.
Do:
Code:
repo sync
Almost there.... once it finishes it is time to try your first build.
To start the build type in this command:
Code:
. build/envsetup.sh && brunch d2tmo -j5
The . build/envsetup.sh part sets up the environment to build. The && part tells the terminal to also do this. The brunch d2tmo tells it to build for the T-mobile S3. Last the -j5 tells it how many jobs to do at once. The higher the number the more jobs it will do. Be careful though because you can do too many jobs for your computer and will bog out and will even cause a build to fail if you run out of memory. Rule of thumb here is one for each core you have then add one. I have a quad core so I do -j5. If you have a dual core do -j3 and if you are not sure you can leave it off completely. (.build/envsetup.sh && brunch d2tmo)
This is where is gets fun. The first build will take a few hours. If you get any errors copy as much of the termial as you can and make a pastebin (www.pastebin.com) and link it here for us to help you with. PLEASE DO NOT PASTE THE WHOLE THING HERE!!! Thanks.
Now if you get a screen with AOKP in a few colors then you have a successful build. Time to backup your phone and test out your work. The Finished zip will be in the out folder. AOKP/out/target/product/d2tmo to be exact. You will want to grab the aokp_d2tmo_unofficial_Mar-25-13.zip this is the one you should flash.
Almost done. Once you have a successful build you will want to install and activate ccache. This will cut your build time in half or more!!!
First you need to install it.
Code:
sudo apt-get install ccache
Put the following in your .bashrc by doing:
Code:
gedit ~/.bashrc
now add
Code:
export USE_CCACHE=1
save then close.
Now to set it you will need to
Code:
ccache -M 50
The 50 stands for 50gigs!!! The recommended size is 50-100GB but the size you use is up to you.
First off let me start with saying this, half assing a kernel or not following all the steps exactly will brick your device!. You have been warned. I personally was every hesitant to even try to make my own kernels because of the brick factor. After researching for weeks and reading like crazy I felt like I had enough knowledge to attempt to build my own kernel. After talking with my buddy TDJ he told me that when it comes to kernels you just have to get learn by hands on. Of course he was right. So be careful and if something doesn't seem right,do not flash it. Also the kernel_test.zip attached is for TMO/ATT S3. I haven't checked to see if the boot block is the same for all of the US S3's. I'll check and update this. Until then only use for TMO/ATT S3.
Code:
#include
/*
* Your warranty is now void.
*
* I am not responsible for bricked devices, dead SD cards,
* thermonuclear war, or you getting fired because the alarm app failed. Please
* do some research if you have any concerns about features included in this ROM
* before flashing it! YOU are choosing to make these modifications, and if
* you point the finger at me for messing up your device, I will laugh at you.
*/
[COLOR="Red"]By using this how to you agree with the above terms![/COLOR]
Now with that out of the way lets have some fun! This how to is for the T999 TW kernel. This guide will work for all S3 devices with minimal changes. Also the basics here will work for all devices. Also at this point the guide is only build a stock kernel without changes. That will come in another update. I will need to show you git and how to use it before you can make changes. Also if you make and changes and you share the kernel with others you have to post your source!! So you will need to know how to use github or bithub. These too will come later.
First you will need to download the source for the kernel. You will need to go to http://opensource.samsung.com/ and find the source for your device. Search for t999 and grab the one named SGH-T999_JB_TMB_Opensource.zip. Or you can grab it from my Goo account here. . . . .
Now you need to extract the zip. Then extract Kernel.tar.gz. Now make a folder in your home directory if you have not already called android. Then inside android make another director called kernel. Last make a folder for you kernel, you can name it whatever. For this how to lets just call it T999_TW_kernel. Now move everything from the extracted Kernel.tar.gz to this folder. This is your kernel working folder.
Next you will need to choose the toolchain you plan on using. There are many great ones out there. Just Google "kernel tool chain" to see the many different ones. The Android NDK comes with a bunch and most are 100% stable. Since I also suport AOKP for many devices, I just use the one they use. I have uploaded it to my github for you guys to download and use. Go to https://github.com/jamison904/arm-eabi-4.6 and click on zip to download it.
Now you will need to set your path and set the cross compile in your make file inside your kernel working folder.
We are going to setup your toolchain path now. Extract the downloaded toolchain from my github and make a folder inside the android folder called toolchain. Now move the extracted tool chain here. Open up the make file in the kernel folder and set your path like below. (of course change Jamison904 to whatever yours is named.) save and close.
Code:
ARCH ?= arm
CROSS_COMPILE = /home/jamison904/android/toolchain/arm-eabi-4.6/bin/arm-eabi-
Name your kernel! Open the make folder and make the change then save and close.
Now open terminal here inside the kernel build folder. You need set it up. You need to:
Code:
make clean && make mrproper
Ok time to pull the defconfig from your phone (This is for a TW Kernel so you need to be running a TW ROM. You also will need to be running a stock kernel for this to work right...) You will need to connect your phone to your computer with adb debugging turned on. Then open the terminal from your desktop and:
Code:
adb pull /proc/config.gz
then
Code:
gunzip config.gz
This will give you a file called config. You will want to rename this file to t999_defconfig. After that you will need to move this file to /home/jamison904 (your user name)/android/kernel/T999_TW_kernel/arch/arm/configs. Drop it here.
Now it is time to attempt to build. You will need to do:
Code:
make xconfig
This will bring up a nice user friendly UI to help you set up the build.
Now you need to click on the folder. Navigate to arch/arm/config and click on your T999_defconfig.
This shows you where to find the schedulers. You can change the default scheduler here. Also can turn them on and off, as well if you want to build them in or make them build as a module.
This shows you where to find the governors. You can change the default governor here. Also can turn them on and off, as well if you want to build them in or make them build as a module.
Now lets see if you set it up correctly.... lol. You will do:
Code:
make
Later after you know that it will build you can seed it up by doing make -j5. This will make with 5 jobs at once. This is way faster but very hard to trouble shoot and find your errors. If it stops without finishing you will need to make clean && make mrproper then do the xconfig again and save and close then "make" .... This will only make with one job at a time thus you have an error and it will stop and you will be able to read the error. Copy and paste to pastebin.com and post the link here and I will help you figure it out.
If you get this, congratulations you have made your first kernel... time to package it up and test.
Finding the zimage (kernel itself.) Navigate to arch/arm/boot and grab the zimage.
Now to find the modules. Do a ctrl f in the root of your kernel build folder and screach for .ko. Make sure to include the . before ko. Then copy and paste these into a folder to hold them for the zip.
Now you need to unpackage a boot.img and replace the zimage then repackage it up. The easiest way to do this is with the Android kitchen. Takes less then a minute. If you have been following my guides here you will already have it setup and have working knowledge of the kitchen. If not, stop here and go catch up, i'll wait.... Ok moving on.
I made a folder called WORKING_Kernel to keep these away from real working folders just in case I forget. Don't need to update my S2 ROM with a S3 kernel. Anyways...
Place a stock boot.img into the folder
Now start up the kitchen and press 0. Then option 12 for boot.img.
Then press w. This will unpack the boot.img.
The end result will be a folder called "BOOT-EXTRACTED"
Open it and you will see the ram-disk and the Zimage (kernel). Delete the Zimage here!
Grab your new Zimage and copy and paste it in to the "boot-extracted"
Now to repackage it. Back over in the Kitchen press "b" to build
Your new kernel is in the boot.img
Now to flash the kernel. I have made you guys an empty flashable zip attached below. This way no one breaks their device trying to flash their kernel. If you do brick you didn't read the directions as this zip is dummy proof so to speak.
Now double click on the kernel_test.zip and drag and drop your new boot.img into the archive.
Now navigate to system/lib/modules and press Ctrl A to select all of the modules then drag and drop these here.
Done. Copy and paste the zip to your SDcard and reboot into recovery and pry.... lol. You will be good if you followed the directions. Enjoy your own build stock TW kernel! Again remember not to public share your kernel unless you have uploaded "your exact source" and can provide a public link to it. You have been warned! Next updates will include how to work git, commits, and github as well as some more advanced kernel tweaks and code. Also how Cherry-pick
For more advanced kernel work you will need meld to work conflicts. Open terminal and:
Code:
sudo apt-get install meld
Now when you get a conflict from cherry picking you will do
Code:
git status
this will show you the conflicting files. Then to work them you will need to
Awesome man. A million+ thanks. by the way you couldnt make it any simpler. It is very understandable. A have a little bit of knowledge but this clear up all my questions.
Re: [Guide][How-to's]Rom's, Smali, code. Links to all S3 MODs and Tweaks!
Indeed, there is a wealth of information scattered all over. It's nice to have everything neatly organized and in a clear concise format, that's easy to understand thx for this Jamison, will be looking forward to the additional information you add to this!
Re: [Guide][How-to's]Rom's, Smali, code. Links to all S3 MODs and Tweaks!
This thread is inspiring me to finally get another Linux box running... and finally get to work building my own ROMs instead of bugging developers for simple stuff I know I could probably do myself.
Great thread!
Sent from my Frosty-powered SGH-T999 via Tapatalk 2
Thanks bro! And thanks guys! This stuff isn't hard at all, you just have to know where to find your answers. When I was learning all this the hard way I always thought, "man it would be nice if someone put a basic all in one guide." Well that is my plans here. Also I will do my best to help with any issues and/or error you might encounter as well as I am sure Jovy wouldn't mind helping you guys out as well. Dude is a stand up guy! That is why I love the Android community, everyone help each other!
Thanks bro! And thanks guys! This stuff isn't hard at all, you just have to know where to find your answers. When I was learning all this the hard way I always thought, "man it would be nice if someone put a basic all in one guide." Well that is my plans here. Also I will do my best to help with any issues and/or error you might encounter as well as I am sure Jovy wouldn't mind helping you guys out as well. Dude is a stand up guy! That is why I love the Android community, everyone help each other!
And let me help you what I can.. Confirmation # 25913992HP008102C
I am a family man like you. I am sure you are good or better than me on balancing between work and life. Kudos my friend. :good:
Re: [Guide][How-to's]Rom's, Smali, code. Links to all S3 MODs and Tweaks!
Bro thank you! Really helps and I really appreciate it! Paypal is going to think something is up with all these donations from you buddy lol! You rock man.
Yeah I try to keep a good balance. I have been doing OK, just haven't been sleeping lately. Have a lot planned here and hope this turns into a one stop developers how to and help thread, also this way we can all work towards a common goal: To make these awesome devices into the super phones they are and how Samsung should of released them.
Is there a compile list somewhere with different mods? I have been searching for a while on this forum and can't seem to locate...
I am not looking into building a rom for the public just wanted to tweak a bit to make something descent for myself...I love doing this kind of things, more of a hubby...something to do my spare time .
How to setup a development environment for nOobs, How to make a basic ROM from Samsung's stock firmware, how to setup and use the apktool, how to compile AOKP for the d2tmo (T-Mobile S3), how to port to an unsupported device for AOSP/CM/AOKP coming....
Table of contents
Setting up Linux and a developers environment how to for Linux - post 2
Android Kitchen how to for Linux - post 3
Apktool how to for Linux - post 4
Manually decompile and recompile smali, jar's and even apks' how to for Linux - post 4
How to compile AOKP for d2tmo (T-mobile S3) - post 5
How to cherry pick - post 5 Thanks to Midnight_Rider - post 5
How to compile a kernel for d2tmo (T-mobile S3) - post 6
Code:
#include
/*
* Your warranty is now void.
*
* I am not responsible for bricked devices, dead SD cards,
* thermonuclear war, or you getting fired because the alarm app failed. Please
* do some research if you have any concerns about features included in this ROM
* before flashing it! YOU are choosing to make these modifications, and if
* you point the finger at me for messing up your device, I will laugh at you.
*/
By using these guides you agree with the above terms!
Ok guys here is my setup that has successfully worked for me for over 2 years. You have to have a developer environment like this to move on to the "how to" build a basic ROM. Also again this guide is for Linux ( 64 bit is a must!!!) Here goes.
Personally I run Ubuntu 12.04 LTS and strongly suggest you use it as well if you plan on doing extensive development. Head over to Ubuntu and download it there. Download page
Now after you have downloaded Ubuntu (64 bit!) you need to install Linux.
Easiest way is to put in a blank DVD and click on the ISO(Ubuntu os) and burn the image on the DVD. You can also setup and burn it onto a thumb drive that is at least 4 gb. You will need to Google this if you want to go that way.
once you have burnt the image you will need to install, reboot your computer and watch the screen (make sure the DVD or thumb drive is in.) Most computers will say either hit "ESC" or F9 or F12 to pull up boot options.
Now select the option that say something about DVD/something,,,, this will bring up the options from within the boot disk. Select live boot. This will bring up Linux. Once it is up sign into your Wifi router because this is needed in the install.
Click on the Icon that says install Ubuntu. Install . . . and follow prompts. Very easy setup...
Congratulations you now have Linux installed.
Before anything you need to install right click terminal then reboot for it to effect. Do this now.
Code:
sudo apt-get install nautilus-open-terminal
Now head over to my github and download the developer setup package I have made for you guys. This way everything is in one place. I will try and keep the tools up to date as well. Download - https://github.com/jamison904/developer_setup
Once downloaded, extract. Then open the folder find andadb.sh. Right click it and go to permissions and mark this file executable. Now open termial and;
Code:
. andadb.sh
Now you will have a few options. BE CAREFUL :evil: not to do them all. Some we still will need to do manually and will cause issues if you do them :shock: here.
**********************************************************
Android ADB Installer 2.1
Main Menu
**********************************************************
1 - Resolve dependencies ( Run this first )
2 - Install Android SDK & Android NDK
3 - Install adb & fastboot
4 - Nautilus right-click to adb push support
5 - MTP Support for Galaxy Nexus <- Do not do!
6 - Create/update the 99-android.rules file
7 - Install aapt & apktool <- Do not do! NEED TO DO MANUALLY
8 - Install git-repo <- Do not do!
9 - Help and information
0 - Exit
*********************************************************
Enter selection:
once you are done with this step you are 90% done. You can now start playing with the Android Kitchen. I will make another thread to show you how to set up and use the apktool.
Update for java
The script above will install an outdated version of java. No worries, here is the fix.
- first you need to uninstall the current version of Java by copying and pasting this into the terminal:
This is a rough draft and I will clean it up and make it look pretty later... :cool:
OK guys this is a step by step "How to"
The goal is to teach you how to take a stock firmware from Samsung and convert it into a custom ROM that anyone can download and flash through a custom recovery like ClockWorksMod (CWM.)
- First off this guide is written for Linux. I am personally using Ubuntu 12.04 at the moment. I really don't believe Android development should be done on Windows so I will not be writing a Windows version of this guide. That being said, I don't have an issue with someone else writing one and using this to convert to as long as it is posted here!
- At this point I am going to assume you are running Linux and have some basic understanding of it. Now you will need to have Java and Android SDK installed. I have written a "HOW TO" above
- extract Samsung's firmware, then extract the .tar. Now move the boot.img, System.img and the cache.img to a folder called "original_update" inside the Android kitchen.
============================================================
Android Kitchen 0.223 - by dsixda (xda-developers.com)
============================================================
> MAIN MENU
1 - Set up working folder from ROM
2 - Add root permissions
3 - Add BusyBox
4 - Disable boot screen sounds
5 - Zipalign all *.apk files to optimize RAM usage
6 - Change wipe status of ROM
7 - Change name of ROM
8 - Show working folder information
0 - ADVANCED OPTIONS
00 - LEGACY OPTIONS (old and rarely used)
99 - Build ROM from working folder
The format for each ROM must be one of the following:
- system.img + optional boot.img/lib.img (e.g. stock ROM or Nandroid)
- ZIP file for a custom ROM (e.g. update.zip)
- ZIP file containing *.img (e.g. stock rom.zip)
- ZIP file containing shipped ROM in SYSTEM + BOOT folder format
- Working folder made with this kitchen (e.g. WORKING_old_rom)
Android OS version : 4.1.1
Device : d2tmo
Model : SGH-T999
ROM Name : JRO03L.T999UVDLJA
Rooted (Superuser.apk + su) : NO
Rooted (unsecured boot.img) : NO
BusyBox installed : NO
BusyBox run-parts support : NO
Apps2SD (Apps to EXT) enabled : NO
/data/app enabled : NO
Custom boot animation allowed : NO
Nano text editor installed : NO
Bash shell support : NO
/system/framework is deodexed : NO
/system/app is deodexed : NO
radio.img found : NO
ROM will wipe all data : NO
Android OS version : 4.1.1
Device : d2tmo
Model : SGH-T999
ROM Name : Hello World!
Rooted (Superuser.apk + su) : YES
Rooted (unsecured boot.img) : YES
BusyBox installed : YES
BusyBox run-parts support : NO
Apps2SD (Apps to EXT) enabled : NO
/data/app enabled : NO
Custom boot animation allowed : NO
Nano text editor installed : NO
Bash shell support : NO
/system/framework is deodexed : NO
/system/app is deodexed : NO
radio.img found : NO
ROM will wipe all data : NO
Now at this point after making your tweaks and changes, you will select option # 99. After that I am normally running after my daughter so I pick option # 2 which automates the zipping, signing, and naming process
Now very import before you flash!! Make sure you compare the blocks from my installer script and the one you have from the kitchen. Make sure that yours has this information and nothing else or you will end up with a soft brick or even a hard brick with no return!!
Code:
/dev/block/mmcblk0p14 - for system
/dev/block/mmcblk0p17 - for cache
/dev/block/mmcblk0p15 - for data
/dev/block/mmcblk0p7 - for the boot.img (kernel)
- Now open the terminal and navigate to the desktop. (or go to Ubuntu software center and search "right click terminal" and download it.
- No that you are in desktop in the terminal you need to give each of the three files root access.
- to do this you will need to chown -R and type the location of the file.:
Code:
chown -R
- The quickest and easiest way to type "chown -R " then the location (jamison904:jamison904) then drag and drop the file into the terminal. So it will look like this (also it will prompt you for your password.)
- Open the terminal in the same folder as the apps you want to mod. I normally take the app an the frameworks and place them in a folder on the desktop. I name it whatever the project is. i.e. "Toggles mod"
- now you will need add the framerork-res.apk and the twframework-res.apk to the apktool.
Code:
apktool if framework-res.apk <- enter, then
apktool if twframework-res.apk <- enter
Now you need to decompile the apk you are working on, lets say the SystemUI.apk
Code:
apktool d SystemUI.apk <- enter
At this point you will make your modifications. . . . then you will need to recompile the apk.
Code:
apktool b SystemUI <- enter
Now if all goes well you will have a new modded apk. One more step and you're done.
- Last you will need to open the archive of both the orignal apk and your new modded apk.
- Grab the META-INF folder and the original AndroidManifest.xml from the original apk and drag and drop both into your new modded apk then close the archive.
- I have attached a test zip for you to use. Just place the apk or jar where it goes. ie...SystemUI.apk goes into system/app and framework-res.apk goes into system/framework. Just double click the zip and go to the folder the apk or jar goes to and drag and drop it in then just close the archive. No signing needed this way.
Now make a new folder. I named mine smali. Place both into the new folder.
Next go to Ubuntu software center and download 7zip.
Lets use the android.policy.jar as an example for this part of the guide.
Take the android.policy.jar and place it into the new folder (smali)
double click on the android.policy.jar to open the archive. Then click on the class.dex and drag it and drop into the folder (smali)
Now for the fun part.
Right click and open terminal here inside the folder. (If you haven't got it yet please do. Go to Ubuntu software center and download right click terminal.)
Now you type this or copy and paste:
Code:
java -jar baksmali.jar -o classout/ classes.dex
this will decompile the class.dex to a folder named class. Make your changes then continue.
This will give you the output of new-classes.dex. If you get any errors or don't get a "new-classes.dex" then you had an error. Copy what the terminal says and paste it here and I will help you figure it out. If it is long please paste it over at pastebin.com and post a link here. Trying to keep it clean in here. Thanks!
You will want to copy the android.policy.jar and the new-classes.dex to a new folder inside the folder you have been working. I name this folder Test1. This way you don't overwrite the stock ones. Plus makes it easiser to keep track of what worked and what did not.
Now all you need to to is double click on the android.policy.jar to open the archive again. Now since you are in the Test1 folder rename new-classes.dex to
classes.dex. Last just drag classes.dex to the archive and drop it. It will add the new classes.dex to the archive. Once it is done close the archive and test to see if your chages worked.
I have attached a test zip for you to use. Just place the apk or jar where it goes. ie...SystemUI.apk goes into system/app and framework-res.apk goes into system/framework. Just double click the zip and go to the folder the apk or jar goes to and drag and drop it in then just close the archive. No signing needed this way.
First off let me start with saying this, half assing a kernel or not following all the steps exactly will brick your device!. You have been warned. I personally was every hesitant to even try to make my own kernels because of the brick factor. After researching for weeks and reading like crazy I felt like I had enough knowledge to attempt to build my own kernel. After talking with my buddy TDJ he told me that when it comes to kernels you just have to get learn by hands on. Of course he was right. So be careful and if something doesn't seem right,do not flash it. Also the kernel_test.zip attached is for TMO/ATT S3. I haven't checked to see if the boot block is the same for all of the US S3's. I'll check and update this. Until then only use for TMO/ATT S3.
Code:
#include
/*
* Your warranty is now void.
*
* I am not responsible for bricked devices, dead SD cards,
* thermonuclear war, or you getting fired because the alarm app failed. Please
* do some research if you have any concerns about features included in this ROM
* before flashing it! YOU are choosing to make these modifications, and if
* you point the finger at me for messing up your device, I will laugh at you.
*/
[COLOR="Red"]By using this how to you agree with the above terms![/COLOR]
Now with that out of the way lets have some fun! This how to is for the T999 TW kernel. This guide will work for all S3 devices with minimal changes. Also the basics here will work for all devices. Also at this point the guide is only build a stock kernel without changes. That will come in another update. I will need to show you git and how to use it before you can make changes. Also if you make and changes and you share the kernel with others you have to post your source!! So you will need to know how to use github or bithub. These too will come later.
First you will need to download the source for the kernel. You will need to go to http://opensource.samsung.com/ and find the source for your device. Search for t999 and grab the one named SGH-T999_JB_TMB_Opensource.zip. Or you can grab it from my Goo account here. . . . .
Now you need to extract the zip. Then extract Kernel.tar.gz. Now make a folder in your home directory if you have not already called android. Then inside android make another director called kernel. Last make a folder for you kernel, you can name it whatever. For this how to lets just call it T999_TW_kernel. Now move everything from the extracted Kernel.tar.gz to this folder. This is your kernel working folder.
Next you will need to choose the toolchain you plan on using. There are many great ones out there. Just Google "kernel tool chain" to see the many different ones. The Android NDK comes with a bunch and most are 100% stable. Since I also suport AOKP for many devices, I just use the one they use. I have uploaded it to my github for you guys to download and use. Go to https://github.com/jamison904/arm-eabi-4.6 and click on zip to download it.
Now you will need to set your path and set the cross compile in your make file inside your kernel working folder.
We are going to setup your toolchain path now. Extract the downloaded toolchain from my github and make a folder inside the android folder called toolchain. Now move the extracted tool chain here. Open up the make file in the kernel folder and set your path like below. (of course change Jamison904 to whatever yours is named.) save and close.
Code:
ARCH ?= arm
CROSS_COMPILE = /home/jamison904/android/toolchain/arm-eabi-4.6/bin/arm-eabi-
Name your kernel! Open the make folder and make the change then save and close.
Now open terminal here inside the kernel build folder. You need set it up. You need to:
Code:
make clean && make mrproper
Ok time to pull the defconfig from your phone (This is for a TW Kernel so you need to be running a TW ROM. You also will need to be running a stock kernel for this to work right...) You will need to connect your phone to your computer with adb debugging turned on. Then open the terminal from your desktop and:
Code:
adb pull /proc/config.gz
then
Code:
gunzip config.gz
This will give you a file called config. You will want to rename this file to t999_defconfig. After that you will need to move this file to /home/jamison904 (your user name)/android/kernel/T999_TW_kernel/arch/arm/configs. Drop it here.
Now it is time to attempt to build. You will need to do:
Code:
make xconfig
This will bring up a nice user friendly UI to help you set up the build.
Now you need to click on the folder. Navigate to arch/arm/config and click on your T999_defconfig.
This shows you where to find the schedulers. You can change the default scheduler here. Also can turn them on and off, as well if you want to build them in or make them build as a module.
This shows you where to find the governors. You can change the default governor here. Also can turn them on and off, as well if you want to build them in or make them build as a module.
Now lets see if you set it up correctly.... lol. You will do:
Code:
make
Later after you know that it will build you can seed it up by doing make -j5. This will make with 5 jobs at once. This is way faster but very hard to trouble shoot and find your errors. If it stops without finishing you will need to make clean && make mrproper then do the xconfig again and save and close then "make" .... This will only make with one job at a time thus you have an error and it will stop and you will be able to read the error. Copy and paste to pastebin.com and post the link here and I will help you figure it out.
If you get this, congratulations you have made your first kernel... time to package it up and test.
Finding the zimage (kernel itself.) Navigate to arch/arm/boot and grab the zimage.
Now to find the modules. Do a ctrl f in the root of your kernel build folder and screach for .ko. Make sure to include the . before ko. Then copy and paste these into a folder to hold them for the zip.
Now you need to unpackage a boot.img and replace the zimage then repackage it up. The easiest way to do this is with the Android kitchen. Takes less then a minute. If you have been following my guides here you will already have it setup and have working knowledge of the kitchen. If not, stop here and go catch up, i'll wait.... Ok moving on.
I made a folder called WORKING_Kernel to keep these away from real working folders just in case I forget. Don't need to update my S2 ROM with a S3 kernel. Anyways...
Place a stock boot.img into the folder
Now start up the kitchen and press 0. Then option 12 for boot.img.
Then press w. This will unpack the boot.img.
The end result will be a folder called "BOOT-EXTRACTED"
Open it and you will see the ram-disk and the Zimage (kernel). Delete the Zimage here!
Grab your new Zimage and copy and paste it in to the "boot-extracted"
Now to repackage it. Back over in the Kitchen press "b" to build
Your new kernel is in the boot.img
Now to flash the kernel. I have made you guys an empty flashable zip attached below. This way no one breaks their device trying to flash their kernel. If you do brick you didn't read the directions as this zip is dummy proof so to speak.
Now double click on the kernel_test.zip and drag and drop your new boot.img into the archive.
Now navigate to system/lib/modules and press Ctrl A to select all of the modules then drag and drop these here.
Done. Copy and paste the zip to your SDcard and reboot into recovery and pry.... lol. You will be good if you followed the directions. Enjoy your own build stock TW kernel! Again remember not to public share your kernel unless you have uploaded "your exact source" and can provide a public link to it. You have been warned! Next updates will include how to work git, commits, and github as well as some more advanced kernel tweaks and code. Also how Cherry-pick
For more advanced kernel work you will need meld to work conflicts. Open terminal and:
Code:
sudo apt-get install meld
Now when you get a conflict from cherry picking you will do
Code:
git status
this will show you the conflicting files. Then to work them you will need to