[DEV][REF]▓Compile your own Kernel From The Samsung Sources:Quite easy to follow!▓ - Samsung Galaxy SL i9003

[DEV][REF]▓Compile your own Kernel From The Samsung Sources:Quite easy to follow!▓
I want this guide to be n00b friendly...so lets start!
1)Install Ubuntu 10.10 or later(virtual distro may work too!)
Use this for samsung devices:
Code:
SUBSYSTEM=="usb", SYSFS{idVendor}=="04e8", MODE="0666"
2)Download the source code from opensource.samsung.com(easier) or sync the sources from the git repo(easy,but download the tarball as its even easier!)
3)Open terminal and download the the necessary tools:
For 32/64 bitsi use this)
Code:
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
For 64 bits ONLY:
Code:
ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib
4)Download the code soucery toochain:Toolchain
ur machine is good to GO!

The Main Thing
Ok,so i assume u have set up your machine
Now,all of the files should be placed in ~/Downloads (for my convinience to explain!but u may put it anywhere)
extract the sources and everything else u downloaded....then go into the top directory
Code:
cd Kernel
u enter into the root of the kernel directory with this
then type :
Code:
gedit Makefile
The Make file will open.........look out for this and change CROSS_COMPILE= "your toolchain path" and EXTRAVERSION="current kernel version"
This will open up the Makefile in a gedit,and the changed values will correspond to wherever u placed your toolchain................the EXTRAVERSION refers to current sub-version of your linux kernel version on ur phone
Get the config from your phone..Type:
Code:
adb pull /proc/config.gz
This will fetch a working config from the current kernel on your phone....u can alternatively make a new one with "make menuconfig"
Then gunzip it and copy it to to ur kernel source root:
Code:
gunzip config.gz
rename to .config
Now,make the necessary changes in your source.When you are done,type:
Code:
make -jX
,where X=no.op cpu threads multiplied by 1 or 2.
Sit down and have a smoke!
The resulting kernel will be in Kernel/arch/arm/boot/zImage
Bind the zImage with the ramdisk with the help of unpacker-repacker tools by Skin1980 and voila!flash it as pda in odin
Happy Flashing!

Guide still to be full completed!

last one ffffffjjjj

Why using a tar archive when there is now a GIT repository for the sources?

Sine. said:
Why using a tar archive when there is now a GIT repository for the sources?
Click to expand...
Click to collapse
bcoz:
i want this guide to be n00b frienly...u cant expect them to sync sources when downloading a tarball is much simpler!

has anyone tried this guide?
i hoped it would help people

Pl post the link for Codesourcery tool chain. All links are reaching dead end.

edited OP with link

I get this message:
Firefox can't find the server at sourcery.mentor.com.

ganeshbiyer said:
I get this message:
Firefox can't find the server at sourcery.mentor.com.
Click to expand...
Click to collapse
strange............i m able to download it and so is shriomman

Could u upload to multiupload.com.
It will be easier to download from there.
Its is ok Now.
Downloading with Google Chrome.
Don't know what the problem is with firefox.

gedit makefile command gives me a blank window
btw @ sak- post in the op that u have to copy the kernel directory to the home page or else it wont b found right ? i copied ther by readin it from the source readme
edit- got this from google http://kibyegon.wordpress.com/2010/05/13/how-to-install-git-on-ubuntu-lucid-10-04/
!! when i use make command it shows error
[email protected]:~/Downloads/git-1.7.7.3$ make
GIT_VERSION = 1.7.7.3
* new build flags or prefix
CC daemon.o
In file included from daemon.c:1:0:
cache.h:19:18: fatal error: zlib.h: No such file or directory
compilation terminated.
make: *** [daemon.o] Error 1

Source code For ICS released ???
http://source.android.com/
chack the news part

shriomman said:
gedit makefile command gives me a blank window
btw @ sak- post in the op that u have to copy the kernel directory to the home page or else it wont b found right ? i copied ther by readin it from the source readme
edit- got this from google http://kibyegon.wordpress.com/2010/05/13/how-to-install-git-on-ubuntu-lucid-10-04/
!! when i use make command it shows error
[email protected]:~/Downloads/git-1.7.7.3$ make
GIT_VERSION = 1.7.7.3
* new build flags or prefix
CC daemon.o
In file included from daemon.c:1:0:
cache.h:19:18: fatal error: zlib.h: No such file or directory
compilation terminated.
make: *** [daemon.o] Error 1
Click to expand...
Click to collapse
did u use the config and was path of toolchain correctly specified in makefile?

sakindia123 said:
did u use the config and was path of toolchain correctly specified in makefile?
Click to expand...
Click to collapse
aaaa... i dono :\ doesnt this thing have a remote assistance ?? :\

screenshot
check this out :\ i dono whats wrong there :|

shriomman said:
check this out :\ i dono whats wrong there :|
Click to expand...
Click to collapse
r u sure there's a makefile in Kernel?try opening it via the gui and check if it is empty

They are all silly mistakes, not knowing how to use linux. (Read some basic manual)
sudo gedit Makefile (Capitalization matters)
to install software from sources ... (git,...)
(install additional compilers .., typical (gcc. ..)
. / configure
make
good luck!

haha lol shriom................that was too stupid a mistake to be spotted!

Related

[GUIDE] Get Android 2.2 source for n00bs

I did this in Ubuntu 10.4 linux that i installed on a 14gig partition of my laptop.
You can do this in VMware or make a partition of your HDD and download wubi.exe to install linux on your partition... its easier than installing windows. You can use this to help develop if you know anything, or as i have done, used it to get the uncompiled .9.png's to edit for themeing, bypassing the draw9patch step cause the guides are already there ready to go through eclipse IDE.
INSTALL ALL LINUX UPDATES THAT WILL POPUP WITH AUTO-UPDATER BEFORE GETTING SOURCE.
on to the good stuff.... open up the terminal and run the following commands
Code:
sudo nano /etc/apt/sources.list
Then add the following to the bottom by scrolling down with your arrow keys and pasting by right clicking, CTRL-V WONT WORK.

Code:
deb http://cz.archive.ubuntu.com/ubuntu jaunty-updates main multiverse
Hit CTRL O and ENTER to save and CTRL X to return to the command line. Now lets get the repo packages cached onto your box using the following command.
Code:
sudo apt-get update
install Java 5 SDK and all the other little packages needed to build Android with this command.
32-bit x86
Code:
sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev valgrind
64-bit x86
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl sun-java5-jdk zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev
Code:
sudo update-java-alternatives -s java-1.5.0-sun
Code:
sudo ln -s /usr/lib32/libX11.so.6 /usr/lib32/libX11.so
moving on
INSTALLING REPO
You can install repo tool any place in your path. We choose a bin directory in our home folder:
Code:
$cd ~
$mkdir bin
$export PATH=$PATH:~/bin
$curl https://android.git.kernel.org/repo >~/bin/repo
$chmod a+x ~/bin/repo
DOWNLOADING ANDROID SOURCE CODE:
Create an empty directory to hold your working files:
Code:
$mkdir mydroid
$cd mydroid
# Run repo init to bring down the latest version of Android with all its most recent bug fixes. You must specify a URL for the manifest:
Code:
$repo init -u git://android.git.kernel.org/platform/manifest.git
NOTE: using -b option we can choose which android version to install:
Code:
$repo init -u git://android.git.kernel.org/platform/manifest.git -b froyo
To pull down files to your working directory from the repositories as specified in the default manifest, run
Code:
$repo sync
NOTE: mydroid directory size grows up to 3.6G.
BUILDING ANDROID
Simply on top of your android directory execute make command:
Code:
$cd mydroid
$make
After some time it will finish.
We get the installed file list in this file:
out/target/product/generic/installed-files.txt
Also some images are created in the same directory: (system.img userdata.img ramdisk.img)
mydroid$ ls out/target/product/generic/
android-info.txt data obj ramdisk.img symbols system.img
clean_steps.mk installed-files.txt previous_build_config.mk root system userdata.img
We have built android source code but now we want to test it:
run the Android Emulator, which comes within the Android SDK
http://developer.android.com/guide/developing/tools/emulator.html
Download Android SDK
http://developer.android.com/sdk/index.html
Install Android SDK
http://developer.android.com/sdk/installing.html
ill post the location of the framework-res.apk drawables and stock app apks to edit for those of you interested in theming.
I appreciate the effort but isn't this almost the same from android central by gbhil?
Sent from my HERO200
Wouldnt know. Die hard xda member. Im sure im not the only one that checks this site only. Im just trying to do my part. We need devs and themers with creative ideas. This is the one of the first few steps toward those interested in learning.
Sent from my Hero CDMA using XDA App
Thank You!!!!!!!
WELL DONE SIR!!!!! Thank you for posting a good repo link for froyo!!!!!
riggsandroid said:
I appreciate the effort but isn't this almost the same from android central by gbhil?
Sent from my HERO200
Click to expand...
Click to collapse
Isn't android central a different website?
myth_mn said:
Isn't android central a different website?
Click to expand...
Click to collapse
Yes, I was thinking if he took it from there to give credit. But the effort is appreciated and not trying to start a problem.
Sent from my HERO200
Made this because of all the errors i ran into and gathered all my sources of research of linux commands like changing your $PATH and installing java after my machine wouldnt find it in the repository, or not being able to get repo installed. Im just trying to help. I would have sourced gbhil if i took it from there. And this isnt a college essay, work cited pages arent necessary, its a courtesy out of respect. Besides... my sources where from blogs and most didnt have anything to do with android. Just throwin that out there. ©
epitaphromance said:
Made this because of all the errors i ran into and gathered all my sources of research of linux commands like changing your $PATH and installing java after my machine wouldnt find it in the repository, or not being able to get repo installed. Im just trying to help. I would have sourced gbhil if i took it from there. And this isnt a college essay, work cited pages arent necessary, its a courtesy out of respect. Besides... my sources where from blogs and most didnt have anything to do with android. Just throwin that out there. ©
Click to expand...
Click to collapse
no problem. i appreciate the work, I'm gonna give it a shot at some piont when I get some time to install ubuntu.
not doubting you didn't do the work, it was only fresh in my mind because i literally looked at it yesterday. thanks again for the info gathering.
Welcome
Sent from my Hero CDMA using XDA App
Just hope your patient between builds... or at least the first build unless you have a real killer machine. Tried it on my laptop (1.8ghz dual core amd)... 2hrs and had to ctrl+c cause I had to go to bed...
Just wanted to say that this also works on linux mint kde 8 (also known as user friendly linux) it is taking forever though as posted good write-up. oh by the f ubuntu. just saying
Hello,
Not sure if you follow this thread or not anymore but I get an error I was hoping someone could help me with? When I run the last "make" commange I get this error:
Checking build tools versions...
************************************************************
You are attempting to build with the incorrect version
of java.
Your version is: java version "1.6.0_20".
The correct version is: 1.5.
Please follow the machine setup instructions at
http://source.android.com/download
************************************************************
build/core/main.mk:117: *** stop. Stop.
Any ideas?
Thanks
jschill31 said:
Hello,
Not sure if you follow this thread or not anymore but I get an error I was hoping someone could help me with? When I run the last "make" commange I get this error:
Checking build tools versions...
************************************************************
You are attempting to build with the incorrect version
of java.
Your version is: java version "1.6.0_20".
The correct version is: 1.5.
Please follow the machine setup instructions at
http://source.android.com/download
************************************************************
build/core/main.mk:117: *** stop. Stop.
Any ideas?
Thanks
Click to expand...
Click to collapse
Assuming you've installed an openjdk-6-jdk package, you can override the normal build restriction of Java 5 by editing the file build/core/main.mk and changing the Java version test to match against "1.6" instead of "1.5". You'll need to do it in two places, once for java and once for javac. I never had to do this to build Cyanogenmod, but you may need to for AOSP.
Decad3nce said:
Assuming you've installed an openjdk-6-jdk package, you can override the normal build restriction of Java 5 by editing the file build/core/main.mk and changing the Java version test to match against "1.6" instead of "1.5". You'll need to do it in two places, once for java and once for javac. I never had to do this to build Cyanogenmod, but you may need to for AOSP.
Click to expand...
Click to collapse
Decad3nce, thanks for posting so fast. The funny thing is I figured it out within 5 minutes of posting but got sucked in to finalizing my source code that I am now just getting back to the post. There are several here in this forum that really help out and you are one of them. I am just now getting brave enough to start cooking but catch on fast. Can't wait to see what you, nfinite and beezy do to the wildfire port!

[DEV GUIDE] Build CM7 from source in its current state. Updated: 2011/05/16-23:52

PLEASE READ THIS BEFORE CONTINUING:
We are changing to a new build system which will result in an updated but VERY different ROM underneath the hood. There is a HIGH POSSIBILITY that building in the current state could BRICK your device, potentially PERMANENTLY. PLEASE DO NOT FLASH unless you are HIGHLY confident you know what you're doing.
For kernel building, see post #2.
For known issues and changelog, see post #3.
Kanged from the CM-Wiki. Yes it's a wiki, yes I could have created an epic page, but we aren't official yet.
Install ADB
Install the Android SDK.
Install the Build Packages
Install using the package manager of your choice:
For 32-bit & 64-bit systems:
Code:
git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev sun-java6-jdk pngcrush schedtool
For 64-bit only systems:
Code:
g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline5-dev gcc-4.3-multilib g++-4.3-multilib
NOTE: On Ubuntu 10.10, and variants, you need to enable the parter repository to install sun-java6-jdk:
Code:
add-apt-repository "deb http://archive.canonical.com/ maverick partner"
Create the Directories
You will need to set up some directories in your build environment.
To create them:
Code:
mkdir -p ~/bin
mkdir -p ~/android/system
Install the Repository
Enter the following to download make executable the "repo" binary:
Code:
curl http://android.git.kernel.org/repo > ~/bin/repo
chmod a+x ~/bin/repo
NOTE: You may need to reboot for these changes to take effect.
Now enter the following to initialize the repository:
Code:
cd ~/android/system/
repo init -u git://github.com/EpicCM/android.git -b teamhacksung-merge
repo sync -j16
Download RomManager and Google Files
NOTE: This only needs to be done when an update to RomManager or GoogleApps is released. If you are up-to-date, you may skip to Building CyanogenMod.
Code:
cd ~/android/system/
./build.sh prepare
Building CyanogenMod
First, check for updates in the source:
Code:
cd ~/android/system/
repo sync
Configure Build & Compile
Now, the environment must be configured to build and the ROM compiled, from code, for the epic.
Code:
cd ~/android/system/
. build/envsetup.sh
./build.sh epic
Build failed? Check post #3 for common problems and solutions.
Install
1. The build system should create a flashable zipfile. Place it on the root of your sdcard.
Optional: Download Google Apps for CyanogenMod 7 and place it on the root of the SD card.
2. Boot into a custom recovery like ClockworkMod Recovery and flash the CM7 update.zip. Then flash google apps if you like.
Please don't flash yet, unless you want an expensive doorstop.
This section of the guide will inform you on how to build a CM7-compatible kernel using our github sources.
Download the Code
Due to the way the new build system works, you'll need the entire CM source to build a proper kernel. (Sorry)
Follow the steps in post #1 to initialize and download our entire CM source repository.
Keeping your code up-to-date:
Code:
cd ~/android/system
repo sync
Toolchain setup
The new build system automatically utilizes the toolchain included in CM7 source.
Prepare to build
The kernel build script requires a few environment vars be set by the CM build system.
Code:
cd ~/android/system/
. build/envsetup.sh
lunch cyanogen_epic-eng
Compile the kernel
Code:
cd ~/android/system/kernel/samsung/2.6.35/
./build.sh epic
cd ~/android/system/releasetools/
./kernel.sh epic
You should now have a flashable zip in out/target/product/epic/
Please don't flash yet, unless you want an expensive doorstop.
This is also incompatible with stock roms, and unless you're amazing, never will be compatible.
KNOWN BUILD-TIME ISSUES
WARNING: These fixes may cause your repo to become out-of-sync from the official repo. Make sure you know how to revert these changes so repo sync doesn't fail.
Error: New build does not boot.
Fix: Working on it
KNOWN RUN-TIME ISSUES
Will update this when it runs.
GUIDE CHANGELOG:
20110516-2352: New build system from teamhacksung.
20110506-1842: Switched to our forks of teamhacksung work.
CODE CHANGELOG:
Available at each of our repositories:
https://github.com/EpicCM
Love seeing these types of posts; makes a pathway for new developers to learn =)
XtaC318 said:
Love seeing these types of posts; makes a pathway for new developers to learn =)
Click to expand...
Click to collapse
I agree! Time to start playing!
Cool guide, makes it easy for the new guys.
Sent from my SPH-D700 using Tapatalk
getting same error. edited make file and tried to remove the samsung/device/crespo device.mk overlap but still a no-go
Code:
build/core/base_rules.mk:479: warning: overriding commands for target `out/target/product/epic/recovery/root/sbin/tune2fs'
bootable/recovery/Android.mk:87: warning: ignoring old commands for target `out/target/product/epic/recovery/root/sbin/tune2fs'
build/core/base_rules.mk:162: *** device/samsung/epic/libs3cjpeg: MODULE.TARGET.SHARED_LIBRARIES.libs3cjpeg already defined by device/samsung/crespo/libs3cjpeg. Stop.
smeyerhuky said:
getting same error. edited make file and tried to remove the samsung/device/crespo device.mk overlap but still a no-go
Code:
build/core/base_rules.mk:479: warning: overriding commands for target `out/target/product/epic/recovery/root/sbin/tune2fs'
bootable/recovery/Android.mk:87: warning: ignoring old commands for target `out/target/product/epic/recovery/root/sbin/tune2fs'
build/core/base_rules.mk:162: *** device/samsung/epic/libs3cjpeg: MODULE.TARGET.SHARED_LIBRARIES.libs3cjpeg already defined by device/samsung/crespo/libs3cjpeg. Stop.
Click to expand...
Click to collapse
yes, that's something that we can't easily fix in our own device repo. you could always remove the crespo folder as a temporary fix, but we need to push a patch upstream that fixes crespo makefiles. I will be adding this to known issues shortly.
So my windows seven crashed on me and I'm gonna go with Ubuntu 10.10 for now
I can play with this on that Linux install, correct?
sent by an Epic4g through the cosmos
raiderep said:
So my windows seven crashed on me and I'm gonna go with Ubuntu 10.10 for now
I can play with this on that Linux install, correct?
Click to expand...
Click to collapse
Yes, it's mentioned in the instructions.
Alternatively, you can use VMWare to do compiling from Windows. That's how I'd set up my old development system. There are tons of free Ubuntu 10.10 vm images.
Updated. Sorry for the mistake in Copy Proprietary Files. That should fix a compile error related to libcamera.
Any clue what causes a build to fail due to unable to dopen system/lib/egl/libandroid_servers.so. When I build with boardconfig has generic audio I'm fine, when I set has galaxys audio it fails
Sent from my SPH-D700 using Tapatalk
dreamsforgotten said:
Any clue what causes a build to fail due to unable to dopen system/lib/egl/libandroid_servers.so. When I build with boardconfig has generic audio I'm fine, when I set has galaxys audio it fails
Sent from my SPH-D700 using Tapatalk
Click to expand...
Click to collapse
Audio in and out works if you leave it at default values.
If you absolutely want to compile with galaxys audio, it looks like ./extract-files.sh might not be pulling that file? Check ~/android/system/vendor/samsung/epic/proprietary/lib/egl/ for that file.
Thanks for the heads up, no the fileisn't in egl and from what I can tell its not supposed to be.
Sent from my SPH-D700 using Tapatalk
Fix: Open up Context.java, find the three chunks of WimaxManager JAVADOC in comments. Delete JUST the commented stuff that's related to WiMax.
Click to expand...
Click to collapse
Can anyone please elaborate, I don't understand wat exactly to be done. Even though I deleted commented lines I still receive errors
Thanks
THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!
So for kernel compilation I received and error
fs/binfmt_aout.c: In function 'load_aout_binary':
fs/binfmt_aout.c:271: error: 'SEGMENT_SIZE' undeclared (first use in this function)
Click to expand...
Click to collapse
And I had to update a line in Makefile
from
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
Click to expand...
Click to collapse
to
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) -Dlinux
Click to expand...
Click to collapse
Still nearly at the end of compile I receive
samsung-kernel-epic/scripts/mksysmap: line 44: arm-none-eabi-nm: No such file or directory
Click to expand...
Click to collapse
I'll see if I can cream system.map from vmlinux and report again
The kernel compilation issue was discussed here: http://forum.xda-developers.com/showthread.php?t=825611
I needed to do
make update-api
Click to expand...
Click to collapse
After removing those comments
it went ahead now the next place I'm stuck is
CameraService.cpp:1478: error: undefined reference to 'openCameraHardware'
Click to expand...
Click to collapse
Any ideas?
Thanks
\m/ I got cm7 compiled
So here are nullghosts instructions:
open android/system/device/samsung/epic/full_epic.mk for editing and
replace any instance of SPH-D700 to epic
Click to expand...
Click to collapse
Then open extract-files.sh for editing and make sure Copy Files (from mid to bottom) list is same as files list (at top)
add these 2 lines to
FILES="
Click to expand...
Click to collapse
section of extract-files.sh
bin/netcfg
lib/libQmageDecoder
Click to expand...
Click to collapse
If you have any other file missing read below:
head -197 extract-files.sh > files may come in handy to compare 2 files
vendor/samsung/__DEVICE__/proprietary/bin/netcfg:system/bin/netcfg
vendor/samsung/__DEVICE__/proprietary/lib/libQmageDecoder.so:system/lib/libQmageDecoder.so
Click to expand...
Click to collapse
are the 2 lines in copy files which did not have corresponding files
Now need to zip it and see if I can get kernel compiled
Can anyone that has it compiled post a zip? I dont wanna download lile 10gb of stuff.
Sent from my SPH-D700 using XDA App

[Guide]Make your own rom(CM9/EVERVOLV) and kernel from source code | Advanced users

I think many want to know how this stuff is actually done,so....read
Kernel Development
U need Linux or Mac OS .The End
I can confirm the below method works on Ubuntu 11.10,32 bit(or other linux distros/mac u need different packages)
1)Open terminal and download these packages(for both 32/64 bit)
Code:
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
For 64 bit ,install more packages,otherwise leave
Code:
ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib
2)Download kernel source code for pico ,which u will compile,from www.htcdev.com (if u want to compile kernel for ics/jb,use lirokoa's source code from www.github.com/lirokoa/htc_pico_kernel )
Extract the archive somewhere safe
3)Download toolchain needed to compile the kernel from www.github.com/sakindia123/android_toolchains
We'll use arm-eabi-4.4.3 for pico
Now let's assume u have correctly set up your machine
extract the sources and everything else u downloaded....then go into the top directory
Code:
cd Kernel
u enter into the root of the kernel directory with this
then type :
Code:
gedit Makefile
The Make file will open.........look out for this and change CROSS_COMPILE= "your toolchain path"
EXAMPLE:
Code:
CROSS_COMPILE ?= /home/sarthak/Downloads/Toolchains/arm-eabi-4.4.3/bin/arm-eabi-
This will open up the Makefile in a gedit,and the changed values will correspond to wherever u placed your toolchain...
Make the kernel config
Code:
make msm7627a_defconfig
NOTE- Do "make htc_pico_defconfig" is making ics/jb kernel
This will make a working kernel config acc. to the source code
Now,make the necessary changes in your source.When you are done,type:
Code:
make -jX
,where X=no.op cpu threads multiplied by 1 or 2.
Sit down and have a smoke!
The resulting kernel will be in Kernel/arch/arm/boot/zImage
Easy,ain't it?
Remember,this guide doesnt teach u how to make particular changes,it just helps u setting up your build environment and compiling from a given source.
Packaging kernel for flashing on target device
- Take a stock boot.img(or any boot.img that works with the rom)
- Downloads boot image tools from -> https://github.com/sakindia123/boot-image-tools and keep them somewhere
- Place boot.img in source_img folder inside the boot.img-tools folder(create if not there)
- Enter the boot tools directory
- Unpack:
Code:
$ mkdir -p unpack
$ tools/unpackbootimg -i source_img/boot.img -o unpack
-Extracting boot.img-ramdisk.gz
Code:
$ mkdir -p boot
$ cd boot
$ gzip -dc ../unpack/boot.img-ramdisk.gz | cpio -i
$ cd ../
Packing a new ramdisk:
Code:
$ tools/mkbootfs boot | gzip > unpack/boot.img-ramdisk-new.gz
Create a new boot.img:
Code:
$ mkdir -p target_img
$ tools/mkbootimg --kernel unpack/boot.img-zImage --ramdisk unpack/boot.img-ramdisk-new.gz -o target_img/boot.img --base `cat unpack/boot.img-base`
Done!
Now take the boot.img from target_img folder and flash via fastboot.Also push the compiled modules or else wifi wont work
Code:
fastboot flash boot boot.img && fastboot reboot
adb push drivers/net/wireless/bcmdhd/bcmdhd.ko /system/lib/modules
adb push drivers/net/kineto_gan.ko /system/lib/modules
NOTE: If u are compiling kernel for stock/sense roms,wifi module will be found in drivers/net/wireless/bcm4330b2/bcm4330.ko
Enjoy !
Compile rom from source
1) Make your own CyanogenMod9 nightly
So cant wait for the developer to release the next build?gettin' itchy?
Compile on your own!
- Packages
For 64-bit systems(For ICS and above,u need 64 bit and above)
Code:
apt-get install git-core gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev:i386 g++-multilib mingw32 openjdk-6-jdk pngcrush schedtool tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
- Create working directories for the build environment:
mkdir -p ~/bin
mkdir -p ~/android/system
- Get Google's repo tool
Code:
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
Reboot
- Sync the Repository
Code:
cd ~/android/system/
repo init -u git://github.com/CyanogenMod/android.git -b ics
repo sync -j16
NOTE- USe -j4 if u have slow net connection!
Wait for a few hours depending upon your net connection,it will download 4-5 GB or more
Then ,after syncing finishes,in the root of the source,open the hidden folder ".repo"
create a file local_manifest.xml and put this xml code to sync relevant repos for compiling cm9 for pico
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="lirokoa/android_device_htc_pico_ics" path="device/htc/pico" revision="ics" />
<project name="sakindia123/ics-vendor-pico" path="vendor/htc/pico" revision="master" />
</manifest>
then save and do "repo sync " again
- Compile the actual rom
This is fun bit.Make changes to the sourc code if u want to fix bugs or experiment,then,in the root of working directory,type
Code:
. build/envsetup.sh
brunch pico -jX
NOTE- REPLACE X with the no. of cores on your computer,do not enter X
Wait for it to compile(depends on how crap the computer is)
When it finishes compiling,output will be in out/target/product/pico/cm9-UNOFFICIAL-xxxxxxxx.zip
Flash the zip via recovery
Enjoy
Compile Evervolv Nightly
SO u dont want cm9,u want to compile evervolv,eh?
Follow the setups upto "Get Google's repo tool" in cm9 guide,but instead of cm9 source ,sync this
Code:
cd ~/android/system/
repo init -u git://github.com/cm2pico/android.git -b ics
repo sync -j16
After syncing,do this
Code:
nano vendor/ev/vendorsetup.sh
in the text editor that opens up,type
[/CODE]add_lunch_combo ev_pico-eng[/CODE]
Then to compile,
Code:
. build/envsetup.sh
lunch
Select pico in menu and type
Code:
make -jX otapackage
Replace X with no. of cores on pc!
pico up output zip from out/target/product/pico/Evervolv-2.2.0.zip
Nice think I might try this. I'm running osx is there different tools avalible or am I better off installing win or Linux in a vm
Sent from my HTC Explorer A310e using xda app-developers app
---------- Post added at 01:48 PM ---------- Previous post was at 01:45 PM ----------
Sorry just read the op properly and seen my question answered
Sent from my HTC Explorer A310e using xda app-developers app
May I use cygwin software to use this on windows to emulate properties of Linux? I heard so!
Nice to see new how to threads...
Sent from my Galaxy Nexus using Tapatalk 2
arunsai123 said:
May I use cygwin software to use this on windows to emulate properties of Linux? I heard so!
Click to expand...
Click to collapse
Not really..there are some things that cant be properly emulated..u need a native install or Virtual MAchine
BUMP- Kernel part of the tut has been completed.Hope u guys are successfully in making your own kernel
dude wheres the tutorial for ROM developement!!
updated with instruction to compile own CM9 and evervolv kang
Great Tutorial dude ...
Great Tutorial dude ... ... very clearly explained .... :laugh: :good: :fingers-crossed:
Great I'm going to compile aokp from its source
Sent from my HTC Explorer A310 using xda premium
time to download
well i have airtel broadband connection(unlimited) on 256 kbps, i get a downloading speed of 30-40 kbps.
so, i wanted to ask you all the size of all the sources/data required to compile a single ROM and time taken to download all those things.
siddharth1102 said:
well i have airtel broadband connection(unlimited) on 256 kbps, i get a downloading speed of 30-40 kbps.
so, i wanted to ask you all the size of all the sources/data required to compile a single ROM and time taken to download all those things.
Click to expand...
Click to collapse
cm9 about 4-5gb, evervolv ics about 6-6.5gb
unlike cm7 where you had to download all supported devices which added additional size to main source (16gb or so) cm9 (by default) and evervolv (from sakindia123 that includes device tree and vendor prop files) both only download the main source only which makes the downloads less in size...........for you it would take a long time to download afew hours (i have 15mbps or 1.5meg a sec so didnt take long) once all setup and synced a single cm9 build takes me just over 1hr and evervolv slightly more, all depends on your hardware ie ram, processor etc.....have fun
LiVeRpOoL-FaN said:
cm9 about 4-5gb, evervolv ics about 6-6.5gb
unlike cm7 where you had to download all supported devices which added additional size to main source (16gb or so) cm9 (by default) and evervolv (from sakindia123 that includes device tree and vendor prop files) both only download the main source only which makes the downloads less in size...........for you it would take a long time to download afew hours (i have 15mbps or 1.5meg a sec so didnt take long) once all setup and synced a single cm9 build takes me just over 1hr and evervolv slightly more, all depends on your hardware ie ram, processor etc.....have fun
Click to expand...
Click to collapse
Can i download these things in installments?
siddharth1102 said:
Can i download these things in installments?
Click to expand...
Click to collapse
really the best way is to fully download in 1 go but in terminal you press Ctrl + z (on Ubuntu) to stop the process and then carry it on later, although it wont sync the whole project until all source is downloaded............
LiVeRpOoL-FaN said:
really the best way is to fully download in 1 go but in terminal you press Ctrl + z (on Ubuntu) to stop the process and then carry it on later, although it wont sync the whole project until all source is downloaded............
Click to expand...
Click to collapse
While learning to compile i found that compiling jelly bean on ubuntu 12.04 is it experimental mode. So, i wanted to ask won't it compile properly and will it work i do so?
siddharth1102 said:
While learning to compile i found that compiling jelly bean on ubuntu 12.04 is it experimental mode. So, i wanted to ask won't it compile properly and will it work i do so?
Click to expand...
Click to collapse
i`ve not used 12.04 for anything, i used 11.10 for cm7 and cm9 but found had to use 10.04.4 (lucid) for evervolv ics (aosp code, not cm modified code) i think jb aosp was compiled on 10.04.4 by android aosp team

[GUIDE] Building Pure Nexus

Introduction
Hello everyone, this is a guide to get you up and running with your own build of Pure Nexus for the Nexus 5X. In this thread, you will learn how to get your computer set up to build and the commands you will need to run. Please read the entire guide and the FAQ. Additionally, this is a developer's thread, there should be no off topic discussion.
Compilation Guide
This is available on my Github, where it may be a little more up to date.
0. Getting started
In this guide, I will go over how to build Pure Nexus on your Linux machine. This particular tutorial will focus on Ubuntu 16.04 as that is what I use (Mint 18 is also good) but this should work with any version of Linux; it does need to be 64-bit however. I will leave the installation of that up to you, Google is a wonderful resource. If you don't have a good computer but still want to build, check out this thread on XDA: http://forum.xda-developers.com/chef-central/android/guide-how-to-build-rom-google-cloud-t3360430
1. Set up your environment
1. Automatically
Code:
sudo apt-get install git-core
git clone https://github.com/akhilnarang/scripts
cd scripts
ls
bash <script-name>
<script-name> should be one of the scripts in the folder for your particular architecture.
2. Manually
1. Install Java 8
Code:
sudo apt-get update
sudo apt-get install openjdk-8-jdk
sudo apt-get install openjdk-8-jre
2. Install other build tools
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip
2. Configure repo and git
If you have any problems with the below commands, try running as root:
Code:
sudo -s
Git is an open source version control system which is incredibly robust for tracking changes across repositories. Repo is Google's tool for working with Git in the context of Android. More reading if you are interested: https://source.android.com/source/developing.html
Run these commands to get repo working (only do this if you did the manual set up method above:
Code:
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
Run these commands to get git working:
Code:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
3. Download the source
First, before downloading the source, create a folder for the source and move into it.
Code:
mkdir ~/<foldername> (eg. mkdir ~/PN or ~/PureNexus)
cd ~/<foldername>
Then, we need to grab the manifest and sync down the repositories. Here are the commands to do this for Pure Nexus for Nougat (make sure you are in the source folder you made above):
Code:
repo init -u https://github.com/PureNexusProject/manifest.git -b n
repo sync --force-sync
Here is the process generally for other ROMs:
When you go to build a ROM, you must download its source. All, if not most, ROMs will have their source code available on Github. To properly download the source, follow these steps:
Go to your ROM's Github (e.g. http://github.com/PureNexusProject)
Search for a manifest (usually called manifest or android_manifest).
Go into the repo and make sure you are in the right branch (located right under the Commits tab).
Go into the README and search for a repo init command. If one exists, copy and paste it into the terminal and hit enter.
If one does not exist, you can make one with this formula:
Code:
repo init -u <url_of_manifest_repo>.git -b <branch_you_want_to_build>
For example:
Code:
repo init -u http://github.com/PureNexusProject/manifest.git -b n
After the repo has been initialized, run this command to download the source:
Code:
repo sync --force-sync
This process can take a while depending on your internet connection.
4. Build it!
At this point, it'd be a good idea to set up ccache. ccache is a compiler cache, it stores previously compiled files in a directory and pulls from that instead of recompiling if nothing has changed. This speeds up compilation a LOT. If you want to use it, follow the below steps:
Open up your .bashrc file in your home directory using a text editor or nano and append this to the end of it:
Code:
export USE_CCACHE=1
Then type:
Code:
source ~/.bashrc
After that, run one of the below command (replacing the # with how many GBs of ccache you want, 50 is recommended)
Use this one if you used the manual method of set up in section 1:
Code:
prebuilts/misc/linux-x86/ccache/ccache -M #G
Use this one if you used the automatic method of set up in section 1:
Code:
ccache -M #G
After that, it's time to build!
Code:
. build/envsetup.sh
breakfast bullhead
mka bacon
After that, your computer will build the flashable zip file and if you see something that says make completed, you've done it!
Any time that you want to rebuild, type the following commands:
Code:
repo sync --force-sync
. build/envsetup.sh
breakfast bullhead
mka clobber
mka bacon
I also have a script to do this on my Github here
Frequently Asked Questions
1.1 Q: I got an error, what do I do??
1.1 A: Well to start, if it is anything with Ninja, I would go ahead and disable it. You can add this to your .bashrc file:
Code:
export USE_NINJA=false
Then type this
Code:
source ~/.bashrc
. build/envsetup.sh
breakfast bullhead
mka clobber
mka bacon
If it is saying you ran out of memory, follow this post.
If it isn't Ninja related, check out @AzraelsKiss's post here, where he has documented a few common issues. If none of those apply, post here with a detailed list of what you have done and we will do our best to help you.
1.2 Q: Can you guys share your personal builds?
1.2 A: No, personal builds are just that: personal. Beans releases whenever he feels that the release is ready for the masses and if a bunch of personal builds are floating around, that tarnishes the Pure Nexus name. We are more than happy to help get you up and running but we will not be sharing our builds. Thanks for understanding!
this wont work on Windows, right?
RonnellTapawan said:
this wont work on Windows, right?
Click to expand...
Click to collapse
I have heard people try to use Bash for Windows but I don't think it will work. Linux or bust.
nathanchance said:
I have heard people try to use Bash for Windows but I don't think it will work. Linux or bust.
Click to expand...
Click to collapse
I tried on bash for windows but it can't build android roms
Dude you should seriously get a XDA medallion or some sort of metal for all you do all over XDA. I see you everywhere. Thanks for building for us and also for this write up. :good: @ nathan
SM210 said:
Dude you should seriously get a XDA medallion or some sort of metal for all you do all over XDA. I see you everywhere. Thanks for building for us and also for this write up. :good: @ nathan
Click to expand...
Click to collapse
Talk to my superiors :silly: thanks for the kind words
Edited.......
Sent from my Nexus 5X using Tapatalk
myawan said:
Anybody wanna share home made build?
Sent from my Nexus 5X using Tapatalk
Click to expand...
Click to collapse
If you read at the end of the OP, it says:
"1.2 Q: Can you guys share your personal builds?
1.2 A: No, personal builds are just that: personal. Beans releases whenever he feels that the release is ready for the masses and if a bunch of personal builds are floating around, that tarnishes the Pure Nexus name. We are more than happy to help get you up and running but we will not be sharing our builds. Thanks for understanding!"
Reason being, because if we start compiling these and handing it out like it's no ones business, we're going to run Pure Nexus into the ground and people will start uploading them on AFH and it'll be one big mess. My guess is, this is just a courtesy by the original poster to those of us who can't wait.
My two cents.:laugh::highfive:
i'm on it!!!!! thank you very much!!! download is taking forever ugh
Building it right now! Thanks
I think this would work in Cygwin. I used to compile stuff for the PS3 way back. I'd have a lot of reading to do if I wanted to build this for my phone.
Which gapps to use with this?
Open Gapps micro are working fine.
Gesendet von meinem Nexus 5X mit Tapatalk
So WE can't share our build either? Or what, i didn't get it.
CreasingMass Dev said:
So WE can't share our build either? Or what, i didn't get it.
Click to expand...
Click to collapse
Don't distribute personal builds. Flash them yourself and that is it.
4 hours of download :crying:
OOH MAN!!!!!! no more space in my device!!! how can i resume that???
Code:
Checking out files: 100% (1717/1717), done.
error: unable to write file current/platforms/android-21/arch-x86_64/usr/lib/libz.a
error: unable to write file current/platforms/android-21/arch-x86_64/usr/lib/libz.so
fatal: cannot create directory at 'current/platforms/android-21/arch-x86_64/usr/lib64': Spazio esaurito sul device
Traceback (most recent call last):
File "/home/matteo/Scaricati/PureNexus/.repo/repo/main.py", line 531, in <module>
_Main(sys.argv[1:])
File "/home/matteo/Scaricati/PureNexus/.repo/repo/main.py", line 507, in _Main
result = repo._Run(argv) or 0
File "/home/matteo/Scaricati/PureNexus/.repo/repo/main.py", line 180, in _Run
result = cmd.Execute(copts, cargs)
File "/home/matteo/Scaricati/PureNexus/.repo/repo/subcmds/sync.py", line 769, in Execute
project.Sync_LocalHalf(syncbuf, force_sync=opt.force_sync)
File "/home/matteo/Scaricati/PureNexus/.repo/repo/project.py", line 1325, in Sync_LocalHalf
self._InitWorkTree(force_sync=force_sync)
File "/home/matteo/Scaricati/PureNexus/.repo/repo/project.py", line 2482, in _InitWorkTree
raise GitError("cannot initialize work tree")
error.GitError: cannot initialize work tree
can i move the PureNexus folder in an external drive and resume??? please
MatteXperiaU said:
4 hours of download :crying:
OOH MAN!!!!!! no more space in my device!!! how can i resume that???
can i move the PureNexus folder in an external drive and resume??? please
Click to expand...
Click to collapse
You can try. Your build times will be much slower though.
Sent from my Nexus 6P using XDA Labs
nathanchance said:
You can try. Your build times will be much slower though.
Sent from my Nexus 6P using XDA Labs
Click to expand...
Click to collapse
i have another partition in the same HD (300GB).. i can use that :fingers-crossed:
which command i need to resume?
sorry for the questions man, you're too kind
TPMJB said:
I think this would work in Cygwin. I used to compile stuff for the PS3 way back. I'd have a lot of reading to do if I wanted to build this for my phone.
Click to expand...
Click to collapse
No promises...
http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/
Out of curiosity, realistically how much disk space would be required to download everything and compile with a 50GB cache? I got everything downloaded and the compile ran but threw some warnings (most of which may have been benign). When the compile terminated with an error, I had about 40MB left on my Linux Mint 18 partition so I assume it ran out of space I started with about 70GB free space
I deleted everything and decided to try again if and when I have a larger partition to play with..... I am currently dual booting on a Windows machine and didn't think to allocate that much space to Mint.
Paul

Guide: Compile /system/bin binaries for your device from AOSP source code

Now tested up to downloading AOSP and make toolbox you should be all set
Please give thanks to this thread: https://forum.xda-developers.com/newreply.php?do=newreply&p=43622764
Warning: I hacked my way through this stuff a few weeks ago I am not an expert!
How to compile Android Open Source Code modules​
I don't compile C code on Windows machines I have no idea about that.
Notice
This guide is a quick and dirty how to make a module. It will not cover finalizing setting up the source codes for your device. It is only my goal to enable you to compile binaries such as grep, toolbox, dumpstate, dalvikvm, jack and etc.
===>] Setup Ubuntu 64bit [<===​Unplug that Windows drive, plug in a fresh hard drive and install Ubuntu latest/greatest. Ignore the recommendation to downgrade gnu make!, for now.
Open a terminal and issue these commands (warning ppa repository for OpenJDK 7 is said to have a security issue?, isn't being updated?.. whatevs it works)
Code:
sudo apt-get update
sudo apt-get upgrade
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get install openjdk-7-jdk
sudo apt-get install openjdk-8-jdk
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
sudo apt-get install git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng
(choose Java 1.7 in the following way)
Code:
sudo update-alternatives --config java
(let me know if I missed anything please)
"Tried the Android SDK only it is missing too many things we need as a developer"
===>] Setup Android Studio SDK & NDK [<===​Installation Paths:
*** I install to /home/username/Android and /home/username/Android/Sdk and /home/username/Android/Sdk/ndk-bundle ***
NOTE: from here forward username will == droidvoider
Note: Android Studio IDE isn't necessary only the SDK & NDK are needed to compile AOSP.
Install Android Studio Proper: (don't worry about setting up paths we will cover that, just install it)
https://developer.android.com/studio/install.html
or
SDK Only:
Typically we install these things manually by creating the directory then just unzipping the files there.
https://developer.android.com/studio/index.html#linux-bundle (scroll down for sdk only)
Code:
mkdir /home/droidvoider/Android
mkdir /home/droidvoider/Android/Sdk
(then unzip the sdk zip to that directory. I recommend the file explorer copy/paste right click uncompress and done.)
https://dl.google.com/android/repository/tools_r25.2.3-linux.zip
Install NDK through the SDK Manger:
(from terminal 'studio.sh' and then configure, and then sdk manger --- if this is hard to figure out tell me I will elaborate)
or
Manually Install Native Development Kit -- 'c programming support'
Download the Native Development Kit from Google: https://developer.android.com/ndk/downloads/index.html
Code:
mkdir /home/droidvoider/Android/Sdk/ndk-bundle
Then just unzip the ndk files into the directory we created above.
===>] Setup your toolchain [<===​** This example is arm64-v8a aarch64 **
1. Navigate to /home/droidvoider/Android/Sdk/ndk-bundle/build/tools and then open a terminal "right click open area"
2. mkdir /home/droidvoider/toolchains
3. ./make_standalone_toolchain.py --arch arm64 --api 23 --stl=libc++ --install-dir /home/mm/toolchains/aarch64-linux-android-4.9
4. cd /home/droidvoider
5. gedit .bashrc and morph this in at the bottom.. (AND edit or replace the existing PATH variable)
DON'T just PASTE IN *my* $PATH export!! I included my entire path statements to show you.
Code:
export PATH=$PATH:/usr/local/android-studio/bin:/home/droidvoider/Android/Sdk/platform-tools:/home/droidvoider/Android/Sdk/ndk-bundle:/home/droidvoider/Android/Sdk/tools
I feel this is human readable, for example change Android_Build_Out to be on your desktop instead if you want.
Code:
export PATH=$PATH:/home/droidvoider/toolchains/aarch64-linux-android-4.9
export NDK=/home/droidvoider/Android/Sdk/ndk-bundle
export SYSROOT=$NDK/platforms/android-23/arch-arm64
export TARGET=aarch64-linux-android
export HOST=$TARGET
export BUILD=x86_64-linux
export ANDROID_NDK_BIN=/home/droidvoider/toolchains/aarch64-linux-android-4.9/bin
export CC=$ANDROID_NDK_BIN/aarch64-linux-android-gcc-4.9
export CPP=$ANDROID_NDK_BIN/aarch64-linux-android-g++
export AR=$ANDROID_NDK_BIN/aarch64-linux-android-ar
export OUT_DIR_COMMON_BASE=/home/droidvoider/Android_Build_Out
Note: You might want to setup an alternate toolchain also but this is all of the puzzle pieces.
===>] Google's version of this How To -- Just for reference [<===​https://source.android.com/source/requirements.html
https://source.android.com/source/initializing.html
===>] Install the repo tool [<===​https://source.android.com/source/downloading.html
(don't type repo init or repo sync --- I will be taking back over from there on the next page)
Added Repair Notes -- Not part of the install!
Have you accidentally installed or removed something you shouldn't have? (welcome to development, here try this before reinstall)
sudo apt-get clean
sudo apt-get update
sudo apt-get install -f
sudo dpkg -a --configure
sudo apt-get dist-upgrade
sudo apt-get install -f
sudo dpkg -a --configure
Selecting the correct AOSP branch and downloading it.
Tested up to downloading AOSP and make toolbox -- you should be all set
===>] Match your build number to it's AOSP sources [<===​preface: You can get this from your device if you're on the same build id as your the available source code from your vendor for your device. Otherwise you need to open the AP file from the firmware that matches those available sources to extract the system.img, to extract build.prop. I explain how to open a system.img file below under retrieving your hardware drivers. build.prop is in the main directory of system.img
(Many times the build number is the same. For me I believe all of MM builds are using this number.)
Assumes sources match current device, worked out true in my case
1. Plug in your device and get it connected. (DEVELOPER OPTIONS|USB DEBUGGING) and select allow on device
2. Retrieve the build number that matches the available sources for your device.
From your ubuntu terminal retrieve the build id using this command:
Code:
adb shell getprop | grep 'ro.build.id'
Yields something similar to this: [ro.build.id]: [MMB29K]
3. Match it up to the Nexus build numbers (This info is for AT&T Note 5 Marshmallow MMB29K, get your specific build number!)
https://source.android.com/source/build-numbers.html#source-code-tags-and-builds
MMB29K android-6.0.1_r1 Marshmallow Nexus 5, Nexus 5X, Nexus 6, Nexus 7 (flo/deb), Nexus 9 (volantis/volantisg)
===>] Bring down a specific AOSP source branch [<===​
4. Make a directory for the source code.
Code:
mkdir /home/droidvoider/Desktop/AOSP_Android_6.01_r1
5.
Code:
cd /home/droidvoider/Desktop/AOSP_Android_6.01_r1
6. Bring down the sources, this one is approximately 13 gigabytes
Code:
repo init --depth=1 -u https://android.googlesource.com/platform/manifest -b android-6.0.1_r1
repo sync
===>] I'm not sure the rest of this is needed [<===​For compiling toolbox the remainder wasn't needed.. But I have a large list of things to do so I can't test each item. If you can't compile a specific module continue reading.
===>] Merge Vendor sources & AOSP sources [<===​
7. Download the available sources for your device. In this example I downloaded PE6 Marshmallow sources for AT&T Note 5:
http://opensource.samsung.com/reception/receptionSub.do?method=sub&sub=F&searchValue=SM-N920A
8. Read the readme file from the sources platform zip to understand how to merge them into the AOSP sources. For the 2 Samsungs I've worked with the idea is to replace any directory that already exists. But if there is just one file such as core.mk only replace the one file. Then edit the .mk files as described in your readme. (and/or take info from cyanogen/lineagos) -- <I can help more, ask>
note: you probably don't need to take the configs from LineageOS and put them into your .mk files. However, if you do need to get more configs then you should get a big fat message when you type make 'modulename'. At first only edit .mk files as described by vendor device source readme file.
===>] Merge in Hardware drivers and etc [<===​possibly unnecessary depends what you're doing
9. Obtain a copy of the firmware for your device that matches the version of the source code you are able to download from your vendor.
for me that was Build Number: MMB29K.N920AUCU2BPE6 but your mileage will almost certainly vary!
10. Download https://github.com/anestisb/android-simg2img
11. Unzip it right in your download folder, open the folder and then 'open in terminal'
12. Make it and then move it a directory in your path. Warning: My command puts in in the Ubuntu default /bin folder.
Code:
make
sudo mv append2simg img2simg simg2img simg2simg simg_dump.py /bin
13. Uncompress the AP file from the matching firmware and extract the system.img into it's own directory
then select that folder, right click, open in terminal
Code:
simg2img system.img sys.raw
mkdir sys
sudo mount -t ext4 -o loop sys.raw sys/
14. A drive mounted, look on your task bar it should've wiggled too. Copy the etc and vendor folders into the main folder of the sources we are merging
===>] Listing and building modules [<===​Navigate to the folder where you download the sources "/home/droidvoider/Desktop/AOSP_Android_6.01_r1" and open in terminal.
Code:
make modules -- list the available modules
make <module name> -- builds a specific module
example: make dumpstate
description: Will build everything needed for dumpstate and place it in the folder we specified in our export (above step). The final build line will read install and detail the final output folder
Example successful output:
[CODE]
Install: /home/droidvoider/Android_Build_Out/Android_6.01_r1/target/product/generic/system/bin/dumpstate
===>] Android Build System, basic intro [<===​Notice: I built this how to to answer the same question from 3 people regarding working with toolbox and the dirtycow exploit. So I decided to give a direct example of using toolbox.c from farm-root
#ifdef
Our makefile is Android.mk and that's where we link things together. If you look at the Android.mk file for farm-root you will notice bridge.c is used 3 different times called different 'module' names. bridge_pull, bridge_push, bridge_pull_boot. Each of these will be binaries of those names.
Inside bridge.c you will see #ifdef FARM_PULL and then you will see #else and further you will see #endif which you may have noticed matches inside the Android.mk file for the bridge modules -DFARM_PULL -DFARM_BOOT <== Notice the double define on bridge_pull_boot
toolbox.c
toolbox.c is going to be the same way. You will need to copy shared.h and shared.c into the directory where toolbox.c resides. Then edit the Android.mk, in our example:
1. Navigate to this directory and open: system/core/toolbox/Android.mk
2. CTRL + F and search for "LOCAL_MODULE := toolbox"
3. Add: LOCAL_CFLAGS += -DFARM_PULL -DFARM_BOOT (in this example add one, both or even new ones you created)
4. Navigate to the main directory of the sources, you should see a Makefile and a build_64bit.sh
5. from terminal: make toolbox
Note: I think from here you can Google it out in a few minutes if that is not the case please let me know.
Working with C cross platform​Ubuntu is Linux based just like Android and this makes testing blocks of code extremely easy. You of course can't use Android headers and in some rare cases you can't test the code on Ubuntu at all but in most cases you can. When I want to design something for Android I open gedit and save it as a .c file. Then I compile it using gcc -o mycode mycode.c There's plenty of examples on using gcc with linux but just understand you can do it all. Then before too much work test it on Android. (helpful commands at end of post)
My advice really is to build out your small blocks of code on your linux box but then paste them into your Android program folder, edit your Android.mk, add it to your Makefile including your 'push' section so that you can simply type make push to test it.
I am in fact trying to encourage you to learn C and not so much trying to encourage you to hack things. But I know that interest/passion is what teaches, not my words and not someone else's curriculum. So in that spirit I will do my best to give examples to help you with 'whatever' it is you are passionate about. Let me know what's missing.
Don't forget to compile for Android first
Before you can test your code you will have compiled it using the cross compiler for Android. ndk-build, or the correct gcc cross compiler. (Personally I put the .c file into a directory with Android.mk and a Makefile then just type make to build it to Android)
see examples section I will add a couple examples.
Android Developer Bridge -- a developers tool
adb is included with the Android SDK along with some other tools. Some of those tools are fastboot for unlocking bootloaders and another way of flashing. There is monitor which is a cool tool for remotely viewing processes, logcat, memory dumps and etc.
But pointedly what we will use the most is simply adb.
Using adb to test your code on locked down Android systems
Shell has fairly high privileges, you may not be aware but you can execute binaries and bash scripts. We use /data/local/tmp/ for these things. You can create a directory, add or remove files, execute your binaries and even execute shell scripts using sh script.sh
ndk-build places the binary in libs/(arch type) .. For a quick test you can just open a terminal in that directory then:
Code:
adb push mybinary /data/local/tmp/
adb shell
cd data/local/tmp
chmod 777 mybinary
./mybinary
Added:
Examples of basic make files for Android.
happy coding
If you get an error​Please reissue the command but pipe the output to a file.
make toolbox > /home/droidvoider/Desktop/build_toolbox-output.txt
zip that up with your source code, including your customized header files and attach it to this thread.
puzzles are fun but I like all the pieces
droidvoider said:
Tested up to downloading AOSP and make toolbox -- you should be all set
===>] Match your build number to it's AOSP sources [<===​preface: You can get this from your device if you're on the same build id as your the available source code from your vendor for your device. Otherwise you need to open the AP file from the firmware that matches those available sources to extract the system.img, to extract build.prop. I explain how to open a system.img file below under retrieving your hardware drivers. build.prop is in the main directory of system.img
(Many times the build number is the same. For me I believe all of MM builds are using this number.)
Assumes sources match current device, worked out true in my case
1. Plug in your device and get it connected. (DEVELOPER OPTIONS|USB DEBUGGING) and select allow on device
2. Retrieve the build number that matches the available sources for your device.
From your ubuntu terminal retrieve the build id using this command:
Code:
adb shell getprop | grep 'ro.build.id'
Yields something similar to this: [ro.build.id]: [MMB29K]
3. Match it up to the Nexus build numbers (This info is for AT&T Note 5 Marshmallow MMB29K, get your specific build number!)
https://source.android.com/source/build-numbers.html#source-code-tags-and-builds
MMB29K android-6.0.1_r1 Marshmallow Nexus 5, Nexus 5X, Nexus 6, Nexus 7 (flo/deb), Nexus 9 (volantis/volantisg)
===>] Bring down a specific AOSP source branch [<===​
4. Make a directory for the source code.
Code:
mkdir /home/droidvoider/Desktop/AOSP_Android_6.01_r1
5.
Code:
cd /home/droidvoider/Desktop/AOSP_Android_6.01_r1
6. Bring down the sources, this one is approximately 13 gigabytes
Code:
repo init --depth=1 -u https://android.googlesource.com/platform/manifest -b android-6.0.1_r1
repo sync
===>] I'm not sure the rest of this is needed [<===​For compiling toolbox the remainder wasn't needed.. But I have a large list of things to do so I can't test each item. If you can't compile a specific module continue reading.
===>] Merge Vendor sources & AOSP sources [<===​
7. Download the available sources for your device. In this example I downloaded PE6 Marshmallow sources for AT&T Note 5:
http://opensource.samsung.com/reception/receptionSub.do?method=sub&sub=F&searchValue=SM-N920A
8. Read the readme file from the sources platform zip to understand how to merge them into the AOSP sources. For the 2 Samsungs I've worked with the idea is to replace any directory that already exists. But if there is just one file such as core.mk only replace the one file. Then edit the .mk files as described in your readme. (and/or take info from cyanogen/lineagos) -- <I can help more, ask>
note: you probably don't need to take the configs from LineageOS and put them into your .mk files. However, if you do need to get more configs then you should get a big fat message when you type make 'modulename'. At first only edit .mk files as described by vendor device source readme file.
===>] Merge in Hardware drivers and etc [<===​possibly unnecessary depends what you're doing
9. Obtain a copy of the firmware for your device that matches the version of the source code you are able to download from your vendor.
for me that was Build Number: MMB29K.N920AUCU2BPE6 but your mileage will almost certainly vary!
10. Download https://github.com/anestisb/android-simg2img
11. Unzip it right in your download folder, open the folder and then 'open in terminal'
12. Make it and then move it a directory in your path. Warning: My command puts in in the Ubuntu default /bin folder.
Code:
make
sudo mv append2simg img2simg simg2img simg2simg simg_dump.py /bin
13. Uncompress the AP file from the matching firmware and extract the system.img into it's own directory
then select that folder, right click, open in terminal
Code:
simg2img system.img sys.raw
mkdir sys
sudo mount -t ext4 -o loop sys.raw sys/
14. A drive mounted, look on your task bar it should've wiggled too. Copy the etc and vendor folders into the main folder of the sources we are merging
Click to expand...
Click to collapse
And where is exactly the main folder? Sorry, Im just confused
DigitalDoraemon said:
And where is exactly the main folder? Sorry, Im just confused
Click to expand...
Click to collapse
it's no problem this stuff isn't easy to just figure out on your own. remember to substitute droidvoider for your ubuntu user name
In this example my sources are on my desktop in a folder named Android_6.01_r1
Sources for toolbox for example:
/home/droidvoider/Desktop/Android_6.01_r1/system/core/toolbox/<sources will be here including Android.mk>
Script for modules, including toolbox
/home/droidvoider/Desktop/Android_6.01_r1/Makefile <--- this is our modules script, if you will
<open a terminal in the above folder then use that Makefile like so>
make toolbox <---- this will compile only what is needed to compile the module 'toolbox' (this takes a minute)
Out export folder we decided in ./home/droidvoider/bashrc
/home/droidvoider/Android_Build_Out/Android_6.01_r1/target/product/generic/system/bin
Anybody, please compile grep utility for arm and x86... Minimum Platform Version Android 4.0.3, API Level - 15
Thanks
Great & useful .

Categories

Resources