[TUTORIAL] Build CyanogenMod 11 on a VPS or Dedicated Server - Nexus 4 General

Introduction
CyanogenMod 11 is a custom firmware used on android phones and tablets. But, you already know that, chances are you've used it. Building ROMs may seem scary and confusing at first because of the code and terminals, but in reality, it's not that difficult. In this thread, we're going to be discussing how to build CyanogenMod on a VPS or dedicated server. I say a server and not a desktop machine because this is going to be geared towards keeping things simple. When you have only one shell to work with, it's usually easier.
Vocabulary
A couple words you may be unfamiliar with will be described here.
- shell: where you type in the commands on your VPS/dedicated server
- VPS: Virtual Private Server, a type of server that is virtualized from physical hardware
- Dedicated Server/dedi: a dedi is a physical server, it can be an old computer, or (recommended) a server from a server host/data center like Incero or Colocrossing
- Linux: the operating system in which we will build android
- SSH: Secure SHell, the world-standard protocol used to control Linux servers
- bash: the shell we're going to use
Linux Commands
In order to control our server, we won't be using a GUI (Graphical User Interface) where you can click things to make things happen, we will be using SSH. SSH sessions are just a prompt where you type in commands. This is where people get scared but calm the f*ck down. It's not as scary as movies make it seem. Here's a rundown of some basic commands we'll be using.
- cd: change directory, change the folder we are working in, equivalent of changing folders in windows explorer
- mkdir: make directory, makes folders
- cp: copy, it copies files
- mv: move, it moves files
- rm: remove, it deletes files
- ls: list files, it's like dir for windows
- curl: downloads files from URLs
- adduser: adds users, linux has users just like windows
- apt-get: package manager, it's used to install things. In Windows, you usually install things from .exe or .msi files. In Linux, you generally use a package manager. This will be explained more later.
- nano: our text editor of choice for this tutorial. I chose nano because it's very simple and easy to use for a beginner.
Basic Intro to Linux
A few things that I'm going to discuss about Linux are directory structure as well as file structure. In Windows, we have our C: drive, which is where pretty much everything stays. In Linux, we have /, it's the same thing, except it's represented as a slash. If I wanted to edit C:\cookies\morecookies.txt in Linux, the same file path would be /cookies/morecookies.txt. A couple other things about Linux are that the file system is case sensitive, meaning I can have two files named Android and android in the same directory and they won't conflict, whereas in Windows it would. Linux also uses / (forward-slash) instead of \ (backslash) in the directory structures.
Now, our shell is interactive, meaning it's not just a box we type things into, we can use it in different ways. One of the things you should know about bash is ~ (the tilda). ~ in Linux refers to our home directory. Every user has their own home directory (by default at least). Standard users' homes are stored in /home. If my username is tanmay, my home directory would be /home/tanmay/. If I'm logged in as tanmay, ~/android refers to a file at /home/tanmay/android. If I'm logged in as bob, ~/android refers to /home/bob/android. If you don't understand all this completely, I don't expect you to, don't worry. This was just to give you a brief introduction to Linux.
Buying a VPS
I'm guessing most of you already know how to do this, so I'll put it in a spoiler for those who don't need it loading loads of images.
For this tutorial, we're going to use a DigitalOcean VPS, you can sign up here: https://www.digitalocean.com/?refcode=2050223a4edc
After you sign up for DigitalOcean, head to the billing tab and enter in credit card info or put some money in through PayPal to get yourself some credits. Once done, click the big green Create button. The hostname can be anything you want, I usually just make it "android" or "build". Now, you have a choice here, you can spend less and wait longer for builds, or spend more and wait less. I recommend one of these:
{
"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"
}
Any lower and the build will likely just fail, and any higher is just unnecessary. 16GB is plenty, and 8GB will work just fine. You can go with 4GB if you really can't afford it, but I don't recommend it.
In Select Image, choose Ubuntu 12.04.4 x64 and click Create Droplet. Wait for it to spin up, and check your email. You'll have an email like this:
We'll use these details later.
Getting into our server with SSH
In order to SSH into our server, we need a client. The most common client for Windows is PuTTY. PuTTY is free and open source, it can be downloaded here: http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe (direct link). Open it and you should see this:
Under IP, type in your server's IP. If you used DigitalOcean, it should be in your email. Click Open and when it says login as:, enter "root" without quotes, and then when it asks for password, use the one supplied in the email.
If you're on Mac or Linux, you can open a terminal and type in:
Code:
ssh [email protected] # replace server.ip with the IP of your server, if you used DigitalOcean, it's in the email
Use the password supplied in the email.
Installing The Necessary Packages
Once we're in, we need to update the server's current packages to the latest ones, we can do so with the following commands.
Code:
apt-get update # update the package sources list
apt-get -y upgrade # upgrade all the current packages
Now that that's done, we can install the libraries and packages we need.
Code:
apt-get -y install git gnupg flex bison gperf \
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 tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev:i386
apt-get -y install build-essential schedtool screen python-software-properties
Android relies on many libraries and compilers, so we can't build it without them.
Oracle Java is closed source, so we have to do some other things to install it.
Code:
add-apt-repository -y ppa:webupd8team/java # add third party source to the package manager's list
apt-get update # refreshes the sources list to include the one we just added
apt-get -y install oracle-java6-installer
While installing oracle-java6-installer, you will be prompted to accept the Oracle Sun Java license agreement whatever, use your arrow keys to select accept then click enter.
Adding Swap
Even with 8GB of RAM, you'll probably run out of memory, so we use swap. Swap is hard drive space that acts as if it's memory for things that aren't important to the host at the current time. We'll need this, because android takes a LOT of RAM to compile.
Code:
fallocate -l 8G /swapfile # create an empty file that's 8GB in size called /swapfile
mkswap /swapfile # format the file to be swap
swapon /swapfile # turn the swapfile on
Adding a User
Now that we have all the required packages to build, let's add a user to build under.
Code:
adduser tanmay # replace tanmay with your username of choice, must be lower case
Enter the password when it prompts for one, then do
Code:
login tanmay # replace tanmay with the username above and enter the password
You should see something like this:
Note: Disregard the system restart message, it's not necessary for our purposes.
You may have noticed that the prompt changed from "[email protected]:~#" to "[email protected]:~$". This shows we're in our new account.
Setting up repo and Downloading the CyanogenMod 11 Source
repo is the tool supplied by Google used to manage the android source code. Since it's used by AOSP, pretty much every ROM uses repo to manage their source. To install repo, we need to make a folder called bin (binary), where we'll store it. This is mainly for organization purposes. After that, we'll download repo to that folder.
Code:
mkdir ~/bin # create a folder called bin in our home directory
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo # download repo and store it in ~/bin/repo
chmod +x ~/bin/repo # mark the file as executable, so we can run it
export PATH=$PATH:~/bin # explained below
The last line may seem scary, but all it does is take the current PATH variable and add ~/bin to it. If you do
Code:
echo $PATH
you get
Code:
[email protected]:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/tanmay/bin
You can see /home/tanmay/bin at the end of it. This allows us to use the repo command anywhere in the filesystem, not only in the ~/bin directory.
Now let's make a folder for our source code.
Code:
mkdir cm-11.0 # make a folder called cm-11.0
cd cm-11 # move into the directory we just made
You should see your shell prompt change like so:
Code:
[email protected]:~/cm-11.0$
This shows us what directory we are in for reference. Now, let's initialize repo in this folder with the CyanogenMod 11 repo.
Code:
git config --global user.name "Your Name" # Necessary for repo to init
git config --global user.email [email protected] # same as above
repo init -u https://github.com/CyanogenMod/android.git -b cm-11.0
When you get prompted if you want color or not, type "y" then press enter.
Now we need to actually download the source.
Code:
repo sync
This takes... a long time. Sit back and relax. If you're using a server, it'll probably take around 10-15 minutes, if you're on a home line, expect a few hours as the source is around 8GB large.
Getting Proprietary Blobs
Since every phone has different hardware, each one requires different drivers. The Nexus 4 (or mako) has it's own, along with every other phone. We need to download these so that CyanogenMod can compile properly. We can incorporate these into our local build using the local_manifests folder.
Code:
cd ~/cm-11.0/.repo # cd into our repo folder
mkdir local_manifests # make a folder called local_manifests
nano local_manifests/roomservice.xml
On the last line, you'll see an editor (nano) open up, this is editing ~/cm-11.0/.repo/local_manifests/roomservice.xml. The name roomservice.xml is just a formality, it can be anything you want. Anyways, inside the file, paste in the following:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<manifest>
<project name="TheMuppets/proprietary_vendor_lge" remote="github" revision="cm-11.0" />
</manifest>
Once you enter that in, press CTRL + X, Y, then enter. This will save and exit the file.
Next run
Code:
cd ~/cm-11.0/ # bring us back to the parent directory of the source
repo sync # sync again to download the new project we added
Don't worry, this sync won't take hours like the last one, this shouldn't take more than a minute or two.
Getting Prebuilts and Building!
We're getting to the actual build! What we have to do now is get the prebuilt apps that CyanogenMod comes with. We can do this with the following command.
Code:
~/cm-11.0/vendor/cm/get-prebuilts
Once those download, run the following.
Code:
export USE_CCACHE=1 # ccache is compiler cache, it makes future builds MUCH faster, this is not necessary if you're only going to build once
source build/envsetup.sh # load the commands supplied by CyanogenMod used to build
lunch cm_mako-userdebug # generate the Makefile, the instructions for the compiler on how to build the ROM
ARE YOU READY?! THIS IS IT.
Code:
mka bacon # yes, bacon
Aaaaaaaaaaaaand wait. Wait a lot. This is going to take a LONG time.
Downloading the ROM
To download your ROM, download WinSCP from here: http://winscp.net/eng/download.php
Once installed (or just downloaded), open it and enter in the same credentials that you used in PuTTY except use the username and password we added ("tanmay" in my case) instead of root. Click login, and click Okay for messages that you get prompted for. Once you're in, open the cm-11.0 folder, then out/product/target/mako/. Inside that folder, you should see a zip called cm-mako-something.zip. Drag this file onto your desktop or a folder of your choice and then flash it.
CONGRATULATIONS YOU BUILT CYANOGENMOD 11 FOR THE NEXUS 4
Wasn't so bad, was it?
I hope this guide has helped you, if it has, please press the Thanks button below.
Thanks for reading!

awesome guide bt can u help me regarding mtk ........how can i add device tree and vendor manually

Nice tutorial. Just want to add that if your going with DigitalOcean you have the choice of deploying an instance that has Docker preinstalled on Ubuntu. In that case following this tutorial is much simpler and easier.
http://forum.xda-developers.com/showthread.php?t=2650345
Thanks !

[email protected] said:
awesome guide bt can u help me regarding mtk ........how can i add device tree and vendor manually
Click to expand...
Click to collapse
Hi bro @[email protected]! Check it may be useful:
https://github.com/axet/android_device_mt6592
https://github.com/axet/android_vendor_mt6592
Regards.
hyperion70.

Related

[HOW-TO] Setup ADB on Ubuntu Linux 64Bit

As you all may know (or may not know or may not even care), Google's current implementation of ADB for Linux only works on 32Bit Linux systems (boooh!) which leaves the rest of us x64 users with the dilemma of either installing an extra redundant 32bit version of Ubuntu that will hord 15Gb of space so that we may type a few ADB commands in the bash prompt or install ADB on Windows for those of us that have it. Ever since I bought my phone and was forced to reboot my beloved free OS to type those few commands, I'd wave my fists in the air and curse Google for not having had enough sense to make a 64Bit implementation.
Fortunately, my fists will need tire themselves no more. Using a guide compiled by a Geeksphone.com forum user called Talpa, I was able to successfully compile and run ADB on a Linux 64Bit system in short order. Little things make me happy and having seen that this technique is not very wide spread on the forums, I've decided to spread the happiness myself...
CREDITS:
Big, big thanks to the users of the geeksphone forums for having pooled their time, skills and efforts together to figure out this hack and a another big thank you to talpa for having sifted through all the of posts and having made a coherent and unified guide out of it. The guide can be originally found at:
http://wiki.geeksphone.com/en/index.php?title=CompileADB64bitLinux
the discussion that lead to the guide is at:
http://forum.geeksphone.com/index.php?topic=850.0
ADB Linux 64Bit (yeeehhhaaaah!!!)
For the sake of added clarity, I've completely rewrote the geeksphone guide. go to your terminal
#> sudo su
#> mkdir /tmp/my-adb
#> cd /tmp/my-adb
if you don't already have it, install git-core:
#>apt-get install git-core
once that's done, type out the following commands:
#> git clone git://android.git.kernel.org/platform/system/core.git system/core
#> git clone git://android.git.kernel.org/platform/build.git build
#> git clone git://android.git.kernel.org/platform/external/zlib.git external/zlib
#> git clone git://android.git.kernel.org/platform/bionic.git bionic
Before you run compile, you need to the following alterations to the compile scripts to make the output bianaries 64bit compatible. As time progress and this post ages in the ageless internet, some additional modifications may be necessary (or they may change the place of the offending code or may add new bits that need to be deleted or changed). You can go back to the GeeksPhone wiki link (up above) to see if the forum members there have updated it. Hopefully by then, Google would have compiled a 64Bit Linux version of ADB and all of this would be unnecessary. If for any reason you're unable or unwilling to modify the source code yourself, go to this link where I have posted the source code that I have modified:
http://www.mediafire.com/file/q42gektqr32nr31/adb-Linux64bit-source-code-jan-2011.zip
Editing the Source Code Yourself
first, edit the file /tmp/my-adb/build/target/product/sdk.mk and delete the last six lines:
==============================
# include available languages for TTS in the system image
include external/svox/pico/lang/PicoLangDeDeInSystem.mk
include external/svox/pico/lang/PicoLangEnGBInSystem.mk
include external/svox/pico/lang/PicoLangEnUsInSystem.mk
include external/svox/pico/lang/PicoLangEsEsInSystem.mk
include external/svox/pico/lang/PicoLangFrFrInSystem.mk
include external/svox/pico/lang/PicoLangItItInSystem.mk
==============================
then, edit the file /tmp/my-adb/build/core/main.mk at line 116 (again the position may change, just keep an eye out for the offending code) and erase the following lines:
==============================
# Check for the correct version of java
java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1\.6[\. "$$]')
ifeq ($(strip $(java_version)),)
$(info ************************************************** **********)
$(info You are attempting to build with the incorrect version)
$(info of java.)
$(info $(space))
$(info Your version is: $(shell java -version 2>&1 | head -n 1).)
$(info The correct version is: 1.6.)
$(info $(space))
$(info Please follow the machine setup instructions at)
$(info $(space)$(space)$(space)$(space)http://source.android.com/source/download.html)
$(info ************************************************** **********)
$(error stop)
endif
# Check for the correct version of javac
javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.6[\. "$$]')
ifeq ($(strip $(javac_version)),)
$(info ************************************************** **********)
$(info You are attempting to build with the incorrect version)
$(info of javac.)
$(info $(space))
$(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
$(info The correct version is: 1.6.)
$(info $(space))
$(info Please follow the machine setup instructions at)
$(info $(space)$(space)$(space)$(space)http://source.android.com/source/download.html)
$(info ************************************************** **********)
$(error stop)
endif
==============================
Edit /tmp/my-adb/build/core/combo/HOST_linux-x86.mk and change every "-m32 string" to "m64"
Now that that's done, you should be able to get the compiling going with the following command:
#> make -f build/core/main.mk out/host/linux-x86/bin/adb
Once that's done, you go to /tmp/my-adb/out/host/linux-x86/bin/ and you get your adb and acp binaries and move them to wherever your OS keeps all the system binaries.
In ubuntu 10.04, that would be
/bin/adb
/bin/acp
That's it, adb should work from your 64 bit linux shell.
==========================
Holy hell that looks overly complicated. I've installed adb about a dozen times on x64 Ubuntu. I'll post a link to the guide i was using in a minute...
Sent from my SGH-T959 using Tapatalk
http://forum.xda-developers.com/showthread.php?t=537508
(skip the last part about setting up fastboot)
except on this step:
SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
Click to expand...
Click to collapse
You need to do lsusb in console (with your phone plugged in) and find the Samsung vendor id, it's like 0ed4 or something, I don't remember.
Much easier, I think.
birgertime said:
Holy hell that looks overly complicated. I've installed adb about a dozen times on x64 Ubuntu. I'll post a link to the guide i was using in a minute...
Sent from my SGH-T959 using Tapatalk
Click to expand...
Click to collapse
Um, yeah, I don't know why the OP is doing all this. All you need to do is download the android SDK for your platform:
http://developer.android.com/sdk/index.html
An adb binary is included in the tarball in the tools directory. Just add that to your path somewhere.
Yes, the binary included in the SDK is 32bit. No, it doesn't matter at all. A clean install of 64-bit Ubuntu includes multilib support for the (very few) 32-bit shared libraries it requires.
If you really, really need a 64-bit binary... well, go for it. But unless you're building your own Linux distribution or are doing something really exotic, it's highly likely that the 32-bit version will work just fine.
Yikes! This is overkill. Dude, just install the lib32 library files. You should really read the Android developers page on how to setup the sdk on 64-bit linux, its all there. ;-) Good luck with this though. Really...
Sent from my SGH-T959 using XDA App
I thought some people might appreciate the instructions to get adb working over WiFi too and this seems like a good place to put it:
Type this in your terminal emulator on your Android device:
Code:
setprop service.adb.tcp.port 5555
stop adbd
start adbd
Then check it with this:
Code:
getprop service.adb.tcp.port
If it doesn't return "5555" and you're rooted, then do a "su" command and try again. You shouldn't need to be rooted for adb over wifi to work, but I haven't tried every device:
Code:
su
setprop service.adb.tcp.port 5555
stop adbd
start adbd
Then check it:
Code:
getprop service.adb.tcp.port
When it returns "5555" then run this command in the terminal (or command prompt) on your computer:
Code:
adb connect 192.168.0.151
(Obviously enter your device's IP address. You must be on the same network as the computer that has the Android SDK installed.)
And you should be connected!
To tell the Android device to listen for adb on the USB port instead of TCP again, enter this into the terminal emulator:
Code:
setprop service.adb.tcp.port -1
stop adbd
start adbd
(again, might need "su" on your device)
Or just reboot the Android device.
And to tell your computer to use USB for adb instead of TCP:
Code:
adb usb
Now, keep in mind, when your Android device is listening for adb via WiFi, it's wide open... anybody that that the Android SDK installed and knows your device's IP address can access it without a password.
HTH,
Billy
PS - Your
{
"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"
}
are appreciated!
Yes, I just installed a clean Ubuntu 64 bit and the lib32 binaries were included. I only needed to create a /etc/udev/rules.d/70-android.rules and enter my device ID - SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666". I can connect via ADB 32 bit just fine.
Of course using 64 bit drivers falls under the I did it because I could category as well. Kudos!
JeremyNT said:
Um, yeah, I don't know why the OP is doing all this. All you need to do is download the android SDK for your platform:
http://developer.android.com/sdk/index.html
An adb binary is included in the tarball in the tools directory. Just add that to your path somewhere.
Yes, the binary included in the SDK is 32bit. No, it doesn't matter at all. A clean install of 64-bit Ubuntu includes multilib support for the (very few) 32-bit shared libraries it requires.
If you really, really need a 64-bit binary... well, go for it. But unless you're building your own Linux distribution or are doing something really exotic, it's highly likely that the 32-bit version will work just fine.
Click to expand...
Click to collapse
Exactly my thoughts as well. It is simple enough to get it working using the standard package that Android provides!
Like others have said adb packaged with the android sdk works fine on ubuntu 10.10 with no additional configuration. The only problem that I know of is you have to run the adb server as root.
Sent from my SGH-T959 using XDA App
I'm pretty sure that you only have to give it root on the first time.
Sent from my SGH-T959 using Tapatalk
phattchumpy said:
Like others have said adb packaged with the android sdk works fine on ubuntu 10.10 with no additional configuration. The only problem that I know of is you have to run the adb server as root.
Sent from my SGH-T959 using XDA App
Click to expand...
Click to collapse
I am able to run the adb server with a user login with guest permissions. Did not have to use root. But I run Ubuntu 10.04. I guess that it would probably be the same for 10.10 as well, but can't confirm.
This is what I do (very simple and fast)
1) Open the terminal and type: wget dl.google.com/android/android-sdk_r07-linux_x86.tgz (Downloads The SDK with ADB)
2) Then type: tar xvfz android-sdk_r07-linux_x86.tgz && cd android-sdk-linux_x86 (Extracts the archive)
3) After that type: sudo mv tools /usr/local/share/android-tools (Moves the sdk tools to your local system folder)
4) Now type: sudo ln -s /usr/local/share/android-tools/adb /usr/local/bin/ (Makes a symbolic link to the adb executable)
5) Then type: sudo adb devices (This will start the adb server and search for connected devices)
You should now see this in your terminal:
List of devices attached
T959730f48f7 device
Firstly, Thanks a lot to the OP for posting this and the link to the geeksphone wiki. I really needed this and I would have removed my existing linux install, had I not come across this in the next few minutes.
Now back to the main reason why I am posting this comment.
I didn't see even one single reply that was grateful to the OP and the first many posts were just plain crap. If you people don't know what someone is talking about, then please don't show your ignorance and move on to troll other threads.
Of course you can install adb from the default google sdk package and it would work fine on 99% of your systems. It is the remaining 1% for whom this post is intended.
This method is for those who have a pure non-multilib 64-bit system. For such users, google has not packaged a 64-bit adb file in their release, and the default adb will not work. Such users have to build the adb file for a 64-bit machine from the sources. It is for such users that this is necessary and it was very much necessary for me, as well as for the OP, I presume.
So if you don't understand something, please don't waste others' time by spamming the post. The title is quite obvious to those who are looking for a solution.
Update: Just as I finished typing this, my adb has got compiled and I am able to run it. Thanks a million once again, OP.
geekoo said:
Firstly, Thanks a lot to the OP for posting this and the link to the geeksphone wiki. I really needed this and I would have removed my existing linux install, had I not come across this in the next few minutes.
Now back to the main reason why I am posting this comment.
I didn't see even one single reply that was grateful to the OP and the first many posts were just plain crap. If you people don't know what someone is talking about, then please don't show your ignorance and move on to troll other threads.
Of course you can install adb from the default google sdk package and it would work fine on 99% of your systems. It is the remaining 1% for whom this post is intended.
This method is for those who have a pure non-multilib 64-bit system. For such users, google has not packaged a 64-bit adb file in their release, and the default adb will not work. Such users have to build the adb file for a 64-bit machine from the sources. It is for such users that this is necessary and it was very much necessary for me, as well as for the OP, I presume.
So if you don't understand something, please don't waste others' time by spamming the post. The title is quite obvious to those who are looking for a solution.
Update: Just as I finished typing this, my adb has got compiled and I am able to run it. Thanks a million once again, OP.
Click to expand...
Click to collapse
damn!
The adb tool has moved to platform-tools/
If you don't see this directory in your SDK,
launch the SDK and AVD Manager (execute the android tool)
and install "Android SDK Platform-tools"
Please also update your PATH environment variable to
include the platform-tools/ directory, so you can
execute adb from any location.
ofcourse they meved it. so ... any new tutorial with android sdk ?
in windows is the same problem with missing adb.exe (but i have an older version installed). just that i use windows for starcraft2 so i want adb for linux (eventually x64).
later edit: found it ->scroll down to platform tools
and after:
extract in a folder, cd to that folder
$sudo apt-get install lib32ncurses5 lib32stdc++6
# echo SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666">/etc/udev/rules.d/51-android.rules
$./adb kill-server
$./adb start-server
(kill and start i don`t know if is necessary, but it can`t do nothing wrong)
connect the device, $./adb devices and shall see it.
$./adb shell and enjoy
$ => as regular user
# => as root
i`m on kubuntu 12.04 (x64) and using an android 2.3.7 (cm7 based) huawei u8180 / orange stockholm
even easier
even easier paste these commands in linux terminal
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install android-tools-adb android-tools-fastboot
btw # < $

[GUIDE] Rolling your own CM7 kernel

I have like 3 private messages per day asking help on the kernel so I decided to write a short tutorial on how to build your own CM7 kernel.
Requirements:
- Linux distro such as Ubuntu (recommended).
- Time and 10 GB.
Instructions:
(Instructions tailored for Ubuntu, somewhat similar for other distros)
1. First we need to download some stuff, open your terminal and type these commands:
Code:
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install git-core gnupg sun-java6-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev gcc-arm-linux-gnueabi
Toolchain is already included.
If you're in a 64-bit machine, run this command too:
Code:
sudo apt-get install ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib
2. Open terminal, navigate to a folder where you want the kernel source and type this:
Code:
git clone git://github.com/CyanogenMod/lge-kernel-sniper.git
After the download, navigate (in the terminal of course) to the new folder.
3. Now we need to edit the Makefile in that newly created folder, open it. Look for the flags:
Code:
ARCH ?= ...
CROSS_COMPILE ?= ...
Change to:
Code:
ARCH ?= arm
CROSS_COMPILE ?= /usr/bin/arm-linux-gnueabi-
Save and close.
4. Now we need a .config file. Run this command (the terminal must be in that kernel folder where Makefile is):
Code:
make ARCH=arm cyanogenmod_hub_defconfig
Voilá, you can find the .config in the folder (control+h to show hidden files).
5. Edit the kernel as you want. You can grab some ideas from my incomplete source of knzo kernel for CM7: http://github.com/mnlsrv/kernel
6. Let's compile it! Run the command:
Code:
make -j4
In the end you'll get a zImage and .ko files (modules).
7. Now use unpackbootimg or Dsixda kitchen to unpack CM7's boot.img (you can extract it from a nightly), replace zImage with yours and repack.
8. Now you need to flash the boot.img; just use the zip for knzo kernel and replace the boot.img for yours; replace the modules too (/system/lib/modules).
9. Flash and enjoy.
Hope I didn't forget to mention any step.
I am not an active dev, but would like to thank you at the first place. Any beginner in android development will surely be grateful to this simple step wise guide....
A few tips:
Custom governors go into /drivers/cpufreq.
Custom I/O schedulers go into /block/.
For each addition you need to change Kconfig and Makefile. Then the .config will need to be updated and this is automatic when you run the make command. Open and edit .config when you're more familiar with all of it.
Here https://github.com/mnlsrv/kernel/commits/master you can see some commits (changes) I did to the kernel and if you click on one of it, it will show exactly how and which files were changed.
Only a remark:
- To completely add a governor, you have to edit /include/linux/cpufreq.c too in order to set a different default governor without compile errors.
if i have more time ,i'll have a try
thank you knzo,you did a great job!
So kind of you knzo... I'll definitely try this if I still have black....
However... Black is still the best phone I ever had.... miss my black very much...
Keep the good works guys, i keep my eyes to this community, wondering how far this device will go....
Beginners guide to making kernel images
Here I have logged down my own experiences with making Optimus Black kernel binary. Being a Windows person myself I know how troublesome and confusing a development under MinGW can get so I decided to do it under VirtualBox instead. I sincerely hope that the steps described below are a good reference to everybody who is interested in modding his or her own kernel but hasn't gotten over the administrative burden yet. Written as from beginner to beginner I tried to be as concise as possible, leaving out nothing important and everything optional. Just enough to get from zero to updated kernel on your phone.
1. Prepare the environment
Download VirtualBox from https://www.virtualbox.org/wiki/Downloads and install it. I downloaded version 4.1.6 which was the latest version at the moment (http://download.virtualbox.org/virtualbox/4.1.6/VirtualBox-4.1.6-74713-Win.exe)
Download Ubuntu from http://www.ubuntu.com/download/ubuntu/download and install it under VirtualBox. I downloaded latest 32-bit version (http://www.ubuntu.com/start-download?distro=desktop&bits=32&release=latest). Install Guest Additions afterwards as well if you want to use clipboard between host and guest operating systems.
Open terminal and create a folder under your home directory for all the things involved.
Code:
mkdir android
cd android
Install Git and get the kernel source. I had to use http protocol as git protocol was blocked for me.
Code:
sudo apt-get install git
git clone http://github.com/CyanogenMod/lge-kernel-sniper.git
2. This is the part where you change the code
Done? Move to the next step and cross your fingers. For the purpose of this guide we are not changing anything.
3. Make the kernel image
Go to kernel directory
Code:
cd lge-kernel-sniper
Install Arm toolchain and make the kernel image
Code:
sudo apt-get install gcc-arm-linux-gnueabi lzma
export ARCH=arm
export CROSS_COMPILE=/usr/bin/arm-linux-gnueabi-
make cyanogenmod_hub_defconfig
make
There was one thing I had to modify before make completed without errors. Inside drivers/net/wireless/bcm4329 I had to remove -Werror from the Makefile because the warnings were considered as errors otherwise. If everything goes well you'll find zImage under arch/arm/boot directory.
4. Create and deploy the update image (see also http://forum.xda-developers.com/showthread.php?t=1350679)
Download Kernel Injector update image template
Code:
cd ..
wget -O output.zip http://forum.xda-developers.com/attachment.php?attachmentid=785468
Update zImage inside update.zip
Code:
zip -j update.zip lge-kernel-sniper/arch/arm/boot/zImage
Update modules inside update.zip
Code:
mkdir modules
find lge-kernel-sniper/ -name "*.ko" -exec cp {} modules \;
zip -d update modules/\*
zip update modules/*
Use your favourite method of getting the update.zip to your phone's SD card, boot into recovery and flash.
Good luck! And as always - comments and suggestions are most welcome!
- Aprold

How To Build a Kernel

Why would you want to build a kernel yourself?
Click to expand...
Click to collapse
Have you read this: http://forum.xda-developers.com/showpost.php?p=21006133&postcount=1144
In that spirit, I'm going to attempt to write a plain-English tutorial on what to do to build this kernel. In fact, change one or two URLs, and you could build practically any kernel!
Note: I'm assuming you're on a PC here. I'm also assuming this isn't your first trip to linux-land, and you've at least used the terminal a few times before now. I'm also going to assume that even if you are a noob, you're not mentally sub-normal.
Note2: If this is your first time building a kernel, you may want to print this out, and go slowly, and if you get stuck, post about it in the thread! It will help me improve the guide.
What makes this different to other tutorials?
Click to expand...
Click to collapse
I'm a noob at building, but a professional at teaching. It's literally my job! In my noobishness, I made good records of pretty much every step, and I've got lots of time for explaining what each step actually does.
THE STEPS
Got a computer?
Click to expand...
Click to collapse
You'll need one to compile stuff. "For Gingerbread (2.3.x) and newer versions, including the master branch, a 64-bit environment is required." (source)
OK. You're probably thinking of compiling a kernel for ICS or higher right? Is your computer only 32 bit? Pull the processor off the motherboard and count the pins. Just kidding. It won't matter if it is AMD or Intel, but it needs to be a 64 bit processor. I can compile a kernel with just 2GB of RAM and my processor is approaching its 9 year. Even with this lousy set-up, compiling a whole kernel from scratch takes only five minutes.
Install Ubuntu 10.04 64-bit. (Click on this link to download the install CD.)
If you've got a spare hard drive, use the whole thing. If you're good at partitioning, you might consider putting the linux swap partition on a separate disk. You'll want it to be at least 8GB. Putting it on a separate disk will speed things up.
If you don't have a spare disk, you're going to have to resize a partition of an existing OS, to make some new space for Ubuntu. Lets say a minimum of 12GB for the OS plus 8GB for the swap. The more space you can give to the OS, the easier your life will be if you're serious about building stuff.
At the end of the installation it will ask to install a boot-loader. This should be on sda (not sda1!) but you may need to adjust your BIOS to point at the right hard-drive if you later find it doesn't boot into Ubuntu when you restart. Don't worry about Windows, Ubuntu provides a boot menu, so you have the option of booting to Windows instead.
Once Ubuntu is installed, reboot then open a terminal and sort out your credentials:
Code:
sudo passwd root
Type in the password you set during the install, then decide on a password for the root user, and enter it once, then again for confirmation. It can be the same as your user password if you like.
Do some updates (this could take a while):
Code:
sudo apt-get update && sudo apt-get dist-upgrade
When it's finally finished, you'll have to reboot, then repeat until there's no updates left.
You're ready to set up a build environment!
Click to expand...
Click to collapse
First, you need a whole bunch of packages. You could copy and paste this into your terminal:
Code:
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" && sudo apt-get update && sudo apt-get install sun-java6-jdk
That's java sorted.
Next up is the dependencies for compiling stuff:
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc libsdl-dev libesd0-dev libwxgtk2.6-dev libncurses5-dev lib32z1-dev gcc-multilib git-core && sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
I think I remember getting an error for one of these. Possibly lib32readline5-dev. If you get that error, make sure you install everything else. Please let me know, and I'll update this step with a fix.
Make sure ADB is initialised:
Code:
gedit /etc/udev/rules.d/51-android.rules
and copy the below into a blank text file, then edit both instances of <username> to your Ubuntu username (lower-case!) and no chevrons: ="<bedalus>" is wrong. You want ="bedalus"
Code:
# adb protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>"
# fastboot protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>"
Now save the file!
Get hold of a Cross-Compiler
Click to expand...
Click to collapse
Follow this link to Mentor Graphics Sourcery CodeBench LITE and do a free signup to get the download link. You can get hold of other ones, like Linaro or Google's own, but I'm using this as an example, because it's the one I use, and Ezekeel published some R&D here that showed there was no measurable benefit to one toolchain over another.
When you've downloaded it, you need to copy it to /opt:
Code:
cd /home/<username>/Downloads
cp arm-some-date-some-version-some-arch.tar.bz2 /opt
Note- Obviously that's not the actual name of the file! But you can see what it's really called when you download it.
Now go to /opt and unpack it:
Code:
cd /opt
tar xjf arm-some-date-some-version-some-arch.tar.bz2
So I've got all the tools. Now what?
Click to expand...
Click to collapse
So now you need to get some source code. You can use 'git clone' if you don't plan on publishing your kernel. But if you've made some modifications and want to share your end result, you need to obey the GPL terms for the linux kernel, which is Open Source, meaning that you are required to make your source available publicly.
Go to github: https://github.com/
...and sign up. It's just a free registration provided you are non-commercial. Github has some useful getting started tutorials, which I suggest you follow:
https://help.github.com/articles/set-up-git
(just follow that first page for now. I will walk you through git in a bit...)
Next, fork a repo:
Go to whichever kernel you like: https://github.com/bedalus/bedalusKERNEL
I'm using mine as an example. Look for the big 'Fork' button.
You've now got your own copy on github, and you can do whatever you like with it, without affecting the original.
However, it's no use if it exists only in the cloud. You need to get a local copy. You'll also want something called a 'remote tracking branch', which will enable you to keep up-to-date with the changes going on in the original repository that you have forked-off from.
Critical Step:
Click to expand...
Click to collapse
Shout 'fork-off!' at the top of your voice.
Uh... okay. Now, to get a local copy, and set up your remote-tracking branches, execute:
Code:
cd /home/<username>/
mkdir mykernel
...you can name your new directory whatever you want. It doesn't have to be 'mykernel', then:
Code:
git clone https://github.com/<your github username>/bedalusKERNEL.git
In the above, put your git username, and substitute bedalusKERNEL.git for whatever your fork is called. You can actually copy and paste the URL from the top of your new github repo's page if you want.
It's going to download about 800MB if I remember correctly. This will take a while, so go have some marmite on toast.
When that's done, you're ready for the remote-tracking branch:
Code:
cd bedalusKERNEL (or whatever your fork is called)
git remote add upstream https://github.com/bedalus/bedalusKERNEL.git
git fetch upstream
The 'git remote add upstream' creates a new branch called upstream, and any changes that the original developer uploads to github can be fetched to your machine with the 'git fetch upstream' command. Notice how this time, the download time is much shorter? That's because of 'delta downloads' which only downloads the differences between what you have, and what they have. (There's some technical detail here.)
Git Tip No. 1: What branches do I have?
Click to expand...
Click to collapse
You can now enter:
Code:
git branch
...to see all your branches. At this point there should be 'origin' and 'upstream'.
Git Tip No. 2: How do I change branches?
Click to expand...
Click to collapse
Changing branches (you might as well do this now just to have a little go):
Code:
git checkout upstream
That will move you onto the upstream branch, as long as you haven't made any 'uncommited' changes in origin. (More on that later.) Change back to origin with:
Code:
git checkout origin
Git Tip No. 3: How do I rename a branch?
Click to expand...
Click to collapse
You might want to rename your branches to help personalise them, just to make remembering which is which a little bit easier. To change origin to 'my_version' do this:
Code:
git branch -m origin my_version
You can change upstream to 'their_version' or something else if you want to. It won't stop anything from working.
More Git Tips later. Let's sort out a build script. If you tinker with any code, you'll inevitably break stuff, and need to fix it, and then need to try building again... So, having a build script is going to save you a lot of time, because there are several steps that can be automated.
Here's how the start of my script looks:
Code:
#!/bin/sh
cd /home/dave/mykernel
git branch
read -p "Correct branch? [Y/N]: " -n 1
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo -e "\n"
exit 1
fi
This is just a little precaution that I put in to give myself the chance to abort the build before it starts if I'm on the wrong branch. If I don't hit y then the script aborts, and I can checkout the right branch, then restart the script.
Code:
echo -e "\nSTARTING...\n"
The \n prints a new line, then on that new line the message 'STARTING...' and then begins another new line. If you put \n\n you can print a blank line. The echo command is a good way of putting notices in a script so you know what stage it is at.
Code:
export PATH=$PATH:/opt/toolchain/bin/
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-none-eabi-
If you put these lines in your script, it sets 'environment variables' that tells the make program where to find the compiler, and what processor it's compiling for (ARM).
If you now save your script in the /mykernel directory you created earlier, git can keep track of it as well as the files integral to the kernel. Save it as whatever you like, e.g. "myscript.sh"
...It's important to have the .sh extension so the system knows it is a script.
To make your script executable, run:
Code:
chmod a+x myscript.sh
Before you execute the script, you need a .config file in the mykernel directory. If you've cloned my repo, you can get a working one by executing:
Code:
cp arch/arm/configs/crespo_release_defconfig ./.config
...this command will only work properly if you are in the mykernel directory when you execute it.
You can mess with this config file if you like! But it's very easy to break the kernel. However, you can always just copy the crespo_release_defconfig again.
Now, to execute the build script run:
Code:
./myscript
If you execute your script, your compiler will now build the kernel. It will take time, but even on my ten-years-old PC it takes less than ten minutes from scratch.
The compiler will spit out a lot of messages. Most of the time it's telling you that it has compiled an object (i.e. a .o file, which will all be linked up later to form the kernel) and sometimes you'll see warnings, which is the compiler telling you it thinks something might be wrong. Don't worry, most of the time the compiler is just being over-cautious.
If the compiler hits a real problem with the code, it will print an error, and tell you what file, and what line, and how far along that line it managed to get to before it didn't know what to do. I'll get back to this later. For now, let's assume everything compiled.
You'll see a message about the zImage being created. That's the kernel. You can't use it as it is, you need to put it into a boot.img so you can flash it.
I find it useful to add this command in my build-script:
Code:
ls -l /home/dave/mykernel/arch/arm/boot/zImage
ls -l means list with long format. It'll print out the entire contents of a directory with size, time, permissions, etc. if you execute it in a directory, or point it to a directory. However, in the command above, I've pointed it specifically at the zImage file, so it only prints out the details for that. This is so I can check the time. If the time is from yesterday, I can see quickly that there has been an error in the build, and the zImage is still the same one I built yesterday, or an hour ago... etc. depending on the time-stamp printed out.
If you get a 'No such file' error, it's because there is no old zImage, because you haven't ever successfully built one yet.
If you sat and watched the entire thing build, then the timestamp should show the current time, minus a few seconds.
How do I make this zImage into a CWM flashable .zip file?
Click to expand...
Click to collapse
Yay! You've built a kernel. Now you need to make everybody else flash it to their phones too
To do this you need to put it into a boot.img, and then into a .zip file.
Making the boot.img
Click to expand...
Click to collapse
Download this: http://d-h.st/wVZ (make-boot necessary files)
It's a small download. It's some very simple tools that can split an existing boot image into a ramdisk and zImage, and can also stitch them back up.
Move mkboot.zip into your mykernel folder, right click on it, and select 'Extract Here'. You can now delete mkboot.zip. There is a tool called unbootimg, that can take apart existing boot.img files, I've made things simple by including my own ramdisk, which is compatible with AOSP and CM ROMs. That file is called cyan2disk_new.cpio.gz
We now need to add some new stuff to the script to stitch our zImage and ramdisk together.
If you've not already added the ls -l command I mentioned above, also add this now. Then:
Code:
cp /home/dave/mykernel/arch/arm/boot/zImage /home/dave/mykernel/mkboot/
cd /home/dave/mykernel/mkboot
./mkbootimg --kernel zImage --ramdisk cyan2disk_new.cpio.gz --cmdline 'no_console_suspend=1 console=bull's --base 0x30000000 --pagesize 4096 -o boot.img
Remember, your username is not dave! Unless it is. Make the appropriate changes to the path.
How do I make the CWM flashable .zip file?
We're nearly there! This bit is relatively painless. At this point you could save and run the script to check that mkboot is working. If it has worked you can use the same ls -l trick from before, but this time target the boot.img file you just created. If the time-stamp is fresh, it means your boot.img is correct.
TIP: If you haven't switched branches, or run 'make clean', all your .o files are unchanged. The make program keeps track of changes, and only recompiles .o files when the corresponding .c file has been altered. If nothing has changed, your build script will execute very quickly!
To make a flashable .zip file, the easiest thing to do is modify an existing .zip file. You can download my kernel for simplicity, since it already has the necessary script for flashing the entire boot partition. (Most kernels here use koush's any-kernel script, which updates only the zImage and keeps the boot partition's existing ramdisk, so if you try to use another kernel .zip as a template, make sure you correct their updater-script. Using my ramdisk and kernel script will also ensure you keep MTP!)
Once you've downloaded my kernel you should extract it in your home folder, then rename the directory to something like 'myzip'
Now add these lines to your build-script:
Code:
cp /home/dave/mykernel/mkboot/boot.img /home/dave/myzip/boot.img
cp /home/dave/mykernel/drivers/scsi/scsi_wait_scan.ko /home/dave/myzip/system/modules/
"What's that second line? With the .ko file?" I hear you say. Depending on what modules you build, you'll need to copy all of them to the folder specified above. Fortunately, when the kernel finishes building, it tells you what modules have also been built. If you don't want modules in your kernel, you can remove the second line above. However, you must edit your .config file: Open it in gedit, use CTRL+F to open the find dialogue, then type "=m" Now, change every one you find into a "=y" ...so now instead of building modules, the kernel will now incorporate all that code into the zImage instead.
Finally, add this line to your build-script:
Code:
7z a -r -tzip /home/dave/mykernel.zip /home/dave/myzip/*
Run the script again. if everything has gone smoothly, then you now have a flashable .zip in your home directory!
Congratulations!
* * * * * * * * *
More git tips!
Click to expand...
Click to collapse
I've compiled a list of commands you may find handy when getting to know git.
Add a remote branch and track it
git remote add ezekeel git://github.com/Ezekeel/GLaDOS-nexus-s-ics.git
git fetch ezekeel
git checkout --track -b bln ezekeel/bln
Merge in the changes
git merge bln
Resolve conflicts
git mergetool
List local branches
git branch
List remote branches
git branch -r
Switch branch
git checkout branch_name
Rename a branch
git branch -m old_branch_name new_branch_name
View log with short sha1 hash
git log -10 --pretty=format:"%h - %ar: %s"
Restore to a particular point
(IMPORTANT! Don't do this if you've already pushed your commits to github!)
git reset --hard <sha1 hash>
Restore to your last commit
git reset --hard HEAD
Restore to one commit before your last commit:
git reset --hard HEAD^
Restore to two commits before your last commit:
git reset --hard HEAD^^ (etc.)
As long as you haven't pushed to github,
squash all your recent commits into one:
git rebase -i <sha1> ...then change push to squash (or fixup) for all except the first one
git rebase -i --abort (to abort!)
Add .file (i.e. hidden file)
git add .file (simple!)
Add all new and modified files
git add .
Deleting files
(i.e. after doing rm <files>)
git add -u (git will note which files have been deleted)
Bring files from a directory in another branch
git checkout cyanogenmod drivers/cpufreq/
Tells you what changes you've made so far
git status
Commit your changes
git commit (type in your notes about what you did, then CTRL+X then Y to save)
Sync your commits to your github repo
git push <repo_name> <branch_name>
Delete a remote branch
(WARNING: This will delete the entire branch from github
Note: You cannot do this to the default github branch, but you can change the default branch in the admin tab on the website)
git push <repo_name> :<branch to be deleted>
General tips! File management, searching... etc.
Click to expand...
Click to collapse
Find a file (useful for troubleshooting in some situations)
find /home/dave/ -name 'buildlean.sh'
(searches the home folder and subdirectories for 'buildlean.sh')
Find within any *.c file, the text "s5pv210_driver" (good for finding bits of code)
find ./ -type f -name *.c | xargs grep s5pv210_driver
Find within any file, the text "s5pv210_driver" (good for finding bits of code)
find ./ -type f | xargs grep s5pv210_driver
Special Mention : bedalus [Original maker of this Post]. Thank Him Not Me!!
I will not help in this thread as I am not a kernel Dev. I just kanged it here so there Can Be New Developers
Click to expand...
Click to collapse
Click to expand...
Click to collapse
I m getting an error which you've mentioned after applying this code
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc libsdl-dev libesd0-dev libwxgtk2.6-dev libncurses5-dev lib32z1-dev gcc-multilib git-core && sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
Click to expand...
Click to collapse
EDIT: page not found https://github.com/bedalus/bedalusKERNEL
l0lh4rd said:
I m getting an error which you've mentioned after applying this code
EDIT: page not found https://github.com/bedalus/bedalusKERNEL
Click to expand...
Click to collapse
Ubuntu??
Which Device??
mithun46 said:
Ubuntu??
Which Device??
Click to expand...
Click to collapse
Ubuntu 12.04 LTS (x64)
l0lh4rd said:
Ubuntu 12.04 LTS (x64)
Click to expand...
Click to collapse
Device???????
@l0lh4rd
Your device probably has different sources. And the page was not found because bedalus doesn't have any public repo by that name anymore.
Below
Sent from my GT-S5360 using xda app-developers app
thanks i'll find a time and try.
I am going to say WOW. Is everyone as lost and confused about what this is or does? I know I am. First off. I think you started off with a very good Tut. The problem is, you never said what you are compiling or what its for. The more advance users can figure it out and actually understand what you said. But what about the n00bs here? If I understand the jibberish you are compiling a Arm kernel off of linux. It would have been more useful if you had mentioned that this is the Arm kernal for the android platform. It would have also been better if you had said what chip your where using. Is this for the Arm5, Arm6, Arm7? You should also give warning about compiling the kernal and how they can screw things up if they don't follow the steps properly and not to skip or try something that is not listed. You also say that you are using Ubuntu, which alot do, but not all. Some use other distro's and that this may not work on all flavors of linux. Some use different commands and some repo's don't work on all distro's either.
Other then that, pretty nice Tut.
mithun46 said:
Have you read this: http://forum.xda-developers.com/showpost.php?p=21006133&postcount=1144
In that spirit, I'm going to attempt to write a plain-English tutorial on what to do to build this kernel. In fact, change one or two URLs, and you could build practically any kernel!
Note: I'm assuming you're on a PC here. I'm also assuming this isn't your first trip to linux-land, and you've at least used the terminal a few times before now. I'm also going to assume that even if you are a noob, you're not mentally sub-normal.
Note2: If this is your first time building a kernel, you may want to print this out, and go slowly, and if you get stuck, post about it in the thread! It will help me improve the guide.
I'm a noob at building, but a professional at teaching. It's literally my job! In my noobishness, I made good records of pretty much every step, and I've got lots of time for explaining what each step actually does.
THE STEPS
You'll need one to compile stuff. "For Gingerbread (2.3.x) and newer versions, including the master branch, a 64-bit environment is required." (source)
OK. You're probably thinking of compiling a kernel for ICS or higher right? Is your computer only 32 bit? Pull the processor off the motherboard and count the pins. Just kidding. It won't matter if it is AMD or Intel, but it needs to be a 64 bit processor. I can compile a kernel with just 2GB of RAM and my processor is approaching its 9 year. Even with this lousy set-up, compiling a whole kernel from scratch takes only five minutes.
Install Ubuntu 10.04 64-bit. (Click on this link to download the install CD.)
If you've got a spare hard drive, use the whole thing. If you're good at partitioning, you might consider putting the linux swap partition on a separate disk. You'll want it to be at least 8GB. Putting it on a separate disk will speed things up.
If you don't have a spare disk, you're going to have to resize a partition of an existing OS, to make some new space for Ubuntu. Lets say a minimum of 12GB for the OS plus 8GB for the swap. The more space you can give to the OS, the easier your life will be if you're serious about building stuff.
At the end of the installation it will ask to install a boot-loader. This should be on sda (not sda1!) but you may need to adjust your BIOS to point at the right hard-drive if you later find it doesn't boot into Ubuntu when you restart. Don't worry about Windows, Ubuntu provides a boot menu, so you have the option of booting to Windows instead.
Once Ubuntu is installed, reboot then open a terminal and sort out your credentials:
Code:
sudo passwd root
Type in the password you set during the install, then decide on a password for the root user, and enter it once, then again for confirmation. It can be the same as your user password if you like.
Do some updates (this could take a while):
Code:
sudo apt-get update && sudo apt-get dist-upgrade
When it's finally finished, you'll have to reboot, then repeat until there's no updates left.
First, you need a whole bunch of packages. You could copy and paste this into your terminal:
Code:
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" && sudo apt-get update && sudo apt-get install sun-java6-jdk
That's java sorted.
Next up is the dependencies for compiling stuff:
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc libsdl-dev libesd0-dev libwxgtk2.6-dev libncurses5-dev lib32z1-dev gcc-multilib git-core && sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
I think I remember getting an error for one of these. Possibly lib32readline5-dev. If you get that error, make sure you install everything else. Please let me know, and I'll update this step with a fix.
Make sure ADB is initialised:
Code:
gedit /etc/udev/rules.d/51-android.rules
and copy the below into a blank text file, then edit both instances of <username> to your Ubuntu username (lower-case!) and no chevrons: ="<bedalus>" is wrong. You want ="bedalus"
Code:
# adb protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>"
# fastboot protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>"
Now save the file!
Follow this link to Mentor Graphics Sourcery CodeBench LITE and do a free signup to get the download link. You can get hold of other ones, like Linaro or Google's own, but I'm using this as an example, because it's the one I use, and Ezekeel published some R&D here that showed there was no measurable benefit to one toolchain over another.
When you've downloaded it, you need to copy it to /opt:
Code:
cd /home/<username>/Downloads
cp arm-some-date-some-version-some-arch.tar.bz2 /opt
Note- Obviously that's not the actual name of the file! But you can see what it's really called when you download it.
Now go to /opt and unpack it:
Code:
cd /opt
tar xjf arm-some-date-some-version-some-arch.tar.bz2
So now you need to get some source code. You can use 'git clone' if you don't plan on publishing your kernel. But if you've made some modifications and want to share your end result, you need to obey the GPL terms for the linux kernel, which is Open Source, meaning that you are required to make your source available publicly.
Go to github: https://github.com/
...and sign up. It's just a free registration provided you are non-commercial. Github has some useful getting started tutorials, which I suggest you follow:
https://help.github.com/articles/set-up-git
(just follow that first page for now. I will walk you through git in a bit...)
Next, fork a repo:
Go to whichever kernel you like: https://github.com/bedalus/bedalusKERNEL
I'm using mine as an example. Look for the big 'Fork' button.
You've now got your own copy on github, and you can do whatever you like with it, without affecting the original.
However, it's no use if it exists only in the cloud. You need to get a local copy. You'll also want something called a 'remote tracking branch', which will enable you to keep up-to-date with the changes going on in the original repository that you have forked-off from.
Shout 'fork-off!' at the top of your voice.
Uh... okay. Now, to get a local copy, and set up your remote-tracking branches, execute:
Code:
cd /home/<username>/
mkdir mykernel
...you can name your new directory whatever you want. It doesn't have to be 'mykernel', then:
Code:
git clone https://github.com/<your github username>/bedalusKERNEL.git
In the above, put your git username, and substitute bedalusKERNEL.git for whatever your fork is called. You can actually copy and paste the URL from the top of your new github repo's page if you want.
It's going to download about 800MB if I remember correctly. This will take a while, so go have some marmite on toast.
When that's done, you're ready for the remote-tracking branch:
Code:
cd bedalusKERNEL (or whatever your fork is called)
git remote add upstream https://github.com/bedalus/bedalusKERNEL.git
git fetch upstream
The 'git remote add upstream' creates a new branch called upstream, and any changes that the original developer uploads to github can be fetched to your machine with the 'git fetch upstream' command. Notice how this time, the download time is much shorter? That's because of 'delta downloads' which only downloads the differences between what you have, and what they have. (There's some technical detail here.)
You can now enter:
Code:
git branch
...to see all your branches. At this point there should be 'origin' and 'upstream'.
Changing branches (you might as well do this now just to have a little go):
Code:
git checkout upstream
That will move you onto the upstream branch, as long as you haven't made any 'uncommited' changes in origin. (More on that later.) Change back to origin with:
Code:
git checkout origin
You might want to rename your branches to help personalise them, just to make remembering which is which a little bit easier. To change origin to 'my_version' do this:
Code:
git branch -m origin my_version
You can change upstream to 'their_version' or something else if you want to. It won't stop anything from working.
More Git Tips later. Let's sort out a build script. If you tinker with any code, you'll inevitably break stuff, and need to fix it, and then need to try building again... So, having a build script is going to save you a lot of time, because there are several steps that can be automated.
Here's how the start of my script looks:
Code:
#!/bin/sh
cd /home/dave/mykernel
git branch
read -p "Correct branch? [Y/N]: " -n 1
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo -e "\n"
exit 1
fi
This is just a little precaution that I put in to give myself the chance to abort the build before it starts if I'm on the wrong branch. If I don't hit y then the script aborts, and I can checkout the right branch, then restart the script.
Code:
echo -e "\nSTARTING...\n"
The \n prints a new line, then on that new line the message 'STARTING...' and then begins another new line. If you put \n\n you can print a blank line. The echo command is a good way of putting notices in a script so you know what stage it is at.
Code:
export PATH=$PATH:/opt/toolchain/bin/
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-none-eabi-
If you put these lines in your script, it sets 'environment variables' that tells the make program where to find the compiler, and what processor it's compiling for (ARM).
If you now save your script in the /mykernel directory you created earlier, git can keep track of it as well as the files integral to the kernel. Save it as whatever you like, e.g. "myscript.sh"
...It's important to have the .sh extension so the system knows it is a script.
To make your script executable, run:
Code:
chmod a+x myscript.sh
Before you execute the script, you need a .config file in the mykernel directory. If you've cloned my repo, you can get a working one by executing:
Code:
cp arch/arm/configs/crespo_release_defconfig ./.config
...this command will only work properly if you are in the mykernel directory when you execute it.
You can mess with this config file if you like! But it's very easy to break the kernel. However, you can always just copy the crespo_release_defconfig again.
Now, to execute the build script run:
Code:
./myscript
If you execute your script, your compiler will now build the kernel. It will take time, but even on my ten-years-old PC it takes less than ten minutes from scratch.
The compiler will spit out a lot of messages. Most of the time it's telling you that it has compiled an object (i.e. a .o file, which will all be linked up later to form the kernel) and sometimes you'll see warnings, which is the compiler telling you it thinks something might be wrong. Don't worry, most of the time the compiler is just being over-cautious.
If the compiler hits a real problem with the code, it will print an error, and tell you what file, and what line, and how far along that line it managed to get to before it didn't know what to do. I'll get back to this later. For now, let's assume everything compiled.
You'll see a message about the zImage being created. That's the kernel. You can't use it as it is, you need to put it into a boot.img so you can flash it.
I find it useful to add this command in my build-script:
Code:
ls -l /home/dave/mykernel/arch/arm/boot/zImage
ls -l means list with long format. It'll print out the entire contents of a directory with size, time, permissions, etc. if you execute it in a directory, or point it to a directory. However, in the command above, I've pointed it specifically at the zImage file, so it only prints out the details for that. This is so I can check the time. If the time is from yesterday, I can see quickly that there has been an error in the build, and the zImage is still the same one I built yesterday, or an hour ago... etc. depending on the time-stamp printed out.
If you get a 'No such file' error, it's because there is no old zImage, because you haven't ever successfully built one yet.
If you sat and watched the entire thing build, then the timestamp should show the current time, minus a few seconds.
Yay! You've built a kernel. Now you need to make everybody else flash it to their phones too
To do this you need to put it into a boot.img, and then into a .zip file.
Download this: http://d-h.st/wVZ (make-boot necessary files)
It's a small download. It's some very simple tools that can split an existing boot image into a ramdisk and zImage, and can also stitch them back up.
Move mkboot.zip into your mykernel folder, right click on it, and select 'Extract Here'. You can now delete mkboot.zip. There is a tool called unbootimg, that can take apart existing boot.img files, I've made things simple by including my own ramdisk, which is compatible with AOSP and CM ROMs. That file is called cyan2disk_new.cpio.gz
We now need to add some new stuff to the script to stitch our zImage and ramdisk together.
If you've not already added the ls -l command I mentioned above, also add this now. Then:
Code:
cp /home/dave/mykernel/arch/arm/boot/zImage /home/dave/mykernel/mkboot/
cd /home/dave/mykernel/mkboot
./mkbootimg --kernel zImage --ramdisk cyan2disk_new.cpio.gz --cmdline 'no_console_suspend=1 console=bull's --base 0x30000000 --pagesize 4096 -o boot.img
Remember, your username is not dave! Unless it is. Make the appropriate changes to the path.
How do I make the CWM flashable .zip file?
We're nearly there! This bit is relatively painless. At this point you could save and run the script to check that mkboot is working. If it has worked you can use the same ls -l trick from before, but this time target the boot.img file you just created. If the time-stamp is fresh, it means your boot.img is correct.
TIP: If you haven't switched branches, or run 'make clean', all your .o files are unchanged. The make program keeps track of changes, and only recompiles .o files when the corresponding .c file has been altered. If nothing has changed, your build script will execute very quickly!
To make a flashable .zip file, the easiest thing to do is modify an existing .zip file. You can download my kernel for simplicity, since it already has the necessary script for flashing the entire boot partition. (Most kernels here use koush's any-kernel script, which updates only the zImage and keeps the boot partition's existing ramdisk, so if you try to use another kernel .zip as a template, make sure you correct their updater-script. Using my ramdisk and kernel script will also ensure you keep MTP!)
Once you've downloaded my kernel you should extract it in your home folder, then rename the directory to something like 'myzip'
Now add these lines to your build-script:
Code:
cp /home/dave/mykernel/mkboot/boot.img /home/dave/myzip/boot.img
cp /home/dave/mykernel/drivers/scsi/scsi_wait_scan.ko /home/dave/myzip/system/modules/
"What's that second line? With the .ko file?" I hear you say. Depending on what modules you build, you'll need to copy all of them to the folder specified above. Fortunately, when the kernel finishes building, it tells you what modules have also been built. If you don't want modules in your kernel, you can remove the second line above. However, you must edit your .config file: Open it in gedit, use CTRL+F to open the find dialogue, then type "=m" Now, change every one you find into a "=y" ...so now instead of building modules, the kernel will now incorporate all that code into the zImage instead.
Finally, add this line to your build-script:
Code:
7z a -r -tzip /home/dave/mykernel.zip /home/dave/myzip/*
Run the script again. if everything has gone smoothly, then you now have a flashable .zip in your home directory!
Congratulations!
* * * * * * * * *
I've compiled a list of commands you may find handy when getting to know git.
Add a remote branch and track it
git remote add ezekeel git://github.com/Ezekeel/GLaDOS-nexus-s-ics.git
git fetch ezekeel
git checkout --track -b bln ezekeel/bln
Merge in the changes
git merge bln
Resolve conflicts
git mergetool
List local branches
git branch
List remote branches
git branch -r
Switch branch
git checkout branch_name
Rename a branch
git branch -m old_branch_name new_branch_name
View log with short sha1 hash
git log -10 --pretty=format:"%h - %ar: %s"
Restore to a particular point
(IMPORTANT! Don't do this if you've already pushed your commits to github!)
git reset --hard <sha1 hash>
Restore to your last commit
git reset --hard HEAD
Restore to one commit before your last commit:
git reset --hard HEAD^
Restore to two commits before your last commit:
git reset --hard HEAD^^ (etc.)
As long as you haven't pushed to github,
squash all your recent commits into one:
git rebase -i <sha1> ...then change push to squash (or fixup) for all except the first one
git rebase -i --abort (to abort!)
Add .file (i.e. hidden file)
git add .file (simple!)
Add all new and modified files
git add .
Deleting files
(i.e. after doing rm <files>)
git add -u (git will note which files have been deleted)
Bring files from a directory in another branch
git checkout cyanogenmod drivers/cpufreq/
Tells you what changes you've made so far
git status
Commit your changes
git commit (type in your notes about what you did, then CTRL+X then Y to save)
Sync your commits to your github repo
git push <repo_name> <branch_name>
Delete a remote branch
(WARNING: This will delete the entire branch from github
Note: You cannot do this to the default github branch, but you can change the default branch in the admin tab on the website)
git push <repo_name> :<branch to be deleted>
Find a file (useful for troubleshooting in some situations)
find /home/dave/ -name 'buildlean.sh'
(searches the home folder and subdirectories for 'buildlean.sh')
Find within any *.c file, the text "s5pv210_driver" (good for finding bits of code)
find ./ -type f -name *.c | xargs grep s5pv210_driver
Find within any file, the text "s5pv210_driver" (good for finding bits of code)
find ./ -type f | xargs grep s5pv210_driver
Special Mention : bedalus [Original maker of this Post]. Thank Him Not Me!!
I will not help in this thread as I am not a kernel Dev. I just kanged it here so there Can Be New Developers
Click to expand...
Click to collapse
excellent but! you will not have a custom kernel. why?
where did "make menuconfig" go?
you selected yes as default, what if i wanted a custom kernel w/o a "Y" for each?
i want to keep my kernel bare minimal. this is not for minimalistic kernel.?
how you pass other kernel params?
you can pass gcc optimizations in -Os but what if i wish to pass it in the kernel build process?
how on earth using this script? can i include firmwares? aka blobwares which are at times ultimate necessity.....?
what if i want to include my patch and the kernel w/o boot w/o special params or switch....?
how do i set the compression params?
well i am still the old school "make menuconfig" and that
cp arch/arm/configs/crespo_release_defconfig ./.config is not my cup of tea. i still like to roll my own kernel the orthodox method, than this automation.
this is okay if you are building your first kernel and you dont know the process. but this is not the right way if you want a complete fine grained inside out control of the device and the kernel.
NOPE NOPE NOPE!
but the git crash course is excellent. i wanted as usual a git flash cards. thanks
+5 to mithun for the git. everything else i found tasty but was a fruit salad, except git tut. which i found very very well documented.
+5 for git. and +1 for the effort for the kernel info.
hope this helps.
thanks
-paul
p.s. very good effort even tho its cut copy paste but the original post didnt address many kernel issues. hope its updated. hope you take it as a positive feedback.
---------- Post added at 03:08 AM ---------- Previous post was at 03:00 AM ----------
TheStrokerace said:
I am going to say WOW. Is everyone as lost and confused about what this is or does? I know I am. First off. I think you started off with a very good Tut. The problem is, you never said what you are compiling or what its for. The more advance users can figure it out and actually understand what you said. But what about the n00bs here? If I understand the jibberish you are compiling a Arm kernel off of linux. It would have been more useful if you had mentioned that this is the Arm kernal for the android platform. It would have also been better if you had said what chip your where using. Is this for the Arm5, Arm6, Arm7? You should also give warning about compiling the kernal and how they can screw things up if they don't follow the steps properly and not to skip or try something that is not listed. You also say that you are using Ubuntu, which alot do, but not all. Some use other distro's and that this may not work on all flavors of linux. Some use different commands and some repo's don't work on all distro's either.
Other then that, pretty nice Tut.
Click to expand...
Click to collapse
thats what i said, how you select the parms and fine controls like choosing the arm arch type. this doesnt do it. it copies the old config. which is excellent for new comers who wants to start to get their feet wet. but if you are building your custom kernel for arm or amd or i386 or mips? this is not at all helpful. if i were a new comer? i could have clicked on the thanks button. for an advanced user? this is a good read/timepass and nothing else. honestly because i got no control. :-s *Unacceptable*
and mithun you should also tell users how to include patches. if you write patches. how will you patch your kernel before you hit make and make bzimage? nope i am sorry this is good for a stock kernel. which has no info about patch and customization this is not complete. edit it and add more info. if you need help. feel free to ask. there are many kernel chaps here.
good luck mithun.
hope this helps.
thanks
-paul
p.s. i am pedantic at times and people hate me for that, but i am sorry i love being a pedantic moron.
Click to expand...
Click to collapse
Click to expand...
Click to collapse
this thread wanst clealry required man as xda-u already has a post regarding this .. so do something useful.most of the steps here are ready made kang stuff .
if my phone doesn't boot up what can be the cause? is there a specific file that i have to look at or not?
matt95 said:
if my phone doesn't boot up what can be the cause? is there a specific file that i have to look at or not?
Click to expand...
Click to collapse
We can never help without logs. But in this case logcat starts after the kernel has been loaded so you need to figure out what's wrong yourself
speed_bot said:
We can never help without logs. But in this case logcat starts after the kernel has been loaded so you need to figure out what's wrong yourself
Click to expand...
Click to collapse
Cause i'm trying to port the Ubuntu touch preview on my HTC One X but id remains on the bootanimation and i think that the problem is with the kernel itself
matt95 said:
Cause i'm trying to port the Ubuntu touch preview on my HTC One X but id remains on the bootanimation and i think that the problem is with the kernel itself
Click to expand...
Click to collapse
Boot anime can't work without a kernel
speed_bot said:
Boot anime can't work without a kernel
Click to expand...
Click to collapse
The problem is that it is stuck at the bootanimation, what can cause this? do you think it could be kernel related?
matt95 said:
The problem is that it is stuck at the bootanimation, what can cause this? do you think it could be kernel related?
Click to expand...
Click to collapse
First up. Does logcat work?
this is what i get
Code:
$ adb logcat
Unable to open log device '/dev/alog/main': No such file or directory
matt95 said:
this is what i get
Code:
$ adb logcat
Unable to open log device '/dev/alog/main': No such file or directory
Click to expand...
Click to collapse
Thanks for Education

[Guide] to Build your KitKat ROM (CM-AOKP-Carbon-Slim) x N5 from source (Ubuntu14LTS)

Hi, my name's Stefano I'm from Italy, and sorry for my poor english. This is the guide to build your own the KitKat (or whatever branch you want) for your HammerHead. We'll start, obviously, setting up your client (PC), and here we'll use ubuntu x64. Is possible to use almost any linux distribution (also MacOSX) but I prefer to stay on what is much supported and known (for me!). This guide is taken from internet and reading forums/blogs. I didn't invent anything, you can found a lot of guides like this. Just this is updated with last changes. For the setup part I read and paste a lot from here (thanks to sylentprofet).
Regard the hardware side you'll need at least of:
a Dual Core processor
4 Gb of RAM
80 Gb of hard disk for each repository (Better if SSD but don't required)
The Graphics Card don't care, we don't use to compile
A good internet connection, you have to download up to 40 Gb of stuff
A lot of patience, if you aren't go to download a ready ROM, it's better!
Time, time, time, time and again time!
How to Configure Ubuntu for Properly Compiling Android ROMs​
This guide applies to Ubuntu 13.04 Raring Ringtail 64 bit (but also down to 12.04 LTS which is the version that I prefer). Do not use the 32 Bit version. Also, PAY CLOSE ATTENTION when to use “sudo” and when to not. It can make things funky if you do something as root that you shouldn’t. During normal build you don't have absolutely need to use "sudo", just during the PC setup.
Much thanks goes out to Google, ProTekk, Canonical, and everyone else that I read a random paragraph here and snippet there.
First, let’s set up the correct JDK.
Many of you probably have some kind of wrong Java installed. Sad cupcake.Let’s get rid of that. Copy and paste this into a Terminal window:
Code:
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
Back to the Terminal. Copypasta the following:
Code:
sudo add-apt-repository ppa:webupd8team/java
This will add the correct PPA to your system for updated builds of Java 6 JDK that are compatible with 13.04 (or less). No more unrecognized Java version errors! Yay! And it’s self updating, so you don’t have to redownload binaries everytime they release a new version.
Next, we actually need to install the package. More copypasta:
Code:
sudo apt-get update && sudo apt-get install oracle-java6-installer
Follow the onscreen instructions. You have to Accept the Licensing Agreement or whatever. Hopefully no human centipede clauses. Once that is completed successfully, you will have to restart any open browsers with Java content for it to display correctly.
To make sure the correct version of Java is activated, run the following at the Terminal prompt:
Code:
java -version
You should see something like the following:
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)​ 
Ok, back to a fresh Terminal prompt. Time for installing the guts to build stuff in Ubuntu. Because (K)Ubuntu no longer carries ia32-libs-multiarch and ia32-libs (from Saucy onwards), it is necessary to install from precise repos:
Code:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse"
sudo apt-get update
sudo apt-get install ia32-libs-multiarch
once is installed, you can remove repository:
Code:
sudo add-apt-repository --remove "deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse"
sudo apt-get update
Before start, install:
Code:
sudo apt-get install dpkg-dev
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5-dev x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z-dev libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc readline-common libreadline6-dev libreadline6 lib32readline-gplv2-dev libncurses5-dev lib32readline5 lib32readline6 libreadline-dev libreadline6-dev:i386 libreadline6:i386 bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev libsdl1.2-dev libesd0-dev squashfs-tools pngcrush schedtool libwxgtk2.8-dev python
And we wait. Don’t worry, this isn’t the crazy downloading part just yet.
When that is done, do this:
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Now it's time to download and setup SDK Tools. First of all download Android SDK Tools for Linux x64. Extract the folder “sdk”, inside package, into your "Downloads" folder and rename it to "AndroidSDK" e.g..
Then come to your terminal and type:
Code:
cd ~/Downloads/AndroidSDK/tools
and after:
Code:
./android sdk
You can now see the GUI that propose all installable packages. Install Platform tools and Tools for most recent Android (4.4), with the most higher API (19+) version. Flag "accept" and install.
Once is complete, you have you need the binary for repo that will let you talk to git servers and download all that precious source code:
Code:
mkdir ~/bin
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
Open "~/.bashrc" to add a line:
Code:
sudo nano ~/.bashrc
At the very bottom, add the following line:
Code:
export PATH=~/bin:$PATH
Save it. In nano that would be Ctrl-O and then Enter. Then Ctrl-X to exit back to a prompt. Type to restart bash:
Code:
source ~/.bashrc
Now you have all need to work (or play) with your ubuntu and it's time to give the sources (repositories) from your preferred Team (who share the source code for their rom). The most known host service for sources and projects is GitHub. E.g. https://github.com/CyanogenMod/
The point of start of any repo is its "manifest" (default.xml) where the team list all it's projects (here an example), only the necessary to the building process.
Until last year was necessary to compile (before begin and looking to platform manifest) an own local manifest where we exclude from download all the devices/kernel/vendor parts unnecessary for our device. This saves up to some Gigabytes of download.
Fortunately now the repositories will download itself the necessary devices/kernel/vendor parts when we'll choose ("lunch") the device to build ("make"). With the exception of AOKP who wanna know, before initialize your local repo, for which device/s you'd like build.
Now I'll write a section for each Team/ROM you want to initialize, that's for me has sense. How take a sense to put each "platform/project" in a different folder (e.g. CarbonDev in a folder and Cyanogenmod in another, both sons of your Home folder).
In the waiting to read next part, better familiarize a little with terms like "breakfast, brunch, lunch, make" into Android contest.
Building Cyanogenmod
In the terminal, now we'll make a folder where to store the Android source code. Typically will make it in your home folder, within a folder called like your projected ROM, to identify from other stuff, open your terminal and type:
Code:
mkdir –p ~/Cyanogenmod
cd ~/Cyanogenmod
Now we are going to initialize your local repository, with the "branch" cm-11.0 (KitKat), in your terminal:
Code:
repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
And now, the most long part of the story: you’re going to get the source. We have to download around 10-15 Gbytes. First of begin the process, you must to know that you can accelerate the process related to your processor and, obviously, to your internet band. You can choose the number of simultaneous processes to start. They depends from the "#" in the "-j" parameter. E.g. the option -j6 is related to a “normal” processor. If you have a performant processor and/or internet connection, try to increment putting –j10 or more. On terminal:
Code:
repo sync -j6
From time to time, check the situation on output, maybe occurs a pair of hours or a whole night. But when all will be done, you’re ready to build Android!
Once you finish your repo sync, you’ll ready to build. In your terminal, into your working folder type (pay attention at the initial “dot”):
Code:
. build/envsetup.sh
The commands are loaded, now you can build (tune your -j# parameter as you want):
Code:
breakfast hammerhead && make -j6 bacon
At the end of all, your fresh ROM to flash will be in Cyanogenmod/out/target/product/hammerhead. Happy flash!
Thanks @Lloir for supervision.
Building AOKP
Reserved 2
Reserved 3
Reserved 4
Reserved 5
Reserved 6
Nice
Thank you man I'm gonna try it out
I am getting a tone of errors while compiling. Is this normal. I'm gonna assume as long as it doesn't stop everything should be OK.
Sent from my hammerhead
Cuzz1369 said:
I am getting a tone of errors while compiling. Is this normal. I'm gonna assume as long as it doesn't stop everything should be OK.
Sent from my hammerhead
Click to expand...
Click to collapse
When u have warnings, it's all right.
When u have errors the building stops itself...
I was about to do the same guide . I have made the part for paranoidandroid and aosp yesterday, but I am now late. Btw good guide. Better than mine.
Make this thread a sticky thread!
Sent from my Nexus 5 using xda app-developers app
@PippoX3 I really appreciate this guide and your help. My phone just booted into my self comiled cm11. This is always something I've wanted to do since I flashed my first ROM a couple years ago. @Lloir it was actually one of yours "evervolv" for HOV I would like to thank both of you for your help thus far and look forward to continue to ask silly questions. To some this sounds like nothing special. But using a rom you compiled yourself for the first time is quite a rush. Thanks again...
Cuzz1369 said:
@PippoX3 I really appreciate this guide and your help. My phone just booted into my self comiled cm11. This is always something I've wanted to do since I flashed my first ROM a couple years ago. (@Llor it was actually one of yours "evervolv" for HOV) I would like to thank both of you for your help thus far and look forward to continue to ask silly questions. To some this sounds like nothing special. But using a rom you compiled yourself for the first time is quite a rush. Thanks again...
Click to expand...
Click to collapse
You're welcome mate. I remember my first builded and flashed rom for HtcOneS and was a big goal for me. Then I understand you. A step away to grow again and learn more and more. Dig it! :laugh:
The only difference for aosp is just changing the link in repo init -u ? I wanna build a stock rom only with advanced brightness adjustment
Sent from my Nexus 5 using Tapatalk
andrei.voinea93 said:
The only difference for aosp is just changing the link in repo init -u ? I wanna build a stock rom only with advanced brightness adjustment
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
Generally yes. Take a look to their readme into manifest platform, usually they explain there how to initialize your local repo. The rest is same for alls...
Thank you
Sent from my Nexus 5 using Tapatalk
I'm getting this error while trying to install packages after the Java step.(Ubuntu 13.10)
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'lib32z1-dev' instead of 'lib32z-dev'
Package ia32-libs is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However, the following packages replace it:
lib32z1 lib32ncurses5 lib32bz2-1.0
I moved on to the next step and receive this:
[email protected]:~$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
ln: failed to create symbolic link ‘/usr/lib/i386-linux-gnu/libGL.so’: No such file or directory
Edit: Found my answer here
http://forum.xda-developers.com/showthread.php?p=50353201
Cuzz1369 said:
I'm getting this error while trying to install packages after the Java step.(Ubuntu 13.10)
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'lib32z1-dev' instead of 'lib32z-dev'
Package ia32-libs is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However, the following packages replace it:
lib32z1 lib32ncurses5 lib32bz2-1.0
I moved on to the next step and receive this:
[email protected]:~$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
ln: failed to create symbolic link ‘/usr/lib/i386-linux-gnu/libGL.so’: No such file or directory
Edit: Found my answer here
http://forum.xda-developers.com/showthread.php?p=50353201
Click to expand...
Click to collapse
I got issues with 13.10 (was a beta, now I don't know...) try 13.04. My prefer is 12.04 or 12.10.
PippoX3 said:
I got issues with 13.10 (was a beta, now I don't know...) try 13.04. My prefer is 12.04 or 12.10.
Click to expand...
Click to collapse
I found the answer and posted above. Worked great now.
Sent from my hammerhead
So I successfully compile slimKat. It gave me 2 different zips in my out folder slim****ota***.zip which was 186mb and slim*****.zip which was only 156mb. What the difference between the two?
Sent from my Nexus 7 using Tapatalk

[GUIDE][A First For Xda] How to Build a rom + more using only the Linux terminal!

How to build a CyanogenMod/Omni/Android Based Rom from source using only a Linux Terminal
A First for XDA I believe? So why this tutorial?
Originally when I was searching about for tutorials on how to build from source, they were all specific to those who use a GUI and this included downloading .zips with a browser and editing files through text editors, extracting files to certain locations and executing files through the file explorer such as "get-prebuilts.sh". There were some that used the linux terminal more then they needed too, this was helpful but not specific, this isn't going to be a tutorial like you see everywhere else, this will be made more specific to those who use either a remote machine, or people who want to use just the Linux terminal like a badass! This will have the commands I use, they may not be the most universally used or the simplest they can be but it's not broke so I shan't fix it! All these tutorials, for me, meant a lot of personal work google-ing and searching my way through commands, this was great as it has helped me learn a lot about Linux Terminal commands, but it has also caused me countless issues, such as uploading my final product and navigating around is a real pain in the ass. This meant it took me quite a while to get my first ever build using just the Linux terminal, and uploading it.​
ForewordRead first
For this tutorial I will try not to make it too device/situation/rom specific because, then that means people have to make changes, which, we will have experienced never ends well, but I will have two variations of the command, the first command will be the generalised command using a HTML style coding for where you should make your changes, an example of this would be for the code <DeviceName>, you would replace it with your device name minus the <>signs (obviously). To then check if you had done it right, I will add in my device name which for this tutorial will be the LG Optimus 4xHD (codename p880). As this may become confusing with many <*> codes popping up, and there are many codenames and device names to keep up with, I will be adding a legend/key with some of the syntax I will be using and what it means, but also include some of the more popular codename and manufacturer names for those who do not know what they are. This tutorial will not tell you how to set up a remote machine, only use a Linux terminal and nothing else much. It may also include a hidden "GUI Cheat" for those with GUI to check if you have done a step correctly. This will be aimed at Ubuntu 13.10 64bit, as you need 64bit to compile (to my knowledge anyway)​
Setting Up Your Build Environment
Okay so the easy-ish bit, this is mainly for people who either the administrator of their "Build Server" or Remote Machine as most "user-based" ones will almost always have theirs set-up for you. This will also be required by users who have set up Ubuntu/other Linux distribution on a host/local machine. You probably will not be able to do this on a user based Remote Machine anyway due to an absence of root access, if this is an issue and one is not setup and you do not have elevated privileges, email the corresponding admin for help! I can't help you here! So now down to business!​Installing the required packages should be as follows, although, if they do not work just google it, I'm sure there are many tutorials with many ways to set up a build environment:
Code:
sudo apt-get install bison build-essential curl flex \
g++-multilib gcc-multilib git-core gnupg gperf \
lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev \
libesd0-dev libncurses5-dev libsdl1.2-dev \
libwxgtk2.8-dev libxml2 libxml2-utils lzop \
openjdk-6-jdk openjdk-6-jre pngcrush schedtool \
squashfs-tools xsltproc zip zlib1g-dev
NOTEIf any GUI comes up for any installation (not sure, been a while since I did it) It should be pretty self-explanatory, for example arrow keys to navigate, enter to select an option etc.
Setting Up Repo's
Okay, so repo is a blanket term here. It can be split up in order to simplify things for the purpose of this tutorial. Repo is a package type thing of commands for handling your repo's. You will need this for Initialising repo's (Repo init) and for syncing sources (Repo sync). I will not be going into different flag meanings, only those which I use in this tutorial.​
Installing the Repo package should be as follows, again google and let me know if I am wrong or it doesn't work!:
Code:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ cd ~/bin
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
NOTEEach $ sign represents a line of command, so you should press enter between commands. For example "mkdir ~/bin <ENTER>" <ENTER> being the action by the user. GUI Users on a local machine may need to reboot at this time or redo it a couple of times until it works, remote users should just disconnect and reconnect again.
Setting up working folders and understanding Directories
Many tutorials will have this step differing from one another, this is because it's all down to personal preference. I prefer to have just the RomName because it's less work, but some prefer to have "Android/<ROMNAME>" or "Android/system/<ROMNAME>". This is because of Git, if a package is called Android_frameworks_Base, it represents the directory <ROMNAME>/frameworks/base/.​
Setting up your working directories is dependent on which Rom you are building.
Generalised Code
Code:
$ mkdir ~/<ROMNAME>
$ cd ~/<ROMNAME>
Example Code
Code:
$ mkdir ~/carbon
$ cd ~/carbon
NOTEThis is creating a directory (mkdir) and navigating to it (cd) to go back when navigating use the "~" sign, it means "Home/<USERNAME>/" it skips some typing is all!
Initialising and Downloading the Repo
Okay so the repo part is perhaps the second longest of all processes you will have when building, it downloads the sources you need to compile with, this is approximately ~18gb maybe? Possibly? So you may need a fair partition or free space on your HDD/SDD for the building process as well.​
Generalised Code:
Code:
repo init -u <GITHUB_LINK_IN_ROM_MANIFEST/ANDROID> -b <CORRESPONDING_BRANCH>
Specific Code:
Code:
repo init -u https://github.com/CarbonDev/android.git -b kk
NOTEAt this point you will see some code and some download stuff, it's just the repo fetching some stuff, at this point, you will be prompted to enter a name and an email, you will either be prompted to enter it, or you will be given the commands needed to do it, this needs to be done, once completed, re-initialize the repo. This will only happen on your first time.
Downloading the code:
Code:
repo sync -j#
NOTE This is going to start the downloading of the sources, the -f is a force flag, this will stop you from receiving any errors in your repo and will re rep sync the source. Other flags can be -j which specifies how many objects to download at once, I choose not to use it but the syntax is -j<NUMBER_OF_JOBS> for example -j10, this should be used in conjunction with the speed and bandwidth of the internet connection supplied, -j4 is default and using a higher flag for a better connection will speed things up considerably, be sure not to over do it thou. See this post for more details!
Setting Up For Your Device
Okay so one of the more important parts, and the parts people usually use the GUI and browsers etc. for, this will be how to do it without those aids. Well on the remote machine anyway, a host machine with GUI is probably needed for changes and links. This will set up vendor, kernel, and device tree.​
General Code in order Kernel, Vendor, Device Tree:
Code:
$ mkdir -p kernel/<MANAFACTURER>/
$ cd kernel/<MANAFACTURER>/
$ git clone <KERNEL_GIT_LINK> <DEVICE_CODENAME/KENREL_NAME>
$ ls
$ cd ~/<ROMNAME>/vendor/
$ git clone <VENDOR_GIT_LINK> <MANAFACTURER>
$ ls
$ cd ~/<ROMNAME>/device
$ mkdir <MANAFACTURER>
$ cd <MANAFACTURER>
$ git clone <DEVICE_TREE_GIT_LINK> <DEVICE_CODENAME>
$ ls
$ cd ~/<ROMNAME>
Specific Code in order Kernel, Vendor, Device Tree:
Code:
$ mkdir -p kernel/lge
$ cd kernel/lge
$ git clone https://github.com/P880-dev/android_kernel_lge_x3.git x3
$ ls
$ cd ~/carbon/vendor
$ git clone https://github.com/P880-dev/proprietary_vendor_lge.git lge
$ cd ~/carbon/device
$ mkdir lge
$ cd lge
$ git clone https://github.com/P880-dev/android_device_lge_p880.git p880
$ ls
$ cd ~/carbon
NOTE There are shorter ways I'm sure, but this works. "ls" checks files in the directory just to double check you did it right. To find the git link it will be on the github of the tree on the left in a box. This only clones the default branch, if it's different you must fork the tree and click settings>default branch and change to the needed one, and use the git clone box from there. Device tree's can be edited per rom on github, or in terminal, for the purpose of using terminal, I'll add to this tutorial.
Making Changes to files
If you are building whichever rom was on your default branch then I guess this step isn't too important for you unless you want to check the files over or you want to edit other files like envsetup.sh to change the build tools versions. This will use the cd, ls, and pico function for editing files. To change configs and stuff in .mk files in device tree. Most people would use gui for file editing and that's why I am showing you the method to do so with ease from the Linux terminal.​
General Code:
Code:
$ cd /device/<MANAFACTURER>/<DEVICE_CODENAME>/
$ ls
$ pico <FILENAME>
Specific Code:
Code:
$ cd device/lge/p880
$ pico cm.mk
NOTE This will open a text editor, the key at bottom represents ctrl + <LETTER> to do different functions. The main ones you use will be "ctrl x" because that is exit. After that you can either edit the name after the changes you made, for example changing CM to Carbon if you were building carbon. You can navigate to any directory, and pico <FILENAME> to edit it! It is easier to make these edits using github after forking a repo, usual changes need to be done to cm.mk and vendorsetup.sh, to know what needs changing, swap cm with the name of the rom, and check the vendor_rom of the rom for the config directories, for nfc and carbon, place a # at the start of the line, this is called hashing out. Change cm.mk when saving or by using mv <FILENAME> <NEW_FILENAME>.
Building the Rom
Okay so now that wasn't too bad was it? Setting up? Some devices that are officially supported do not need the above steps, but then again, if you was officially supported, why would you need to build? Anyways, this will show you how to get the pre-builts (if needed) and how to start the build of the rom. Cheated and used the GUI yet? If not, Good on ye! I will be adding the commands for adding legacy drivers and some other miscellaneous codes and commands in the next post! Including ccache for those who are on host/local machines rather than remote machines.​
Generalised Code:
Code:
$ cd ~/<ROMNAME>/vendor/cm
$ . get-prebuilts.sh
$ cd ~/<ROMNAME>
Option #1: $ . build/envsetup.sh
Option #2: $ source build/envsetup.sh
[I]This last step varies between rom, so I will give the most generalised, check the manifest or building tutorial for the Rom to find out the way to build[/I]
$ brunch <DEVICE_CODENAME> -j<NUMBER_OF_CPU_CORES_+1>
Specific Code:
Code:
$ cd ~/carbon/vendor/cm
$ . get-prebuilts.sh
$ cd ~/carbon
$ . build/envsetup.sh
$ lunch
$ corresponding number
$ make carbon -j18
NOTE This will then start the build, this can take from 1-10hours to build depending on performance and other variables, it takes me ~1hour 15mins for a build of a KitKat Rom. Each ROM has a different build script, this means it can be a different chosen command each time, brunch is the most commonly used, check their manifest or look for a ROM specific building tutorial. -j# is the amount of jobs it will compile at one time, putting an insane number will not make it build faster. Put the amount of cores +1 to be safe. My server has 16cpu threads, and can handle -j18. A -j flag is not needed. Some build scripts support a time brunch <DEVICE_CODENAME> flag to time how long the build has taken. You may be prompted to enable colour display, enable, it looks pretty.
Completed Build, Now What?
So on this journey you have set up a build environment, set up your repo's, and device specific changes needed to buid and you have built a rom. So how do you access the build you just worked your ass off for? For the average user like me who does not have access to ftp, you can either use a program called plowshare as a non root user, or use a command line tool made by xda user GermainZ to upload to devhost using a python script. This is what we will set up next. Or you can use the GUI and extract the Rom and move to your phone straight, for us using remote machines we cannot do this, so we must upload.​
Devhost Set-Up code (supports Anon Uploads):
Code:
$ cd ~/
$ git clone git://github.com/GermainZ/dev-host-cl.git dev-host-cl
$ cp dev-host-cl/devhost-py2.py ~/bin/devhost
$ chmod +x ~/bin/devhost
Uploading your ROM:
Code:
$ cd out/target/product/<DEVICE_CODENAME>/
$ ls
$ devhost upload -u <USERNAME> -p <PASSWORD> <ROM_ZIP_FILE_NAME>
Example:
Code:
$ cd out/target/product/p880
$ ls
For anon upload: $ devhost upload CARBON-KK-UNOFFICIAL.zip
For user upload: $ devhost upload -u username -p password CARBON-KK-UNOFFICIAL.zip
$ cd ~/carbon
Before building again make sure you either:
Code:
A: $ make clean
B: $ make clobber
To remove the directory fully:
Code:
$ cd ~/
$ rm -rf <ROM_FOLDER_NAME>
NOTEThis is installing the script for python 2, if you use python change "python-py2.py" to just "python.py". Do this if it doesn't work first time for you also. Plowshare will be in the miscellaneous post below this one for other codes for users who do not wish to use devhost. The link to the Rom will be on the bottom of the terminal after it is finished uploading. Some errors are server based, make sure you check the error if you are given one.
Did you make it?
Did you manage to complete it without using GUI and cheating? I bet you did! Post in the thread (Don't quote anything) saying you successfully completed the challenge of using no GUI and link to the finished product and I wall add your name to the "Hall of Fame" that will be placed either at the bottom of this thread or on the bottom of the next post! This should now help give you more experience in building from source with a Linux terminal for uses who have no previous experience, or are new to having access to a remote machine.​
Foot Note
So here is my tutorial on how to build a rom from source using no gui and only the Linux terminal, it is a longer process but is the only process when using a remote machine. I hope I made it easy to understand and I hope you will stay to read the other miscellaneous codes and commands that are still to come on the next post. This tutorial was written up by scratch by me, I thank GermainZ for the devhost script, but I had no help in writing up this tutorial, I believe it may also be a first for xda as when I was searching, I didn't find one to follow. Commands in this are done the long way I know. I will explain why and add how to shorten them and some other shortcuts in the miscellaneous section at the bottom of this thread.
Fluoxetine.​
Miscellaneous
Okay so as promised throughout the thread this section is going to contain other codes that may be useful to you (after gaining experience) including some shortcuts for coding that are really simple, it will also include other scripts such as plowshare for those who hate devhost (can't see why you would thou). I plan to continuously add to this part of thread with extra goodies, so keep posted here. For this purpose I will be using HIDE markers for each code as they are optional, and not for everyone. The key for the HTML style syntax I used for this thread (as self-explanatory as it is) will come at the bottom of my opening posts for this thread, kinda like to round it off you could say haha. Logically they should go at the top, however I am neither Spok nor Sheldon Cooper!​
Legacy Folders (Display and Audio)
Code:
$ cd ~/<ROMNAME>/hardware/qcom/
$ git clone https://github.com/Evervolv/android_hardware_qcom_display-legacy.git display-legacy
$ cd ~/<ROMNAME/hardware/qcom/
$ git clone https://github.com/Evervolv/android_hardware_qcom_audio-legacy.git audio-legacy
$ cd ~/<ROMNAME>
Plowshare
Code:
$ wget http://plowshare.googlecode.com/files/plowshare4-snapshot-git20YYMMDD.GITHASH.tar.gz
$ tar xvzf plowshare4-snapshot-git20YYMMDD.GITHASH.tar.gz
$ cd plowshare4-snapshot-git20YYMMDD.GITHASH
$ make install PREFIX=/home/$USER
See this for more information on using plowhshare: https://code.google.com/p/plowshare/wiki/Readme4 [/CODE]
Shortcuts and other codes (WIP)
#Grouping Commands
Code:
$ mkdir cm && cd cm
&& is a grouping command, it literally means "And then"
#Making Paths
Code:
$ mkdir -p kernel/lge
$ cd kernel/lge
-p flag with mkdir creates a path instead of mkdir * cd * mkdir * cd
#Moving and Copying Files
Code:
$ cd ~/home && mv file.txt ~/home/documents
This will move the "file.txt" to your documents.
$ cd ~/home && scp file.txt ~/home/documents
This will copy the "file.txt" to your documents.
#Removing files and Directories
Code:
$ rm -rf ~/home/documents
This will remove the folder "documents"
$ cd ~/home/documents && rm file.txt
This will delete the file.txt
#Downloading Files/Patches
Code:
$ wget file.link
$ wget github.com/commit.patch
$ git apply commit.patch
Add .patch to the end of the commit to make a patch, navigate to the corresponding directory where it needs to be applied, wget it, and apply the name of it.
#SpeedTest
Code:
$ git clone https://github.com/sivel/speedtest-cli.git
$ cd speedtest-cli
$ ./speedtest_cli.py
This will test download and upload speeds.
[/HIDE]
[B]Device Codenames (Should always be lowercase) (WIP)[/B]
[HIDE] [CODE]
LG Optimus 4xHD p880
Nexus 4 Mako
Nexus 5 Hammerhead
Nexus 7 WiFi Flo
Nexus 7 LTE Deb
Manufacturer Names (Should always be lowercase) (WIP)
Code:
Sony
Lge
Samsung
Asus
Htc
Well, here we are, the Key
Code:
<ROMNAME> Name of the Rom, Carbon, Cm, AOKP, AOSP, Beanstalk, DU, There's plenty to choose from!
<DEVICE_CODENAME> Find the codename for your device from it's github as it is most likely going to be used there!
<GIT_LINK> The link to the corresponding package/manifest on github, google to find the roms github and then search it's repo's
<MANAFACTURER> Well, who made your phone? Check devices github for this one too!
<CORRESPONDING_BRANCH> The branch the manifest is on github, it will most likely include this with the repo link for your convenience
If I missed something, a friendly PM will do! Don't want any confuffled users here!
Hall of Fame for users who managed to follow this confusingly long guide!
Code:
Just Me for now, to get your name put here (will be tagged) just post in thread with an [B]"Hey Fluoxetine! I completed the building with Linux Terminal Challenge, Here is my finished product (Link to product) and I didn't cheat by using the GUI! You're the best!"[/B]
Closing Statement
Well guys, I thank you for taking the time to read and follow my tutorial on building from source using only the Linux terminal, this is a great way to build some experience, maybe gain some confidence in building from source and help you get some original work under your belt! To my knowledge, I believe this is the first tutorial which is specifying on how to build using just the Linux terminal and with some extra goodies! I will keep this updated as both Linux, and android evolve in order to keep it up to date, in mainstream with xda and to just make users life that little bit easier. I think this also proves, even noobs can turn things around by studying up, I managed to learn and write all of this within 3weeks of having an android phone! (16, had an iPhone before, big mistake) Would be great to have this featured on xda *Hint Hint* Vote for it! *Hint Hint*. Wonder if this could qualify for xda university material? Haha, anyways, hope this helped!​
Fluoxetine.
Other Stuff No One Will Read
Thanks go out to Rom Dev Teams, xda for giving a place to post this, GermainZ for his devhost script, and Danny19901 for testing and proof reading basically anything and everything I shove infront of him! Haha!​
Donations
I don't like Electronic Payments, the middle man always takes his cut and it's not fair, I don't want donations, cut out the relay and the time, PM with the amount you want to Donate, and I'll send you the link to an amazon item with my details for you to buy for me and have sent straight to me! Would be much appreciated! Will probably be food, I love food :'3
Requests for Rom builds or additions to this post
PM, PM, PM, I do not care about getting messages (In fact it makes me feel loved) So do not be scared to request a Rom build, or request I add something I have missed out from this tutorial! All requests welcome, however this is not going to be a Q&A Thread with compilation issues, it is purely for the knowledge of how to compile, if you have problems with setting up/changing files/navigating, by all means post, all "Error" posts that are not specific to me will be cleaned because I probably won't know how to fix ^.^
Some Hardware Issues
Okay so some of users out there will be thinking "Hmm, is my hardware good enough to build a whole rom with, I can't even run battlefield or -otherGameHere-. The short answer to this is that you probably can, it may just take a little while longer for you, I think you need to have a 64bit machine full stop. However you also need RAM, a fair bit of it, at least 4gb if you plan to compile and nothing else. If not, you can compile on 1ghz, just will take a while and may freeze so keep checking and make the terminal as small as you can. SWAP May be your best friend for those with GUI, this doesn't apply for Remote Machine Users. You can format a partition on your HDD/SSD, or on a USB Stick (preferred) as a Linux Swap partition of 4gb+ to use as extra Rom, just format and swap-on using Gparted which should be installed on Ubuntu standard.​
GPL, Disclaimer, And Goodbye
So here we go, if you do build a Rom following this tutorial, be sure to release/add the kernel source on github to your thread in order to be compliant with the GPL, otherwise you may be in a spot of trouble, that being said I am not responsible for anything that happens to you/your machine/your phone/tab/anything really, unless this wins you the lottery or a similar payload, in which case I love you and we should get married (No Homo) haha.​
Additions, Edits, Other stuff that doesn't fit anywhere else really haha
Okay so what about the other types of cool things you can do to make this maybe a little bit easier? Well even like you guys probably are i am also still learning how to properly use git, and linux etc. so here i will be adding any of the cool things i learn. This will be great as a reference for me to look back at resources and recollect any information that may filter out of my brain, but may also be useful for you to learn at the same rate as i do! So check it out ​
Okay so today (18.02.14) i found a cool little trick using .sh files to help with the whole setting up malarcky and can make it easier if you plan to build the same rom on a weekly/nightly basis.
Okay, so what you can do whilst in the terminal is to add a file on a text basis, you can do this by running
Code:
$ pico setup.sh
This will open up the text editor on a blank document in which you can edit yourself, this is what you need, to begin with you should probably aim to write something for on screen guide/a type of ui just to let you know whats happening, this will work like a build script does, infact the same method can be applied there. Okay so whatneeds to go into it? First you want the print, this is displayed using a command known as echo.
Code:
echo 'Whatever you want to write'
This will displayed when you execute the script. So what next? Well you can choose to have it run a ui print after each action or just once at the start and then leave it to default ui to guide you. So how do you set the actions you want to do? Simply just start writing the commands!
Code:
echo 'setting up'
mkdir -p kernel/<MANUFACTURER> && git clone <KERNEL_CLONE_LINK> <CODENAME> && cd ~/<ROMNAME>/vendor && git clone <VENDOR_CLONE_LINK>
<MANUFACTURER> && cd ~/<ROMNAME> && mkdir <MANUFACTURER> && cd <MANUFACTURER> && git clone <DEVICE_CLONE_LINK> <CODENAME> && cd
~/<ROMNAME>/vendor/cm && sh get-prebuilts && cd ~/<ROMNAME> && . build/envsetup.sh && breakfast <CODENAME> && brunch <CODENAME> -j7 && cd
~/<ROMNAME>/out/target/product/<CODENAME>/
This will set up the kernel, vendor, and device and start building the rom, you may want to remove/add steps but that is how you can do it if you want to build multiple times, this can take a while to ammend for each different rom you use but it works like a dependencies file. To add UI after each one just add it after each step (short version example to follow)
Code:
echo 'setting up'
Mkdir -p kernel/<MANUFACTURER>
echo 'Cloning Kernel now'
Save this file with ctrl +w and save as a .sh file. Once this is done and in your root, working directory you can simply do:
Code:
. setup.sh
Or whichever you set it as!
NOTE
This may not always work, but it is a good way to set up quickly and efficiently, if a step goes wrong it is best to continue manually rather then re-executing the file, for those with GUI, you can just double click the sh file, this does include the prebuilts from CM, you cann a step by using the && command or create multiple scripts to run one after the other to do a separate job. This does require default branches on github to be the ones you are going to be using. The one i use as an example for carbon is as follows
Code:
echo "Setting up Kernel, Vendor, and Device ready to build Carbon Rom"
mkdir -p kernel/lge && cd kernel/lge && git clone https://github.com/P880-dev/android_kernel_lge_x3.git x3 && cd ~/carbon/vendor && git clone https://github.com/P880-dev/proprietary_vendor_lge.git lge && cd ~/carbon/device && mkdir lge && cd lge && git clone https://github.com/Fluoxetine/android_device_lge_p880.git p880 && cd ~/carbon && . build/envsetup.sh && lunch p880 && make carbon -j30 && cd out/target/product/p880/
Great job mate very useful thread
Sent from my LG-P880 using Tapatalk
Nice work mate! I'm a noob but very interested in these type of things and this looks very useful.I'll see if I can do a 'Lil something with this and let you know if it works out!kudos my man!
Sent from my HTC One using xda app-developers app
nice very good thread for our p880 maybe there will not be more q's about bugs and other stuffXD
i will try this challange later i am tired a bit of building roms by myself, because i have lot of work..
btw i didnt know there are some gui tools for building romsXD
If I may add a suggestion repo sync -f is not the best idea (at least for the first sync), as if a repo can't be downloaded, it just gets skipped, but the repo script still does on syncing, which means you may be missing some source code in case something goes wrong.
So repo sync should be better, at least for the initial sync. Also, the -j flag can speed up things extremely, on systems with a good internet connection, the default is -j4 (if you don't specify another value), but if you run this on a speedy connection, it will slow the DL extremely down.
I, for one, am running -j20 on my home connection (~1.2MB/s DL), but -j80 on a server, I have access to (dunno the exact max speed, but it's fast enough to sync CM in under 7 minutes ). -j4 would take an eternity, as it cannot use the entire bandwidth of the server
BTW, the codenames and manufacturers usually are all lowercase
laufersteppenwolf said:
If I may add a suggestion repo sync -f is not the best idea (at least for the first sync), as if a repo can't be downloaded, it just gets skipped, but the repo script still does on syncing, which means you may be missing some source code in case something goes wrong.
So repo sync should be better, at least for the initial sync. Also, the -j flag can speed up things extremely, on systems with a good internet connection, the default is -j4 (if you don't specify another value), but if you run this on a speedy connection, it will slow the DL extremely down.
I, for one, am running -j20 on my home connection (~1.2MB/s DL), but -j80 on a server, I have access to (dunno the exact max speed, but it's fast enough to sync CM in under 7 minutes ). -j4 would take an eternity, as it cannot use the entire bandwidth of the server
BTW, the codenames and manufacturers usually are all lowercase
Click to expand...
Click to collapse
Added your changes, and some suggested by @me4488 so thanks for that guys, in addition to this and to kinda bump the thread i did add another
Additions, Edits, Other stuff that doesn't fit anywhere else really haha
Click to expand...
Click to collapse
Section with a build script type creating thing in it for users to muck about with
Hope this is of a help to you all!
Damn this is a big thread
it look really great but... i would like to use the offical tree and blobs...... i got a lot of it done oke but i seems to get lost in finding the "offical" vendor in step setting up for your device.
could any body help me out? just trying to compile offical cyanogenmod just to try. and to understand how it all works.
ok i got something starting
but i get this message
You are attempting to build with an unsupported JDK. will find and try to install the right JDK
moneyvirus said:
[..]
but i get this message
You are attempting to build with an unsupported JDK. will find and try to install the right JDK
Click to expand...
Click to collapse
what's the output of?
Code:
java -version
laufersteppenwolf said:
what's the output of?
Code:
java -version
Click to expand...
Click to collapse
It seems he is using java1.7 .. He must change all things to work under 1.6 but i dont remember how XD it is explained somewhere at xda university
Sent from my LG-P880 using xda app-developers app
gerciolisz said:
It seems he is using java1.7 .. He must change all things to work under 1.6 but i dont remember how XD it is explained somewhere at xda university
Sent from my LG-P880 using xda app-developers app
Click to expand...
Click to collapse
well apperently i'm not using java 1.7.
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.4)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
this is what i got @laufersteppenwolf
moneyvirus said:
well apperently i'm not using java 1.7.
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.4)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
this is what i got @laufersteppenwolf
Click to expand...
Click to collapse
I mean there was a command which shows every detail about wchich things are using which java.. Sometimes you can have java 1.6 installed but some parts of system are using 1.7.. Ill try to find it
Edit. I remember it was in compiling cm11 thread somewhere on xda.
There was something about setting up java alternatives AS far AS i remember
Sent from my LG-P880 using xda app-developers app
Nice tutorial If i was a developer of roms o would definetely use your way, i like the old school linux throught terminal exploring
Sent from my LT22i using xda app-developers app
moneyvirus said:
well apperently i'm not using java 1.7.
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.4)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
this is what i got @laufersteppenwolf
Click to expand...
Click to collapse
Alright, then just ignore the error It's saying it'd be the wrong java version, because you're using openJDK, and not oracle, but openJDK is just as fine as oracle
gerciolisz said:
I mean there was a command which shows every detail about wchich things are using which java.. Sometimes you can have java 1.6 installed but some parts of system are using 1.7.. Ill try to find it
Edit. I remember it was in compiling cm11 thread somewhere on xda.
There was something about setting up java alternatives AS far AS i remember
Sent from my LG-P880 using xda app-developers app
Click to expand...
Click to collapse
Java 7 (1.7) is also compatible. It isn't officially supported, and you might run into problems compiling pure AOSP, but other custom ROMs should compile just fine
Thanks for the feedback i'm still having 1 question the Vendor, the unoffical tree is completly clear but i can't find it in the offical source so i mean something like
$ git clone https://github.com/P880-dev/proprietary_vendor_lge.git lge but than on the offical cyanogenmod github.
moneyvirus said:
Thanks for the feedback i'm still having 1 question the Vendor, the unoffical tree is completly clear but i can't find it in the offical source so i mean something like
$ git clone https://github.com/P880-dev/proprietary_vendor_lge.git lge but than on the offical cyanogenmod github.
Click to expand...
Click to collapse
here you go:
Code:
cd vendor
git clone [email protected]:TheMuppets/proprietary_vendor_lge.git -b cm-11.0 lge
croot
ok i found it..
source: http://forum.xda-developers.com/nexus-4/general/guide-cm11-how-to-build-cyanogenmod-11-t2515305
Verify the symlinks. Javac, Java, Javaws, Javadoc, Javah, Javap and Jar should all point to the right Java location and version:
Code:
Code:
$ ls -la /etc/alternatives/java* && ls -la /etc/alternatives/jar
If they are pointing to the wrong versions you have to change that to OpenJDK6.
Select the default Java version for your system:
Code:
Code:
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javaws
$ sudo update-alternatives --config javadoc
$ sudo update-alternatives --config javah
$ sudo update-alternatives --config javap
$ sudo update-alternatives --config jar
That's it.
Click to expand...
Click to collapse
when i had problems with compiling and got some famous errors i changed to this OpenJDK6 with this method and it solved it so if is not solution for your problem maybe its helpful for others
when i was compiling some time ago i must read few compiling threads to make it work and understand it
ok probbably this is a really stupid from my side but this is what i did.
and probbably i'm too noob for this, but i tried this:
i downloaded by example rastakat.
downloaded all the steps... without any error.
But in the last step when i type lunch and i have to choose wich version i would like to compile i can't find P880......
i have the feeling i have to edit some stuff but to be honest i don't know that yet....
will try later on.
maybe you need custom local manifest to p880-dev sources or official p880 sources..
moneyvirus said:
ok probbably this is a really stupid from my side but this is what i did.
and probbably i'm too noob for this, but i tried this:
i downloaded by example rastakat.
downloaded all the steps... without any error.
But in the last step when i type lunch and i have to choose wich version i would like to compile i can't find P880......
i have the feeling i have to edit some stuff but to be honest i don't know that yet....
will try later on.
Click to expand...
Click to collapse
You've set yourself a pretty hard task, first of all, compiling a yet unsupported ROM, but mostly a (more-less) AOSP ROM...
this means you can't use lunch, but you need to do the following:
Download the p880-dev device tree, kernel and vendor blobs
Edit the "inherit" paths inside the .mk files of the device tree
Without (except for the above mentioned) changes, you can run "lunch cm_p880-eng"
Then you can make -j<your_value> bacon

Categories

Resources