[tool] ANDROID_IMG_REPACK_TOOLS - Android Software Development

[tool] ANDROID_IMG_REPACK_TOOLS
&
Android_ROM_IMG_Repacker​​
android_img_repack_tools is a kit utilites for unpack/repack android ext4 and boot images in LINUX & WINDOWS
includes binaries:
mkbootfs
simg2simg
make_ext4fs
make_ext4fs_def
mkbootimg
ext2simg
simg2img
img2simg
sgs4ext4fs - Chainfire's tool
unpackbootimg - CyanogenMod tool
mkbootimg_tools - xiaolu
Android_ROM_IMG_Repacker
sources used:
https://android.googlesource.com
https://github.com/CyanogenMod/android_system_core.git
https://github.com/Chainfire/sgs4ext4fs
how to make:
Preparation OS:
Code:
sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev build-essential zip curl libncurses5-dev zlib1g-dev valgrind libreadline6-dev gcc-multilib g++-multilib libc6-dev x11proto-core-dev libx11-dev libz-dev gawk texinfo automake libtool cvs libsdl-dev
Dowload repo:
Code:
git clone https://github.com/ASdev/android_img_repack_tools
Choose branch, for example:
Code:
cd android_img_repack_tools
git checkout android-4.4.4_r2.0.1
Building tools:
Code:
chmod +x configure
./configure
will download source from android git repositories
Code:
make
will compille binaries: mkbootfs simg2simg make_ext4fs mkbootimg sgs4ext4fs unpackbootimg ext2simg img2simg simg2img
Code:
make clean
will remove binaries
Code:
make clear
wiil remove sources
credits:
android.googlesource
Chainfire
CyanogenMod
go to the repository
Already have a branch:
android-2.3.7
android-4.0.4
android-4.1.1
android-4.1.2
android-4.2.2
android-4.3
android-4.4.2
android-4.4.3
android-4.4.4
android-5.0.0
android-5.0.2
android-5.1.0
android-5.1.1
android-6.0.0
android-6.0.1
Usage:
Code:
## Converting sparse flashing system.img from flashing android sparse img to ext4 img
$ simg2img system.img system.raw.img
## or all parts of sparse img
$ simg2img system.img* system.raw.img
## Mounting ext4 img for edit
$ mkdir system_mnt
$ mount -t ext4 -o loop system.raw.img system_mnt
Code:
## Creating new android sparse img for flashing (android 2.3.6-4.2)
$ mkuserimg.sh -s system_mnt system_new.img ext4 ./system [size partition MB for example 1024M]
## or
$ make_ext4fs -s -l 1024M system_new.img system_mnt
more
$ mkuserimg.sh -s system system.img ext4 /system [size partition MB for example 1024M] file_contexts
Code:
## Converting ext4 img to sparse img for flashing (android 4.3-etc)
$ ext2simg -v system.raw.img system_new.img
Code:
## Changing sparse img header size from 28bit to 32bit (for Samsung Exynos Octa)
$ sgs4ext4fs --bloat system_new.img system_32bit.img
Code:
## Remove Moto extra header... (for Motorola G-series, making after unsparse img)
$ mv system.raw.img system.moto.img
$ dd if=system.moto.img of=system.raw.img ibs=131072 skip=1
ANDROID_IMG_REPACK_TOOLS_CYGWIN WINDOWS​
ANDROID_IMG_REPACK_TOOLS_CYGWIN is a kit utilites for unpack/repack android ext4 and boot images in WINDOWS
mkbootfs.exe
simg2simg.exe
make_ext4fs.exe
mkbootimg.exe
ext2simg.exe
img2simg.exe
simg2img.exe
sgs4ext4fs.exe - Chainfire's tool
unpackbootimg.exe - CyanogenMod tool
Already have a branch:
android-4.1.2
android-5.1.0
android-5.1.1
android-6.0.0
android-6.0.1
Already have a .exe:
WINDOWS REPO
XDA:DevDB Information
android_img_repack_tools, Tool/Utility for the Android General
Contributors
A.S._id
Version Information
Status: Testing
Created 2014-01-06
Last Updated 2016-04-17

Odin3 ROM Editor
Reserved

Android ext4fs ROM editor
Android_ROM_IMG_Repacker
It is automatise for android_img_repack_tools for Linux & Windows CYGWIN
Instructions:
credits:
android.googlesource
@Chainfire
@Chenglu
@xpirt
Added v.2.1
* Configure:
Auto choice OS for compilation android_img_repack_tools
* MOUNT ext4 img:
Auto converting sparse to raw img
Auto find magic sparse img and remove vendor extra header
Auto choice OS for mount or extract raw img
* MAKE_EXT4FS - new img ANDROID permission:
Auto extract 'file_contexts' from recovery.img (if exist)
* EXT2SIMG - raw to sparse
Auto choice chunk header (28/32 bytes)
Added v.2.2
* Fixed some bugs

mod edit
Thank you very much. I'm waiting for you.

[tool] ANDROID_IMG_REPACK_TOOLS - CYGWIN EXE
Android_img_repack_tools - cygwin exe

Thanks you. I got it!

added branches:
android-2.3.7_r1
android-4.0.4_r2.1
android-4.2.2_r1.2
android-4.3_r3.1
android-4.4.2_r1

Some headers missed. I am using Ubintu 12.04 and installed zlib1g-dev for compiling zlib_host. But make_ext4fs don't compiling:
Building make_ext4fs...
extras/ext4_utils/make_ext4fs.c: In function 'build_directory_structure':
extras/ext4_utils/make_ext4fs.c:175:27: error: 'struct stat' has no member named 'st_stat'
extras/ext4_utils/make_ext4fs.c:176:26: error: 'struct stat' has no member named 'st_stat'
extras/ext4_utils/make_ext4fs.c:177:26: error: 'struct stat' has no member named 'st_stat'
make: *** [make_ext4fs] Error 1

MATPOC said:
Some headers missed. I am using Ubintu 12.04 and installed zlib1g-dev for compiling zlib_host. But make_ext4fs don't compiling:
Building make_ext4fs...
extras/ext4_utils/make_ext4fs.c: In function 'build_directory_structure':
extras/ext4_utils/make_ext4fs.c:175:27: error: 'struct stat' has no member named 'st_stat'
extras/ext4_utils/make_ext4fs.c:176:26: error: 'struct stat' has no member named 'st_stat'
extras/ext4_utils/make_ext4fs.c:177:26: error: 'struct stat' has no member named 'st_stat'
make: *** [make_ext4fs] Error 1
Click to expand...
Click to collapse
Well you has two ways:
This http://www.zlib.net/
or
Code:
make clean
make clear
./configure
cd ./zlib/src
./configure
make
sudo make install
cd ../..
make clean
make

A.S._id said:
Well you has two ways:
This http://www.zlib.net/
Click to expand...
Click to collapse
As I said I have compiled zlib_host by installing zlib1g-dev. Compile broken at ext4fs - maybe there are no extra headers for ext4fs, such as for struct stat.

MATPOC said:
As I said I have compiled zlib_host by installing zlib1g-dev. Compile broken at ext4fs - maybe there are no extra headers for ext4fs, such as for struct stat.
Click to expand...
Click to collapse
1. zlib1g-dev - не входит в состав zlib
2. у меня установлена Ubuntu 13.10 amd64 gcc 4.8
поэтому - не могу точно ответить по 12.04
gt.
1. zlib1g-dev - not part of zlib
2. I have installed Ubuntu 13.10 amd64 gcc 4.8
so - I can not exactly answer to 12.04
Click to expand...
Click to collapse

MATPOC said:
As I said I have compiled zlib_host by installing zlib1g-dev. Compile broken at ext4fs - maybe there are no extra headers for ext4fs, such as for struct stat.
Click to expand...
Click to collapse
Assembly must be done on 64 bit OS. Only installing zlib-1.2.8
View attachment zlib-1.2.8.tar.gz
And the following packages
Code:
sudo apt-get update
sudo apt-get install ia32-libs
gcc 4.8 can be set separately

hi sir. may i ask you to update op with more explanation of what can do your tool?
i understood that it unpack and repack boot.img and compile binaries...
and after that i am wondering what more? what for?
i use kernel tool master to unpack and repack boot.img...
what is the diffeence and the purpose of you tools?
thank you...
i know i miss of knowledge so that is why i ask.

desalesouche said:
hi sir. may i ask you to update op with more explanation of what can do your tool?
i understood that it unpack and repack boot.img and compile binaries...
and after that i am wondering what more? what for?
i use kernel tool master to unpack and repack boot.img...
what is the diffeence and the purpose of you tools?
thank you...
i know i miss of knowledge so that is why i ask.
Click to expand...
Click to collapse
Old binary do not work with newer versions of android

alexyuh said:
Old binary do not work with newer versions of android
Click to expand...
Click to collapse
does that tool can take binaries from one kernel to port it to another?

desalesouche said:
does that tool can take binaries from one kernel to port it to another?
Click to expand...
Click to collapse
The way is not into repacking boot image, but different version of android has different parametrs of FS. Example android 4.3 ext4 FS has support SELinux, but 4.1 and older hasn't

A.S._id said:
The way is not into repacking boot image, but different version of android has different parametrs of FS. Example android 4.3 ext4 FS has support SELinux, but 4.1 and older hasn't
Click to expand...
Click to collapse
I still don't get the purpose of these tools. I've been running Gentoo Linux as my primary OS for a dozen years, all the tools I need to compile kernels, create boot images, ramdisks, initrds, extract and manipulate from already created images, are already installed on my system by default. Why would I need these too? Are these supposed to be time-savers? Shortcuts? I still don't understand.

Odysseus1962 said:
I still don't get the purpose of these tools. I've been running Gentoo Linux as my primary OS for a dozen years, all the tools I need to compile kernels, create boot images, ramdisks, initrds, extract and manipulate from already created images, are already installed on my system by default. Why would I need these too? Are these supposed to be time-savers? Shortcuts? I still don't understand.
Click to expand...
Click to collapse
Well, how I can see, you're HTC user, and maybe this utilities isn't you needs, because htc don't use sparse images, and different header block size in self rom. But samsung, sony, asus and different brands using it...

why is this error?
Building mkbootimg...
core/mkbootimg/mkbootimg.c: In function 'main':
core/mkbootimg/mkbootimg.c:245:9: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [mkbootimg] Error 1
Click to expand...
Click to collapse

rogerscrack said:
why is this error?
Click to expand...
Click to collapse
cd zlib/src
make clean
./configure
make
sudo make install
and try again...

Related

How to build Carbon rom JB 4.3.1 for i9195 & i9190

How to build Carbon for Serranoltexx{gt-I9195} & serrano3gxx {gt-I9190}
this guide is based on cyanogenmod's how to wiki
i made this easy, you just need do these things and you will download only carbon rom and serranoltexx spesific files so you dont need edit much files. i made it easier for you.
For both 32-bit & 64-bit systems, you'll need:
Code:
bison build-essential curl flex git-core gnupg
gperf 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
Click to expand...
Click to collapse
In addition to the above, for 64-bit systems, get these:
Code:
g++-multilib gcc-multilib lib32ncurses5-dev
lib32readline-gplv2-dev lib32z1-dev
Click to expand...
Click to collapse
Open your Terminal and paste these commands line by line
Code:
mkdir -p ~/bin
mkdir -p ~/carbon
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
export PATH=${PATH}:~/bin
Code:
cd ~/carbon/
Download the Source
this is original carbon source but i edited it because it includes alot devices, kernel and vendor files that we dont need.
Code:
repo init -u https://github.com/proxuser/android.git -b jb3 && repo sync -f
wait it downloads the source. go out and drink a coffee or play with your smartphone, do whatever you want
it downloads carbon spesific serrano3gxx and serranoltexx devices.
after you full downloaded Carbon source, let get include some fm fixes.
Code:
cd ~/carbon/frameworks/av
git fetch http://review.cyanogenmod.org/CyanogenMod/android_frameworks_av refs/changes/24/51424/1 && git cherry-pick FETCH_HEAD
cd ~/carbon/frameworks/base
git fetch http://review.cyanogenmod.org/CyanogenMod/android_frameworks_base refs/changes/52/49752/2 && git cherry-pick FETCH_HEAD
if you sync your repo these patches will be overwritten by carbon rom. you need apply them again like above.
so are we ready to build ? :S maybe ? ok lets try
go to vendor/carbon folder and open vendorsetup.sh
then add these lines bottom or top of file
Code:
add_lunch_combo carbon_serranoltexx-userdebug
add_lunch_combo carbon_serrano3gxx-userdebug
if you want build for i9195 go to terminal
cd ~/carbon/
Code:
source build/envsetup.sh
breakfast serranoltexx
if you want build for i9190 go to terminal
cd ~/carbon/
Code:
source build/envsetup.sh
breakfast serrano3gxx
you will get information with what build number, what device and so on..
now time to start building
Code:
export USE_CCACHE=1
you want build for i9195 then
Code:
brunch serranoltexx
you want build for i9190 then
Code:
brunch serrano3gxx
if you face any errors, ask it here.
reserved for me
Amazing Tutorial
Good to see you are helping people like me learn +1 keep it up
What do you think this would run like under a Win8 environment in a Virtual Machine?
hi proxuser, followed your guide, but at breakfast got an error about nfc_enhanced.mk missing from /carbon/vendor/carbon/config, fixed that by copying that file from cyanogenmod.
Brunch gave me the following error:
Code:
make: *** No rule to make ta
rget `/home/gerbrand/android/output/carbon/target/common/obj/JAVA_LIBRARIES/telephony-msim_intermediates/classes.jar', needed by `/home/gerbrand/android/output/carbon/target/common/obj/APPS/Phone_intermediates/classes-full-debug.jar'. Stop.
make: *** Waiting for unfinished jobs....
logtags: /home/gerbrand/android/output/carbon/target/common/obj/APPS/Phone_intermediates/src/src/com/android/phone/EventLogTags.java <= packages/apps/Phone/src/com/android/phone/EventLogTags.logtags
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
any suggestions how to fix?
tinnef said:
hi proxuser, followed your guide, but at breakfast got an error about nfc_enhanced.mk missing from /carbon/vendor/carbon/config, fixed that by copying that file from cyanogenmod.
Brunch gave me the following error:
Code:
make: *** No rule to make ta
rget `/home/gerbrand/android/output/carbon/target/common/obj/JAVA_LIBRARIES/telephony-msim_intermediates/classes.jar', needed by `/home/gerbrand/android/output/carbon/target/common/obj/APPS/Phone_intermediates/classes-full-debug.jar'. Stop.
make: *** Waiting for unfinished jobs....
logtags: /home/gerbrand/android/output/carbon/target/common/obj/APPS/Phone_intermediates/src/src/com/android/phone/EventLogTags.java <= packages/apps/Phone/src/com/android/phone/EventLogTags.logtags
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
any suggestions how to fix?
Click to expand...
Click to collapse
look here http://forum.xda-developers.com/showpost.php?p=46723395&postcount=1600
go to /carbon/.repo/manifests/
open default.xml
and find
Code:
<project path="frameworks/opt/telephony" name="CyanogenMod/android_frameworks_opt_telephony" remote="cm" revision="cm-10.2" groups="pdk" />
add after
Code:
<project path="frameworks/opt/telephony-msim" name="CyanogenMod/android_frameworks_opt_telephony-msim" remote="cm" revision="cm-10.2" />
you also can try
make carbon -j7
after select serrano*** in lunch menu
i added missing projects in my manifest too.
you can do a repo init and repo sync again.
it will only add new projects to repo and will sync them.
Code:
repo init -u https://github.com/proxuser/android.git -b jb3 && repo sync -f
Will try editing the manifest.
tinnef said:
Will try editing the manifest.
Click to expand...
Click to collapse
look i edited my msg. try it
proxuser said:
look i edited my msg. try it
Click to expand...
Click to collapse
Just to be safe I deleted the whole thing and started from scratch. It build fine, now.
Still got the error about missing /vendor/carbon/config/nfc_enhanced.mk, though
tinnef said:
Just to be safe I deleted the whole thing and started from scratch. It build fine, now.
Still got the error about missing /vendor/carbon/config/nfc_enhanced.mk, though
Click to expand...
Click to collapse
I will look at it. and will report back here
Sent from my GT-I9195 using xda premium
could you also make a tutorial on how to compile the AOSP kernel, you made? And how to make a flashable .zip of it.
junkyde said:
could you also make a tutorial on how to compile the AOSP kernel, you made? And how to make a flashable .zip of it.
Click to expand...
Click to collapse
there are enough guides for kernel build. but all this needs basic knowledge. but i may write next weeks a guide about kerlen build for s4 mini devices.
proxuser said:
there are enough guides for kernel build. but all this needs basic knowledge. but i may write next weeks a guide about kerlen build for s4 mini devices.
Click to expand...
Click to collapse
Cool, thank you very much :good:
Can I use this to build AOKP or AOSPA3+ ? With some changes ?
Envoyé de mon GT-I9195 en utilisant Tapatalk
I tried to follow it, but it won't work (anymore?):
$ source build/envsetup.sh
including device/generic/armv7-a-neon/vendorsetup.sh
including device/generic/mips/vendorsetup.sh
including device/generic/x86/vendorsetup.sh
including device/samsung/serrano3gxx/vendorsetup.sh
including device/samsung/serranoltexx/vendorsetup.sh
including vendor/carbon/vendorsetup.sh
including sdk/bash_completion/adb.bash
[[email protected] carbon]$ breakfast serranoltexx
including vendor/carbon/vendorsetup.sh
build/core/product_config.mk:238: *** _nic.PRODUCTS.[[device/samsung/serranoltexx/carbon.mk]]: "vendor/carbon/config/nfc_enhanced.mk" does not exist. Stop.
** Don't have a product spec for: 'carbon_serranoltexx'
** Do you have the right repo manifest?
Click to expand...
Click to collapse

Kernel compilation fails with "Exec format error"

Hi,
I downloaded the LG G2 kernel source from https://www.lg.com/global/support/opensource/opensourceList?types=ALL&search=D802.
I followed the instructions in the readme:
Code:
2. Kernel Build
- Uncompress using following command at the android directory
tar xvzf LG-D802(G2)_Android_JB_D802_10a_Kernel.tar.gz
- When you compile the kernel source code, you have to add google original prebuilt source(toolchain) into the android directory.
- Run following scripts to build kernel
a) cd kernel
b) export PATH=$PATH:tools/lz4demo
c) make ARCH=arm CROSS_COMPILE=../prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi- g2-open_com-perf_defconfig zImage -j4
* "-j4" : The number, 4, is the number of multiple jobs to be invoked simultaneously.
* lz4demo : More information can be found at "https://code.google.com/p/lz4/"
- After build, you can find the build image(zImage) at arch/arm/boot/
I downloaded the prebuilt toolchain from https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6.
This is the exact error message:
Code:
../prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-gcc -Wp,-MD,scripts/mod/.empty.o.d -nostdinc -isystem ../prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-gcc -print-file-name=include [Errno 8] Exec format error -I/root/kernel/arch/arm/include -Iarch/arm/include/generated -Iinclude -include /root/kernel/include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-msm/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -O2 -fstack-protector -mabi=aapcs-linux -mno-thumb-interwork -funwind-tables -D__LINUX_ARM_ARCH__=7 -march=armv5t -Wa,-march=armv7-a -msoft-float -Uarm -fomit-frame-pointer -g -DKBUILD_STR(s)=#s -DKBUILD_BASENAME=KBUILD_STR(empty) -DKBUILD_MODNAME=KBUILD_STR(empty) -c -o scripts/mod/.tmp_empty.o scripts/mod/empty.c [Errno 8] Exec format error
I am running a fresh installation of ubuntu 12.04 x86.
Any ideas how to fix this?
Guess I can answer that myself: Android can only be build on 64-bit machines.

[Guide] How to build kernel from source on ubuntu 13.10...

Here are the steps to build your own kernel from source. This guide is showing you how to build your first the stock kernel on your own..... It is kick start for making things on your own way....
This guide applies to i9082/i9082L and general devices also.:laugh:
This guide assumes you have basic knowledge of linux and linux system configuration.
Prerequisites
1. Ubuntu 13.10
2. patience...lots and lots of patience.
Click to expand...
Click to collapse
Here starts the fun:-
1. Installing ubuntu 13.10.
This can be done in 3 ways and I am not gonna cover it all.
- along with windows ,i.e dual boot
- in virtualbox within windows
- as a windows application installation with "wubi" installer
For starting user i think second option, i.e installing in virtualbox is best.
here's starting tutorials
http://www.youtube.com/watch?v=tDDRFiwHujg
NOTE - you should have atleast 100 Gb partion for virtualbox.
Click to expand...
Click to collapse
2. Getting the kernel source.
Download source from http://opensource.samsung.com/
Type i9082 in search box and download "GT-I9082_SEA_JB_Opensource_Update1.zip"
After download unzip the source into new folder in home directory.
Type in terminal from you kernel directory.
Code:
unzip GT-I9082_SEA_JB_Opensource_Update1.zip
Then extract tar.
Code:
mkdir kernel
tar xzf kernel.tar.gz -C kernel
Click to expand...
Click to collapse
3. Setting up building environment.
Copied from http://soupdawg.wordpress.com/
All credits goes to
mysteriously inconspicuous
Click to expand...
Click to collapse
Initializing a fresh Android Build Environment in Ubuntu 13.10 sucks, right? The instructions at the AOSP page are outdated and inaccurate. Near as I can tell, they try to have you install 2 JDKs, the first one not even being the correct link for Saucy Salamander, and the second being OpenJDK. Which might work. But I dunno about all that, I’d rather have Oracle’s official stamp when it comes to building for Android.
Currently most of the guides are up to 12.04 LTS, which is fine and dandy, but being on the cutting edge is nice too.
This guide applies to all variations of Ubuntu 13.10 Saucy Salamander 64 bit. 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.
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 unless you’re starting with a fresh Ubuntu base, and even then maybe.
Let’s get rid of that. Copy and paste this into a Terminal window:
Code:
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
Follow the instructions to remove OpenJDK.
If you must keep it, it’s possible. But I’m not going to tell you how to do it here. I don’t want any chance of confusion or mistake.
Now copy and paste the following into the Terminal:
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.10.
No more unrecognized Java version errors! And it will update automatically with the rest of your system.
Next, we actually need to install the package. More copy-paste:
Code:
sudo apt-get update && sudo apt-get install oracle-java6-installer
Follow the on-screen instructions. You have to Accept the Licensing Agreement to complete the install. Hopefully no human centipede clauses.
Let’s make sure the correct version of Java is activated, run the following Terminal command:
Code:
java -version
You should see something like the following:
Code:
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.12-b01, mixed mode)
Ok, back to a fresh Terminal prompt. Time for installing the guts to build stuff in Ubuntu:
Code:
sudo apt-get install git-core gnupg ccache lzop flex bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5 lib32z1 lib32bz2-1.0 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
When that is done installing, run the following command in your Terminal window:
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
That’s it on the package side of things.
You guessed it, time for more Terminal. This really is the easiest way, seriously. And it’s totally worth it when you’re basking in the glory of a bunch of people on XDA.
The binary for a program called “repo” will let you talk to git servers and download all that precious source code. That second part after the && allows it to be executable:
Code:
mkdir ~/bin && curl http://commondatastorage.googleapis.com/git-repo-downloads/repo ~/bin/repo && chmod a+x ~/bin/repo
Use your favorite text editor to open ~/.bashrc
I like nano:
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. Restart bash:
Code:
source ~/.bashrc
That should be everything. Now you’re ready to build Android the right way. Luck!
4. Installing toolchain
Anyway, first order of the day is to get the official arm toolchain, which I'm going to install in /usr/local/share/ since I plan to keep using it for some time:
Code:
# cd /usr/local/share/
# git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6
Cloning into 'arm-eabi-4.6'...
remote: Sending approximately 124.64 MiB ...
remote: Counting objects: 33, done
remote: Finding sources: 100% (33/33)
remote: Total 580 (delta 146), reused 580 (delta 146)
Receiving objects: 100% (580/580), 124.64 MiB | 715 KiB/s, done.
Resolving deltas: 100% (146/146), done.
Now, let's add that arm toolchain to our path:
Code:
# export PATH=$PATH:/usr/local/share/arm-eabi-4.6/bin
# arm-eabi-gcc --version
arm-eabi-gcc (GCC) 4.6.x-google 20120106 (prerelease)
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5. Compiling kernel
Now we need to set the variables that will tell the OS that we're cross compiling (again, something that you may want to do in your .profile using something like alias cross='export ARCH="arm";export SUBARCH="arm";export CROSS_COMPILE="arm-eabi-"'):
Code:
# export ARCH=arm
# export SUBARCH=arm
# export CROSS_COMPILE=arm-eabi-
Finally, we can initialize our default config and get going:
Prepare source for new compilation
Code:
make bcm28155_capri_ss_baffin_rev05_defconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/lex.zconf.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
arch/arm/mach-capri/custom_boards/Kconfig:19:warning: defaults for choice values not supported
arch/arm/mach-capri/custom_boards/Kconfig:25:warning: defaults for choice values not supported
arch/arm/mach-capri/custom_boards/Kconfig:31:warning: defaults for choice values not supported
arch/arm/mach-capri/custom_boards/Kconfig:37:warning: defaults for choice values not supported
#
# configuration written to .config
#
Code:
# make -j*
(...)
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
* stands for number of cpus your computer has.like my has 4 so I will make it j4
* bcm28155_capri_ss_baffin_rev05_defconfig is stock config, for cm11 you will have diffrent config and for some cutom kernel something else.
6. Crafting an Android boot.img
The format of this Android boot images can be found in the bootimg.h of the mkbootimg tool from the android platform/system/core source. I guess we have to start somewhere, and we'll need to produce our own images, so let's start by fetching and recompiling mkbootimg then.
Code:
# git clone https://android.googlesource.com/platform/system/core bootimg-tools
Cloning into 'bootimg-tools'...
remote: Counting objects: 92, done
remote: Finding sources: 100% (92/92)
remote: Total 19302 (delta 11674), reused 19302 (delta 11674)
Receiving objects: 100% (19302/19302), 5.87 MiB | 655 KiB/s, done.
Resolving deltas: 100% (11674/11674), done.
# cd bootimg-tools/libmincrypt/
# gcc -c *.c -I../include
# ar rcs libmincrypt.a *.o
# cd ../mkbootimg
# gcc mkbootimg.c -o mkbootimg -I../include ../libmincrypt/libmincrypt.a
mkbootimg.c: In function 'main':
mkbootimg.c:245:9: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]
# cp mkbootimg /usr/local/bin/
# cd ../cpio
# gcc mkbootfs.c -o mkbootfs -I../include
# cp mkbootfs /usr/local/bin/
New improved bootimg-tools can be found at.
Code:
# wget https://github.com/pbatard/bootimg-tools/archive/master.zip
lets compile from there
Code:
# cd /usr/src/android/bootimg-tools/mkbootimg/
# wget https://raw.github.com/pbatard/bootimg-tools/master/mkbootimg/unmkbootimg.c
# gcc -o unmkbootimg unmkbootimg.c
# cp unmkbootimg /usr/local/bin/
Now at last, you have the minimum of unmkbootimg, mkbootimg and mkbootfs installed in your path, and we can get going with our testing of the kernel.
I'll assume that you have a /usr/src/android/boot where you copied your boot.img, so let's get going....
Code:
# cd /usr/src/android/boot/
# ls
boot.img
# unmkbootimg -i boot.img
kernel written to 'kernel' (4738320 bytes)
ramdisk written to 'ramdisk.cpio.gz' (516287 bytes)
To rebuild this boot image, you can use the command:
mkbootimg --base 0 --pagesize 4096 --kernel_offset 0xa2008000 --ramdisk_offset 0xa3000000 --second_offset 0xa2f00000 --tags_offset 0xa2000100 --cmdline 'console=ttyS0,115200n8 [email protected] androidboot.console=ttyS0 vc-cma-mem=0/[email protected]' --kernel kernel --ramdisk ramdisk.cpio.gz -o boot.img
Code:
# ls
boot.img kernel ramdisk.cpio.gz
As an aside that you don't need to run, but since it should be elementary that this is the basic functionality you want from a proper boot image unpack tool, we can confirm that the data provided by the unpack tool will produce a boot.img that is binary identical to the original one-
Code:
# mkbootimg --base 0 --pagesize 4096 --kernel_offset 0xa2008000 --ramdisk_offset 0xa3000000 --second_offset 0xa2f00000 --tags_offset 0xa2000100 --cmdline 'console=ttyS0,115200n8 [email protected] androidboot.console=ttyS0 vc-cma-mem=0/[email protected]' --kernel kernel --ramdisk ramdisk.cpio.gz -o myboot.img
Code:
# ls
boot.img kernel myboot.img ramdisk.cpio.gz
# cmp -l boot.img myboot.img
#
Moving on. Since we just want to test a kernel, we shouldn't really have to touch the cpio image (ramdisk), but then again, my goal here is to give you as many pointers as I can, so we might as well see how we craft our own ramdisk while we're at it. What we're going to do here, as an academical exercise, is add an it_works file at the root of the filesystem, which we'll look for after we booted, to confirm that can use our modified stuff all the way through.
Code:
# mkdir ramdisk
# cd ramdisk
# gunzip -c ../ramdisk.cpio.gz | cpio -iu
1841 blocks
# ls
charger init.superuser.rc
data init.trace.rc
default.prop init.usb.rc
dev lpm.rc
file_contexts proc
fstab.capri_ss_baffin property_contexts
fstab.goldfish res
init sbin
init.bcm281x5.usb.rc seapp_contexts
init.capri_ss_baffin.rc sepolicy
init.cm.rc sys
init.environ.rc system
init.goldfish.rc ueventd.capri_ss_baffin.rc
init.log.rc ueventd.goldfish.rc
init.rc ueventd.rc
init.recovery.capri_ss_baffin.rc
# touch it-works
# ls
charger init.superuser.rc
data init.trace.rc
default.prop init.usb.rc
dev it-works
file_contexts lpm.rc
fstab.capri_ss_baffin proc
fstab.goldfish property_contexts
init res
init.bcm281x5.usb.rc sbin
init.capri_ss_baffin.rc seapp_contexts
init.cm.rc sepolicy
init.environ.rc sys
init.goldfish.rc system
init.log.rc ueventd.capri_ss_baffin.rc
init.rc ueventd.goldfish.rc
init.recovery.capri_ss_baffin.rc ueventd.rc
# find . | cpio -o -H newc | gzip > ../myramdisk.cpio.gz
1850 blocks
# cd ..
# ls
boot.img kernel myramdisk.cpio.gz ramdisk/ ramdisk.cpio.gz
We're finally set for the last part, where we copy the kernel we compiled earlier, and invoke mkbootimg with the set of parameters we got from unmkbootimg, and use both our modified kernel and cpio image:
Code:
# cp ~/kernel/arch/arm/boot/zImage .
# ls
boot.img kernel myramdisk.cpio.gz ramdisk/ ramdisk.cpio.gz zImage*
# mkbootimg --base 0 --pagesize 4096 --kernel_offset 0xa2008000 --ramdisk_offset 0xa3000000 --second_offset 0xa2f00000 --tags_offset 0xa2000100 --cmdline 'console=ttyS0,115200n8 [email protected] androidboot.console=ttyS0 vc-cma-mem=0/[email protected]' --kernel zImage --ramdisk myramdisk.cpio.gz -o myboot.img
# ls
boot.img kernel myboot.img myramdisk.cpio.gz ramdisk/ ramdisk.cpio.gz zImage*
7. testing new boot.img
Finally, a custom boot.img we can test. Let's press on by copying this myboot.img file into the directory we have adb and fastboot installed and run the following ser of commands which, unlike what many other guides seem to advise (what the heck, guys?), is NOT going to flash the kernel/boot.img but simply run it from memory. This means that, in case there's any mishap, you can simply power the "grand" off and you'll be good as new:
Code:
# ./adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
# ./adb reboot bootloader
# ./fastboot boot myboot.img
downloading 'boot.img'...
OKAY [ 0.223s]
booting...
OKAY [ 0.023s]
finished. total time: 0.246s
All in all, this looks fairly good. And a quick look to the root filesystem (through adb shell or through ssh) will also confirm that our it_works file is there, so we can also add whatever we want on the initial filesystem. Neat!
From there on, you can go ahead and tweak your kernel and initial filesystem exactly as you see fit. And after you have tested that everything works as it should, you can go ahead and flash the boot partition with your shiny custom boot.img, using:
ODIN or cwm flashable zip
This is last part...
8. making flashable files
Tar your boot.img file so it can be flashed with Odin.
tar cvf mynewkernel.tar boot.img
md5sum -t mynewkernel.tar >> mynewkernel.tar
mv mynewkernel.tar mynewkernel.tar.md5
Click to expand...
Click to collapse
Note:- myboot.img is renamed to boot.img
9.Flashing kernel through ODIN
Flash mynewkernel.tar.md5 with odin under PDA. Please follow the flashing guides found in other posts.
Hope i help few of you...
Please HIT thanks if you find this helpful.:laugh:
Thankyou k2wl for this tutorial and pls also tell how to get pawitp source code for rom and kernel from his repositries : https://github.com/pawitp/android_device_samsung_i9082
https://github.com/pawitp/android_kernel_samsung_i9082
Repo tool is not working because there is no android manifest file in his repository
Pls help me
mr.phantom said:
Thankyou k2wl for this tutorial and pls also tell how to get pawitp source code for rom and kernel from his repositries : https://github.com/pawitp/android_device_samsung_i9082
https://github.com/pawitp/android_kernel_samsung_i9082
Repo tool is not working because there is no android manifest file in his repository
Pls help me
Click to expand...
Click to collapse
run the following in terminal
$git clone https://github.com/pawitp/android_device_samsung_i9082.git
and
$ git clone https://github.com/pawitp/android_kernel_samsung_i9082.git
k2wl said:
run the following in terminal
$git clone https://github.com/pawitp/android_device_samsung_i9082.git
and
$ git clone https://github.com/pawitp/android_kernel_samsung_i9082.git
Click to expand...
Click to collapse
well i already have done that cloning for cm11 but it had only downloaded files around 200KB and i dont think so that cm11 source code would be that much small
hi
mr.phantom said:
well i already have done that cloning for cm11 but it had only downloaded files around 200KB and i dont think so that cm11 source code would be that much small
Click to expand...
Click to collapse
That's not cm11 source. For that u need another tutorial.
Meanwhile try wiki.CyanogenMod.org
It has instructions for Building for new device
Code:
unmkbootimg.c:25:21: fatal error: bootimg.h: No such file or directory
#include "bootimg.h"
^
compilation terminated.
Getting this while compiling unmkbootimg
i actually am surprises that there are many unofficial CMs in high ends with HALO IN IT.. though our developers try to make rom as close to real one as possible...what if the users want halo integration (as developers only know it :/)
help..
akiratoriyama said:
Code:
unmkbootimg.c:25:21: fatal error: bootimg.h: No such file or directory
#include "bootimg.h"
^
compilation terminated.
Getting this while compiling unmkbootimg
Click to expand...
Click to collapse
try compiling as a root.
k2wl said:
try compiling as a root.
Click to expand...
Click to collapse
How to convert zImage to boot.img
Or do I have to directly copy it ?
Sent from my GT-I9082 using Tapatalk
raghavsharmaxda said:
i actually am surprises that there are many unofficial CMs in high ends with HALO IN IT.. though our developers try to make rom as close to real one as possible...what if the users want halo integration (as developers only know it :/)
help..
Click to expand...
Click to collapse
k2wl said:
try compiling as a root.
Click to expand...
Click to collapse
akiratoriyama said:
How to convert zImage to boot.img
Or do I have to directly copy it ?
Sent from my GT-I9082 using Tapatalk
Click to expand...
Click to collapse
read the last section of post, it covers the conversion of zimage to boot.img...
seems you compiled successfully.
congrats.:victory:
But what about boot.img ?
We need a boot.img in /android/boot ?
Now at last, you have the minimum of unmkbootimg, mkbootimg and mkbootfs installed in your path, and we can get going with our testing of the kernel.
I'll assume that you have a /usr/src/android/boot where you copied your boot.img, so let's get going....
Click to expand...
Click to collapse
Hi @k2wl.For the part "make -j8",if you don't mind putting a sign for others to only compile at the amount of their CPU have otherwise it will caused some error for others who are compiling
1 CPU= make -j1 with least error
Sent from my iPad using Tapatalk
Really nice guide especially about packing the initramfs with the zimage to make boot.img.
Sent from my GT-I9082 using Tapatalk
akiratoriyama said:
But what about boot.img ?
We need a boot.img in /android/boot ?
Click to expand...
Click to collapse
take one from my stock kernel zip....
Techix18 said:
Hi @k2wl.For the part "make -j8",if you don't mind putting a sign for others to only compile at the amount of their CPU have otherwise it will caused some error for others who are compiling
1 CPU= make -j1 with least error
Sent from my iPad using Tapatalk
Click to expand...
Click to collapse
thanks for suggestion.
skullface said:
Really nice guide especially about packing the initramfs with the zimage to make boot.img.
Sent from my GT-I9082 using Tapatalk
Click to expand...
Click to collapse
thanks....will modify more..
k2wl said:
That's not cm11 source. For that u need another tutorial.
Meanwhile try wiki.CyanogenMod.org
It has instructions for Building for new device
Click to expand...
Click to collapse
ok will check it out and will you make a guide for that also??
mr.phantom said:
ok will check it out and will you make a guide for that also??
Click to expand...
Click to collapse
if people wanted it, will make cm11 compilation from source tutorial for it.
Thanks to ya k2wl
{
"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"
}
Sent from my GT-I9082 using Tapatalk
happy developing.....glad i helped you...
keep trying for learning new features...
k2wl said:
if people wanted it, will make cm11 compilation from source tutorial for it.
Click to expand...
Click to collapse
Pls k2wl make a new tutorial which include cm11 compilation for grand from source and its kernel also
Hey @k2wl
Just wanted to say thank you for this comprehensive guide. Very detailed.
I never had any interest in tweaking a kernel. I am more of a java guy. But after reading your guide, I thought, why not?!
So I started working on it. Now I have a fully functional kernel compiled separately from the ROMs that I compile.
I even named it. Nebula Kernel.
Learning alot about kernels since I started working on it. As I am tweaking nebula for myself and i'll use this kernel as my daily driver so i'll add tweaks and governors according to me, the ones which I'll use. I like keeping things light and simple! I'll use your github for reference and help. If I face any problems, I'll ask you.
Thank you for the guide!

[ Guide ] [ Tutorial ] Compiling 64 bit Android Kernel [ Yureka ] [ NOOB Friendly ]

This is My first post on XDA
From the day I owned YUreka I always wished to compile my own kernel. I searched on the web for compiling 64bit android kernel but didn't get satisfying results. So I did some research and asked some android developers, I got help from some developers but some of the developer refused may be due to their attitude or may be they didn't want to share their ideas / knowledge. Anyways here's a guide for compiling 64 bit kernel. I have also made a video tutorial check that out [ status == uploaded ].
What will YU need :
1. Ubuntu 64 Bit OS
2. Good Internet Connection.
3. Usable Brain.
4. Basic Knowledge of Linux.
Lets Start
First we need to get some important stuff / tools / software .
1. Open Ubuntu Software center and install JDK 7 or JDK 8
2. Open terminal and run the following command
Code:
sudo apt-get install libncurses5-dev
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Code:
sudo apt-get install -y ccache &&echo 'export PATH="/usr/lib/ccache:$PATH"' | tee -a ~/.bashrc &&source ~/.bashrc && echo $PATH
Code:
export USE_CCACHE=1
Code:
mkdir ~/bin
Code:
export PATH=~/bin:$PATH
Code:
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
Code:
chmod a+x ~/bin/repo
Now YU'r Linux machine is all set to compile kernel.
3. Now YU need to download a toolchain. I have uploaded the toolchain that i used for compiling the kernel. Click from here > h t t p s ://drive.google.com/open?id=0B9D4jOdpRzZHOURMTS1VaXplc0U
4. Time to download Kernel sources. For this tutorial I am using Varun Chitre's Thunderzap kernel. Here is the link for thunderzap's sources > h t t p s ://github.com/varunchitre15/thunderzap_tomato
.Select branch as cm 12.1 from left and press download on the right.
5. Make a directory "android-kernel" under "/Home" and place both the zips in "android-kernel" directory.
6. Extract both the zips. Now YU will have two folders one of toolchain and other of kernel source.
7. YU no more need the zip files just delete both the zips.
8. Open the kernel source folder and type the following code.
9. Run the following command to point the variable to toolchains path :
Code:
export CROSS_COMPILE=/home/r0h4n/android-kernel/aarch64-linux-android-4.9-uber-master/bin/aarch64-linux-android-
If YU followed along with me YU will just have to change the name of the user ( replace <r0h4n> with <YU'r username> )
10. Time to Compile your kernel :
Code:
export ARCH=arm64
Code:
export SUBARCH=arm64
Code:
export USE_CCACHE=1
Code:
make cyanogenmod_tomato-64_defconfig
The name of defconfig file may be different check it in "kernel_source/arch/arm64/defconfig/"
Code:
make menuconfig
Here YU can explore various options. I'll not explain everything in detail here.
Now the final command make. It takes a parameter -jn. Where ( n = # of threads per core + 1 )
I have a Dual core processor with 2 thread per processor so for me it is " make -j3 ".
Code:
make -j3
Now sit back and relax.......let the kernel compile
Got a compilation error ?
Post it here.
Now we need to create a flashable zip. Download this kernel flash zip from here > h t t p s : //drive.google.com/open?id=0B9D4jOdpRzZHdTJibndqQzhVdFk
1. Extract kernel.zip.
2. Navigate to tools in "/kernel".
3. Open "kernel_source/arch/arm64/boot/".
4. Copy "Image".
5. Replace it with the "Image" in "/kernel/tools/Image".
6. Copy "kernel_source/driver/stagging/prima/wlan.ko" and replace it with "kernel/system/lib/modules/wlan.ko".
7. Goto "/kernel" select all the three folders "META-INF", "system", "tools" and rezip it.
8. Flash the zip via recovery and now YU'r Phone rocks YU'r own compile kernel.
Rohan459 said:
This is My first post on XDA
Click to expand...
Click to collapse
Life saver for the 64bit part, thank you very much! :good::good::good:
some issues
Hello, i'm trying to compile this kernel (for xiaomi redmi note 3 "kenzo") https://github.com/cyanogenmod/android_kernel_xiaomi_msm8956/tree/stable/cm-13.0-ZNH5Y, and get the flashable zip.
I made a few tries and i can't do it, i going to tell you my problems and how i could fix some of them.
Error 1:
when i try to compile i get this error:
scripts/Makefile.build:455: recipe for target 'drivers/video/msm' failed
make[2]: *** [drivers/video/msm] Error 2
scripts/Makefile.build:455: recipe for target 'drivers/video' failed
make[1]: *** [drivers/video] Error 2
make[1]: *** Waiting for unfinished jobs....
I solved it changing a line in /home/user/Desktop/android_kernel_xiaomi_msm8956-stable-cm-13.0-ZNH5Y/drivers/video/msm/msm_dba/msm_dba.c
I changed #include <msm_dba_internal.h> for rhis #include "msm_dba_internal.h"
After that i get another error.
Error 2:
After solve Error 1, when i try to compile i get this error:
make[1]: *** No rule to make target 'arch/arm64/boot/dts/msm8956-mtp.dtb', needed by 'arch/arm64/boot/Image.gz-dtb'. Stop.
make[1]: *** Waiting for unfinished jobs....
OBJCOPY arch/arm64/boot/Image
/home/guille/Desktop/android_kernel_xiaomi_msm8956-stable-cm-13.0-ZNH5Y/arch/arm64/Makefile:84: recipe for target 'Image.gz-dtb' failed
make: *** [Image.gz-dtb] Error 2
make: *** Waiting for unfinished jobs....
This error i solved disabling this line #CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE=y in cyanogenmod_kenzo_defconfig, but i don't know if this is the correct way.
After that changes i get finally the image (used in the tutorial) and image.gz, then i proced to put the image and wlan.ko in in kernel.zip, but when i flash it the phone don't boot.
What can i do?
P.S.: Sorry my bad english.
Hello the friend really super guide and especially the only one or with whom I managed to compile my own kernel.
Is especially as said in the OP I contact a lot of kernel dev and nobody answered so I will have only one person to thank lol.
omega691 said:
Hello, i'm trying to compile this kernel (for xiaomi redmi note 3 "kenzo") https://github.com/cyanogenmod/android_kernel_xiaomi_msm8956/tree/stable/cm-13.0-ZNH5Y, and get the flashable zip.
I made a few tries and i can't do it, i going to tell you my problems and how i could fix some of them.
Error 1:
when i try to compile i get this error:
scripts/Makefile.build:455: recipe for target 'drivers/video/msm' failed
make[2]: *** [drivers/video/msm] Error 2
scripts/Makefile.build:455: recipe for target 'drivers/video' failed
make[1]: *** [drivers/video] Error 2
make[1]: *** Waiting for unfinished jobs....
I solved it changing a line in /home/user/Desktop/android_kernel_xiaomi_msm8956-stable-cm-13.0-ZNH5Y/drivers/video/msm/msm_dba/msm_dba.c
I changed #include <msm_dba_internal.h> for rhis #include "msm_dba_internal.h"
After that i get another error.
Error 2:
After solve Error 1, when i try to compile i get this error:
make[1]: *** No rule to make target 'arch/arm64/boot/dts/msm8956-mtp.dtb', needed by 'arch/arm64/boot/Image.gz-dtb'. Stop.
make[1]: *** Waiting for unfinished jobs....
OBJCOPY arch/arm64/boot/Image
/home/guille/Desktop/android_kernel_xiaomi_msm8956-stable-cm-13.0-ZNH5Y/arch/arm64/Makefile:84: recipe for target 'Image.gz-dtb' failed
make: *** [Image.gz-dtb] Error 2
make: *** Waiting for unfinished jobs....
This error i solved disabling this line #CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE=y in cyanogenmod_kenzo_defconfig, but i don't know if this is the correct way.
After that changes i get finally the image (used in the tutorial) and image.gz, then i proced to put the image and wlan.ko in in kernel.zip, but when i flash it the phone don't boot.
What can i do?
P.S.: Sorry my bad english.
Click to expand...
Click to collapse
Change directory and try again
Sent from my Redmi 3S using Tapatalk
i have this error:
sound/soc/msm/msm8996.c:34:26: fatal error: device_event.h: No such file or directory
#include <device_event.h>
^
compilation terminated.
i'm on ubuntu 16.04.02 x64
i think the problem is the library "libevent-dev" but i don't understand how to fix it because libevent-dev is installed
problem in yureka
i rooted my phone long back.. but i didnt used it...lots of problems in it it is in boot loop amd when ever it is luckily on wifi is not working ...it is not even displaying near by wifi and not even data connection ,i thought of new cm12 rom and flashed it stiill same issue. and more over after flashing stock cm12 and it is still in boot loop..please help
Hello there,
i am having this said problem when i follow your tutorial on how to build a 64bit kernel.
Code:
In file included from include/linux/compiler.h:54:0,
from include/uapi/linux/stddef.h:1,
from include/linux/stddef.h:4,
from /home/protox/android/berlin_kernel/include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/linux/mod_devicetable.h:11,
from scripts/mod/devicetable-offsets.c:2:
include/linux/compiler-gcc.h:106:30: fatal error: linux/compiler-gcc7.h: No such file or directory
#include gcc_header(__GNUC__)
^
compilation terminated.
/home/protox/android/berlin_kernel/scripts/mod/Makefile:34: recipe for target 'scripts/mod/devicetable-offsets.s' failed
make[2]: *** [scripts/mod/devicetable-offsets.s] Error 1
scripts/Makefile.build:468: recipe for target 'scripts/mod' failed
make[1]: *** [scripts/mod] Error 2
make[1]: *** Waiting for unfinished jobs....
HOSTCC scripts/dtc/livetree.o
HOSTCC scripts/dtc/srcpos.o
HOSTCC scripts/dtc/treesource.o
HOSTCC scripts/dtc/util.o
HOSTCC scripts/dtc/dtc-lexer.lex.o
HOSTCC scripts/dtc/dtc-parser.tab.o
HOSTLD scripts/dtc/dtc
Makefile:559: recipe for target 'scripts' failed
make: *** [scripts] Error 2
make: *** Waiting for unfinished jobs....
Can you please help me out mate
Thanks
hello sir can you help me please??
my device is redmi note 4x ( mido ) snapdragon 625 64 bit i build kernel without error but when i want to flash it on my device
device not boot to system but to fastboot mod and need to flash other kernel to make it boot ?? any idea about that ?
Compiling kernrl
I need some help if any body is out there .after months of trying and trying i am finally able to compli my kernel .after is completes with no error i go to arch/arm64/boot and all i have is am image.gz and and image no ziamge or nothing ive goigle it but i cant figure out whats the next step
akino553 said:
hello sir can you help me please??
my device is redmi note 4x ( mido ) snapdragon 625 64 bit i build kernel without error but when i want to flash it on my device
device not boot to system but to fastboot mod and need to flash other kernel to make it boot ?? any idea about that ?
Click to expand...
Click to collapse
The kernel has not compiled properly...
fowler82 said:
I need some help if any body is out there .after months of trying and trying i am finally able to compli my kernel .after is completes with no error i go to arch/arm64/boot and all i have is am image.gz and and image no ziamge or nothing ive goigle it but i cant figure out whats the next step
Click to expand...
Click to collapse
Find a zip with the image.gz and image file and replace the files with ur compiled files.
Rohan459 said:
Find a zip with the image.gz and image file and replace the files with ur compiled files.
Click to expand...
Click to collapse
Once I build the kernel and I build the modules how do i find them to load them does anybody no
Toolchains
fowler82 said:
Once I build the kernel and I build the modules how do i find them to load them does anybody no
Click to expand...
Click to collapse
go in kernel root directory and within search box look for .ko files. It will give you a list of modules from where you can copy them and paste in your new ROM system/lib/modules directory.
can any device use the kernel.zip to flash the boot.img after replacing wlan.ko ?
Rohan459 said:
This is My first post on XDA
From the day I owned YUreka I always wished to compile my own kernel. I searched on the web for compiling 64bit android kernel but didn't get satisfying results. So I did some research and asked some android developers, I got help from some developers but some of the developer refused may be due to their attitude or may be they didn't want to share their ideas / knowledge. Anyways here's a guide for compiling 64 bit kernel. I have also made a video tutorial check that out [ status == uploaded ].
What will YU need :
1. Ubuntu 64 Bit OS
2. Good Internet Connection.
3. Usable Brain.
4. Basic Knowledge of Linux.
Lets Start
First we need to get some important stuff / tools / software .
1. Open Ubuntu Software center and install JDK 7 or JDK 8
2. Open terminal and run the following command
Code:
sudo apt-get install libncurses5-dev
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Code:
sudo apt-get install -y ccache &&echo 'export PATH="/usr/lib/ccache:$PATH"' | tee -a ~/.bashrc &&source ~/.bashrc && echo $PATH
Code:
export USE_CCACHE=1
Code:
mkdir ~/bin
Code:
export PATH=~/bin:$PATH
Code:
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
Code:
chmod a+x ~/bin/repo
Now YU'r Linux machine is all set to compile kernel.
3. Now YU need to download a toolchain. I have uploaded the toolchain that i used for compiling the kernel. Click from here > h t t p s ://drive.google.com/open?id=0B9D4jOdpRzZHOURMTS1VaXplc0U
4. Time to download Kernel sources. For this tutorial I am using Varun Chitre's Thunderzap kernel. Here is the link for thunderzap's sources > h t t p s ://github.com/varunchitre15/thunderzap_tomato
.Select branch as cm 12.1 from left and press download on the right.
5. Make a directory "android-kernel" under "/Home" and place both the zips in "android-kernel" directory.
6. Extract both the zips. Now YU will have two folders one of toolchain and other of kernel source.
7. YU no more need the zip files just delete both the zips.
8. Open the kernel source folder and type the following code.
9. Run the following command to point the variable to toolchains path :
Code:
export CROSS_COMPILE=/home/r0h4n/android-kernel/aarch64-linux-android-4.9-uber-master/bin/aarch64-linux-android-
If YU followed along with me YU will just have to change the name of the user ( replace <r0h4n> with <YU'r username> )
10. Time to Compile your kernel :
Code:
export ARCH=arm64
Code:
export SUBARCH=arm64
Code:
export USE_CCACHE=1
Code:
make cyanogenmod_tomato-64_defconfig
The name of defconfig file may be different check it in "kernel_source/arch/arm64/defconfig/"
Code:
make menuconfig
Here YU can explore various options. I'll not explain everything in detail here.
Now the final command make. It takes a parameter -jn. Where ( n = # of threads per core + 1 )
I have a Dual core processor with 2 thread per processor so for me it is " make -j3 ".
Code:
make -j3
Now sit back and relax.......let the kernel compile
Got a compilation error ?
Post it here.
Now we need to create a flashable zip. Download this kernel flash zip from here > h t t p s : //drive.google.com/open?id=0B9D4jOdpRzZHdTJibndqQzhVdFk
1. Extract kernel.zip.
2. Navigate to tools in "/kernel".
3. Open "kernel_source/arch/arm64/boot/".
4. Copy "Image".
5. Replace it with the "Image" in "/kernel/tools/Image".
6. Copy "kernel_source/driver/stagging/prima/wlan.ko" and replace it with "kernel/system/lib/modules/wlan.ko".
7. Goto "/kernel" select all the three folders "META-INF", "system", "tools" and rezip it.
8. Flash the zip via recovery and now YU'r Phone rocks YU'r own compile kernel.
Click to expand...
Click to collapse
created kernel using tutorial,,,but this kernel boots in fastboot mode only..
dont know why..
device is lenovo k6 note(sd430 msm8937)
please help
i am facing this error and can not resolve the problem.
property '#gpio-cells' in node /soc/msm_cdc_pinctrl_us_euro_sw or bad phandle (referred from /soc/sound:qcom,cdc-us-eu-gpios[0])
arch/arm64/boot/dts/qcom/msm8953-pmi8937.dtb: Warning (gpios_property): Missing property '#gpio-cells' in node /soc/cdc_comp_pinctrl or bad phandle (referred from /soc/sound:qcom,cdc-comp-gpios[0])
arch/arm64/boot/dts/qcom/msm8953-pmi8937.dtb: Warning (gpios_property): Missing property '#gpio-cells' in node /soc/msm_cdc_pinctrl_pri or bad phandle (referred from /soc/sound:qcom,pri-mi2s-gpios[0])
arch/arm64/boot/dts/qcom/msm8953-pmi8937.dtb: Warning (gpios_property): Missing property '#gpio-cells' in node /soc/msm_cdc_pinctrl_quin or bad phandle (referred from /soc/sound:qcom,quin-mi2s-gpios[0])
arch/arm64/boot/dts/qcom/msm8953-pmi8937.dtb: Warning (gpios_property): Missing property '#gpio-cells' in node /soc/msm_cdc_pinctrl_us_euro_sw or bad phandle (referred from /soc/sound-9335:qcom,cdc-us-eu-gpios[0])
arch/arm64/boot/dts/qcom/msm8953-pmi8937.dtb: Warning (gpios_property): Missing property '#gpio-cells' in node /soc/msm_cdc_pinctrl_quin or bad phandle (referred from /soc/sound-9335:qcom,quin-mi2s-gpios[0])
arch/arm64/boot/dts/qcom/msm8953-pmi8937.dtb: Warning (interrupts_property): interrupts size is (12), expected multiple of 8 in /soc/[email protected]
CC lib/mpi/generic_mpih-lshift.o
DTC arch/arm64/boot/dts/qcom/msm8953-ext-codec-rcm-overlay.dtbo
Error: ../arch/arm64/boot/dts/qcom/msm8953-audio-cdp.dtsi:14.1-11 syntax error
FATAL ERROR: Unable to parse input tree
scripts/Makefile.dtbo:24: recipe for target 'arch/arm64/boot/dts/qcom/msm8953-ext-codec-rcm-overlay.dtbo' failed
make[3]: *** [arch/arm64/boot/dts/qcom/msm8953-ext-codec-rcm-overlay.dtbo] Error 1
../scripts/Makefile.build:653: recipe for target 'arch/arm64/boot/dts/qcom' failed
make[2]: *** [arch/arm64/boot/dts/qcom] Error 2
arch/arm64/Makefile:194: recipe for target 'dtbs' failed
make[1]: *** [dtbs] Error 2
make[1]: *** Waiting for unfinished jobs..

Building Android for some devices (Huawei Y6 - msm8909 - in this Guide)

Today i share my knowledge to setup and build lineageos-7 for the Huawei Y6.
First of all we need to install some things.
Run these commands with root or sudo.
Code:
apt-get install -y bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop maven openjdk-8-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev g++-multilib gcc-multilib lib32ncurses5-dev lib32readline6-dev lib32z1-dev ccache rsync tig sudo imagemagick android-tools-adb android-tools-fastboot bc bsdmainutils file screen bash-completion wget nano
This one works well for Ubuntu 16.04 64 bit.
After that create a user with that you like to build android and log in with that user.
You need to run the following command after login:
HTML:
mkdir ~/bin && cd ~/bin && curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > repo && chmod a+x repo && cd
After that you should configure git. For me it is:
HTML:
git config --global user.name "username" && git config --global user.email "[email protected]"
Now you can start to fetch the sources.:
HTML:
mkdir lineageos-7.1 && cd lineageos-7.1 && repo init -u git://github.com/LineageOS/android.git -b cm-14.1 && repo sync
That will set up up a fresh source for lineageos-7.1 at all. Everything from now is device specific.
First we should create the basic folders for our device. I always fetch the sources for the huawei cherry to get the deps.:
HTML:
cd ~/lineageos-7.1 && . build/envsetup.sh
That will set up the lineageos build env.
Next command:
HTML:
breakfast cherry
That will fetch some sources for qcom devices.
Now we need to get the files to build lineageos-7.1 for our huawei y6.
HTML:
cd ~/lineageos-7.1/kernel/huawei && git clone https://github.com/giorgio130/android_kernel_huawei_msm8916.git msm8908 -b cm-14.1 && cd ~/lineageos-7.1/devices/huawei && git clone https://github.com/giorgio130/android_device_huawei_scale.git scale -b cm-14.1 && git clone https://github.com/giorgio130/android_device_huawei_msm8909-common.git msm8909-common -b cm-14.1 && git clone https://github.com/giorgio130/proprietary_vendor_huawei.git ~/lineageos-7.1/vendor/huawei -b cm-14.1
That was a simple Do that after that command quene. Nothing special for linux users.
If you got everything at the right place, please edit:
lineageos-14.1/device/huawei/msm8909-common/BoardConfigCommon.mk
and change:
HTML:
TARGET_KERNEL_SOURCE := kernel/huawei/msm8916
to:
HTML:
TARGET_KERNEL_SOURCE := kernel/huawei/msm8909
Now we should be ready to go. Go back to the base folder and run:
HTML:
. build/envsetup.sh && export WITH_SU=true && brunch lineage_scale-userdebug
With that commands everybody should be able to build and run LineageOs for the Huawei Y6 and other devices. It is the same with only other devices.
Step 1.
HTML:
. build/envsetup.sh
will source up the LineageOS.
Step 2.
HTML:
export WITH_SU=true
will enable full root access inside the finished build.
Step 3.
HTML:
brunch lineage_scale-userdebug
will build a flashable zip file for the Huawei Y6 aka Huawei Scale.
HTML:
make clean && make clobber
will clean up your whole environment before or after you compiled Android. You need to run step 1, 2, and 3 again after you run this or changed something.
Edit 1: Moved text to code.
Edit 2: Added some stuff.
Edit 3: Cleanup
@Runner85sx thank a lot, was looking for such tutorial.
On the lineage for y6 scl l01 the rotation is reverse. Can please guide me how to solve it.
Ps am not a dev but want to learn, for can manage to do minor changes
Thanks a lot! Hope to see new developers get into this device. Thanks
haidar.com said:
@Runner85sx thank a lot, was looking for such tutorial.
On the lineage for y6 scl l01 the rotation is reverse. Can please guide me how to solve it.
Ps am not a dev but want to learn, for can manage to do minor changes
Click to expand...
Click to collapse
I'm not sure why you have this problem. My device is working still well. I built new flashable zips and tested them. Everything okay till now here with an debranded Vodafone Huawei Y6 SCL-L01.
So you may you/me have a problem with DTS/DTB.
Can I use this to build AOSP for Y6?
Runner85sx said:
I'm not sure why you have this problem. My device is working still well. I built new flashable zips and tested them. Everything okay till now here with an debranded Vodafone Huawei Y6 SCL-L01.
So you may you/me have a problem with DTS/DTB.
Click to expand...
Click to collapse
How did you debrand your y6?
emre.yv said:
Can I use this to build AOSP for Y6?
Click to expand...
Click to collapse
Yes. You only need to modify some files inside device/huawei/msm8909-common and device/huawei/scale
Is it posible to make cm 11 for y6?
Ruven03 said:
Is it posible to make cm 11 for y6?
Click to expand...
Click to collapse
I'm not an advanced developer but, if Runner85sx bring android 7 to our device, You'll be able to change some files and create older version (cm 11), but the only problem is, unfortunately there's a chance that drivers would have some problems or/and simply not work.
Just a stupid question... Can you tell me what files I need to edit to make it work on AOSP? I want to compile the source without compiling the kernel and using the stock one
thanks
How?
Whether other devices can use this to build a custom kernel and use this kernel source
@Runner85sx thank you... I feel so empowered.... now trying to figure out how to deal with the camera. Any idea where I must start, cause I am beginning to miss my selfies
vajohnify said:
@Runner85sx thank you... I feel so empowered.... now trying to figure out how to deal with the camera. Any idea where I must start, cause I am beginning to miss my selfies
Click to expand...
Click to collapse
You are welcome.
I think the right place to start is the source code of the camera driver.
hi dear @Runner85sx thanks for your guide and work on this device... :fingers-crossed:
I have try this guide on desktop without problems...
but on my pi3 with berryboot last version and ubuntu mate 16.04 after the command
Code:
sudo apt-get install -y bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop maven openjdk-8-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev g++-multilib gcc-multilib lib32ncurses5-dev lib32readline6-dev lib32z1-dev ccache rsync tig sudo imagemagick android-tools-adb android-tools-fastboot bc bsdmainutils file screen bash-completion wget nano
i have this problem after Reading package lists... Done
Building dependency tree
Reading state information... Done
Code:
E: Unable to locate package lib32ncurses5-dev
E: Unable to locate package lib32readline6-dev
E: Unable to locate package lib32z1-dev
I have read you use pi 3 to built android I can know your set up or a solution to my error? Thanks :laugh:
Is there like a program or something that I can use to learn how to code? Cause I'm interested in learning but I don't know where to start and all of what you posted did not make any sense to me.
adam_s_459_ said:
Is there like a program or something that I can use to learn how to code? Cause I'm interested in learning but I don't know where to start and all of what you posted did not make any sense to me.
Click to expand...
Click to collapse
Same
Hello XDA Community! I'm building my first custom ROM and I have a question: Is it required to flash the ROM on the device or I can do something familiar to 'fastboot boot' style?
EDIT: And one more question: I'm making cm10 rom and will it work when I port our tree to this rom (kernel version etc)
EDIT 2: I have a problem while porting because cm10 didn't find cherry when typing breakfast cherry. Any Ideas?
Won't compile
Thank you Runner85sx so much for this comprehensive quick start guide. This is just what this community is missing.
I have changed in the following text all the backslashes to slashes in order for the forum to let me post. It thinks the paths are links and blocks my post as a new user. Ridiculous.
I run up to some issues executing the commands.
Firstly the 7th command I think should be:
HTML:
cd ~\lineageos-7.1\device\huawei
instead of:
HTML:
cd ~\lineageos-7.1\devices\huawei
Secondly the file that needs editing:
HTML:
~\lineageos-14.1\device\huawei\msm8909-common\BoardConfigCommon.mk
should be:
HTML:
~\lineageos-7.1\device\huawei\msm8909-common\BoardConfigCommon.mk
And lastly the last command
HTML:
brunch lineage_scale-userdebug
failed with the following output:
HTML:
including vendor\cm\vendorsetup.sh
build\core\product_config.mk:254: *** _nic.PRODUCTS.[[device\huawei\scale\lineage.mk]]: "device\cyanogen\msm8909-common\msm8909.mk" does not exist. Stop.
Device scale not found. Attempting to retrieve device repository from LineageOS Github (http:\\github.com\LineageOS).
Repository for scale not found in the LineageOS Github repository list. If this is in error, you may need to manually add it to your local_manifests\roomservice.xml.
build\core\product_config.mk:254: *** _nic.PRODUCTS.[[device\huawei\scale\lineage.mk]]: "device\cyanogen\msm8909-common\msm8909.mk" does not exist. Stop.
build\core\product_config.mk:254: *** _nic.PRODUCTS.[[device\huawei\scale\lineage.mk]]: "device\cyanogen\msm8909-common\msm8909.mk" does not exist. Stop.
** Don't have a product spec for: 'lineage_scale'
** Do you have the right repo manifest?
complaining that the directory "cyanogen" does not contain a directory called "msm8909-common", so I copied it from "~\lineageos-7.1\device\huawei\msm8909-common" (probably a stupid thing to do, but it was a quick try).
Then I had some compiling activity but unfortunately ended with the following output:
HTML:
Checking build tools versions...
build\core\base_rules.mk:183: *** device\huawei\msm8909-common\camera\QCamera2\HAL: MODULE.TARGET.SHARED_LIBRARIES.camera.msm8909 already defined by device\cyanogen\msm8909-common\camera\QCamera2\HAL.
build\core\ninja.mk:166: recipe for target '\home\hlucid\lineageos-7.1\out\build-lineage_scale.ninja' failed
make: *** [\home\hlucid\lineageos-7.1\out\build-lineage_scale.ninja] Error 1
make: Leaving directory '\home\hlucid\lineageos-7.1'
#### make failed to build some targets (43 seconds) ####
Does anybody have a clue of what is wrong? Any help is appreciated. Thanks.

Categories

Resources