Guide - Introduction to Rom building/development - ONE General

Hello everyone.
I’ve decided to build this tutorial in order to assist all developers and builders into the ROM and kernel development. I’ve felt motivating into writing this small post because I feel that the current information available is confusing and also do not provide the set of skills and information to help someone in the first steps.
This tutorial will be divided on:
The Machine Configuration
The tools of development
The Source
Hardware
Software
What to do to be able to Innovate
The Machine Configuration
In order to have a good machine configuration you should select your distro based on the packages which are provided to developers. In my opinion the best distros are Fedora and Ubuntu. It is important to learn a bit how Linux works in order to fully understand what we are editing as Android is nothing more than equivalent Linux system where you run java on a virtual machine. In other words, you’ll understand with time that many parts which are used on Linux Operating system it is also used on Android Operating System (example: bionic, kernel libs).
After you installed your Linux system you’ll need to prepare your machine for building. For that you’ll need to install the following packages:
Code:
sudo apt-get install git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng maven
sudo apt-get install openjdk-7-jdk
Code:
sudo apt-get install android androidsdk-uiautomatorviewer android-copyright android-src-vendor android-emulator android-tools-adb android-headers android-tools-adbd androidsdk-ddms android-tools-fastboot androidsdk-hierarchyviewer android-tools-fsutils androidsdk-traceview
After you have the basic packages installed we are going to add the repo instructions to you git in your machine. Basically this will interpret the source information when you are syncing new code from google repos and we’ll add to the folder /bin/repo.
To do that we’ll run.
Code:
[B]mkdir -p ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo[/B]
And run the /.profile. Basically this command will reload information of the new settings for your profile, where it’ll read the folder ~/bin/repo information for all situations. In the future only makes sense to load again in case you have added a new repo instruction.
Code:
[B]. ~/.profile[/B]
Now we are going to sync the source code. I’ll use here as an example CyanogenMod as I believe to be the easiest for anyone which is starting. Lets imagine we are going to put all the source on a folder named cm, you’ll have to just run the following commands.
Code:
[B]mkdir ~/cm
cd ~/cm
repo init -u git://github.com/CyanogenMod/android.git -b cm-13.0[/B]
So in order to explain what we’ve done here by steps. The repo init –u basically is a command instructing to go to the GitHub on that specific location and extract what is available on the cm-13.0 branch regarding to manifests. So basically it’ll automatically push the file which has all CyanogenMod source to .repo/ folder with the name manifest.xml
After you have loaded this command you’ll run the repo sync , basically this command consists on downloading all the code into your building folder (in this case cm folder).
After the repo sync is complete you’ll have interest on having a local_manifests. Basically on this local_manifests.xml , where some developers prefer to name it as roomservice.xml it is where you’ll add the changes to the manifest.xml or even sources which you wish to add to your building folder. This is a solution to you never edit the manifest.xml.
Usually it is added on the local_manifests the folders related to your device tree. I’ll give in this example how to build for the OnePlus One (bacon).
A device tree consists on configurations where you set information related to your device. Example if is qualcom, usually is android_device_qcom_common (where is the general settings) together with android_device_oneplus_bacon (where are the specific settings). When I say settings, for you to understand is like compile with the folder hardware/qcom/display for the display. You should take some time to explore to understand what is in it.
So you’ll add your local_manifests.xml this way.
Code:
[B]
mkdir .repo/local_manifests
nano .repo/local_manifests/local_manifests.xm[/B]l
You now add:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="CyanogenMod/android_device_oneplus_bacon" path="device/oneplus/bacon" remote="github" revision="cm-13.0" />
<project name="CyanogenMod/android_device_oppo_common" revision="cm-13.0" remote="github" path="device/oppo/common"/>
<project name="CyanogenMod/android_device_qcom_common" path="device/qcom/common" remote="github" revision="cm-13.0" />
<project name="CyanogenMod/android_kernel_oneplus_msm8974" path="kernel/oneplus/msm8974" remote="github" revision="cm-13.0" />
<project name="TheMuppets/proprietary_vendor_oneplus" path="vendor/oneplus" remote="github" revision="cm-13.0" />
</manifest>
Now you need to run the repo sync command again.
This has to do separately the first time or it won’t sync all the files you need. In case the repo sync fails with an error saying you need to do –force-sync just run repo sync –force-sync (this happens only when you change common git sources with your manifest.
After the sync is done you are ready to build!
To start building you’ll need to run the .envsetup.sh , which will load all the source code into memory. After that breakfast bacon userdebug (in case it is for the OnePlus One device), then later make bacon (the word bacon it is to be used on all devices , here it is just a coincidence with OnePlus One)
Code:
[B]. build/envsetup.sh
breakfast bacon
make bacon[/B]
After it compiled your rom will be located at /cm/out/target/product/bacon/
Easy until here? I hope so.
Possible errors :
Q: Receive error: fatal: duplicate path xxx/xxx in ~/cm/.repo/manifest.xml
A: edit .repo/local_manifests/local_manifests.xml to remove the item which matches the item located in bold.
Q: How big is the repo?
A: 50GB just source code and around 10GB when built per device. Therefore you should aim to have about 60GB free on your system.
The tools of development
Git
Probably many of you question about what it is git, read about it on the github manuals etc and still cannot figure out how to work (I took two weeks to understand that it is really simple). So imagine that you have a diary, but instead of being separated by dates it is separated by titles, which we call commits. And what is a commit? Basically it is a portion of code. So when you make a change and want to record that change, you create a commit and in the end it’ll be a portion of code. This portion of code, known as commit, can be easily ported between different sources.
Here is an example:
https://github.com/jgcaaprom/androi...mmit/9f16b3cd79ad7bb8c821a518ca73725f19c38478
The commit number is: 9f16b3cd79ad7bb8c821a518ca73725f19c38478
This commit has recorded a change of IZAT_DEBUG_LEVEL = 2 .
Now how to bring other commits from different sources into our source.
The process comes in 3 phases:
First we’ll have to add the source where the commits that interests us are with git add source_name link
Second we’ll download that source by using git fetch source command
Thirdly we’ll cherry-pick (bring the portion of code recorded in the commit) into our source in order to make the changes automatically.
So lets see a real scenario. Imagin you are interested on cherry-picking this source:
https://github.com/CyanogenMod/android_device_oneplus_bacon
What you’ll have to do is.
Step one: git add cm https://github.com/CyanogenMod/android_device_oneplus_bacon.git
Step two: git fetch cm
Step three: (imagine this is the commit you want:
https://github.com/CyanogenMod/andr...mmit/58027fcbea4dd9fbb5aaeb8ae5f6e32bdf613573 )
The commit number is: 58027fcbea4dd9fbb5aaeb8ae5f6e32bdf613573
So you’ll git cherry-pick 58027fcbea4dd9fbb5aaeb8ae5f6e32bdf613573
And voila! You’ve done your cherry-pick . Now it is important to have in mind how the cherry-pick process works which I’ll explain on the next step.
Cherry-picking
Cherry-picking is a process of importing code from one source to another. So the process that git does basically is, compares your present files in the source with the files that was on the source you are cherry-picking and if everything is a match it’ll change the code automatically for you.
Now lets pick up the example above and imagine that the changes you are doing instead of being exactly the same as described here:
https://github.com/CyanogenMod/andr...mmit/58027fcbea4dd9fbb5aaeb8ae5f6e32bdf613573
Your source has a difference which doesn’t have this line:
32 private static String CONTROL_PATH = "/proc/touchpanel/keypad_enable";
You’ll notice that it’ll give a conflict. The reason for that is because the git when comparing understood that there was no match between the sources. When that happens means basically that there might be changes you should do in order for the code to be compatible, so you’ll have to review that code.
Now the review process is very simple. For you to see which files are in conflict you’ll have to run git status ( basically this command informs you of the situation of the commits which are being cherry-picked and the changes which you’ve done. )
You’ll notice that the files which need to be edited/review are in red. In case it appears files in green, means that there was a perfect match and doesn’t need a review.
Pretty useful right?
After you finish editing all the code you’ll do git add . and for this exercise do git status again just for you to see what happened . Everything is green. To finish the cherry-pick you’ll now do git commit and done!
How to record my own changes and create a commit with it.
Basically this process is exatly the same as the previous one, the only difference is that after you made the changes, you can make git status, then git add filename in case you want to commit only one file or git add . in case you wish to commit all the files and to record the commit you write git commit, or git commit –m “commit message”.
Congratulations! You’ve just recorded your commit!
Git push/pull
There will be moments where we just wish that we could be lazy and cherry-pick everything all at once. Well there are some scenarios where you can actually do that, but remember it is not perfect. Lets imagine we are using the source above, and CyanogenMod uploaded like 20 different commits, your source is not exactly like CM source but you wish to keep your changes and also have all changes from CM what to do?
1) You can cherry-pick one on one. And waste a lot of time…
2) You can make a new source based on cm and include your changes there
3) You can git pull
Git pull basically will update your source with CM source by merging all the commits. You do that with:
git pull cm cm-13.0 (in case your rom is Marshmallow)
The git pull should only be used when the sources are very similar and you are using as a base. Basically it’ll warn you that’ll merge the code and voila done! 20 commits added to the source.
Now when on the situation that the sources are slight different or very different it’ll create a conflict. Again the git will do comparisons between the entire sources, check which commits are missing, compare the files just like with cherry-picking. And when you do git status, it’ll appear on red all files where you need to review your code.
After you finish, same as before
Code:
[B]git add .
git commit[/B]
Done.
I hope you are understanding everything until here.
git reset HEAD~n
This command is rarely used but is super usefull. Basically you are saying to git that you with to remove n commits you've reated/cherry-picked. For you guys to understand how it works, basically imagin you have just written/cherry-picked 10 commits, and you do git reset HEAD~3 , he'll basically remove from records 3 commits. But... That doesn't mean he reverted the code! In case you wish reset the code you need to do git reset --hard.
Also it is very usefull to help rewrite the history. Lets think the example I given before. When you do a git reset HEAD~3 , basically on a history of A B C D E F G H I J commits, the git will remove only the recorded commits H I J. If you do after a git status, you'll understand that the code is still there, which means the changes you done on H I J will still be there. So you can create a new commit with H I J all together . Simple!
Another way to create a unique commit with H I J is by using git rebase -i HEAD~3 , where you basically are instructing the git that you wish to rebase the source with an interactive selection. You'll see that it'll appear a commit list where you can remove other commits from history. But since you wish to create a unique commit you'll wish to change the instruction from pick with the letter s (without capslock term for squash) . Example:
Code:
[B]pick d0c49f4 UsbDeviceManager: Remove charging from persisted function composition
s 2c755a6 SystemUI: fix NFC tile sometimes hiding
s e39d1d7 Revert "base: start nfc service prior to systemui"
pick 9164274 DocumentsUI : Hide advanced menu option when in forced mode
pick 5f8d3f8 Themes: Expose Power Dialogs
pick 9153396 SysUI: Don't let rogue themes ruin notifications
pick 226797c Revert "Only show keyguard panel if on lockscreen + no activity on top"
pick e843aaf Fix NPE in DocumentsUI when rotate UI before format as internal
pick 26079d3 SystemUI: detect rotation and resize mKeyguardBlur accordingly
pick 80b060d Automatic translation import
pick 4282864 Automatic translation import
pick d442df6 wifi: Enable WiFi IpReachabilityMonitor by default
pick 9cf937f SystemUI: Add margin in qs_tile_top between instruction text and add button[/B]
Cool right?
And I believe I've covered with some examples the git. As you can see, once you get used to git you'll be able to use it easily.
Toolchains
There has been a big debate from many developers on which toolchains to use. Many prefer sabermod, others prefer uber, others google toolchain, etc. It is in fact debatable. If you ask me which one to use, I would say google or uber (very similer to google) and the gcc used by stock on the source. The reason is simple, the code is optimized for a certain gcc version, if you start using a gcc version which is not prepared to be used on the code, it won't translate correctly your instruction.
The source
When you start building roms, you should at least know a little about how the source of android is organized, what language it is used, etc. On android it is used C, C++, Java, Assembly. Withing the following folders inside the source it is used:
Java
Frameworks
Packages
external (some packages)
C++
ART
bionic
hardware
C
kernel
hardware
Assembly
bionic
some of the kernel libs
This is important for you to navigate easily within it. Some of you ask yourselfs what is one thing or another. I'll represent that to the following image which is published on the google developers page.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Now I believe you wish to know which parts should be used in order to put a rom working for a certain device. Those parts are:
Hardware
Kernel
device tree
Vendor blobs
These parts are the "base" of your build to put a certain device in a working, since on these parts is where lies the instructions for the device to understand what to do.
The build folder is where you specify instructions of the building process. For example : Certain optimization, which GCC to use, where will the compiler find the apps to compile.
frameworks, system, packages and some of the folders within the external folder are the packages of what you will have inside the rom which is general and can be present on any rom.
external folder has present different things, compilers such as proguard, jemalloc. external software used by the rom such as sqlite.
prebuilts folder has present everything related to stuff which is already compiled, in this case clang, gcc toolchains.
I've done a very summarize version of the source in order for you to understand how that google built things, so I hope it is simple to understand these basics.
(to continue)

reserve1

reserve2

reserve3

Another great contribution bro. Thanks for your work and for your help. Starting read right now
Edit: Amazing guide
Just one request, please bold when you write a command. I think it becomes more eligible.

@jgcaap I think this is useful
For those already have JDK8 installed, they can use it by adding this code to $HOME/.bashrc
Code:
EXPERIMENTAL_USE_JAVA8=true
You just have to source ~/.bashrc before make bacon

There's nothing better than learning something from a professional who you know has done such a great work. Thanks a million!! @jgcaap

Very useful.. Thanks for sharing =D>
Sent from my A0001 using XDA-Developers mobile app

FSadino said:
@jgcaap I think this is useful
For those already have JDK8 installed, they can use it by adding this code to $HOME/.bashrc
Code:
EXPERIMENTAL_USE_JAVA8=true
You just have to source ~/.bashrc before make bacon
Click to expand...
Click to collapse
I'll speak about different custom GCC and also other compilers, but it'll be on another section. I'll continue writing this on wednesday (exam tomorow). I believe that my guide will help understand all the basics.
If I speak about that mode, I believe it'll give the idea that it is a feature of linux and it isn't. It is something you can change inside the source in many different ways.

jgcaap said:
I'll speak about different custom GCC and also other compilers, but it'll be on another section. I'll continue writing this on wednesday (exam tomorow). I believe that my guide will help understand all the basics.
If I speak about that mode, I believe it'll give the idea that it is a feature of linux and it isn't. It is something you can change inside the source in many different ways.
Click to expand...
Click to collapse
This might sound a little stupid but which JDK version is recommended? 7 or 8? Seems like 7 cause you have to enable "Experimental Use" for 8.

Great guide! Can you, if you have time, also post a guide only focusing on kernel building?

abhibnl said:
Great guide! Can you, if you have time, also post a guide only focusing on kernel building?
Click to expand...
Click to collapse
The guide is incomplete, will write more on wednesday. I'll cover everything in a very simple waywith praticle solutions.

thank you , that what was looking to develop on my tablet , I can use basic as this tutorial for other devices.
continue with tutorial , as many want to learn, but has no simple guide to base

you must wrote revision="cm-13.0" /> instead of revision=”cm-13.0” /> 'cause it give you an error that you can't be able to repo sync

fafa77140 said:
you must wrote revision="cm-13.0" /> instead of revision=”cm-13.0” /> 'cause it give you an error that you can't be able to repo sync
Click to expand...
Click to collapse
i literally stared at this for like 1h and didn't find any difference could you please elaborate more...

baconxda said:
i literally stared at this for like 1h and didn't find any difference could you please elaborate more...
Click to expand...
Click to collapse
The quotation marks surrounding cm-13.0 in first post are not the right ones. So you need to replace those quotation marks if you copied and pasted the code in your manifest. Just delete the quotation marks and type them again.

joshuous said:
The quotation marks surrounding cm-13.0 in first post are not the right ones. So you need to replace those quotation marks if you copied and pasted the code in your manifest. Just delete the quotation marks and type them again.
Click to expand...
Click to collapse
ohhhkayyy.........:good:

fafa77140 said:
you must wrote revision="cm-13.0" /> instead of revision=”cm-13.0” /> 'cause it give you an error that you can't be able to repo sync
Click to expand...
Click to collapse
good catch. I never thought the keyboard would be writting differently when not on the terminal. Thanks

jgcaap said:
good catch. I never thought the keyboard would be writting differently when not on the terminal. Thanks
Click to expand...
Click to collapse
No problems

fafa77140 said:
No problems
Click to expand...
Click to collapse
updated more stuff today.

Related

[ Tutorial / Reference ] Learning to Build for Galaxy Note

--
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
INTRODUCTION
There are several guides and tutorials that teach you how to build your own custom firmware from source.
To the trained eye, the steps to be followed are essentially the same.
But to users with relatively lesser experience in programming or software development/scripting of any kind, it often seems to be a daunting task.
One of the many reasons for this is that users usually have atleast 2 similar guides open side-by-side on their screens.
And when one or two lines of code/instruction do not match, all hell breaks loose.
This might not be the case with you, but it sure was with me.
This guide is based solely on my experience in starting from scratch, trying to build a ROM from CyanogenMod and AOKP sources​​
Before we proceed any further, I would like to clarify that this is NOT a definitive tutorial,
nor is it the best way to get started in ROM development.
There may be ‘kanging’ involved, zipping-unzipping as well.
Purists may take exception to some steps – but then they are purists for a reason.
My purpose is NOT to oppose what the better-skilled developers opine,
nor is it to encourage the said procedures.
However, in the event that I do mention using them –
be aware that the attempt is solely to provide a small impetus to enthusiastic learners, so that it may help them have some know-how on how to finally get started. ​
I intend to proceed slowly, rather than publishing the entire thing all at once
and then having confused users discussing Step 2 and Step 2002 at the same time.
In order to avoid this, the posts that follow will be updated in parts i.e
we shall together proceed ahead once a sizable majority of participants have successfully completed a chunk of required steps.
This, I feel, will ensure that the ensuing discussions are enjoyed and benefitted from by several more users at any given time.
REQUIREMENTS
We would be using the CM10 and AOKP sources as reference to learn building for our device.
For the purpose of this tutorial, we shall work together on the following environment –
◘ Ubuntu 12.04 64-bit
◘ A minimal requirement of a Quad-Core processor with >= 4 GB RAM
◘ A high-speed connection >= 2 mBps
◘ Solid State Drives are highly recommended.
◘ Google Toolbar
◘ Patience
◘ Patience
◘ And more Patience
​
Assuming that you would be syncing either one of the source trees, you would require
about 70-80GB of free space to sync repositories and compile a ROM from start to finish.
Users on Windows have an option of dual-booting.
If they are hesitant to do so, they can also run Ubuntu using a Desktop Virtualization Software.
However, in this case you would then require atleast 6GB of RAM, if not more,
to run both operating systems concurrently.
Users building on a remote server, I presume, would be spoilt for choices different Linux distributions available.
Be sure to have an SCP client in handy.
It is my humble request that we all follow good etiquettes and rules all the more strictly to ensure an enriching learning environment.
◘ Please do not troll here.
◘ The thread is not to be used for smug remarks or aspersions (as most of us are accustomed to)
◘ Code Snippets that will be posted on this thread using the code tag, as part of this thread, are supposed to be entered into the Linux terminal.
◘ You are requested to use Pastebin to post logs and build errors
◘ Please do not use any fancy fonts or bold typefaces.
◘ Please do not create Thank You posts if a particular solution solves your problem.
​
Each and every solution will be verified, and the author in turn will be requested to mark his post in Bold-Green.
Hence the last point above..
It is a given that this shall forever be a Work in Progress.
Things will be added, things will be removed as time flies by.
The only thing that should remain constant is the willingness to learn.
And the willingness to use Google Search.
BIBLIOGRAPHY
◘ [Tutorial] Compile JB on Ubuntu
◘ [TUTORIAL] So You Want To Build AOKP JB? [Ubuntu 12.04+]
◘ CyanogenMod WiKi
◘ Android Open Source Project
◘ Frequent IRC chats with Pier and bajee11
◘ Google chats with other kind developers, users and friends
--
Part 1: Setting-up Build Environment
--
A Build Environment is the state of the machine being used for development, including the directory structure and environment variables for your particular project. ​
Additionally, the command-line build environment for the platform and projects is your build release directory.
And so it follows that though we have our Ubuntu installations done, we are still required
to install additional packages to set-up a build environment suited for our purpose.
OpenJDK is an open-source implementation of the Java Platform, Standard Edition, and related projects.
We shall use OpenJDK-6. Type the following in your terminal -
Code:
$ sudo apt-get install openjdk-6-jdk
At the end of this step you might get a message in terminal related to the need
to update certain elements to complete installation of required packages.
For this, simply run
Code:
$ apt-get update
Python is a general-purpose, interpreted high-level programming language,
whose design philosophy emphasizes code readability.
It may already be installed on your system. But no harm in checking -
Code:
$ [B]sudo apt-get install python[/B]
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Code:
$ [B]sudo apt-get install git-core[/B]
The Android software development kit (SDK) includes a comprehensive set of development tools.
These include a debugger, libraries, a handset emulator based on QEMU, documentation, sample code, and tutorials.
There are 2 ways to install this.
If your Ubuntu setup is on your Home PC and you have GUI access,
you can download the package from here
http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz
To do the same via command line, type this in your terminal -
Code:
$ [B]wget http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz[/B]
This will download the very same package for you to the current working directory.
Now, you have to extract the folder inside the archive, and place it in your home directory.
To do this, enter the following command in your terminal -
Code:
$ [B]tar -xvzf[/B] <filename>.<extension>
For example, if your archive is named android-sdk_linux.tar.gz
where
android-sdk_linux = filename
tar.gz = extension
you will type -
Code:
$ [B]tar -xvzf android-sdk_linux.tar.gz[/B]
Once your folder is extracted, move it to your home directory. Search Google on how to do it.
Next step is to define the path.
For this, go to your home folder and look for a file named .bashrc
For users having the comfort of a GUI, press Ctrl + H incase the file is not visible.
Remote users can use their SCP Client to find the file easily.
Open the file to edit it, and at the bottom paste the following lines -
Code:
# Android tools
export PATH=${PATH}:~/<folder_name>/tools
export PATH=${PATH}:~/<folder_name>/platform-tools
export PATH=${PATH}:~/bin
In the same manner and place, look for the file named .profile and add the following lines at the end -
Code:
PATH="$HOME/<folder_name>/tools:$HOME/<folder_name>/platform-tools:$PATH"
Once, done you now have the Android SDK successfully installed. :good:
In the end, you have to install the remaining packages and libraries and dependencies and what not.
This varies as per the version of the Ubuntu installation.
Since we are (hopefully) on Ubuntu 12.04 (64-bit) , we need to enter the following command in our terminal -
Code:
$ $ s[B]udo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev:i386[/B]
and then
Code:
$ [B]sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so[/B]
In the even that you get errors relating to unavailability of g++ and gcc
run the following in terminal -
Code:
$ [B]apt-get install gcc[/B]
Code:
$ [B]apt-get install g++[/B]
and then repeat the previous steps.
I would also advise that you install the following as well (more on it later) -
Code:
$ [B]apt-get install lzma[/B]
Code:
$ [B]apt-get install screen[/B]
With the above done, all that is left to do is to initialize the repository that you require and then sync it to your machine or remote server. This we do in the next part.
--
Part 2: Fetching sources
--
Repo is a repository management tool that was built on top of Git
.
Repo unifies the many Git repositories when necessary, does the uploads to the revision control system, and automates parts of the Android development workflow.
Repo is not meant to replace Git, only to make it easier to work with Git in the context of Android.​
More information on the subject can be found here.
In our context, we need to download repositories of the correct Android branch (ICS, JB etc) for which we want to build.
But whose branch?
That is completely upto you to decide.
The first step is to 'download and install the repo binaries'. Issue the following commands in terminal -
Code:
$ [B]mkdir ~/bin[/B]
$[B] PATH=~/bin:$PATH[/B]
$ [B]curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo[/B]
$ [B]chmod a+x ~/bin/repo[/B]
With this done, we now make a new folder in our home directory where we would be downloading our rom sources by initializing the relevant repo
Code:
$ [B]mkdir myrom[/B]
$ [B]cd myrom[/B]
For CM10
Code:
$ [B]repo init -u git://github.com/CyanogenMod/android.git -b jellybean[/B]
For AOKP
Code:
$ [B]repo init -u git://github.com/AOKP/platform_manifest.git -b jb[/B]
You will most likely be prompted for certain details like name, email etc. Fill those in and proceed to the next step.
Once you have the above completed ( repo has been initialized in /....) it is time to sync! :good:
Simply issue the command -
Code:
$ [B]repo sync[/B]
You might have come across variations like
Code:
$ repo sync [B]-j4[/B]
or
Code:
$ repo sync [B]-j16[/B]
Essentially, all are performing the same function. Only difference is that by adding that little -j
we are specifying how many jobs we want to run concurrently, which is in a way directly related
to the number of cores powering your machine.
I have a quad-core, he has a dual-core, what should we use?
Go ahead and see for yourself.
Your first sync (rather a download) would likely take around 45 minutes to 1 hour, if you have a decent internet connection.​
The first time I decided to do this, I wasn't aware of how big the repositories could be, or what sort of an internet connection one would require.
As long as it was an unlimited data plan (yes we have limited data plans in our country), it would be fine I thought.
I had the screen active for around 6 hours without any signs of stopping, until I was finally put out of my misery by good friend antiochasylum -
me: Wow
It takes us a day to download movies
20kbps. Its party time if I can get anything
above 100kbps
Matt: Holy ****. Lol. Mrs Antis galaxy s2 lte gets 5500 down.
Blows the **** outta my note
me: :sniff:
Click to expand...
Click to collapse
Sit back and enjoy.
Do not get all tensed if the text on your screen suddenly stops moving OR is stuck at some place.
Unless and until you are back to the bash shell with a definite error message explaining why repo sync was interrupted - you are all good. :laugh:
--
rvd
reserved
one more
last
And this one is for me..... Thanks a lot dude... will keep watching this space..
Thank you so much, this is great for us newbies :highfive:
Wow, wanted to learn since longthanks
Great idea toxic, you might've just encouraged me to start compiling and building again
Sent from my GT-N7000 using XDA Premium HD app
thanks
Grrr888888. thank you very much :good:
Thank you, with my computer it gonna take forever compiling , it's is only dual core 2,1 ghz :silly:.
But since i've got patient, i'm gonna try.
PS: I have plans to install gentoo on the same team at some point in the future so this will be easy in comparison.
Please share this with other users who might be interested so that all can benefit.
Thanks
Sent from my GT-N7000 using xda premium
While setting up Ubuntu via VM for windows i am able to run though entire installation procedure but getting an critical error after i restart when the installation is complete..
sorry, this may not be exactly related with the topic directly but i thought i might find my answer here..
Sent from my GT-N7100 using Tapatalk 2
What would the error message be? I mean what exactly does it say?
Sent from my GT-N7000 using xda premium
http://pastebin.com/VLtJzaqd
Ubuntu log for your ready reference.
sunny2303 said:
http://pastebin.com/VLtJzaqd
Ubuntu log for your ready reference.
Click to expand...
Click to collapse
It seems he SATA controller in your VM has only one port configured and is unavailable to make hotplugging work.​
Make sure you are not trying to run your installation from a Guest/Limited account.
Also, in case you're trying to run Ubuntu from a CD instead of copying files to the the hard disk, you may face some problems.
Sent from my GT-N7000 using xda premium
Thanks this solution worked You were right the isse was with SATA controller.. I had not assigned it. After assigning it under settings, it worked.
Now I have moved slightly ahead... at the path setting stage
export PATH=${PATH}:~/<folder_name>/tools
export PATH=${PATH}:~/<folder_name>/platform-tools
export PATH=${PATH}:~/bin
while we are writing this in .bashrc are we supposed to replace <folder_name>/ with actual folder name? like say extracted folder name is android-sdk-linux which is placed under home.. so should we write <android-sdk-linux> ?

Paranoid RPG (Repo Pleb Guide)

This should act as a basic guide for improving your workflow while using repo/git
This takes into consideration that you already have the repo tool installed, initialized and synced.
You are still encouraged to read up on how Git actually works as this attempts to keep simple layman terms
Useful guide - http://source.android.com/source/developing.html
Basic terms
HEAD - A pointer to the current active commit (top commit of the current branch)
Branch - Alternate working path, keeps it's own history and modifications
Unstaged - Git keeps track of all file changes regardless of if they are committed or not.
This allows you to select which changes you want to commit without having to first revert your changes.
To stage a change, you'll need to execute the command git add
Staged - Once you perform git add on a modified file, it's now staged and ready for committing.
Note:
You can build and test modified files without actually staging or committing them
You however, cannot push upstream changes without first committing those changes
Basic commands:
repo start (used to create a new branch with one or more projects)
Code:
repo start branchName projectPath projectPath2 ...
git add (used to stage modified/new files)
Code:
git add pathAndFileName
git add .
git add pathAndFileName stages only the named file, while git add . will stage all unstaged files
Click to expand...
Click to collapse
git rm (used to stage deleted files)
Code:
git rm pathAndFileName
git add -u
git rm pathAndFileName stages only the named file (to be deleted), while git add -u will stage all unstaged files that are to be deleted
Click to expand...
Click to collapse
git diff (used to compare file changes, shows the diff between HEAD and the current project state)
Code:
git diff
git diff fileName
When diff is executed, if a file is not specified, it shows the difference between all files changed
The file being compared is shown at the top of the analysis, followed by it's differences
Example: diff --git a/AndroidManifest.xml b/AndroidManifest.xml
Click to expand...
Click to collapse
Deleted lines start with a minus (-) sign
New lines start with a plus (+) sign
Lines starting with @@ are simply line numbers within the file
Example: changing one line in AndroidManifest.xml
Code:
[B]diff --git a/AndroidManifest.xml b/AndroidManifest.xml[/B]
index e5ce889..5b8c41e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
[COLOR="RoyalBlue"]@@ -1581,7 +1581,7 @@[/COLOR]
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.app.action.START_ENCRYPTION" />
[COLOR="Red"]- <category android:name="android.intent.category.DEFAULT" /> />[/COLOR]
[COLOR="SeaGreen"]+ <category android:name="android.intent.category.DEFAULT" />[/COLOR]
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
git status (shows the status of modified files, staged or unstaged)
Code:
git status -s
git commit (commits your staged files to the working directory)
Code:
git commit -a
git commit -m [message]
git commit --amend
commit -a
This should be your standard for creating commit messages. Allows for multi-line entry for well formatted commit messages
commit -m 'commitMessage'
This is essentially a short-cut that allows you to enter a quick commit message
commit --amend
Allows you to amend the commit. It can be used simply to update the commit message or to include new files in a previous commit instead of creating a brand new commit.
Click to expand...
Click to collapse
git remote (create a link to another repository for easy referrence)
Code:
git remote add remoteAlias remotePath
Example: git remote add Google [url]https://android.googlesource.com/platform/frameworks/base.git[/url]
git fetch (update your local copy of a remote branch, does not affect your working directory)
Code:
git fetch remoteAlias -branch
git pull (brings your repository up to date with a remote repository. Updates your working directory)
Code:
git pull remoteAlias - branch
git cherry-pick (fetches and merges files from a remote repository into your local repository)
Code:
git cherry-pick SHA
git log (lists all commits/commit history on your current branch)
Code:
git log
Recommended workflow
- repo sync
- Create branch (repo start) <or use previously created branch>
- Do some programming/cherry-picking
- git status to see what changed
- git diff [file] to see exactly what was modified
- git add [all or selected] file(s)
- git commit -a | -m [message] | --amend to commit
Click to expand...
Click to collapse
Notes on repo syncing
Repo sync pulls in all changes from the remote repository defined in your local manifest
and update your working directory to match the state of said repository.
Firstly, git will not overwrite any commit, so don't worry about that.
However, there are two ways that repo sync handles the upstream updates.
If you work on an unnamed or non-tracking branch, repo sync leaves your HEAD and switches to the tip of the branch specified in the manifest. This makes it appear as though your changes were deleted.
If you are on a tracking branch, repo sync will rebase your commits on top of the branch tip, after updating your working directory.
(i.e., re-apply your changes after the upstream updates so you now have updated remote files plus your own commits)
Recommendation: you should create a tracking branch before committing. This does not mean every time you want to commit you should start a new branch, but, for better workflow you should have at least one main tracked branch. For testing various new features/cherry-picks its best to branch first before committing.
repo start my_branch frameworks/base
Notes on repo start
- You are automatically switched to the new branch (for the specified projects only) once repo start branch is executed.
- New branches are created based on the HEAD of the remote repo in your manifest.
- Projects not specified for the new branch (in the repo start command) will remain on their current branch.
Example: You have commits on branch 1 and you decide to create branch 2
branch1 contains
ProjectA
ProjectB
ProjectC
repo start branch2 ProjectA ProjectC
Your build environment will now contain
branch2/ProjectA
branch1/ProjectB
branch2/ProjectC
Click to expand...
Click to collapse
This is important to note because if changes present in branch1/ProjectB depend on code in branch1/ProjectA or branch1/ProjectC you will run into errors if branch2/(projectA or ProjectC) does not contain those required changes. To avoid this, simply repo start branch2/ProjectB as well, even if you don't intend to make changes to this project on your new branch. Of course, if there are no dependencies, there is no need to branch additional projects.
- Other projects can be added to an existing branch by simply running repo start again and using the existing branch name
- If you create a tracking branch, repo sync will rebase it automatically. So you don't have to do it by hand.
Notes on cherry-picking
Manual
git fetch remoteBranch
git cherry-pick commit_SHA
Automatic
login to gerrit
click the downloads tab
copy & paste cherry-pick link into the appropriate project path in terminal
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Regardless of the method used, cherry-picking a commit will not always result in a clean merge.
If there is a conflict you will see a message similar to Prerecorded image for...
A bad merge does not mean bad code. It simply means your working directory is not at the same point
as the working directory used for the commit you are attempting to pick. This may be because you are
picking a commit from one ROM to another or the working directory was updated since the commit was
uploaded to gerrit
Conflicts must be cleared manually.
The simplest conflicts would present as merge tags
<<<<<<HEAD
=========
>>>>>>> commitMessage
Click to expand...
Click to collapse
This is not the only thing you should look out for however, there may also be
-- Duplicated or deleted lines of code/resources
-- Unnecessary resources
-- Missing resources
Use git diff to see which files conflict and again to see the changes in those files. Of course you have to actually open those files and make your edits/fixes. Once edidted, simply commit the changes to the existing cherry-picked commit
git status
git add <changed files>
git commit (Opens the cherry-pick commit message)
Save ... and you're done
Click to expand...
Click to collapse
Reserved
Reserved...
Thanks a lot! could you elaborate on the git diff function? as I am trying to build PA4+ w/ halo and cherry picking the 1st and 2nd part i figured out but the git diff function shows some syntaxes I don't follow as I have no background in coding but I want to learn!
steijn0 said:
Thanks a lot! could you elaborate on the git diff function? as I am trying to build PA4+ w/ halo and cherry picking the 1st and 2nd part i figured out but the git diff function shows some syntaxes I don't follow as I have no background in coding but I want to learn!
Click to expand...
Click to collapse
I've modified the OP with a few more details on diff.
Thanks for this! Looking forward, someday I will use this.

[GUIDE] How to build a Samsung Kernel July 30, 2016

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
How to compile a Samsung Kernel from source​
Ok folks, I am going to show you how to build a Sammy kernel from source. This will be a very long guide, so I might miss one or two things. But we will solve that if it happens.
Below is a list of requirements that you must have in order to be successful.
REQUIREMENTS
1. For the best outcome, you need to be on Linux. I dont support VM Box
2. All the android dependencies. (Which I will provide)
3. Toolchain
4. A github account or the like. Its free.
5. Be familiar with terminal commands
6. And have alot of patients
SETTING UP YOUR BUILD ENVIRONMENT
First thing we need to do is set up your build environment. So in order to do this we need to install some packages to make sure your kernel
compiles correctly.... So open a terminal on your desktop, and copy and paste the code into your terminal from below:
Code:
sudo apt-get install git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng
HOW TO GET YOUR KERNEL SOURCE
Samsung keeps all of their source code on Samsung Open Source here. So open this in your browser...once you have you want to click on "Mobile"
The next screen will have a search box. Inside that box you need to type in YOUR model number...
The next screen will show all of the available source code for your device. Select the one that you need, the most current one...
Now you have downloaded the kernel source.......now we need to extract it. This where you need to pay attention...
You will have a "home" folder. Open it and create a "new" folder and name it anything you want. This is where you will extract the kernel source to. Once you have
your folder created you need to navigate to your download folder, thats where the kernel zip will be located. Right click on the zip and select "extract here"...it will
then extract the kernel.tar to your download folder. Once its done you will see the new folder it has made and this is what it should look like when you open it
Now, right click on kernel.tar. Then select "extract to"......a window will pop up, select the new folder you just created. It will then extract all the kernel files to that folder.
That will be your kernel source. It should look similiar to mine...
Now you have your source. But, Sammy left out some files (imagine that)......so your going to need to get them. The easiest way is for you to clone my source
from Github. So go here. See the green tab that says Clone or download? Click it, it will bring up another
small widow.....click on the clipboard icon....open a terminal in your HOME FOLDER.....inside the terminal type git clone and then paste the url after
This will now download MY source to your home folder. Now lets pay close attention here.....You need to open YOUR source in a window, and open MINE in
another window. We will be copying several files from my source to yours.
In my source navigate to drivers/video/exynos. Copy and paste "decon_dual_dsi" and "decon_dual_display" folders to YOUR source. If you already have these files
in your source, you can skip this.
Now we need to get a couple more files. (Non T-Mobile users see post #3) Download these files here. Open the zip and copy them to
your source. In another words just drop them in. Please note that the "output" folder contains empty folder for the G920T and G925T. IF you are building the G920F you need
to change the folder name. Thats very important. We will get more into the build_kernel.sh and env_setup.sh later.
Now we need to get our toolchain. I have decided to get yall to use a custom toolchain instead of stock. There are several that you can use, but for this will use UberTC. So go
here. Now open your HOME folder and then open a terminal. On the webpage click "clone", copy
and paste it into the terminal. It will now download the toolchain to your home folder.
Seeing that we have our toolchain now, we need to set the path from it to our source so the compiler will know what to use at build time. The path needs to be set in 2 places in your source.
One in the env_setup.sh, and in the Makefile......This is how you do this ANYTIME you change your toolchain:
Now navigate to your home folder, you will see the UberTC toolchain you cloned earlier. Now you want to open it like this aarch64-linux-android-5.3-kernel/bin/. Now you will
need to copy the entire address line...mine is like this: /home/sick/aarch64-linux-android-5.3-kernel/bin/ Yours should be the same except for "sick", it should be your username.
Now, you need to open env_setup.sh with your text editor (mousepad, gedit, etc).....scroll to the bottom to where you see # system compiler
export CROSS_COMPILE=/home/sick/aarch64-linux-gnu-5.3/bin/aarch64-........REPLACE /home/sick/aarch64-linux-gnu-5.3/bin/aarch64- with the address from your toolchain folder.
It should look like this when you are done /home/sick/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-..................YES, you need to type aarch64-linux-android- after bin/
The screen shot below shows a different toolchain than what we are using. So pay that no mind.
Now open your Makefile.......I want you to replace the ENTIRE file from the one I provided below.
Open the Makefile with your text editor.....see line #7 #TOOLCHAIN_DIR = $(CURDIR)/toolchain/aarch64-linux-gnu-5.3/bin/aarch64-
Change it to this : #TOOLCHAIN_DIR=$(CURDIR)/toolchain/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-
Line #8 need to be just like the one you set in env_setup.sh......
Mine looks like this: /home/sick/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-
Now the toolchain is set, and the compiler will use it to build the kernel.
OK, I'm going to skip a step on editing the defconfig for now. Reason being is that once we upload your source to Github you will need some basic Github
commands when you change things within your source and need to commit them.
UPLOADING SOURCE TO GITHUB
I assume by now that you have made a Github account. So now we need to create a repository so we can upload your source. This is'nt too difficult to do....
Go to Github....There will be a green tab that says New Repository, click on it.
Now you need name the repository......name it whatever you wish
On the next 2 screen shots select the ones I have highlighted, then select Create repository
Once the new repository is created it will look like this......
Ok, minimize your Github page, (dont close it).......open your kernel source folder. Inside the folder open a terminal and type: git init
Next I want you to type EXACTLY like this: git add .
Press enter.....in a minute or two it will start to load all your files......once its complete you need to maximize your Github page. Click on the green tab, then on the
small clipboard icon, in the terminal i want you to type: git remote add origin (paste the url from the clipboard). It should look like this...
Press enter. If you dont get any errors it will look like this.
Now type this: git commit -m Stock source Where I have Stock source you can change to whatever you want
It will start uploading your source
Once that is complete you need to type: git push origin master
It will ask for your Github username and then password
Now sometimes Github can be a pain and you will get this error when you try to push your source
To get around this, you need to type: git push -f origin master........then your username and password
Once it completes the upload process go ahead and refresh your Github page and it should look like this...
You have now uploaded your source to Github.
SETTING UP env_setup.sh FOR BUILDING YOUR VARIANT
When you look at env_setup.sh you will see that on line #68 says G920T. IF you are going to build for example the G920F, you need to change it
from G920T to G920F and so on.....
Now take a look at line #70....that is the defconfig file. So in your kernel source folder go to arch/arm64/configs. You will see the original name
for one or both config files. I changed the name on mine which correspond with my env_setup.sh. If you are NOT going to change the name on the
defconfig then you must change it back to original in env_setup.sh.
Earlier I had you use the Makefile I provided instead of the one that came with your source......That is MY Makefile from Twisted. So, we are going to have
to make a couple of edits in your defconfig file so you can take advantage of a few things that are included in my Makefile......
Open the Makefile in your kernel source......look at lines 10-19. Those 2 need to be enabled in your defconfig. So now go to arch/arm64/configs. Open
the config file that you will be using with a text editor.......add I want you to add these 2 lines just as I have them....
Now we just made a change to your source. The changes are what is called local. We need to commit them to Github. In order to do that you need
to open a terminal in your kernel source and type: git status
You should see this
You need to copy like this
Then type: git add (paste it here) then enter
Now type: git commit and you will get this.....
You will need to type a commit line. If you leave it blank it WILL NOT commit your changes. See how mine is......
Now to commit those changes from above you need to type the following: Ctrl+o enter Ctrl+x.......if you did it correctly it will look like this....
Then type: git push origin master then enter. Type your username and password......And this is what it should look like
if you did it all correctly...
Now at this point you can look at your Github page and see that it has been committed.......
TIME TO COMPILE
This part is rather simple. I'm going to give 2 examples on how to build for the G920T and the G920F. Now remember, our env_setup.sh says
G920T on lines 68 and 69. So thats what we will build....
In your kernel source open a terminal and type this: sudo build_kernel.sh G920T press enter. It should look like this...
Once you type your password and hit enter it should look like these.....
Now for the G920F build.......all you need to do is change the names in your env_setup.sh. Where it says G920T you change to G920F.
Same goes for any S6 device. Just change the name in the file.
Also make sure the name of your config file matches in both the env_setup.sh and in arch/arm64/configs.......
AT THE END OF THE BUILD YOU WILL BE ASKED TO USE s=stock or c=custom DT.IMG........SELECT S!!!!
NOW YOU HAVE BUILT IT......NOW WHAT.....
If you have followed along you will have made sure the output folder in your source has the device name you were compiling. Look in that folder,
and there will be a flashable zip as well as a tar file for Odin.
Well folks, that about covers it. In post #2 I will show you how to cherry-pick commits and fix simple HEAD errors. If anyone has issues or is
lost please post the problem and I will help you the best I can.......
I dont think I missed anything. If I did we will address it when the time comes. Remember, this is a guide to get you started. I suggest you try to use
Google to find other kernel threads that has building information and so on.......
A special thanks to the following folks:
Especially to my bro @ShinySide for getting me starting in the kernel bizz
@halaszk for his awesome build script
@UpInTheAir for various code source and BUILD SCRIPTS
And of course.....ME
Telegram Invite
https://telegram.me/joinchat/DnmUJwsL2XJPvYYSezOnfA
XDA:DevDB Information
How to build a Samsung Kernel, Kernel for the Samsung Galaxy S6
Contributors
The Sickness
Kernel Special Features:
Version Information
Status: Stable
Created 2016-08-02
Last Updated 2016-08-01
HOW TO CHERRY PICK COMMITS
This part of the guide isnt really that hard to understand. You just need to make sure what you pick will work on your kernel......I advise for you
to pick from the same device. If your building for the G920T, you need to pick from the S6.....Please note that it doesnt matter if the commit is
2 weeks old or 2 years. In another words, firmware isnt a factor. Your stock source is what is from the latest firmware. The kernel code is many
years old....its just improved over time. So lets get started......
First question.....where would you cherry pick from? Well Github is the answer. So to make this easy will will use my Twisted Kernel source.
Go to here. Now in your kernel source open a terminal.....
What we need to do is "fetch" my source......its a remote hook up you might say. So on the web page click the green tab that says
Clone or download, then click on the clipboard icon.......go to your terminal and type: git fetch (paste url you just copied), hit enter. It will set
up a remote hook. Once its done you can pick any or all of my commits.
A point to remember, you ALWAYS pick from the oldest to newest, unless you commit each pick you make. So, let me show you how. On the Github page
on the left side it says 388 commits, select it. It will now bring up all the commits. Scroll to the bottom of the page and select older.....keep doing that until
you reach the end.....so you should be here......
Now, what you really need to do is read the commit BEFORE you pick it. Most have a description, and some dont. But, everyone wants a "permissive" kernel.
So, the commit that says Set kernel to "permissive" is our first one. To the far right of the commit is a clipboard icon, click it......now in your terminal
type: git cherry-pick (paste from the clipboard) then hit enter. It will look like this when its done
Now we need to commit the cherry-pick we just made. So in your terminal type: git push origin master......then your username, then your password.
When its done it will look like this
Now, lets say you made a cherry-pick and you get this error.......
When you get this error there is a problem with the commit. So in your terminal type: git status.......and it will look like this after
So what we need to do is find out what the issue is. 99.9% of the time its a "HEAD" issue......which is the case here. So, go to block/Kconfig.iosched...thats the first issue.
Open it with your text editor. Look at line 35, 36, and 119. Those NEED to be deleted
Now go to block/Makefile... you can see here that you need to delete lines 18, 19, and 28.
Now once you have fixed those errors you need to commit it. To do that you need to copy the folder location like this.....
Then once you have it copied you will need to type: git add (paste it here)...then it will look like this
Now do the same to the other...it will look like this
Now we need to commit those changes. Type: git commit.........it will look like this
Now you will notice that the commit message is already there....so there is no need to change it. So now we need to commit. To do that
you need to select Ctlr+o.........then enter.........Ctlr+x...............and it will look like this
Then in your terminal type: git push origin master........then your username..then your password. Then take a look at your Github
page and you will see the commit appear.
That covers basic cherry-pick..........
How to use Mkboot to edit your ramdisk​
Here will will learn how to use mkboot to do many things...... The first thing we need to do is clone mkboot.img from Github. So you need to go
here. Now open a terminal in your home folder and "clone" the source.....it should look like this
Then when you open the folder it should look like this
Now, you need to place your stock boot.img into the folder. Its up to you to get your boot.img from your device firmware. I cant do
everything for you...lol. Drop the boot.img in like this
Now, in the mkbootimg_tools folder you need to open a terminal and type: ./mkboot boot.img unpacked......hit enter. Looks like this
When its done unpacking the boot.img it will look like this
Now, for all non T-Mobile users.........
In your kernel source you need to go to your build_kernel folder. Now "make" a folder of your device IE: G920F......G920I...etc
Once you have this folder made you need to take the ramdisk, dt.img, and img_info from the unpacked folder in mkboot_tools and
place them in the new folder you just created in build_kernel...like this
Now your ready to build....
Really hope this helps bring development up for our device, probably not by much but if anything at least I can keep the tmobile variant alive, thanks for taking the time out of your busy days to write this guide, even when you retire still giving to this community.
Thanks for the guide might have to switch to Linux since I'm on Windows:good:
genuine55 said:
Thanks for the guide might have to switch to Linux since I'm on Windows:good:
Click to expand...
Click to collapse
Linux is really the only way to go. I removed Windows from my machine a very long time ago..
Once you go Linux, you will never go back to Windows.
The Sickness said:
Linux is really the only way to go. I removed Windows from my machine a very long time ago..
Once you go Linux, you will never go back to Windows.
Click to expand...
Click to collapse
How do I go about installing Linux by the way? Thanks
genuine55 said:
How do I go about installing Linux by the way? Thanks
Click to expand...
Click to collapse
That is another topic.......that depends of if you want to keep Widows with dual boot, or replace Windows with Linux
The Sickness said:
That is another topic.......that depends of if you want to keep Widows with dual boot, or replace Windows with Linux
Click to expand...
Click to collapse
Think I would prefer dual boot to keep windows
genuine55 said:
Think I would prefer dual boot to keep windows
Click to expand...
Click to collapse
http://www.pcworld.com/article/2955...linux-with-windows-what-you-need-to-know.html
The Sickness said:
http://www.pcworld.com/article/2955...linux-with-windows-what-you-need-to-know.html
Click to expand...
Click to collapse
Thanks bro will read up on it
The Sickness said:
How to compile a Samsung Kernel from source​
Ok folks, I am going to show you how to build a Sammy kernel from source. This will be a very long guide, so I might miss one or two things. But we will solve that if it happens.
Below is a list of requirements that you must have in order to be successful.
REQUIREMENTS
1. For the best outcome, you need to be on Linux. I dont support VM Box
2. All the android dependencies. (Which I will provide)
3. Toolchain
4. A github account or the like. Its free.
5. Be familiar with terminal commands
6. And have alot of patients
SETTING UP YOUR BUILD ENVIRONMENT
First thing we need to do is set up your build environment. So in order to do this we need to install some packages to make sure your kernel
compiles correctly.... So open a terminal on your desktop, and copy and paste the code into your terminal from below:
Code:
sudo apt-get install git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng
HOW TO GET YOUR KERNEL SOURCE
Samsung keeps all of their source code on Samsung Open Source here. So open this in your browser...once you have you want to click on "Mobile"
The next screen will have a search box. Inside that box you need to type in YOUR model number...
The next screen will show all of the available source code for your device. Select the one that you need, the most current one...
Now you have downloaded the kernel source.......now we need to extract it. This where you need to pay attention...
You will have a "home" folder. Open it and create a "new" folder and name it anything you want. This is where you will extract the kernel source to. Once you have
your folder created you need to navigate to your download folder, thats where the kernel zip will be located. Right click on the zip and select "extract here"...it will
then extract the kernel.tar to your download folder. Once its done you will see the new folder it has made and this is what it should look like when you open it
Now, right click on kernel.tar. Then select "extract to"......a window will pop up, select the new folder you just created. It will then extract all the kernel files to that folder.
That will be your kernel source. It should look similiar to mine...
Now you have your source. But, Sammy left out some files (imagine that)......so your going to need to get them. The easiest way is for you to clone my source
from Github. So go here. See the green tab that says Clone or download? Click it, it will bring up another
small widow.....click on the clipboard icon....open a terminal in your HOME FOLDER.....inside the terminal type git clone and then paste the url after
This will now download MY source to your home folder. Now lets pay close attention here.....You need to open YOUR source in a window, and open MINE in
another window. We will be copying several files from my source to yours.
In my source navigate to drivers/video/exynos. Copy and paste "decon_dual_dsi" and "decon_dual_display" folders to YOUR source. If you already have these files
in your source, you can skip this.
Now we need to get a couple more files. Download these files here. Open the zip and copy them to
your source. In another words just drop them in. Please note that the "output" folder contains empty folder for the G920T and G925T. IF you are building the G920F you need
to change the folder name. Thats very important. We will get more into the build_kernel.sh and env_setup.sh later.
Now we need to get our toolchain. I have decided to get yall to use a custom toolchain instead of stock. There are several that you can use, but for this will use UberTC. So go
here. Now open your HOME folder and then open a terminal. On the webpage click "clone", copy
and paste it into the terminal. It will now download the toolchain to your home folder.
Seeing that we have our toolchain now, we need to set the path from it to our source so the compiler will know what to use at build time. The path needs to be set in 2 places in your source.
One in the env_setup.sh, and in the Makefile......This is how you do this ANYTIME you change your toolchain:
Now navigate to your home folder, you will see the UberTC toolchain you cloned earlier. Now you want to open it like this aarch64-linux-android-5.3-kernel/bin/. Now you will
need to copy the entire address line...mine is like this: /home/sick/aarch64-linux-android-5.3-kernel/bin/ Yours should be the same except for "sick", it should be your username.
Now, you need to open env_setup.sh with your text editor (mousepad, gedit, etc).....scroll to the bottom to where you see # system compiler
export CROSS_COMPILE=/home/sick/aarch64-linux-gnu-5.3/bin/aarch64-........REPLACE /home/sick/aarch64-linux-gnu-5.3/bin/aarch64- with the address from your toolchain folder.
It should look like this when you are done /home/sick/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-..................YES, you need to type aarch64-linux-android- after bin/
The screen shot below shows a different toolchain than what we are using. So pay that no mind.
Now open your Makefile.......I want you to replace the ENTIRE file from the one I provided below.
Open the Makefile with your text editor.....see line #7 #TOOLCHAIN_DIR = $(CURDIR)/toolchain/aarch64-linux-gnu-5.3/bin/aarch64-
Change it to this : #TOOLCHAIN_DIR=$(CURDIR)/toolchain/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-
Line #8 need to be just like the one you set in env_setup.sh......
Mine looks like this: /home/sick/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-
Now the toolchain is set, and the compiler will use it to build the kernel.
OK, I'm going to skip a step on editing the defconfig for now. Reason being is that once we upload your source to Github you will need some basic Github
commands when you change things within your source and need to commit them.
UPLOADING SOURCE TO GITHUB
I assume by now that you have made a Github account. So now we need to create a repository so we can upload your source. This is'nt too difficult to do....
Go to Github....
TO BE CONTINUED...........
Click to expand...
Click to collapse
thx. but why no vm box?
Gesendet von meinem SM-G920F mit Tapatalk
Can confirm it works on a MacBook Pro with El Capitan
inteks said:
thx. but why no vm box?
Gesendet von meinem SM-G920F mit Tapatalk
Click to expand...
Click to collapse
Alot of Vm applications limit how much ram you can set and then it would take quite awhile with lower resources on build time probably up to 3 hours in some cases where it could be 1 hour and less
1 extremely good vm application I use for everything is VMwareworkstation It's quite expensive but worth it and fully able to change any settings needed at any time
Theres a free 30 trial if you plan on going the vm way for workstation
Maqical said:
Alot of Vm applications limit how much ram you can set and then it would take quite awhile with lower resources on build time probably up to 3 hours in some cases where it could be 1 hour and less
1 extremely good vm application I use for everything is VMwareworkstation It's quite expensive but worth it and fully able to change any settings needed at any time
Theres a free 30 trial if you plan on going the vm way for workstation
Click to expand...
Click to collapse
i use virtualbox normaly and without performance issues! the last time i build a kernel is some time ago. for my xperia neo [emoji6] but this was although virtualbox with debian and i had no problems with it!
i thought about kernel building for s6 because all kernel projects are EOL and i have no money for a new device for now. btw i quite happy with my 128gb version [emoji12] only batterytime is a bit low. maybe i swap the battery for a s7egde battery sometime...
Gesendet von meinem SM-G920F mit Tapatalk
Is possible to show us how to build your Twisted kernel for 920F, please? :fingers-crossed: :angel: Call audio not working Or how to update older kernel to new sources? Thanks
BTW, your Twisted kernel is the best :good::good::good:
pawo99 said:
Is possible to show us how to build your Twisted kernel for 920F, please? :fingers-crossed: :angel: Call audio not working Or how to update older kernel to new sources? Thanks
BTW, your Twisted kernel is the best :good::good::good:
Click to expand...
Click to collapse
This guide will show you how to build a kernel. I will also explain how to cherry pick commits and such...so yes, you can build one just like my Twisted kernel
@The Sickness
Nice guide:good:
Cool @TheSickness this will be easier than referring to our hangouts conversations Thanks buddy. I told u I eventually got some errors using git cherry pick. Looking out for that part of the tut
Actually . . . the build script(s) were initially sourced from here : https://github.com/halaszk/Perseus-halaszk-universal5433 and if you diff them, will be HUGE changes. The 'modern' build script(s) version you are currently using was packaged within my SkyHigh v3.4 source (which isn't a requirement for GPL). I have since moved on and of course kept improving them since . . . .
I always leave original credit in all my scripts, even if the code has been modified (sometimes) beyond recognition . . .

[GUIDE][2018]All you need to know to build Android from scratch!

Introduction​So, I will start off by telling a little bit about myself. I got interested in Android building in November 2017. I found most of the guides "inadequate" for pure newbies like me.
This is my second guide and the first one for No-Knowledge newbies so please do correct me . I will also add some humor so you don't get bored
The guide will be divided into a few parts-
Using linux and enjoying it(No offense to GNU/Linux enthusiasts. please don't start a debate, its just my personal opinion)
Basic git for complete newbies
Compiling your first ROM(Lineage)
Compiling your first non-Lineage ROM
Choosing a Programming lanugage
Basics to resolving conflicts
Compiling AOSP-based roms for CAF devices(For which I couldn't find a guide)
It will probably take a while for you to read this but its must to read everything carefully. Lets start off right away
Using Linux and Enjoying it!
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
There are more than adequate guides for using Linux. I will just help you choose the distro and recommend some guides
Personally, I used Linux wayyyy before I started building android(~2013) I didn't do much at first so I got most of my Linux experience in 2016-2018
Some distros I recommend-
Ubuntu 16.04 or 18.04 (Probably the best for newbies imo) - https://www.ubuntu.com/download/desktop
Arch Linux(Could be problematic to install for newbies so I recommend you install Antergos first - https://Antergos.com/try-it/ )
Linux Mint - https://linuxmint.com/download.php (Newbie friendly)
Debian GNU/Linux (Easier than Arch imo, slightly(very slightly) harder than Ubuntu) - https://www.debian.org/
You absolutely MUST live boot them and feel them. I highly recommend you to install them on a small partition(~40GB) to get the best experience. Please don't use linux on a server at first!
I personally started with Ubuntu 12.04 for a month or so, 14.04 as well for a few months. I became a daily user when 16.04 came out.
Currently, I am using Antergos. However, for building I liked Arch as it had everything "bleeding edge"(Search it if you don't know what this means xD)
Here are some absolutely noob friendly guides-
https://www.youtube.com/watch?v=opBKvGi77cU
For Ubuntu (Long guide but indepth!)
https://www.youtube.com/watch?v=G0AFuhVSvEk
For Linux Mint (Again, Long but indepth!)
Use them for atleast a week or two before you even jump into android building! A month of daily usage is recommended so you know how to tackle basic problems. Youtube will always be your friend and so will be google. You can't hate Linux once you know how to use it! The only reason why I use Windows is because of gaming and applications such as Photoshop and Illustrator(I know there are alternatives, again just my personal opinion!)
See you after a week! No? Seriously use linux for atleast a week!
Using Linux will also hone your google skills(Not even kidding)
Basic git for complete newbies
Personally, I myself don't do advanced stuff with git myself and here are the subcommands you will be using the most with git -
clone
cherry-pick
revert
merge
commit
push
I will give a brief explanation of each and link some guides! Why brief? Because I expect you to have a thinking like a linux user now . Also, you can switch to a server now!
Here is a playlist by github -
https://www.youtube.com/watch?v=noZnOSpcjYY&list=PLg7s6cbtAD15G8lNyoaYDuKZSKyJrgwB-
If you are not satisfied(I wasn't) you can search youtube for a specifc command as well! (i.e cherry-pick)
clone -
Simply clones the repository including its commit history!
Usage-
Code:
git clone <repo> -b <branch> <directory>
If you don't specify a branch, it will clone from the default branch.
If you don't specify a directory, it will make a folder with the name of the repo
Example -
Code:
git clone https://github.com/ChimeraKernelProject/chimera_land-current -b lineage-16.0 chimera
(Shameless self advertising xD)
cherry-pick-
Generates a diff from a commit and applies it to the local repo
Usage-
Code:
git cherry-pick sha
You do need to fetch the repository from which you are picking a commit
Using-
Code:
git fetch <repo> <branch>
If the branch isn't specified, it fetches the default branch instead
Cherry-picking multiple commits-
Code:
git cherry-pick sha1^..sha2
This picks all the commits from sha1 to sha2(i.e the commits between sha1 and sha2, including sha1 and sha2)
You may or may not get a conflict for which I will have a seperate section.
Example-
Code:
git fetch https://github.com/ChimeraKernelProject/chimera_land-current lineage-16.0
git cherry-pick 9e8a821ba64f5b498843b025d1804e3818dda480^..8e80e52915492328e80378f7ecff0cb44fdc1344
(Try figuring out what I did )
What is SHA you ask? You don't have to know what it actually is so just consider it to be an identifier for a commit.
revert
Generates a diff of the commit and reverses it(pretty much the opposite of cherry-pick)
The usage is same as cherry-pick.
merge
Kind of like cherry-picking multiple commits but it compares the history of the local and the remote and then generates a common diff for the commits that are not in local
Also, you do need to fetch before merging.
Usage-
Code:
git merge <remote>
Example-
Code:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git v3.18.125
git merge FETCH_HEAD
(The example here is of upstreaming the kernel )
commit and push
Generates a commit for staged files
Usage-
Code:
git commit -m "some message" -m "sub-message"
some optional parameters-
--signoff
--author="name <author email>
If you forgot to add a file to the commit, you can -
Code:
git commit --ammend
Again, you can use the optional parameter.
how to stage files you ask?
you simply use-
Code:
git add <filepath>
If you did your linux lessons correctly, you might know that, you can use "." and ".." in filepath(redo them if you don't know xD)
finally, to "push" your changes to a remote repo-
Code:
git push -u <repolink>
It will ask for authentication. You use your github(or whatever you prefer) account for that.
After using -u once, you won't have to pass the parameter again.
Lets end this with an example-
Code:
git add .
git commit -m "add 69 hour battery life" -m "best" --signoff --author="someone <[email protected]>"
git push -u https://github.com/ChimeraKernelProject/chimera_land-current
(Also please don't use a stupid commit message like the one I showed xD. This one was just for the lulz)
This one was big. oof. Took me a while to write and probably will take a while for you to read too .
You might ask why did I tell you to search xyz in this one so much! Simple reason- I want you to get used to searching your problems!
Mastering git takes alot of time! I am not any good myself and I search alot of stuff on google myself! (Sometimes even problems related to merging and checking out!)
Compiling your first ROM(LineageOS)
I bet you have been getting restless by now! The previous guides were to build the excitement to build your first ROM!
Why Lineage? Simple. Its one of the easiest ROM to build. Pretty well documented and most importantly, alot of video guides to check if you are confused at any point!
It is highly recommended to use a server at this point as you will be pulling alot of data and you will require alot of processing power.
You can build locally if you have good internet.
Here are the minimum requirements(imo)-
i3 6100 or equivalent
8 GB RAM
300GB HDD(500 GB+ is highly recommended)
Lets start off by the dependencies. I am assuming you are on Ubuntu or Linux Mint. These are the dependencies you need to install -
Code:
openjdk-8-jdk
git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip
You know how to install them don't you now
Lets install Repo now-
Code:
mkdir ~/bin
edit your .bashrc in the home directory with your preffered file editor(I use nano) and add this line to the bottom (Hint - hold pgdwn to jump to the bottom quickly)-
Code:
PATH=~/bin:$PATH
Then execute these commands-
Code:
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
Code:
chmod a+x ~/bin/repo
Lets sync Lineage now shall we
First add your github account to the git config using-
Code:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Here, you should use your github email! (See https://help.github.com/articles/about-commit-email-addresses/ if you don't want to use personal email)
Make a dir in which you will do the rom stuff and cd to it
Before we initialize and sync LineageOS, you have to decide which branch you are choosing as well
You can check your device forum and see what Android versions does the device have. PS- You might wanna check the LineageOS thread. The developer must have provided a link to their kernel source(If they didn't, report the thread to mods kek). Click and navigate through their github. you will find a repo named- android_device_(vendor)_(devicecodename) . you probably know the vendor and the codename from the forum don't you?For example its- android_device_xiaomi_land for my device(Yea right I have an old as hecc device pls no laugh ). Check the branch of the ROM. It will probably something like lineage-16.0 or 15.1 etc. Also if you have an official device, you can check its branch at- https://github.com/LineageOS .
Welp now you know the branch, lets start!
Code:
repo init -u git://github.com/LineageOS/android.git -b <branch>
repo sync
To sync a little bit faster, here's a better command I got from StatiXOS git -
Code:
repo sync -c -f --force-sync --no-tag --no-clone-bundle -j$(nproc --all) --optimized-fetch --prune
Also, if your sync stopped midway because of your ISP(BSNL :'( ), you can just start the sync again.
If you are on another distro such as arch, you might have to do some extra steps- https://wiki.archlinux.org/index.php/android#Building
Now that you have synced, You may choose one of the 2 paths-
If you have official LineageOS, choose me!
Setup the environmental Variables with-
Code:
source bu*/e*
Clone your vendor blobs from TheMuppets repo - http://github.com/TheMuppets
or, from your preferred developer.
The usual repo name is proprietary_vendor_(vendorname). For example, in my case its proprietary_vendor_xiaomi . It should have a folder with your device codename
If not, try changing the branch!
You should be cloning them to vendor/(vendorname)
start bulding right away with-
Code:
brunch lineage_<codename>-<buildtype>
here, codename is your device codename and buildtype is one of these-
user, userdebug, eng .
I recommend userdebug at first. user builds are pretty much as limited as your stock rom. eng builds are actually the one you should use for debugging the rom. These are not secure for daily usage.
This will start the build and you probably won't get an error as its official. If you do, you can just search it up on google. Once the build is done, you will get filepath in the command output. Generally, the build is in
<workingdir>/out/target/product/<codename>/xyz-UNOFFICIAL.zip .
If you have unofficial Lineage, choose me!
I am assuming you are in the working directory
Welp, lets start off by searching for the required trees.
Here's what you need-
Device Tree
Kernel Source
Vendor Blobs
Usually I find them by checking the post of the unofficial Lineage thread and click the kernel source link(Again, if they didn't post it, you should report the thread ). Go to the dev's profile and check his repositories. Here are the usual naming schemes for each one of them-
Device tree - android_device_(vendorname)_(devicecodename)
Kernel Source - android_kernel_(vendorname)_(devicecodename) or! android_kernel_(vendorname)_(soccodename)
Vendor Blobs - proprietary_vendor_(vendorname) or, proprietary_vendor_(vendorname)_(devicecodename)
Device tree should be obvious. It should be cloned to - device/(vendorname)/(devicecodename)
As for kernel tree, soccodename menas the codename of the SoC you have in the device. The thread should have it already as the kernel is licensed in GPL v2(GNU Public License V2, for more info check - https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html ). To know where you need to clone the kernel tree, check the "BoardConfig.mk" of your Device tree and check the "TARGET_KERNEL_SOURCE" line. It tells where you need to clone the kernel
vendor name should be obvious as well now. If your vendor name doesn't have the codename, it should be cloned to vendor/<vendorname>
if it has the devicecodename, it may or may not be the device tree and still be like this-
If it doesn't look like this, it should be cloned to vendor/<vendorname>/<devicecodename>
Here's the repo list of an ideal dev-
Setup environmental variables-
Code:
source bu*/e*
Start the build! -
Code:
brunch lineage_<codename>-<buildtype>
here, codename is your device codename and buildtype is one of these-
user, userdebug, eng .
I recommend userdebug at first. user builds are pretty much as limited as your stock rom. eng builds are actually the one you should use for debugging the rom. These are not secure for daily usage.
Now since you are using an unofficial tree, it is likely that you might hit an error. One of the most common error is when brunch is unable to find your target device. a simple fix for that is to navigate to your device tree and make a file called "vendorsetup.sh"
It should have this line in it-
Code:
add_lunch_combo lineage_<codename>-userdebug
where(you guessed it), codename is your device codename. Run the environmental variable setup again and you should be ready to build.
You might hit errors. Google is always your friend. If you are absolutely sure that you can't find it on google, check the help group section in the thread!
Once the ROM is ready, you will find the filepath in the command ouput. Generally its in out/target/product/<codename>/xyz-UNOFFICIAL.zip
Uploading files to google drive
There's a really nice guide availabe here- http://olivermarshall.net/how-to-upload-a-file-to-google-drive-from-the-command-line
Congratulations! You just made your first rom. If you find this hard, this is just the beginning! There's a very rough road ahead.
Compiling your first Non-Lineage ROM
PS. - The ROM has to be "Lineage-based".
thee aren't eft f'r aosp bas'd roms!
I will be using XenonHD as an example as it is pretty easy to build and it was pretty much one of the first roms i ever built.
Building a Lineage-based rom is as easy as building Lineage!
You go to the rom's git(I usually google search or check it in one of the rom's thread for any device) and check the repo manifest. The usual naming scheme for a repo is-
android_manifest
platform_manifest
manifest
android
etc.
In xenonHD's case, its platform_manifest(and all other repo names will start with platform prefix)
A proper ROM source should have the syncing instructions and building instructions. Lets check the XenonHD's example
make a working dir for the rom in which you will do your rom stuff.
Initialize and sync it. The initializing and syncing part is always the same across the ROMs. (You know which branch to use now. Don't you?)
Again, clone all the required trees!
Now now now, don't get excited yet! Before you start brunching, there is some stuff you need to change.
Usually you can refer to one of the official trees in the ROM organization. For example, https://github.com/TeamHorizon/android_device_xiaomi_kenzo has proper commits. You should be looking at the "Initial XenonHD" commit. You can obviously ignore commits like https://github.com/TeamHorizon/andr...mmit/c076f8c7199d0cddbe6a1e0d05bf3ffc63080d1d as they are device specific. The basics are always the same-
Rename lineage.mk to (romname).mk . refer to the device tree if you are unsure about the romname
edit the (romname).mk and change all the lineage instances to (romname). refer to the commit if unsure.
rename lineage.dependencies to (romname).dependencies .
Renaming the kernel defconfig isn't really necessary so you can ignore that.
Setup the environmental variables(Same across all the roms)-
Code:
source bu*/e*
start the build using the supported command given by the ROM devs.
Code:
brunch codename-<buildtype>
in XenonHD's case. However its different across most of the roms so never forget to read manifests!
You are more likely to hit errors with these spinoffs. Google is your friend(I can't remember how many times I have repeated this) and so is LineageOS repo! You have alot of references if the error is not device specific. Learn to fix derps! Check the help groups sections and ask if its absolutely necessary! Again, the command output will have the filepath of the final ROM zip!
You aren't ready yet. You need to gain alot more experience in compiling ROMs and here are some ROMs that you should be able to build at this point- Resurrection Remix, DotOS etc. Most of the lineage based roms support brunch. (Be careful tho, as a few AOSP based roms support it too. You might have a hard time compiling those!)
Choosing a programming language
At this point, it is highly suggested to learn a programming language if you want to escape the Buildbot stage. I am not forcing you, but you will have alot of trouble in doing advanced stuff.
There are several beginner friendly languages-
bash (the easiest)
Python (Recommended)
Kotlin (Android App development, quite easy)
Harder, recomended to learn after the easy langages-
Java (Gotta learn java if you want to make your own custom ROM at some point :3 )
C/C++ (Other than System UI, most of the other stuff for Android is written in C or C++)
Anything else you like! Once you get the basics, its not hard to learn another language .
The reason why I recommend Python is because it was the first language I learnt! Its pretty easy(Though, the OOP, Object Oriented Programming part is slightly advanced). It has wide applications and THE preferred language for Machine Learning and AI stuff, Period(OMG BUZZWORDS).
Kotlin is also fairely easy. I haven't programmed much in kotlin though I know basic syntaxes. If you learn it first, you won't have much trouble with learning Java. Probably. You can learn Java at first as well but you might have trouble! C is a must learn if you want to modify the Kernel and C++ is a must if you want to modify other code like HALs!
Python takes a day or two to learn! Not even kidding. I recommend this nice playlist by CSDojo - https://www.youtube.com/watch?v=Z1Yd7upQsXY&list=PLBZBJbE_rGRWeh5mIBhD-hhDwSEDxogDg
If you are interested in programming Machine learning, I recommend this playlist- https://www.youtube.com/playlist?list=PLOU2XLYxmsIIuiBfYad6rFYQU_jL2ryal
I learnt Kotlin basics from this Video - https://www.youtube.com/watch?v=H_oGi8uuDpA but there are more advanced videos as well.
I can't link Java tutorials as I haven't learnt it and nor do I plan to anytime soon. You can of course check youtube .
I learnt C from books and The C programming language by Dennis Ritchie and Brian W Keringhan is a must read! I quite liked "Programming in ANSI C" by E. Balagurusamy as well. You can of course, learn it on youtube.
Getting into programming takes a while and you might not like it at first but if you do, you will always enjoy it!
Basics To Conflict Resolution
It is assumed that you have a mind of a programmer and thus the guide will have alot less spoon feeding!
Lets get back to git and discuss about Conflict resolution. From time to time, you might want to cherry-pick something or perform a merge and you might get a "conflict".
Here's a basic idea!
The code between <<< HEAD and ===== is your previous code and the code between ====== and >>>> (commit SHA) is the new code from the commit. You get this if a part of the file in the commit is not the same as your local file.
There are 3 possibilities -
The code between <<<< HEAD and ===== is not required, thus you can delete that (Mostly)
The code between ===== and >>>>> is not required, thus the new change is not required (Rarely)
Both the old code and the new code is required (Pretty common!)
How do you decide between the three? You actually check the commit you are picking. In case of a merge, you can just view the history of a file and check the changes on github. Mostly, that should be enough for a decision. In case of a conflict while upstreaming my kernel, I usually refer to android-linux-stable project - http://github.com/android-linux-stable . Other times, I actually use my brain and figure out the option myself!
Compiling AOSP-based roms for CAF devices
Welp, I took alot of your time! You surely learnt plenty. Its the final part of this guide Took me a while to write all this ;_; .
I am assuming that you are fairly experienced now and you have atleast basic programming knowledge and plenty experience with git.
For starters, I recommend you to try AOSIP! It is highly compatible with Lineage trees and it shouldn't be much trouble to modify your device tree for it.
No spoon feeding at this point . Lets revise the basic idea! -
Find the rom source
Find the appropriate branch
Check the manifest for syncing and building instructions
Refer to another device tree(Possibly a tree of a similar device) and modify your device tree! (The hard part as its different from lineage based roms)
Environment setup
Start the build
Most of the AOSP-based roms use these commands-
Code:
lunch <codename>-<buildtype>
Code:
mka bacon
The lunch part is always there in Maximum AOSP based ROMs and the building command maybe different(i.e
Code:
time mka kronic
in AOSIP)
Another part I want to mention is about "HALs" . Usually most of the ROMs (even AOSP-based) ship with CAF HALs and support project pathmaps. However, some ROMs don't. Probably because they are not intended for CAF devices or the sources aren't properly complete yet! To build these ROM succesfully, I clone the CAF HALs from the lineage repo. These are- display-caf, media-caf, audio-caf, bt-caf and wlan-caf.
The first 3 HALs are usually platform specific so do check the branch on LineageOS! (for example, its lineage-16.0-caf-8996 branch for 821 series family SoCs for pie). The next step is to remove project pathmpas from both the device tree and the HALs. You can refer to the changes done by PedroKalil -
https://github.com/KAOSP/platform_hardware_qcom_display-caf/commits/aosp-8.1-8996
https://github.com/KAOSP/platform_hardware_qcom_media-caf/commits/aosp-8.1-8996
https://github.com/KAOSP/platform_hardware_qcom_audio-caf/commits/aosp-8.1-8937
Don't be lazy. Don't clone these HALs as these are outdated! Refer to them and do the appropriate changes on the latest Lineage HALs. the libbfqio changes may not be required as alot of AOSP-based roms have started to ship with it.
As for the Changes required in Device tree, you can refer to -
https://github.com/rupansh/pie_device_xiaomi_land/commit/c118701ba20a70fd59e32833417adeb7b08ab1d0 (The custom Audio policy is probably already enabled so no need to do that)
and https://github.com/rupansh/pie_device_xiaomi_land/commit/23215a2d8d5f1976657190f2a8f19f3fd111c250 (Depends on the path you cloned your HAL to)
You should now be able to compile any AOSP-based ROM! Experience is the key. Some other AOSP-based roms I recommend - NitrogenOS, AEX, AOSCP, Pixel Experience(Fairly easy), Pixel Dust(One of the hard), AOSPA( teach me when you fix the cneserver error lulz) .
Thats all you need to know to build AOSP-based ROMs for CAF devices .
If you wish to get into Android and Linux Kernel Development, Learning C is a must! I recommend this guide by nathanchance if you are ready! - https://forum.xda-developers.com/an...erence-how-to-compile-android-kernel-t3627297
Groups for help
https://t.me/AndroidBuildersHelp
https://t.me/LinuxKernelNewbies (Linux Kernel only)
Your device groups
Let me know if you want your group here
Credits
@tanish2k09 and @Swapnil Soni ( For guiding me even though I had 0 knowledge, co-operating with my idiotic requests)
ABH (Helping me realise that you can fix most of the errors by just searching properly)
@nathanchance (for his awesome kernel guides)
@KalilDev (For helping me with building AOSP based roms)
@ZeroInfinity (For machine learning tutorials kek)
@riteshsaxena (Bess sources for reference xD, Helping me with pie bringup which caused rapid progress for me)
You, the reader
I hope you learnt plenty of stuff from the guide. It took me a while to type this you see :3 .
​
awesome sir
rupanshji said:
@KalilDev (For helping me with building AOSP based roms)
Click to expand...
Click to collapse
This is one of the best or the most helpful guide I've ever read! I'll Recommend this for anyone who wants to join the ROM building club.
10/10 tutorial, thanx dev.
Thank you for this, OP
any guide like this for mtk devices?

[GUIDE/HOW-TO] Building LineageOS for an Unsupported Device

Foreword:
This is my own notes I created to build LOS for my device (SM-T713 or gts28vewifi). After reading this, I encourage you to create your own notes as it will help you better understand the build process.
I followed the official guide here with additional reading here since we are building this for a device no longer officially supported by LOS.
Requirements:
A fast CPU. How fast? All depends on how long you can wait for the build.
At least 16Gb RAM is a must.
Around 300Gb 50Gb disk space since at least 100Gb of it will be devoted to "ccache".
*nix system, mine is on Ubuntu so the commands below are Debian-based.
Step 1: Setup the environment.
sudo apt install -y bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool libncurses5 libncurses5-dev libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev python-is-python3
mkdir -p ~/bin
mkdir -p ~/android/lineage
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
cd ~/android/lineage
repo init -u https://github.com/LineageOS/android.git -b lineage-17.1
Step 2: Get the device manifest file.
local_manifests/gts28vewifi.xml at lineage-17.1 · team-infusion-developers/local_manifests
Contribute to team-infusion-developers/local_manifests development by creating an account on GitHub.
github.com
...and save to ~/android/lineage/.repo/local_manifests/gts28vewifi.xml
Then do:
repo sync
Step 3: Turn on caching to speed up build. Note that I used 300Gb instead of 100Gb (just personal preference).
mkdir ~/ccache
export CCACHE_DIR=~/ccache
export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
ccache -M 300G 50G
Step 4: Select Build.
source build/envsetup.sh
lunch
select lineageos_gts28vewifi-userdebug (whatever number it's identified under)
Step 5: Prepare the output:
make clean-apache-xml
make clean
make apache-xml
make ims-common
Step 6: Build it!
brunch gts28vewifi
Now go have a few coffees and come back later.
Epilogue:
I'm sure there are many different ways to build this but this method works for me. Just want to get the knowledge out so you can find a way that works for you.
@thisisludachris, I have been building roms for about 18 months now and can share that ccache is typically less than 10G per rom.
You can check by doing
ccache -s
Here is output from my machine building one rom.
Bash:
$ ccache -s
Summary:
Hits: 758742 / 837008 (90.65 %)
Direct: 693243 / 845272 (82.01 %)
Preprocessed: 65499 / 143805 (45.55 %)
Misses: 78266
Direct: 152029
Preprocessed: 78306
Uncacheable: 293976
Primary storage:
Hits: 1499615 / 1682320 (89.14 %)
Misses: 182705
Cache size (GB): 7.89 / 20.00 (39.45 %)
Also, it is possible to build a rom with less than 16GB DRAM if you apply these patches below. Obviously, the more the better, but I have use the patches below to build when I had less than 16GB DRAM.
https://forum.xda-developers.com/t/guide-how-to-build-android-11-with-low-ram.4298483/
Thanks for the info
thisisludachris said:
Step 2: Get the device manifest file.
local_manifests/gts28vewifi.xml at lineage-17.1 · team-infusion-developers/local_manifests
Contribute to team-infusion-developers/local_manifests development by creating an account on GitHub.
github.com
...and save to ~/android/lineage/.repo/local_manifests/gts28vewifi.xml
Then do:
repo sync
Click to expand...
Click to collapse
Sorry but for me this step fails. The repo command doesn't seem to find the files from team infusion:
team-infusion-developers/android_device_samsung_team-infusion-developers:
remote: Repository not found.
fatal: Repository »https://github.com/team-infusion-developers/android_device_samsung_team-infusion-developers/« nicht gefunden
error: Cannot fetch team-infusion-developers/android_device_samsung_team-infusion-developers from https://github.com/team-infusion-developers/android_device_samsung_team-infusion-developers
Does the procedure still work for you?
Paradroid
paradroid28 said:
Sorry but for me this step fails. The repo command doesn't seem to find the files from team infusion:
team-infusion-developers/android_device_samsung_team-infusion-developers:
remote: Repository not found.
fatal: Repository »https://github.com/team-infusion-developers/android_device_samsung_team-infusion-developers/« nicht gefunden
error: Cannot fetch team-infusion-developers/android_device_samsung_team-infusion-developers from https://github.com/team-infusion-developers/android_device_samsung_team-infusion-developers
Click to expand...
Click to collapse
It looks like whomever put up the manifest screwed up with cut and paste. It should probably be
Code:
<project name="team-infusion-developers/android_device_samsung_msm8976-common" path="device/samsung/msm8976-common" remote="github" revision="lineage-17.1" />
otherwise all the common code won't get compiled and integrated into the rom.
Yes @retiredtab is correct, there is an incorrect entry in the manifest file from team-infusion-developers. Please update the correct line as pointed out. Thanks.
@paradroid28 I just went over to my build folder and pulled out my manifest file as per below if you want to copy & paste them:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="LineageOS/android_hardware_samsung" path="hardware/samsung" remote="github" revision="lineage-17.1" />
<project name="LineageOS/android_hardware_sony_timekeep" path="hardware/sony/timekeep" remote="github" revision="lineage-17.1" />
<project name="team-infusion-developers/android_device_samsung_gts28vewifi" path="device/samsung/gts28vewifi" remote="github" revision="lineage-17.1" />
<project name="team-infusion-developers/android_device_samsung_msm8976-common" path="device/samsung/msm8976-common" remote="github" revision="lineage-17.1" />
<project name="team-infusion-developers/android_kernel_samsung_msm8976" path="kernel/samsung/msm8976" remote="github" revision="lineage-17.1" />
<project name="team-infusion-developers/proprietary_vendor_samsung_msm8976" path="vendor/samsung" remote="github" revision="lineage-17.1" />
</manifest>
​@thisisludachris
@retiredtab
Thank you for your efforts. I compared your manifest against the one I downloaded -> they are identical. So I probably have made a different error. ATM i don't know where to look, but i admit, i do not speak "git" fluently. Last time i built an Android ROM successfully was probably 2016-ish , therefore i was very happy about your notes thisisludachris.
If you have another idea where i can have messed up, please let me know.
paradroid28 said:
Thank you for your efforts. I compared your manifest against the one I downloaded -> they are identical.
Click to expand...
Click to collapse
If you followed post #1 exactly, namely
Code:
mkdir -p ~/android/lineage
# save manifest to
~/android/lineage/.repo/local_manifests/gts28vewifi.xml
check to make sure ~/android/lineage/.repo/local_manifests/gts28vewifi.xml is the correct file.
There should only be one .xml file in that directory otherwise the build system will try and parse it.
Another thing you can do is
Code:
cd ~/android/lineage/.repo
grep -iRl "android_device_samsung_team-infusion-developers"
to see where that statement is hiding from you.
paradroid28 said:
​@thisisludachris
@retiredtab
Thank you for your efforts. I compared your manifest against the one I downloaded -> they are identical. So I probably have made a different error. ATM i don't know where to look, but i admit, i do not speak "git" fluently. Last time i built an Android ROM successfully was probably 2016-ish , therefore i was very happy about your notes thisisludachris.
If you have another idea where i can have messed up, please let me know.
Click to expand...
Click to collapse
Perhaps start with which step from above that you are stuck on. Also, if you want to post a screenshot of your error, perhaps I can try to help troubleshoot. Bear in mind though I have limited knowledge in codes and compiling but will try nonetheless.
For those on Windows OS, you can install Ubuntu via WSL2 with the following command run in PowerShell:
Code:
wsl.exe --install
More info here if you require more details on running Ubuntu in Windows.
I'd be interested to see how you go with compiling on Ubuntu via WSL2 in Windows OS
thisisludachris said:
Perhaps start with which step from above that you are stuck on. Also, if you want to post a screenshot of your error, perhaps I can try to help troubleshoot. Bear in mind though I have limited knowledge in codes and compiling but will try nonetheless.
Click to expand...
Click to collapse
The step that fails is 'repo sync'. I Now deleted line 6 in the local manifest (which is generating the error because a certain repository is not found by my computer) and the sync command finished successfully .
Now i will try building it and see, if i am missing something vital.
Maybe you have a very smart computer which finds more repos than mine.
Good work @paradroid28, hope it went well.
@thisisludachris
@retiredtab
Well, i have to thank you again and to apologize, because at first i misread post #5. There lies the solution. So every file of the local manifests from team infusion is faulty atm and refers to a repo that does not exist.
With the corrected manifest i was able to successfully build a ROM for my gts28velte. It remains to be tested on the device.
You might update post #1 to give people following it, a hint, that there is a problem with the manifest and how it can be fixed.
Paradroid
@thisisludachris, @paradroid28, the next step for the 2 of you is to actually fix some the problems. I started just like you guys compiling what was given, but after a while, I learned how to fix the bugs and then take the next step and actually make the next Android version. I don't write code, but I copy working code from other repos (giving credit to original authors of course).
If you want guidance on how to do this, let me know.
retiredtab said:
@thisisludachris, @paradroid28, the next step for the 2 of you is to actually fix some the problems. I started just like you guys compiling what was given, but after a while, I learned how to fix the bugs and then take the next step and actually make the next Android version. I don't write code, but I copy working code from other repos (giving credit to original authors of course).
If you want guidance on how to do this, let me know.
Click to expand...
Click to collapse
yes please!
just bought a new POCO m4 pro 5g
never done that before but what the hell, might as well
any bit of guidance would be very much appreciated
retiredtab said:
@thisisludachris, @paradroid28, the next step for the 2 of you is to actually fix some the problems. I started just like you guys compiling what was given, but after a while, I learned how to fix the bugs and then take the next step and actually make the next Android version. I don't write code, but I copy working code from other repos (giving credit to original authors of course).
If you want guidance on how to do this, let me know.
Click to expand...
Click to collapse
that would be nice - would be good to try and get 18.1 on my Galaxy Tab TM-813 (gts210vewifi)
been a long time since built android, but would be fun to try and get back into it
On curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo, it gets stuck on this:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 45277 100 45277 0 0 278k 0 --:--:-- --:--:-- --:--:-- 279k
When I enter the link, (https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo) in a browser, it comes out with an error:
<Error>
<Code>AccessDenied</Code>
<Message>Access denied.</Message>
<Details>
Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object.
</Details>
</Error>
Ok few questions, what if your device is unofficial? what about the manifest? Also the guide differs if i want to build lineage 19.1?
Skorpion96 said:
what if your device is unofficial?
Click to expand...
Click to collapse
It's the same steps whether it's official or unofficial.
Skorpion96 said:
what about the manifest?
Click to expand...
Click to collapse
That's something you need to build or use an existing one. If you're new to building, I suggest building a rom that is offiical for a device you have. That way, you will see the entire process start to end.
Skorpion96 said:
Also the guide differs if i want to build lineage 19.1?
Click to expand...
Click to collapse
No. It's basically the same.

Categories

Resources