[GUIDE]A Noob Guide On Building Your Own Custom Kernel on WIN10 (ARM & ARM64 & MTK) - Android Software Development

[GUIDE]A Noob Guide On Building Your Own Custom Kernel on WIN10 (ARM & ARM64 & MTK)
1. INTRODUCTION:​
This is a guide to build your own custom kernel. Although I'm still a "noob" at this,
I've struggled a lot to build one as all the guides which I followed were not very clear.
So I hope this will be clear enough and as noob friendly as possible!​
You will learn how to:
- Build a kernel for arm and mediatek devices on windows 10
- Add feature
- Basic use of git
Prerequise :
- Updated windows 10 64bits (falls creators update)
- A decent computer with a decent internet speed
- Space on your HDD The minimum space for a kernel source (and its compiled code) is about 2 GB
- Minimal linux knowledge (Terminal, Commands etc)
- Your Brain
- And finally patience
2.Setting UP ENVIRONMENT:​
Installing ubuntu :
1 - Go in Settings -> Update and Security -> For developers and turn on developers mode then
2 - go in Control Panel > Programs > Turn Windows Features On Or Off and enable Windows subsystem for linux
3 - Reboot your computer
4 - launch linux subsystem now and let it download all it need and set up your password (remember it ! you'll need this password later)
5 - Go in microsoft app store and download Ubunutu by canonical group limited
6 - Open ubuntu (a windows with your name and computer name wil appear), congrats you installed ubuntu on windows 10 !
Seting up you environment :
1 - Type "apt-get update" (will update all repo for apps and dependencies)
From here it is nearly the same as my previous guide, but be careful there is some little changes
2 - Type "sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2" (will install all dependencies to build kernel)
3 - Check if dependencies are correctly installed :
- Then type "gcc"
If "gcc" is already installed, you should see "gcc : fatal error : no input file"
- Then type "make"
If "make" is already installed, you should see "make: *** no target specified and no makefile found. stop."
- Then type "git"
If "git" is already installed, you should see bunch of basic git commands
Now you're almost ready to start building your kernel!
Toolchains:
There are several types of toolchains (GCC, Linaro and few custom made ones)
Warning : Not every single device kernel will boot (or even compiles) with older or newer GCC
- For ARM:
We'll be using GCC 4.7 in this tutorial (link : https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7/ )
-Open terminal and type: "mkdir kernel"(Type the name you want, I used "kernel")
-Then type "cd kernel" (the name which you used above)
-Then type "git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7"
-Wait till it finishes.
- For ARM 64:
For ARM 64 you need a 64 bit kernel compiler (there's "aarch64" in the name for telling that's a 64 bit compiler)
Exemple : https://releases.linaro.org/archive/13.07/components/toolchain/binaries/gcc-linaro-aarch64-linux-gnu-4.8-2013.07-1_linux.tar.xz
3.DOWNLOADING SOURCE FILES FOR YOUR DEVICE:​
Now you have to find a github that contains your kernel source.
Search on Google or XDA to find a kernel github repo for your device.
A kernel github looks like this: "https://github.com/atxoxx/android_kernel_samsung_msm8974/tree/xenomTW"
On the upper left side you can see branch: completed by a name
These are the different versions of the kernel/project (generally can be for testing, android version etc)
QUICK EXPLANATION OF FILES/FOLDERS:
- /arch/arm/configs : contains the config files for device (where you add option like new governors, features etc)
- /output/arch/arm/boot/ : Where zimage is stored (will explain that later)
- build.sh : Script to make the building much easier (will explain how it works later)
- /arm-cortex-linux-gnueabi-linaro_5.2-2015.11-2 : I put the toolchain in my kernel source making it easier to find (your kernel's toolchain name may be different)
If you don't have your kernel source yet, you need to download it.
Open terminal and make sure that you are in "kernel" folder (the one you previously created)
Then type in terminal : "git clone "URL of the github kernel" -b "name of the branch" "
For Example : "git clone https://github.com/atxoxx/android_kernel_samsung_msm8974 -b xenomTW"
Good! Now you have your kernel source!
4.BUILDING:​
For an easier way you can go to the location using your file explorer to : "/home/"name of your session"/kernel"
You'll see two folders (The Toolchain and The Kernel Source)
Go into your kernel source folder.
- For ARM:
Copy paste this:
#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=
mkdir output
make -C $(pwd) O=output "name of defconfig and variant if needed"
make -j4 -C $(pwd) O=output
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export ARCH=arm: Defining which kernel architecture type it is (For example arm64 etc)
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- mkdir output: Create a directory for storing compiled zimage
- make -C $(pwd) O=output : Defining defconfig for guiding kernel compilation (will explain later)
- make -j4 -C $(pwd) O=output: where the building start, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
- cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage: This one is for moving image into the second path (thanks @Has.007 for this infromation)
Click to expand...
Click to collapse
Example :
#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=$(pwd)/arm-cortex-linux-gnueabi-linaro_5.2-2015.11-2/bin/arm-cortex-linux-gnueabi-
mkdir output
make -C $(pwd) O=output msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_ks01_skt_defconfig SELINUX_DEFCONFIG=selinux_defconfig
make -j4 -C $(pwd) O=output
cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage
Click to expand...
Click to collapse
- For ARM 64:
Copy paste this:
#!/bin/bash
export ARCH=arm64
export CROSS_COMPILE="path to your toolchain" (it have to end by something like "nameofarch-something-")
mkdir output
make -C $(pwd) O=output "name of defconfig and variant if needed"
make -j4 -C $(pwd) O=output
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export ARCH=arm64: Defining which kernel architecture type it is (For example arm64 etc)
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- mkdir output: Create a directory for storing compiled zimage
- make -C $(pwd) O=output : Defining defconfig for guiding kernel compilation (will explain later)
- make -j4 -C $(pwd) O=output: where the building start, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
- cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage: This one is for moving image into the second path (thanks @Has.007 for this infromation)
Click to expand...
Click to collapse
Example :
#!/bin/bash
export ARCH=arm64
export CROSS_COMPILE=$(pwd)gcc-linaro-aarch64-linux-gnu-4.8-2013.07-1_linux\bin\aarch64-linux-gnu-
mkdir output
make -C $(pwd) O=output msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_ks01_skt_defconfig SELINUX_DEFCONFIG=selinux_defconfig
make -j4 -C $(pwd) O=output
cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage
Click to expand...
Click to collapse
- For Mediatek:
Copy paste this:
#!/bin/bash
export CROSS_COMPILE="path to your toolchain" (it have to end by something like "nameofarch-something-")
export ARCH=arm ARCH_MTK_PLATFORM=
make "name of defconfig and variant if needed"
make -j4
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- export ARCH=arm ARCH_MTK_PLATFORM=: Defining which kernel architecture type it is (For example arm64 etc) "ARCH_MTK_PLATFORM=" is for specifying which mediatek platform it is
- make _defconfig : Defining which defconfig to use (will explain later)
- make -j4: where the building starts, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
Click to expand...
Click to collapse
Example :
#!/bin/bash
export CROSS_COMPILE=$(pwd)/arm-eabi-4.8/bin/arm-eabi-
export ARCH=arm ARCH_MTK_PLATFORM=mt6580
make pixi4_4_8g1g_defconfig
make -j4
Click to expand...
Click to collapse
When these step are done make sure you are in kernel folder in terminal and type "sudo bash build.sh" then type your password you set up in first launch of linux subsytem
(sudo is important, windows 10 ubuntu seems to handle permission differently than native ubuntu)
The compilation have started
If it compiles without any problems:
Wait till it finishes (it'll say something like "zimage is ready")
If you followed arm and arm64:
Then go to "/Output/arch/arm/boot/" to find your zimage.
Click to expand...
Click to collapse
If you followed mediatek:
Then go to "/arch/arm/boot/" to find your zimage.
Click to expand...
Click to collapse
Caution : Not all kernel build Zimage, it can build image or other compressed image
If in case you have any errors:
Check and see what it says, generally it'll tell you where the error is.
If the text is going too fast reduce the -j number as explained above.
For reference I compile with an AMD Phenom X4 3.4GHz,Samsung HDD and 8GB of RAM and it takes around 10min to build
It is recommanded to type in the terminal "make clean" and "make mrproper" before compiling again​
5.MAKING THE KERNEL BOOT:​
You have 2 solutions here:
1) You can use @osm0sis anykernel method, which is explainded here: "https://forum.xda-developers.com/showthread.php?t=2670512" (A huge shoutout to him!)
OR
2) You can unpack the boot.img (from the same rom (CM, touchwizz,sense etc) and android version) and swap Zimage in it explained here : "https://forum.xda-developers.com/showthread.php?t=2073775" (thanks again to @osm0sis !)
Before flashing the kernel which you've made, backup your "stock" boot.img and Then flash your kernel and see if it boots!
6.HOW TO ADD FEATURE TO KERNEL WORK:​
Here starts the most interesting part! Now let's see how it works:
Basically you can add: Governors, IO Schedulers, Overclock the CPU & Many Tweaks...
Checkout the github section (Section 7) to see how to add them properly.
Here's an exemple for adding a governor (this one is called Intellimm) : https://github.com/gugu0das/android...mmit/7186ee60c171b06ea3a027e8383be392d3186bb1
The text in the blue box is the commit description (generally tells you about the changelog, general information and who originally made the commit)
The other text boxes tell you about where and which files have been modified/changed.
Everything in green indicates what has been added.
Everything in red indicates what has been deleted.
We can see in the first 2 text boxes that in "arch/arm/configs/" "msm8974_sec_defconfig" and "cm_msm8974_sec_defconfig" have been modified.
Between the lines 140 and 141 of this files this text has been added : "CONFIG_CPU_FREQ_GOV_INTELLIMM=y"
(This line is for enabling Intellimm when you're compiling your kernel)
Same technique applies to the other text boxes (what has been added and deleted and it's location)
Depending on the features you add, more or less files can be modified, added or deleted.
So to sum it up, a Commit let's you see all the changes which have been made and everything else!
7.GUIDE TO GITHUB:​
For this, I'll direct you over to this awsome guide made by @eagleeyetom !
8.GPL (IMPORTANT !!!):​
The Rules as they apply on XDA
As XDA has no legal power to uphold the GPL (and frankly we want to stay as far away from doing so as possible), we can’t force any of our users to abide by the GPL. However it is in XDA’s interests as well as the interests of our developer-base to ensure all GPL-derived materials hosted or linked on XDA comply fully with the GPL.
GPL-derived materials that do not come with the complete sources used to compile the GPL components are considered warez, and will be treated as such under forum rule 6 and 9.
If you use GPL components, but do not make any modifications to them whatsoever, you should provide a link to the original source of your GPL code.
Sources accompanying a release should be complete, and contain all the necessary source code for any modules, scripts or definition files. Complete sources will be defined as those which compile correctly and completely against the platform for which the software is distributed, and which contain any and all modifications made to the released General Public Licenced code. The source code supplied should be the exact version for which the source code is being requested, complete with all modifications.
EXAMPLE: Here’s a bit of code that could be used as a template to post your releases
<Kernel Or Author Name> <Kernel Nr>:
<Source>|<ReadMe>|<Credits>|<Other>
The Very Quick Summary of General Public License (GPL)
The text of the GPL Licence itself will be used to reach any final conclusion regarding any disputes over GPL Licenced materials. The above is a summary of what XDA expects of members using GPL code, and the complete text can be read at the GNU website.
The GPL states that anyone who modifies GPL licenced code is required to make available the sources used to compile it. This is to further improve and encourage collaborative work, as well as to ensure that the best code possible is produced, and to encourage peer-review of all work. This benefits both developers and end users in numerous ways, including:
Allowing anyone to verify the code they are trusting with their data, and its authenticity
Encouraging community collaboration to produce faster fixes and updates, and better code
Helping bring new developments from other devices and fields to your own, letting you benefit from new code that wouldn’t have been available without this sharing.
The GPL imparts great freedom for GPL end users. It ensures innovation is never stifled and no project is dependent upon any single developer.
It is in everyone’s interest for the GPL to be adhered to, as it gives us all better ROMs, better transparency, and a better atmosphere for developers to work together to make great code.
Click to expand...
Click to collapse
THANKS :​
- @ravish_919 : For testing and correcting this guide
- @karkasss : As my friend and support
- @gugu0das : For helping me a lot when I tried to build my kernel
- @eagleeyetom : For his awsome github guide
- @osm0sis For his aswsome anykernel solution
- @kirito9 : Huge thanks to him for providing mediatek guide !
- @F4uzan : Huge thanks to him for giving me a lot of useful information to fill this guide !
- @sunilpaulmathew : For providing an advanced method to rename your kernel ! (again)
- @nathanchance : For a proper kernel naming method
- @RendyAK and @DroidThug : For correcting me about "#!/bin/bash"
- @ahmed.ismael : For helping me, giving feedback and his huge support !
- Microsoft and canonical for the windows linux subsystem documentation
- All the developers for their hard work !
- XDA and The Community!

TIPS AND TRICKS​
1. You can use a copy of a defconfig file with different setup :
Usage : Use a "stock" one and use another one with esperimental feature for testing without altering original defconfig
Exemple : copy "stock" defconfig and in copied one add a governor see if it compile and work
How to do : Create a second build.sh with modified defconfig name !
2. Change kernel name and version :
Simple method :​Edit this line "CONFIG_LOCALVERSION="-" after - in your defconfig
Exemple : CONFIG_LOCALVERSION="-XenomTW-3.2.6"
Advanced methods :​
Method 1 :
1. Go in Makefile in the root folder of your kernel source
2. Add
CONFIG_LOCALVERSION="nameofyourkernel"
LOCALVERSION="versionofyourkernel"
Click to expand...
Click to collapse
Exemple :
VERSION = 4
PATCHLEVEL = 4
SUBLEVEL = 127
EXTRAVERSION =
CONFIG_LOCALVERSION="-FlashKernel"
export LOCALVERSION="-v1.00"
Click to expand...
Click to collapse
Caution ! Never touch or edit VERSION, PATCHLEVEL, SUBLEVEL, and EXTRAVERSION !
Click to expand...
Click to collapse
Method 2 :
1. Go in "scripts/mkcompile_h"
2. Add
LINUX_COMPILE_BY="nameofyourchoice"
LINUX_COMPILE_HOST="nameofyourchoice"
Exemple
Click to expand...
Click to collapse
3. Solve problem with PATH :
If you encounter "IS YOUR PATH CORRECT" problem try in terminal :
"export PATH="pathtotoolchainlocation"/bin:$PATH"
Exemple : export PATH=/home/3lambda/kernel/M8_Kernel/arm-eabi-4.7/bin:$PATH
4. Access ubuntu folders :
Path location to ubuntu folder is : C:\Users"NAME"\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home
Caution ! Editing files here directly from windows may break permission, you'll have to fix them if so (look on google on how to)
More to come...

Edit and update are coming, I may have forgot things let me know
Feed back also appreciated

highly appreciated
thank you

Good guide although I would say the advanced method for changing the kernel name is making totally unnecessary edits to the source code. There is already a framework in place for configuring the version string however you want. Editing EXTRAVERSION could result in conflicts during stable merges. The version gets generated in the following order:
Code:
$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(CONFIG_LOCALVERSION)$(LOCALVERSION)
VERSION, PATCHLEVEL, SUBLEVEL, and EXTRAVERSION are set in the main Makefile, the first three should never be touched. CONFIG_LOCALVERSION and LOCALVERSION should be what the user sets.
For example:
Code:
VERSION = 4
PATCHLEVEL = 4
SUBLEVEL = 127
EXTRAVERSION =
CONFIG_LOCALVERSION="-FlashKernel"
export LOCALVERSION="-v1.00"
would result in the following output:
Code:
4.4.127-FlashKernel-v1.00

nathanchance said:
Good guide although I would say the advanced method for changing the kernel name is making totally unnecessary edits to the source code. There is already a framework in place for configuring the version string however you want. Editing EXTRAVERSION could result in conflicts during stable merges. The version gets generated in the following order:
VERSION, PATCHLEVEL, SUBLEVEL, and EXTRAVERSION are set in the main Makefile, the first three should never be touched. CONFIG_LOCALVERSION and LOCALVERSION should be what the user sets.
For example:
would result in the following output:
Click to expand...
Click to collapse
Thanks for pointing this out
I'll take a look when I'll have time

Nice! Been looking for something like this. XDA feed brought me here.

is it necessary do in win10? or you can simply do it in linux pc without WIN10?
thanks for the post!

tobarreh said:
is it necessary do in win10? or you can simply do it in linux pc without WIN10?
thanks for the post!
Click to expand...
Click to collapse
it should be done on linux
but windows can handle linux as a subsystem now so the guide for people like me who is dumb enough to use windows
seriously skip the ubuntu installation steps on sindows and start building your kernel by following the other steps :good:
Sent from my OnePlus 5 using XDA Labs

nathanchance said:
Good guide although I would say the advanced method for changing the kernel name is making totally unnecessary edits to the source code. There is already a framework in place for configuring the version string however you want. Editing EXTRAVERSION could result in conflicts during stable merges. The version gets generated in the following order:
Code:
$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(CONFIG_LOCALVERSION)$(LOCALVERSION)
VERSION, PATCHLEVEL, SUBLEVEL, and EXTRAVERSION are set in the main Makefile, the first three should never be touched. CONFIG_LOCALVERSION and LOCALVERSION should be what the user sets.
For example:
Code:
VERSION = 4
PATCHLEVEL = 4
SUBLEVEL = 127
EXTRAVERSION =
CONFIG_LOCALVERSION="-FlashKernel"
export LOCALVERSION="-v1.00"
would result in the following output:
Code:
4.4.127-FlashKernel-v1.00
Click to expand...
Click to collapse
I personally like to define "LINUX_COMPILE_BY" and "LINUX_COMPILE_HOST" in "scripts/mkcompile_h" just like in this commit by @franciscofranco. By adding this
Code:
LINUX_COMPILE_BY="francisco"
LINUX_COMPILE_HOST="franco"
would display "[email protected]"
3lambda said:
Thanks for pointing this out
I'll take a look when I'll have time
Click to expand...
Click to collapse

Added new kernel naming method by @nathanchance and @sunilpaulmathew, huge thanks to them !
I'll need feedback see if some of these steps aren't clear or if I forgot things
I may also add a video soon and maybe screenshots
Stay tuned

sunilpaulmathew said:
I personally like to define "LINUX_COMPILE_BY" and "LINUX_COMPILE_HOST" in "scripts/mkcompile_h" just like in this commit by @franciscofranco. By adding this
Code:
LINUX_COMPILE_BY="francisco"
LINUX_COMPILE_HOST="franco"
would display "[email protected]"
Click to expand...
Click to collapse
He stopped doing that after I pointed out the same thing can be achieved without any source code edits (since it would change it for everyone building your source)
Code:
export KBUILD_BUILD_USER=francisco
export KBUILD_BUILD_HOST=franco
From: https://github.com/torvalds/linux/blob/master/scripts/mkcompile_h

If I downloaded a zip file of my source code, how do I extract it, since this is no longer just cloning from Git?

https://github.com/gugu0das/android...mmit/7186ee60c171b06ea3a027e8383be392d3186bb1
link is dead . please update this part of the guide as it is the most important part for me . Thanks for this awesome guide. more updates to come

I'm really looking forward to any and all updates on this thread. I'm old and loosing my mind and all my "Re-Memories" too, so I need all the help I can get.... LOL

permission denied
* placed the toolchain in home folder *
when i initiate compilation it says permission denied
how do i fix?

kwshl said:
* placed the toolchain in home folder *
when i initiate compilation it says permission denied
how do i fix?
Click to expand...
Click to collapse
execute with 'sudo' make

otonieru said:
execute with 'sudo' make
Click to expand...
Click to collapse
that doesn't help, i did

kwshl said:
* placed the toolchain in home folder *
when i initiate compilation it says permission denied
how do i fix?
Click to expand...
Click to collapse
did you place it by doing a git clone or do a cp command ?

this will lessen the nuisance i hope
otonieru said:
did you place it by doing a git clone or do a cp command ?
Click to expand...
Click to collapse
[email protected]:/mnt/g/linux/oreo# bash k.sh
make: execvp: /home/kwshl/aarch64-linux-android-4.9/bin/aarch64-linux-android-gcc: Permission denied
HOSTCC scripts/basic/fixdep
HOSTCC scripts/basic/bin2c

Related

[GUIDE][ICS] Compile Cyanogenmod 9 on Mac OS X Lion

There are a lot of toturials for building CM9 on ubuntu or CM7 on Mac but I couldn't find a decent toturial for building CM9 on Mac (specially Lion). Development in AOSP/CM land is rapid and guides frequently need updating. I had to spend a little time to figure everything out and I decided to share it here.
This tutorial is for building CM9 (ICS) for Galaxy Nexus GSM (maguro) on Mac OS X Lion 10.7.3 using Xcode 4.3 and homebrew . You can easily make the instructions work for most other cm9 devices, but I wouldn't know anything about that.
DISCLAIMER: I'm not responsible if you blow yourself up, blah blah blah
However, I've tried to make this as noob friendly as possible because, well I'm a noob myself
Instrunctions:
UPADTE (MAY 29TH) : The Xcode 4.3 default compiler (llvm-gcc) used to be incompatible with CM9. Thanks to jocelyn and topprospect, the LLVM compatibility patches from mainline AOSP are now merged into CM9. Therefore, you can now use Xcode 4.3 and its command line tools without installing another compiler. However, since GCC is still the only officially supported compiler, incompatibilites with llvm-gcc could still be introduced with future updates. Therefore, if your build fails, it might be worth it to try installing and compiling with GCC 4.2. See the Troubleshooting section for more info.
Now that we have Xcode 4.3 and Xcode command line tools (CLT) installed, let's continue.
Open Terminal and run
Code:
java
if you don't have Java, you will get a prompt asking you to download and install Java. Go ahead and install it.
If you don't have adb and fastboot working, download the android-sdk from google (version r18 as of now) and put it in /usr/local/ and rename the folder to "android-sdk".
Install the homebrew package manager
Code:
/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
To make sure that homebrew and android-sdk executables are in $PATH:
Code:
touch ~/.bash_profile && echo "PATH=/usr/local/bin:/usr/local/sbin:$PATH:/usr/local/android-sdk/tools:/usr/local/android-sdk/platform-tools" >> ~/.bash_profile
Relaunch Terminal for the change to take effect.
At this point you can run
Code:
brew doctor
to detect any problems there might be (Homebrew may instruct you to use the xcode-select utility to select the xcode installation path). Hopefully, your system is raring to brew
Now we have to install a bunch of packages:
Code:
brew install git coreutils findutils gnu-sed gnupg pngcrush repo
We now need to create a couple of symlinks so that the gnu versions of 'sed' and 'find' are used rather than the osx provided versions :
Code:
ln -s /usr/local/bin/gfind /usr/local/bin/find && ln -s /usr/local/bin/gsed /usr/local/bin/sed && ln -s /usr/local/bin/gstat /usr/local/bin/stat
It's time to create a case sensitive image which will hold our working directory:
Code:
hdiutil create -type SPARSE -fs "Case-sensitive Journaled HFS+" -size 40g -volname "android" -attach ~/Desktop/Android
Now we have a disk image in ~/Desktop/Android. Mount it if it's not mounted already. (Don't be picky about the size, the image will only take as much as space as its contents).
Now we need to create a working directory inside the mounted volume:
Code:
cd /Volumes/android && mkdir cm9 && cd cm9
We can initialize and download the source now:
Code:
repo init -u git://github.com/CyanogenMod/android.git -b ics && repo sync && say 'finished'
Now we need to get the required proprietry files for our device. We can get these from the device itself. Connect your phone (make sure USB Debugging is enabled) and run the following (for maguro):
Code:
cd /Volumes/android/cm9/device/samsung/maguro/ && ./extract-files.sh
[If you see errors in the output from extract-files.sh, see the Troubleshooting section below]
For Google devices,we can also get them directly from google. For maguro, download the 3 files and extract them to /Volumes/android/cm9. Then,
Code:
cd /Volumes/android/cm9
/Volumes/android/cm9/extract-broadcom-maguro.sh
/Volumes/android/cm9/extract-imgtec-maguro.sh
/Volumes/android/cm9/extract-samsung-maguro.sh
We also need the prebuilts (like ROM manager and Term.apk):
Code:
/Volumes/android/cm9/vendor/cm/get-prebuilts
You can optionally tell the build to use the ccache tool. CCache acts as a compiler cache that can be used to speed-up rebuilds :
Code:
export USE_CCACHE=1 && /Volumes/android/cm9/prebuilt/darwin-x86/ccache/ccache -M 20G
Default is 1GB. Anything between 20GB-50GB should be fine.
Before starting the build, we need to workaround an issue with Lion and compiling the QEMU emulator.
[This step doesn't seem to be needed anymore. QEMU is automatically ignored on OS X/Darwin]
If you build now, you're probably gonna get kernel build errors regarding the missing elf.h header (this error might be device specific). Fortunately, we already have this file downloaded, so we only need to copy it to /usr/local/include:
Code:
cp /Volumes/android/cm9/external/elfutils/libelf/elf.h /usr/local/include
FINALLY, we are ready to build:
Code:
cd /Volumes/android/cm9 && source build/envsetup.sh && brunch
Pick your device from the list and enter the number. For maguro, you could use "brunch maguro" instead and skip the menu. Depending on your system, this will take 30min-4hours.
You should now see a beautiful zip file waiting to be flashed:
{
"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"
}
​Troubleshooting:
The extract script for maguro seems to be a little outdated, as it doesn't pull the gps proprietary blob. You can either use the google provided scripts, or add koush's git repository for your device to your local_manifest.xml.
As explained above, the CM9 source is currently compatible with llvm-gcc. In the future, if llvm-gcc fails to build correctly, you should try installing and compiling using GCC4.2 (the Xcode 3 compiler). You can install apple-gcc4.2 from homebrew:
Code:
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb
This version of gcc can happily coexist with Xcode 4.x .
So now you have GCC 4.2 installed, but it won't be used unless we update the corresposing environment variables:
Code:
export CC=/usr/local/bin/gcc-4.2 && export CXX=/usr/local/bin/g++-4.2
Notice that using the export command is temporary. If you relaunch Terminal, you will need to set these again. However, this is a good thing, because changing these values permanently (by putting them in ~/.bash_profile) can interfere with other builds.
If you use this method, the build might fail while compiling "external/zlib/x86/adler32.c". It appears that a recent change in zlib has introduced an incompatibility with gcc 4.2. you have to revert the following 2 commits:
Code:
cd external/zlib
git revert dd6786cae3f4493faa6661d5f74db587932f15d7
git revert 13bf40af68236c961542bdee1d4b7c0176bf15a0
Alternatively, you can add topprospect's zlib on github (which has those commits reverted) to your local_manifast.xml. Simply run:
Code:
nano /Volumes/android/cm9/.repo/local_manifest.xml
and add the following line
Code:
<project name="dferg/android_external_zlib" path="external/zlib" remote="github" />
If you get a build error, and your error is not covered here, copy the last 20-30 lines of the build output AND the output from the following command into pastebin and post the link. Hopefully me or someone else will help you.
Code:
echo -e "\nENV:\n$(env)\n\nWHICH GCC\n:$(which gcc)\n\nWHICH G++:\n$(which g++)\n\nWHICH CC:\n$(which cc)\n\nWHICH C++:\n$(which c++)\n\nBREW DOCTOR:\n$(brew doctor)\n\nBREW LIST:\n$(brew list)\n\n/USR/BIN:\n$(ls -l /usr/bin | grep gcc)\n\n/USR/LOCAL/BIN:\n$(ls -l /usr/local/bin | grep gcc)\n\n"
​Notes/Extras:
To quickly setup your environment, add an alias like the following to ~/.bash_profile:
Code:
alias cm9env="hdiutil attach PATH-TO-DISK-IMAGE -mountpoint /Volumes/android && cd /Volumes/android/cm9 && source ./build/envsetup.sh && export USE_CCACHE=1"
alias cm9build="cm9env && make clobber && reposync && brunch maguro"
Now you can save time by using "cm9env" to get your environment setup or "cm9build" to compile a clean updated build.
To clear your output directory for a new build, run "make clobber". You probably don't need this if you've only changed a few lines of code.
To cherry pick yet-to-be-merged changes from the gerrit instance:
1. Pick an open commit from CM Gerrit
2. Under list of Patch Sets pick the latest and open cherry-pick tab
3. Check what Git repository the url is pointing e.g. http://review.cyanog...frameworks_base
4. In your CM9 working tree go to the corresponding directory, which in this case is something like ~/your-working-directory/frameworks/base/
5. Now simply paste the whole line seen in CM Gerrit cherry-pick tab e.g. "git fetch http://review.cyanog....rameworks_base refs/changes/00/13100/4 && git cherry-pick FETCH_HEAD"
It should be now included in your next compiled build. When doing repo sync again, cherry picks will be lost.[CREDIT Fihlvein from xda]
Click to expand...
Click to collapse
Enjoy your custom built CM9!
I updated OP with some updated info about Xcode 4.3.
Nice work man. Very helpful.
conantroutman said:
Nice work man. Very helpful.
Click to expand...
Click to collapse
thanks! I'll try to keep this topic updated as issues with mac are introduced/resolved.
Nice write up. Thanks.
Before I start again from scratch I have a question. Does this guide apply to previous versions of mac os x (mine is 10.6.8)? I used the official android initializing build environment page & cm7 wiki page for the instructions to setup my build environment.
Also, any tips to switch from macports to homebrew?
In the past I've had to cherry pick to get my OS X build environment set up for CM9. The compile from source fails because I started with macports instead of homebrew (bad idea). I tried to switch to homebrew without success. Any tips to switch from macports to homebrew?
For the sake of keeping this page on topic a pm response is ok if that is what you prefer.
Hi thanks for this !! Helpful one question what do i change so i can do AOSP instead of cm9??
grad061980 said:
Nice write up. Thanks.
Before I start again from scratch I have a question. Does this guide apply to previous versions of mac os x (mine is 10.6.8)? I used the official android initializing build environment page & cm7 wiki page for the instructions to setup my build environment.
Also, any tips to switch from macports to homebrew?
In the past I've had to cherry pick to get my OS X build environment set up for CM9. The compile from source fails because I started with macports instead of homebrew (bad idea). I tried to switch to homebrew without success. Any tips to switch from macports to homebrew?
For the sake of keeping this page on topic a pm response is ok if that is what you prefer.
Click to expand...
Click to collapse
Yes, this guide should work fine on Snow Leopard. It mostly depends on your Xcode version. If you have Xcode 3, you can skip step 1 entirely, since you already have gcc4.2 as part of Xcode.
If you have access to Xcode 4.2 and above, you will need to install gcc4.2 separately, as explained in the guide.
Now regarding Macports, I strongly suggest that you completely uninstall Macports before installing homebrew. Instructions are here: http://guide.macports.org/chunked/installing.macports.uninstalling.html
WonkyYew said:
Hi thanks for this !! Helpful one question what do i change so i can do AOSP instead of cm9??
Click to expand...
Click to collapse
Full instructions are available on android.com : http://source.android.com/source/initializing.html
If you are using this guide, you need to change the repo initialization command to :
Code:
repo init -u https://android.googlesource.com/platform/manifest
and then do repo sync. You can setup ccache as usual. I don't think AOSP has the "brunch command", so you have to use launch and then make.
Run "lunch" and select an option from the menu. You can find more info about the options here: http://source.android.com/source/building.html. For maguro, you should use "full_maguro-userdebug".
To start the build, use
Code:
make -j$(sysctl -n hw.ncpu)
@ArmanUV. Sounds good & thanks for the input. I'll give the link to macports uninstall a go.
Im a real noob, whats the advantage of compiling from source?
Thanks for the help man !
Hi, thanks for your guide, setting up the repo was no problem at all!
But: I'm getting the following error when building.
Code:
external/zlib/x86/adler32.c: In function ‘adler32_MMX’:
external/zlib/x86/adler32.c:747: error: can't find a register in class ‘GENERAL_REGS’ while reloading ‘asm’
external/zlib/x86/adler32.c:747: error: ‘asm’ operand has impossible constraints
make: *** [out/host/darwin-x86/obj/STATIC_LIBRARIES/libz_intermediates/adler32.o] Error 1
make: *** Waiting for unfinished jobs....
Seems to be a problem with the compiler, but I'm on xcode 4.3 and I've installed gcc-4.2 and set the env vars. Any help?
ArmanUV,
Thanks so much for posting this guide. Very helpful!
Are you having any trouble with errors like this?
Code:
external/zlib/x86/adler32.c: In function ‘adler32_MMX’:
external/zlib/x86/adler32.c:747: error: can't find a register in class ‘GENERAL_REGS’ while reloading ‘asm’
external/zlib/x86/adler32.c:747: error: ‘asm’ operand has impossible constraints
Googling for this error implies that the fix is to use a version of GCC > 4.2. But there does not seem to be a GCC 4.4 in Homebrew.
Thanks again for the guide!
EDIT: Sorry for the double post with empyyy. Seems like there is someone else having my same issue!
topprospect said:
ArmanUV,
Thanks so much for posting this guide. Very helpful!
Are you having any trouble with errors like this?
Code:
external/zlib/x86/adler32.c: In function ‘adler32_MMX’:
external/zlib/x86/adler32.c:747: error: can't find a register in class ‘GENERAL_REGS’ while reloading ‘asm’
external/zlib/x86/adler32.c:747: error: ‘asm’ operand has impossible constraints
Googling for this error implies that the fix is to use a version of GCC > 4.2. But there does not seem to be a GCC 4.4 in Homebrew.
Thanks again for the guide!
EDIT: Sorry for the double post with empyyy. Seems like there is someone else having my same issue!
Click to expand...
Click to collapse
empyyy said:
Hi, thanks for your guide, setting up the repo was no problem at all!
But: I'm getting the following error when building.
Code:
external/zlib/x86/adler32.c: In function ‘adler32_MMX’:
external/zlib/x86/adler32.c:747: error: can't find a register in class ‘GENERAL_REGS’ while reloading ‘asm’
external/zlib/x86/adler32.c:747: error: ‘asm’ operand has impossible constraints
make: *** [out/host/darwin-x86/obj/STATIC_LIBRARIES/libz_intermediates/adler32.o] Error 1
make: *** Waiting for unfinished jobs....
Seems to be a problem with the compiler, but I'm on xcode 4.3 and I've installed gcc-4.2 and set the env vars. Any help?
Click to expand...
Click to collapse
You guys seem to have the same issue. What sort of Xcode configuration are you using? Can you post the output from "which gcc","which g++", "gcc -v", "g++ -v" and "cc -v"?
ArmanUV said:
You guys seem to have the same issue. What sort of Xcode configuration are you using? Can you post the output from "which gcc","which g++", "gcc -v", "g++ -v" and "cc -v"?
Click to expand...
Click to collapse
I am on Lion 10.7.4 with Xcode 4.3.2. Here is the output that you asked for:
Code:
# echo -n "which gcc: "; which gcc; echo -n "which g++: "; which g++; echo ""; echo "gcc -v:"; gcc -v; echo ""; echo "g++ -v:"; g++ -v; echo ""; echo "cc -v:"; cc -v
which gcc: /usr/bin/gcc
which g++: /usr/bin/g++
gcc -v:
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.9~22/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.9~22/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
g++ -v:
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.9~22/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.9~22/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
cc -v:
Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.3.0
Thread model: posix
They are pointing to LLVM, but my CC and CXX variables point to:
Code:
env|grep 4.2
CXX=/usr/local/bin/g++-4.2
CC=/usr/local/bin/gcc-4.2
Do I need to add something to PATH? I'm sure I just missed something obvious in your instructions.. Thanks for helping!
topprospect said:
I am on Lion 10.7.4 with Xcode 4.3.2. Here is the output that you asked for:
Do I need to add something to PATH? I'm sure I just missed something obvious in your instructions.. Thanks for helping!
Click to expand...
Click to collapse
Everything checks out. I'm away from my main machine so I can't run a test build, but I suspect that a recent change is causing problems.
Now, regarding the compiler, Setting CC/CXX *should* take care of everything, but I am currently not 100% sure that somewhere in a makefile, these environment variables aren't being ignored. Since I wrote the guide, I noticed a lot of clang warnings in the build, which means that CC/CXX is not honored and /usr/bin/cc and /usr/bin/c++ is being used.
A more robust method of making sure gcc-4.2 is being used is creating symlinks to gcc-4.2 and g++-4.2 :
Code:
ln -s /usr/local/bin/gcc-4.2 /usr/local/bin/gcc
ln -s /usr/local/bin/gcc-4.2 /usr/local/bin/cc
ln -s /usr/local/bin/g++-4.2 /usr/local/bin/c++
ln -s /usr/local/bin/g++-4.2 /usr/local/bin/g++
Obviousely, a systemic method like this has its downsides but it may be the only choice without having to change CM code (especially since I lack the knowledge to do so )
[I recently found out that master aosp is no longer using CC/CXX to find the compiler (see ./build/core/combo/). Instead, it uses "gcc" and "g++" directly, which means that llvm-gcc will be used no matter what env variable you have. Fortunately, unlike cm9, master aosp is supposed to build fine with llvm-gcc (except for qemu, which doesn't matter for device images). ]
ArmanUV said:
Everything checks out. I'm away from my main machine so I can't run a test build, but I suspect that a recent change is causing problems.
Now, regarding the compiler, Setting CC/CXX *should* take care of everything, but I am currently not 100% sure that somewhere in a makefile, these environment variables aren't being ignored. Since I wrote the guide, I noticed a lot of clang warnings in the build, which means that CC/CXX is not honored and /usr/bin/cc and /usr/bin/c++ is being used.
A more robust method of making sure gcc-4.2 is being used is creating symlinks to gcc-4.2 and g++-4.2 :
Code:
ln -s /usr/local/bin/gcc-4.2 /usr/local/bin/gcc
ln -s /usr/local/bin/gcc-4.2 /usr/local/bin/cc
ln -s /usr/local/bin/g++-4.2 /usr/local/bin/c++
ln -s /usr/local/bin/g++-4.2 /usr/local/bin/g++
Click to expand...
Click to collapse
Okay, just tried this. I created a new dir (/Volumes/Android/bin) that simply houses those softlinks you recommended. Then I put /Volumes/Android/bin at the beginning of my PATH. That should fix it without breaking the rest of the system, e.g. homebrew.
The GENERAL_REGS problem still exists though. Pretty sure b/c gcc 4.2.1 doesn't understand this construct properly (need a newer version of gcc).
So I backed out the change that introduced this adler32.c.
https://github.com/CyanogenMod/android_external_zlib/commit/13bf40af68236c961542bdee1d4b7c0176bf15a0
The compile is getting farther now. I have to run to work so I'll post later if it succeeds.
The weird thing is: This change was made back in December. Why would it have worked for you?
topprospect said:
The compile is getting farther now. I have to run to work so I'll post later if it succeeds.
Click to expand...
Click to collapse
Build works (and boots!) with the following:
Code:
cd external/zlib
git revert dd6786cae3f4493faa6661d5f74db587932f15d7
git revert 13bf40af68236c961542bdee1d4b7c0176bf15a0
Note the 1st revert is just to avoid massive conflicts seen when reverting the 2nd one by itself. The 2nd revert is the one that really matters here.
So this isn't really a solution.. Seems like we need to move to a newer version of gcc or figure out a patch to adler32.c that makes it gcc 4.2 compatible.
topprospect said:
Build works (and boots!) with the following:
Code:
cd external/zlib
git revert dd6786cae3f4493faa6661d5f74db587932f15d7
git revert 13bf40af68236c961542bdee1d4b7c0176bf15a0
Click to expand...
Click to collapse
The first revert works fine, however the second one gives me the following error:
Code:
$ git revert 13bf40af68236c961542bdee1d4b7c0176bf15a0
error: could not revert 13bf40a... Implement vectorized adler32 and optimized slhash
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
error: Could not parse conflict hunks in zlib.h
empyyy said:
The first revert works fine, however the second one gives me the following error:
Code:
$ git revert 13bf40af68236c961542bdee1d4b7c0176bf15a0
error: could not revert 13bf40a... Implement vectorized adler32 and optimized slhash
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
error: Could not parse conflict hunks in zlib.h
Click to expand...
Click to collapse
Well, run git status. You'll see that the only conflict is in the comments in zlib.h. So, you can just ignore it.
topprospect said:
Okay, just tried this. I created a new dir (/Volumes/Android/bin) that simply houses those softlinks you recommended. Then I put /Volumes/Android/bin at the beginning of my PATH. That should fix it without breaking the rest of the system, e.g. homebrew.
The GENERAL_REGS problem still exists though. Pretty sure b/c gcc 4.2.1 doesn't understand this construct properly (need a newer version of gcc).
So I backed out the change that introduced this adler32.c.
https://github.com/CyanogenMod/android_external_zlib/commit/13bf40af68236c961542bdee1d4b7c0176bf15a0
The compile is getting farther now. I have to run to work so I'll post later if it succeeds.
The weird thing is: This change was made back in December. Why would it have worked for you?
Click to expand...
Click to collapse
topprospect said:
Build works (and boots!) with the following:
Code:
cd external/zlib
git revert dd6786cae3f4493faa6661d5f74db587932f15d7
git revert 13bf40af68236c961542bdee1d4b7c0176bf15a0
Note the 1st revert is just to avoid massive conflicts seen when reverting the 2nd one by itself. The 2nd revert is the one that really matters here.
So this isn't really a solution.. Seems like we need to move to a newer version of gcc or figure out a patch to adler32.c that makes it gcc 4.2 compatible.
Click to expand...
Click to collapse
Nice find. I tried to compile this morning and I ran into the same issue. This is what I don't understand: I did a couple of builds about a week ago without running into this issue. But, the latest commits on zlib are from 2 months ago.
Amazingly, the Xcode 4.3 toolchain (clang and llvm-gcc) builds this external/zlib/adler32.c just fine.
An alternative to this problem is to install an up to date gcc 4.7 :
Code:
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gcc.rb
and then create symlinks to gcc-4.7/g++-4.7. I have not tested this yet.

[EXPERIMENTAL/TOOLS/GUIDE/ADV.] Toolchain gcc 4.6.3 Cygwin/Linux/OSX; kernel builds

The following contains binaries, and instructions for use of an experimental newer toolchain than those included in the android pre-built package.
This is provided to allow existing linux kernel developers experiment with the updated version of GCC (besides the complicated building instructions the code just has a small patch for a known issue with android and 4.6.* otherwise is directly from GNU (see build information below)
The packages I'm also providing to help developers current on windows (With cygwin but no other virtual environment) to start exploring android Linux kernel development for their devices. (In addition to a OSX toolchain for more advanced mac users)
due to the slight differences between kernels on different devices this How To is intended to be used for advanced users who can adjust for the differences required for the devices specific kernel.
I may add additional guides to this thread if I find a need for them.
[size=+1]Binary Toolchains[/size]
I have two versions of a GCC-4.6.3 toolchain
1) For x86 linux: toolchain-4.6.3.tar.bz2 (Sha1: c8c57aba6ad92e9acddf29ba8620ba880be09a81)
2) For Cygwin (windows): toolchain-4.6.3.cygwin.tar.bz2 (Sha1: 6947e1c1ba95195019f542eb8ba0708667b63eca)
3) For OSX (mac/darwin): toolchain-4.6.3.darwin.tar.bz2 (Sha1: 9a977f0672863fdd9501383a6ad1e30723281f68)
[size=-1]> The linux version was built via this script: http://pastebin.com/b2dZ8YtG (or in the included toolchain_notes.txt)
> The cygwin/darwin version uses the same source however has a slightly modified script (see the included toolchain_notes.txt for the updated script)[/size]
[size=+1]System Requirements[/size]
Note I have a 64bit debian linux box, and a 64bit version of WIndows7 Pro running cygwin, while I believe these binaries ought to be compatible with all x86 linux and cygwin installs these have not been tested by a wide number of people yet.
> Linux users: If you have a working android build environment likely no additional requirements are needed. In addition you must build any kernel/android utilities from a case sensitive filesystem or disk image.
> OSx users: the cygwin packages will give you an idea of what is required, please also see the README in the tar.bz2 about manually installing elf.h
> Cygwin users: as its unlikely you have compiled a kernel with cygwin up to this point you may wish to ensure the following packages are installed (as well as any cygwin recommends to be used with them):
vim
vim-common
make
cmake
lzop
gcc
gcc-core
gcc-g++
wget
git
git-compleation
libncurses-devel
python​
Cygwin users must also set their NTFS file partition to allow case sensitive files:
To do this open regedit and change:
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel\obcaseinsensitive
to 0
after this reboot and the NTFS kernel will allow cygwin to use case sensitive files (ie 'AbC' and 'aBc' as two different files)​
[size=+1]Advanced Kernel Building Guide[/size]
Since may devices are slightly different this can only be a high level kernel building guide
Please ask for any specific directions from the current kernel maintainer.
To most people who have built kernels before this will look familiar, the most important part is preparing your local environment to use the new toolchain,
1) If you have not already download the tar.bz2 above, (pick the one for the computer you are preparing to build kernels on)
2) extract the file (for the sake of this guide I will assume it is extracted into a ~/android directory)
ie on cygwin you might:
mkdir -p ~/android
cd ~/android
tar -xjvf toolchain-4.6.3.cygwin.tar.bz2
Note: steps one and two are just properly installing the toolchain, you will not need
to repeat them to build a different kernel.
2.b) OSX Only: check elf.h
open ~/android/toolchain-4.6.3/README in a text editor and check if elf.h is installed, otherwise manually install it as per the readme
3) fetch your kernel source into the ~/android directory and change into the
source codes root directory
(this can be via a git repo or tarball)
example if you wanted my ACER a100/a500 source you might run:
git clone git://github.com/ezterry/AcerTabKernel.git
cd AcerTabKernel
change this to match the source you are fetching
4) In the root directory of the kernel source (~/android/AcerTabKernel in the about a100/a500 example) update the environment for the cross compiler
add the toolchain to your path:
export PATH=$HOME/android/toolchain-4.6.3/bin:$PATH​
set the cross compile:
export ARCH=arm
export CROSS_COMPILE=arm-linux-androideabi-
export KERNEL_DIR=`pwd`​
(this will need to be done once for each terminal you use to run any of the following make commands)
5) Grab your configuration
From the device:
adb pull /proc/config.gz
gzip -dc config.gz > .config
or from a prepared configuration if it's included in your code base by running
make _defconfig
example for the a100/a500 code base is 'make vangogh_defconfig' for the a100 and 'make picasso_defconfig' for the a500
6) Customize configuration
just run menuconfig and use the UI to update settings
make menuconfig​
7) building the kernel (zImage)
This is normal at this point with 'make -j'
so for a quad core CPU you can run
make -j5​
(note: the wrong number in the -j argument will not harm the build but may slow down the building process by either using too few threads or needing to keep track of too many)
8) If it worked you will now have the kernel in arch/arm/boot/zImage
this can be injected into the boot.img (as the kernel, using an existing ramdisk) as is
If it failed for your kernel your kernel source may need one of the common patches
9) Building modules
the following will prepare the modules in subdirectory mod:
make modules
rm -rf mod
mkdir mod
cp `find ./ | grep .ko$` modules.order mod/​
After these commands [if no errors] you can simply copy the contents of mod/ to /system/lib/modules on your device, note it is recommended usually to remove the existing contents of /system/lib/modules unless there is a closed source module required from the previous build despite the new kernel.
[size=+1]Common Patches Required[/size]
If your kernel has not been built for the new toolchain or on cygwin before you may require some of these common patchs: (I've thus far only tested this on my Acer A100/A500 source)
wireless/bcm4329 for GCC-4.6.3:
https://github.com/ezterry/AcerTabKernel/commit/123f32e27e2c74f1c1789ae5d6d5a1c04e1e264c
linux kernel module patch for cygwin (broken elf.h):
https://github.com/ezterry/AcerTabKernel/commit/220db49593cf6b9f3b556e2f4b75b2f6d3ff556c
Error compiling security/smc/bridge_pub2sec.S (I required the cygwin elf patch and this patch to build the Franco galaxy nexus kernel)
0001-Fix-build-error-with-4.6.3-toolchain-smc-0.patch
(use 'git am 0001-Fix-build-error-with-4.6.3-toolchain-smc-0.patch' to apply)
OSX stat patches (fixes errors between GNU and BSD stat):
https://github.com/ezterry/AcerTabKernel/commit/0c49df3cc1a05a0ccd98201511cdc0534aaeb35a
Errors loading newly built modules (modules appear to build cleanly but wont install):
simply add -fno-pic to CFLAGS_MODULE
https://github.com/ezterry/AcerTabKernel/commit/c5ed0fcb014d36936a86ad253f15af43de2f644a
(I can add others here if highlighted to me, and as I find them)
[size=+1]Other Toolchain uses[/size]
The linux toolchain can be used to build android components, however this requires various manipulation to the android /build git repository as currently various other toolchains have hard coded paths into the prebuilt repo. If you intend to incorporate this into your build it may be best to inject the toolchain into your prebuilt repo rather than expect your users to download the links above, ensure to keep the compile notes as it explains how to get the source code to the toolchains)
On cygwin/osx it may also be possible to build android applications however I've not yet tested this as the scripts to make a proper build are complex when attempted outside the android build tree.
Excellent!!! thanks Man!!! Has been looking for one of these
Added in the OSX version of the toolchain (and some related patches)
Also if you are having problems with your modules built with this toolchain a CFLAG fixes it. (see note in common patches)
FINALLY!!! Great Instructions followed them to the T and BAM got my kernel compiled!!!
wow your toolchain is so small, many thanks, just compiled a kernel for my LG P500 gonna test it, thanks again
Bookmarked for testing when I wake up...
I can almost put: "Building under Windows is not currently supported." (quote from google), unofficially at least, out of my mind...
I have been spoiled by Windows for far too long I fear, my attempt for this last week at getting Linux setup and building CM9 has been nothing but a complete FAILURE, too many single line entrys for different distributions/package combo's, commands I dont know and cant find because of wildcard portions of them and lack of understanding, and not enough scripts like the wonderful Compile CM9 script someone put up (cant run it because all the pre-req's arent setup).
Good god Ill be jumping for joy if this works tomorrow on WinBlows!
EDIT: never mind, problem solved, what I need to know now won't be solved here
I wish i knew how to go about doing this..
Thanks
Thanks For ........... i Really need It .........
Hammerfest said:
Bookmarked for testing when I wake up...
I can almost put: "Building under Windows is not currently supported." (quote from google), unofficially at least, out of my mind...
I have been spoiled by Windows for far too long I fear, my attempt for this last week at getting Linux setup and building CM9 has been nothing but a complete FAILURE, too many single line entrys for different distributions/package combo's, commands I dont know and cant find because of wildcard portions of them and lack of understanding, and not enough scripts like the wonderful Compile CM9 script someone put up (cant run it because all the pre-req's arent setup).
Good god Ill be jumping for joy if this works tomorrow on WinBlows!
Click to expand...
Click to collapse
If you succeed tell me how to do it in a more familiar way
I get errors regading the processor not being supported?
brfield said:
I get errors regading the processor not being supported?
Click to expand...
Click to collapse
Sorry I can't support devs that have not learned cut copy and paste.
You probably forgot to export some of the environment variables or are just trying to run a arm binary on your PC and or a x86 binary on your arm device.
But why am I guessing? Why don't we know what you tried to run and what the actual text of the error was.. what type of kernel you tried to build, what you are running?
These packages are for developers if you feel like using them its time to learn to how to trouble shoot a problem and write a ticket to explain said problem clearly to others with at least some information to give us a chance to understand.
Sent from my Galaxy Nexus using Tapatalk 2
Great guide. Have the bcm4329 wireless module, so followed the tips and everything compiled and works!
Thanks!
one question,how to compiled android kernel with -O3 optimization?
jxxhwy said:
one question,how to compiled android kernel with -O3 optimization?
Click to expand...
Click to collapse
Um, in general its recommended you don't:
-O3 is not recommended for the kernel as many low level parts require the assembly code generated to remain as is and not be optimized as will be by some of the options -O3 enables thus likely reducing the stability of your kernel.
---
That said the menuconfig has an option to optimize for size (-Os) if enabled else -O2
For other optimization (including tuning for your cpu) you can add them to the CFLAGS_KERNEL/CFLAGS_MODULE in the make file.)
For -O3 like functionality you could add the increment to the line:
-finline-functions, -funswitch-loops, -fpredictive-commoning, -fgcse-after-reload, -ftreel-vectorize, -ftree-partial-pre and -fipa-cp-clone
-Ofast is -O3 with -ffast-math as well
If you do build with all the -O3 or-Ofast options ensure you test the kernel for stability and run some benchmarks. (as it may not actually be faster depending on the cache misses)
The first option I'd start pruning was the one mentioned in my reference below -fgcse-after-reload.
If you really insist on -O3 rather than just adding the optimization you want that are not in O2,it can be added also in the Makefile where the configure flag is checked and its added to KBUILD_CFLAGS
Obviously all and any of this is at your own risk, anything that breaks you have to find a way to fix it.
Reference:
Gcc optimize options:
http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
Talk of O3 and the kernel (not android specific)
http://unix.stackexchange.com/questions/1597/compiling-gnu-linux-with-o3-optimization
ezterry,thank you very much!
I want to build cm9 kernel using toolchain 4.6.3.
How to replace the default GCC 4.4.3 to 4.6.3 version?
BTW,I use the way -- make bootimage
jxxhwy said:
ezterry,thank you very much!
I want to build cm9 kernel using toolchain 4.6.3.
How to replace the default GCC 4.4.3 to 4.6.3 version?
BTW,I use the way -- make bootimage
Click to expand...
Click to collapse
If you are asking in a cm9 build tree.. its a pain, best is to update the cm kernel makefile to point the build chain temporarily.
If you mean just to compile by hand as described in the op
Once the kernel is compiled find an anykernel update.zip or manually use mkbootimg or fastboot to merge it with the ram disk. Cm9 targets mkbootimg and unpackbootimg (if I'm not mistaken) will build the applications to unpack your current (or the default cm9) boot image and re-create them with your custom kernel built from hand.
Now,I runing script file:
#Let's make sure the environment is clean and ready to compile the kernel
echo "Cleaning house!!"
make mrproper
echo "House cleaned, lets build a kernel!!!"
#
# Lets set the kernel defconfig
echo "defconfig = cyanogenmod_iprj_defconfig"
make ARCH=arm cyanogenmod_iprj_defconfig
#
# Let's build a kernel
echo "Now compiling kernel, go get a soda! "
ARCH=arm CROSS_COMPILE=~/Android/sourcecm9/cm9/toolchain-4.6.3/bin/arm-linux-androideabi- make zImage -j4
#
if [ -f arch/arm/boot/zImage ]; then
echo "Plague has been compiled!!! You can find it in arch/arm/boot/zImage"
else
echo "Kernel did not compile, please check for errors!!"
fi
but,I got some error output:
/home/xxx/cm9/toolchain-4.6.3/bin/arm-linux-androideabi-ld: cannot find usr/initramfs_data.o: No such file or directory
thanks again!!!
I think that means there is an issue with your config..
Most android kernels require initramfs, but don't specify a file, as its provided by the bootloader.. However in your case it is trying to embed it into the kernel.
Sent from my A500 using Tapatalk 2
ezterry said:
I think that means there is an issue with your config..
Most android kernels require initramfs, but don't specify a file, as its provided by the bootloader.. However in your case it is trying to embed it into the kernel.
Sent from my A500 using Tapatalk 2
Click to expand...
Click to collapse
issue has been resolved by myslef.Thanks for your time.

[B928] OC kernel 0.1 [one-hit wonder]

This will not be worked on any longer thanks to Huawei's incompetence. I'm glad my main phone isn't by them. I leave my 0.2 diff attached (which did make my phone faster FWIW - and has fsync() control. Not of use to me, but people who use a modified libsqlite would like it...). Feel free to apply it and see if you can somehow fix dhd.ko loading.
Hi,
Not one for names, so this shall be known as "OC kernel" This is built from the ICS U8800pro source that Huawei put out.
Install at your own risk; I take no responsibilty for any damage that may occur through the usage of this kernel.
Features:
ADB as root
Overclocking enabled (thanks to genokolar)
Undervolting interface added (from genokolar, who took it from a SE kernel modder somewhere) - I think SetXperia can use it
SIO I/O scheduler added
SmartassV2 cpufreq scheduler (AnDyX mod) - although I think ondemand does a bit better IMO
sysfs entry to turn off keypad lights (I wrote an applet for this some time back, I'll dig it out later)
Logcat is always enabled now as the ServiceMenu toggle doesn't work anymore
Minimum display backlight is set to 15, but I think Android needs a framework change to use it. You could try RootDim
Kernel actually builds (and Bluetooth works)
ZRAM (+ swap) support. ZRAM is optimized for Android (taken from Siyah kernel). I'll write up the instructions on enabling this later
CIFS as module
Extras:
Change schedulers and phone speed:
Use a tool like No Frills CPU or SetCPU.
Turn off button lights:
Install the ButtonLight widget and add it to your main screen. I've published the source before in another thread; seek it out if you're after its (bad) code.
It's buggy the first few times you run it, but works fine after that.
Dim screen to 14:
The minimum backlight level is now set to 15. RootDim from the Play Store lets you set it to that.
Mount Windows shares:
Grab CifsMounter and point it to the cifs.ko in /system/lib/modules. You may also need to insmod nls_utf8.ko and md4.ko.
Enable ZRAM (taken from Siyah kernel):
(Note I've not used ZRAM so I have nothing to say on its stability, good or bad)
Grab a BusyBox binary from somewhere
Run the following commands:
Code:
echo 90 > /proc/sys/vm/swappiness #You must set the swappiness high to ensure that the compressed RAM is accessed first!
echo $SIZE > /sys/devices/virtual/block/zram0/disksize #Set size to whatever you wish. 100MB is 104857600 = 100 * 1024 * 1024
busybox mkswap /dev/block/zram0
busybox swapon /dev/block/zram0
Dump the lines in install-recovery.sh if you want to be ZRAMMed every time you boot the phone (although in that case, make sure you have
Code:
busybox swapoff /dev/block/zram0 > /dev/null 2>&1 #Use > /dev/null 2>&1 for every busybox command in install-recovery.sh as it will discard any messages outputted
echo 1 > /sys/devices/virtual/block/zram0/reset
before the lines above)
Install:
Flash the attached ZIP in CWM recovery. You should backup your original boot.img and /system/lib/modules first
Source:
Take http://www.huaweidevice.com/worldwi...=toDownloadFile&flay=software&softid=NDY3NTU= and apply attached diff
at last..xaaxxaa!!but why with modules too???whats their use?
pikachukaki said:
at last..xaaxxaa!!but why with modules too???whats their use?
Click to expand...
Click to collapse
'cause I add a new module - cifs (used by CifsMounter if you want to mount Windows shares) - and because the modules that are originally in /system/lib/modules need to be replaced so that they can load with this kernel (I don't know what those modules do, but I'd rather play it safe)
qwerty12 said:
'cause I add a new module - cifs (used by CifsMounter if you want to mount Windows shares) - and because the modules that are originally in /system/lib/modules need to be replaced so that they can load with this kernel (I don't know what those modules do, but I'd rather play it safe)
Click to expand...
Click to collapse
Boot normally change io to sio and smartassv2...1500mhz lets check..good work..i envy you and i want your guide on compiling...xaaxax im off to bed!!
fps is locked!!xaaxax
pikachukaki said:
Boot normally change io to sio and smartassv2...1500mhz lets check..good work..i envy you and i want your guide on compiling...xaaxax im off to bed!!
fps is locked!!xaaxax
Click to expand...
Click to collapse
I'll write it up sometime - but bear in mind I'm not an expert at this
Regarding FPS: do the install-recovery.sh trick
Only thing I modify in initramfs is the ro.secure setting so that ADB can be ran as root
qwerty12 said:
I'll write it up sometime - but bear in mind I'm not an expert at this
Regarding FPS: do the install-recovery.sh trick
Only thing I modify in initramfs is the ro.secure setting so that ADB can be ran as root
Click to expand...
Click to collapse
You did a great job i couldnt even compile the kernel without changes!!you did great!!
the difference is obvious !!
Sent from my U8800Pro using xda premium
Pika When U add This Kernet To ur ROM?
As expected from qwerty12!
Great job!
I'll also request a guide on how to build the kernel like pika asked.
Hope you continue to improve the kernel! A thanks is simply not enough to thank you for your work, but thanks again
husen4u said:
Pika When U add This Kernet To ur ROM?
Click to expand...
Click to collapse
I wont!just d/w it and flash it!simple!
Sent from my U8800Pro using xda premium
Now what you suggest oc ics or kalo gb?
Sent from my U8800pro using xda app-developers app
husen4u said:
Now what you suggest oc ics or kalo gb?
Sent from my U8800pro using xda app-developers app
Click to expand...
Click to collapse
From now on i wont ever go back to GB ever again! if our luck changes and someone release cm9 i will forget what gb is!! there are some small bugs but the rom is usable for everyday!!
Moihack said:
As expected from qwerty12!
Great job!
Click to expand...
Click to collapse
Thank you
I'll also request a guide on how to build the kernel like pika asked.
Click to expand...
Click to collapse
Certainly, sir.
Hope you continue to improve the kernel! A thanks is simply not enough to thank you for your work, but thanks again
Click to expand...
Click to collapse
Unfortunately I won't be working on this anymore unless Huawei get back to my request for the source to the the dhd.ko module (which they may not have to comply with because the license for the module states "Unless you and Broadcom execute a separate written software license agreement governing use of this software" so the U8800pro version may not be under GPL). I made (well, found on the Internet) more optimizations but the Wi-Fi refuses to turn on because the dhd.ko module refuses to load. Only way I can get something working is to build the source that Huawei give or attempt to force other versions of the bcm source to load, but it's unlikely that would work.
--
Anyway, a small guide.
I used an x86_64 laptop running (X)ubuntu 12.04.1 to follow these steps. This page was a great resource.
Prerequisites:
A computer running GNU/Linux (a Mac should work in theory - the same toolchain we use is built for it, too, but I have no idea how OS X works)
git installed (apt-get install --no-install-recommends git-core is enough under Ubuntu)
sudo apt-get install flex bison gperf build-essential libncurses5-dev zlib1g-dev ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib abootimg
Getting ADB working
One of the best things to do is getting ADB set up, as you then have easy communication with the device. It's not essential but you'll just end up wasting time transferring files through other, longer means.
Grab the Linux platform tools ZIP from here: http://www.hariadi.org/android/manually-download-of-android-sdk-tools-and-sdk-platform-tools/. Extract the adb binary from the zip file, preferably to somewhere in your $PATH. chmod 755 it. chown, if necessary.
Next, open http://aur.archlinux.org/packages/an/android-udev/android-udev.tar.gz and, doing all this as root (sudo in Terminal etc.), place 51-android.rules in /lib/udev/rules.d/ (not the best place - but it works), chmod 644 it and chown root:root it.
Next, execute /usr/sbin/groupadd adbusers, followed by gpasswd -a USERNAME adbusers, USERNAME being the user you normally log on with.
Restart (while you can force Linux to see the new group through the, well, newgrp command udev will not "see" the new rule, despite how much you try with udevadm).
That should be ADB set up (give it a test, remembering to enable USB debugging mode on the phone first!).
On to preparing your workarea.
--
Create a new folder in your home folder and cd to it. This folder will house the prebuilt folder of toolchains and other stuff, and the kernel source in a folder of its own.
In this folder, execute git clone --depth 1 https://android.googlesource.com/platform/prebuilt.git and move onto the next step, since the download takes a while. That command grabs the prebuilt toolchain from Google using Git, but doesn't obtain a deep history for each file to make the download quicker.
Open http://www.huaweidevice.com/worldwi...=toDownloadFile&flay=software&softid=NDY3NTU= and save the source to your Downloads directory. After git has finished running, still in the folder with the "prebuilt" folder, execute tar jxf ~/Downloads/HUAWEI_U8800pro<tab - as in actually press tab> and you should have a kernel folder alongside the prebuilt one.
Building the kernel
cd to this new kernel folder.
First things first: make sure that Bluetooth is properly enabled by editing the Makefile. Find the line #ifeq ($(ENABLE_BTLA_VER30),true) and comment out every line in that section except for KBUILD_CFLAGS += -DHUAWEI_BT_BTLA_VER30 so you end up with this:
Code:
#/* < DTS2012020604357 zhangyun 20120206 begin */
# Add Huawei Marco for different BT chip
#ifeq ($(ENABLE_BTLA_VER30),true)
KBUILD_CFLAGS += -DHUAWEI_BT_BTLA_VER30
#endif
#ifeq ($(ENABLE_BLUEZ_VER30),true)
#KBUILD_CFLAGS += -DHUAWEI_BT_BLUEZ_VER30
#endif
#/* DTS2012020604357 zhangyun 20120206 end > */
Commenting out the offending code leaves you with a kernel that builds but a Bluetooth module that won't start up - the same also applies if you try to build with the other define.
You can also make things easier for yourself by replacing the following
Code:
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
with
Code:
ARCH ?= arm
CROSS_COMPILE ?= ../prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
else you will have to put "ARCH=arm CROSS_COMPILE=../prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-" after "make" each time. Remember this as I'll be assuming that you went for the option to edit the Makefile. I also assume that the prebuilt folder is above the kernel one. Adjust CROSS_COMPILE if necessary.
The ARCH variable is self-explanatory, but the CROSS_COMPILE variable (and the toolchain that it's pointing to) need to be set because the standard GNU development tools that apt installs don't produce output that an ARM processor can understand. So you cross-compile: the tools are for the X86 architecture but produce ARM output. 4.4.3 is chosen because the stock kernel is compiled with GCC 4.4.3 (if you run "adb shell cat /proc/version" you'll see). The arm-eabi-4.4.3 folder is chosen over arm-linux-androideabi-4.4.x because it specifies that magic "3" (I know, bad way to decide but it works), and over i686-android-linux-4.4.3 because we don't want to produce code for the PC.
Get the current configuration in use by the stock kernel (as that's a good point to start from - a known working configuration): http://wiki.cyanogenmod.com/wiki/Building_Kernel_from_source#Configure_the_Build
I'd also recommend placing a copy of .config as arch/arm/configs/<your funky name here> so that if .config gets deleted (make clean etc.) you can run make <the name you gave to the file in arch/arm/configs> and have .config come back again.
(cp arch/arm/configs/<the name you gave to the file> .config if you didn't modify the Makefile to specify the ARM arch.)
Run make oldconfig (not always necessary - generally it's invoked if you've applied a patch that introduces a new config option and the option then needs to go into your .config. Run make menuconfig afterwards and customize away.
When you're done, run make -jX - X as in the number of cores you have + 1. So, in my case, with a quad-core processor and HyperThreading enabled on all of them, "make -j9" works for me. If the compile went OK, you'll be left with a message saying that arch/arm/boot/zImage is ready. If not, run "make" without the -jX argument and make should stop where the error occurs. Have fun fixing the error!
Assuming that you have a new, shiny zImage, it's now time to put it into your boot.img.
Updating your boot.img:
Google have tools for this purpose but I've never used them so I don't know how they work. abootimg works fine for this, however.
Pull the current boot.img off your phone: adb pull /.cust_backup/image/boot.img.. I'd recommend creating a backup somewhere.
Create a new directory to store the boot.img in on your computer and run abootimg -x boot.img (if you had fun enabling every option in the kernel, you'll see why I'm telling you to use the -x option first rather than directly use the -u option). Now run abootimg -u boot.img -k <path to your newly built zImage>.
If this succeeds, yay! If not and you're told it's too big for the boot image, then don't worry. Take the size it's saying that the zImage is and convert that number into hex. Edit bootimg.cfg and change the value of the bootsize setting into the number you just converted into hex. We'll now repack again, but this time running abootimg -u boot.img -f bootimg.cfg -k <path to your newly built zImage>. This should work.
Sending the boot.img to the phone
If your ADB is already running as root, you can do the following to upload the new bootimg:
Code:
adb shell mount -o remount,rw /.cust_backup
adb push boot.img /.cust_backup/image/
adb reboot
If not, just reboot into pink screen mode and copy and paste.
Check System Settings and the version number should've changed. Congratulations!
Extras
Installing the modules:
OK, so you decided to build parts of the kernel as a module and you want to actually, y'know, have the modules present on the device. After building the kernel, execute:
make INSTALL_MOD_STRIP=1 modules_install INSTALL_MOD_PATH=<any folder name here>
If you look in that folder, you'll find the modules neatly wrapped up in folders, along with other text files. These text files are useless on a stock ROM because there's no modprobe - you need BusyBox for that. And since we don't want to have them seperated in folders (this is how the stock kernel does it), the files would be wrong, anyway. If you want to use modprobe and have BusyBox installed, you can run depmod on the phone after transferring the modules.
To get the modules into one folder make the directory "modules" in a folder higher-up to where the modules are stored, and then run for i in `find . | grep ko`; do mv "$i" ../modules/; done to move them into that folder.
At this point, I'd just recommend using my OC_Kernel.zip and replacing the modules in that. Or you can adb push them over to the /system/lib/modules folder (after issuing an "adb remount" - assuming that ADB is running as root in the first place).
Making ADB run as root:
As root on your computer, (we want to preserve permissions) use abootimg to split the boot image and extract the contents of the initrd:
abootimg -x boot.img && mkdir newramdisk && cd newramdisk && zcat ../initrd.img | cpio -i --no-absolute-filenames (--no-absolute-filenames is important! I trashed a Ubuntu install by leaving it out - the initrd contains ARM binaries of core Linux programs and if the initrd.img contains an absolute path of "/" then these files will get placed in /)
Make any changes you desire to the initrd. To have adb run as root, just edit /default.prop and set ro.secure to 0. Make sure that the editor you used didn't leave any backup files.
When you're done, run find . -print | cpio -o -H newc | gzip -n -9 > ../initrd.img and this will put the modified initrd folder back into initrd.img.
After that run cd .. ; abootimg -u boot.img -r initrd.img to actually put the initrd.img back into the boot.img.
If you run into a space error, you can do one of three things:
if you only made a single change (like enabling ADB), check to see that there is no backup file (default.prop~) littered about
you can remove the lengthy comments and copyright notices from the files to make space
you can use the trick we used earlier with abootimg to increase the size number in bootimg.cfg for the initrd
Overclocking:
Just look at the acpuclock C file (and possibly relevant cpufreq changes - but I can't remember) in my "OC kernel" diff. Make sure that the option in the kernel config is selected to limit the speeds to the U8800pro's native 1GHz, otherwise the phone will boot at 2GHz!
Rebuilding the Wi-Fi module:
I hope to be able to write this one since it's apparently needed in some cases, but it depends on if Huawei come through
any idea about this error?
drivers/mfd/pmic8058.c:327: error: rtc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:327: error: rtc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:241: error: othc0_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:241: error: othc0_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:250: error: othc1_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:250: error: othc1_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:261: error: othc2_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:261: error: othc2_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:183: error: misc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:183: error: misc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:210: error: thermal_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:210: error: thermal_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:270: error: batt_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:270: error: batt_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:152: error: pm8058_charger_resources causes a section type conflict
drivers/mfd/pmic8058.c:152: error: pm8058_charger_resources causes a section type conflict
matteof93 said:
any idea about this error?
drivers/mfd/pmic8058.c:327: error: rtc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:327: error: rtc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:241: error: othc0_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:241: error: othc0_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:250: error: othc1_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:250: error: othc1_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:261: error: othc2_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:261: error: othc2_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:183: error: misc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:183: error: misc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:210: error: thermal_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:210: error: thermal_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:270: error: batt_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:270: error: batt_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:152: error: pm8058_charger_resources causes a section type conflict
drivers/mfd/pmic8058.c:152: error: pm8058_charger_resources causes a section type conflict
Click to expand...
Click to collapse
Honestly, I have no idea. What toolchain are you using and where was your .config obtained from? Even when the Bluetooth thing was giving me errors, I never once saw that
same toolchain you have used. i have tried with ubuntu 12.04 x64 and ubuntu 10.04 x86 but same problem.....i have obtained my config from my phone using adb command
matteof93 said:
same toolchain you have used. i have tried with ubuntu 12.04 x64 and ubuntu 10.04 x86 but same problem.....i have obtained my config from my phone using adb command
Click to expand...
Click to collapse
I don't know why the same toolchain works on my laptop but not yours :\
Someone with a similar problem (same?) solved it by using an older toolchain: http://forum.xda-developers.com/showpost.php?p=27294383&postcount=7157
thanks thanks thanks.....i saw that post this morning but i did not noticed the post with the solution
UPDATE: NOW KERNEL COMPILED CORRECTLY....this means that tomorrow i know what to do
ZRAM (+ swap) support. ZRAM is optimized for Android (taken from Siyah kernel). I'll write up the instructions on enabling this later
qwerty your owning us some instructions!!xaaxxa
pikachukaki said:
qwerty your owning us some instructions!!xaaxxa
Click to expand...
Click to collapse
Done, check the first post
I also won't be working on this. My email (which does clearly state what I want, even if it's long-winded):
Dear Sir/Madam,
I recently built a kernel for my U8800pro from your sources and it
works fine, except that the Wi-Fi will not start because the dhd.ko
module that comes with the B928 firmware refuses to load into my
modified kernel. After looking around, the bcm4329 source is what I
need to build (usually distributed outside of the kernel); however, it
seems that the U8800pro uses a customized version. After looking at
the strings of the dhd.ko on the B928 firmware, I have seen many
strings that are present in that dhd.ko binary do not appear in:
* bcm_4.218.248.6_7x25_wifi_driver.tar from the Huawei Device website,
despite it having the same version number
* the bcm4329 source in the Qualcomm CodeAurora Git repository
* the bcm4329 source on the NyVIDIA Tegra Git repository
Furthermore, the strings also do not appear in the ICS kernel nor the
Gingerbread one. I can only conclude that Huawei have their own
specialized version of the bcm4329 4.218.248.6 source for the U8800pro
that is distributed outside the kernel. I understand that Qualcomm
allow the option to let the vendor arrange to have the code
distributed under a different license provided that the vendor makes
an agreement beforehand with Qualcomm. Otherwise it becomes GPLed by
default. If Huawei chose to make an agreement, then I have no right to
ask. However, I believe it is still licensed under the GPL for two
reasons:
* Running modinfo on the dhd.ko from the B928 firmware says this:
"license: GPL v2
* Both bcm_4.218.248.6_7x25_wifi_driver.tar.gz and
[S7][SoftWare]S7_Broadcom_BCM4329_4.218.205.0_Open_Source are under
the GPL
I would like to request the source code, please, of the bcm4329
4.218.248.6 source that is modified for the U8800pro if the code is
under the GPL
Best regards
Click to expand...
Click to collapse
was met with the following generic response:
Dear Customer,
Thank you for contacting Huawei device.
This is our website link http://www.huaweidevice.com/worldwide/searchResult.
do?method=execute&searchString=U8800pro where you can download the secure
code for U8800pro to you.
Once again thank you for contacting Huawei device.
Best Regards.
Huawei Device Customer Care Team.
Click to expand...
Click to collapse
Since my U8800pro is not my main phone anymore, I do not have the energy to fight. Nor do I want to work on Huawei's kernel, where you have to be careful about what you change or the Wi-Fi module won't load (and Huawei won't give you the source - which they should do since I'm sure it's under GPL). matteof93 will most likely produce something better or when everyone starts producing their own kernels and make enough improvements to be hit with the same issue as I, they'll start to get more emails and listen
@qwerty at the last command it said that device is busy...also is there any way that you can make it for init.d so it will be easier??thx!!

[Guide] Compiling iPerf3

Hi,
This is a guide on compiling iPerf3 for the Zenfone 2 (x86-64 architecture). iPerf3 is a tool for active measurements of the maximum achievable bandwidth on IP networks. It supports tuning of various parameters related to timing, buffers and protocols (TCP, UDP, SCTP with IPv4 and IPv6). For each test it reports the bandwidth, loss, and other parameters.
Requirements :-
1) A recent Linux distro (I use Ubuntu 14.04.2 LTS) running x86-64.
2) Development tools i.e. C compiler, linker, etc... all the necessary tools to run configure, make, etc..
3) iPerf3 source code - latest as of this post is 3.0.11.
4) Small patch to source code to make it work on Android. iperf-3.0.11-android-patch.
Steps :-
(1) Extract the source code to a directory of its own :-
Code:
tar xzf iperf-3.0.11-source.tar.gz
cd iperf-3.0.11
(2) Patch the source :-
Code:
patch -p1 < ../iperf-3.0.11-android-patch
(3) Run configure :-
Code:
./configure
(4) Run make :-
Code:
make
(5) If all goes well, you will end up with a dynamically linked binary which is not what we want on the Android device. We will have to delete this and build a statically linked binary.
Code:
rm src/iperf3
(6) Edit src/Makefile and look for the line :-
Code:
iperf3_CFLAGS = -g
and replace it with :-
Code:
iperf3_CFLAGS = -g -all-static
(7) Now, run make again for the final time :-
Code:
make
(8) Strip the binary & verify it is a static binary :-
Code:
strip src/iperf3
file src/iperf3
That's it! just copy the iperf3 binary file to your Android device and move it to your /system/xbin or whatever directory in your PATH.
Hope it works for you guys. I'll be happy to help out anyone who needs more details.
Cheers.
UPDATE 2015-08-12 :
Here's a link to a precompiled & stripped binary. https://goo.gl/Q1l1yh
Can you please share binary file. I don't have development enviroment.
harpreet.s said:
Can you please share binary file. I don't have development enviroment.
Click to expand...
Click to collapse
Hi,
I've added a link to a compiled binary. Use at your own risk
Cheers.
Hi,
could you share instruction how to build iperf for arm?
because now it compiled for x86
thanks,
By any chance do you know how to compile a static binary for windows? The instructions you provided worked great I compiled a static binary for MAC and linux and android. now I could use one for windows
Compile 3.1.7, 3.2 and 3.3 for Android
Hi there,
I am new to Android Development. I have a need to compile iPerf 3.1.7, 3.2 and 3.3 for android. I see that a patch file is required in the reading here. Could you elaborate perhaps on what the patch does? I assume i will need to create something similar for 3.1.7, 3.2 and 3.3. Any help would be much appreciated thanks.

[GUIDE]A Noob Guide On Building Your Own Custom Kernel (ARM & ARM64 & MTK)

1. INTRODUCTION:​
This is a guide to build your own custom kernel. Although I'm still a "noob" at this,
I've struggled a lot to build one as all the guides which I followed were not very clear.
So I hope this will be clear enough and as noob friendly as possible!
You will learn how to:
- Build a kernel for arm and mediatek devices (arm64 coming soon)
- Add feature
- Basic use of git
Requirements:
- A computer running any distribution of linux 64 bit (Unbuntu, archlinux etc) as the Primary OS or a Virtual Machine (I used BBQ linux x64)
- Space on your HDD (On my Virtual Machine I set 40GB, set yours according to how many kernels you want to build) The minimum space for a kernel source (and its compiled code) is about 2 GB
- Minimal linux knowledge (Terminal, Commands etc)
- Your Brain
- And finally patience
2. SETTING UP YOUR BUILD ENVIRONMENT:​
- Open your terminal and type "sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2"
(The command can be different depending upon your linux distribution)
- Then type "gcc"
If "gcc" is already installed, you should see "gcc : fatal error : no input file"
- Then type "make"
If "make" is already installed, you should see "make: *** no target specified and no makefile found. stop."
(In your native language)
- Then type "git"
If "git" is already installed, you should see bunch of basic git commands
Now you're almost ready to start building your kernel!
Toolchains:
There are several types of toolchains (GCC, Linaro and few custom made ones)
Warning : Not every single device kernel will boot (or even compiles) with older or newer GCC
- For ARM:
We'll be using GCC 4.7 in this tutorial (link : https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7/ )
-Open terminal and type: "mkdir kernel"(Type the name you want, I used "kernel")
-Then type "cd kernel" (the name which you used above)
-Then type "git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7"
-Wait till it finishes.
- For ARM 64:
For ARM 64 you need a 64 bit kernel compiler (there's "aarch64" in the name for telling that's a 64 bit compiler)
Exemple : https://releases.linaro.org/archive/13.07/components/toolchain/binaries/gcc-linaro-aarch64-linux-gnu-4.8-2013.07-1_linux.tar.xz
3.DOWNLOADING SOURCE FILES FOR YOUR DEVICE:​
Now you have to find a github that contains your kernel source.
Search on Google or XDA to find a kernel github repo for your device.
A kernel github looks like this: "https://github.com/atxoxx/android_kernel_samsung_msm8974/tree/xenomTW"
On the upper left side you can see branch: completed by a name
These are the different versions of the kernel/project (generally can be for testing, android version etc)
QUICK EXPLANATION OF FILES/FOLDERS:
- /arch/arm/configs : contains the config files for device (where you add option like new governors, features etc)
- /output/arch/arm/boot/ : Where zimage is stored (will explain that later)
- build.sh : Script to make the building much easier (will explain how it works later)
- /arm-cortex-linux-gnueabi-linaro_5.2-2015.11-2 : I put the toolchain in my kernel source making it easier to find (your kernel's toolchain name may be different)
If you don't have your kernel source yet, you need to download it.
Open terminal and make sure that you are in "kernel" folder (the one you previously created)
Then type in terminal : "git clone "URL of the github kernel" -b "name of the branch" "
For Example : "git clone https://github.com/atxoxx/android_kernel_samsung_msm8974 -b xenomTW"
Good! Now you have your kernel source!
4.BUILDING:​
For an easier way you can go to the location using your file explorer to : "/home/"name of your session"/kernel"
You'll see two folders (The Toolchain and The Kernel Source)
Go into your kernel source folder.
- For ARM:
Copy paste this:
#!/bin/bash
export ARCH=arm
export CROSS_COMPILE="path to your toolchain" (it have to end by something like "nameofarch-something-")
mkdir output
make -C $(pwd) O=output "name of defconfig and variant if needed"
make -j4 -C $(pwd) O=output
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export ARCH=arm: Defining which kernel architecture type it is (For example arm64 etc)
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- mkdir output: Create a directory for storing compiled zimage
- make -C $(pwd) O=output : Defining defconfig for guiding kernel compilation (will explain later)
- make -j4 -C $(pwd) O=output: where the building start, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
- cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage: This one is for moving image into the second path (thanks @Has.007 for this infromation)
Click to expand...
Click to collapse
Example :
#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=$(pwd)/arm-cortex-linux-gnueabi-linaro_5.2-2015.11-2/bin/arm-cortex-linux-gnueabi-
mkdir output
make -C $(pwd) O=output msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_ks01_skt_defconfig SELINUX_DEFCONFIG=selinux_defconfig
make -j4 -C $(pwd) O=output
cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage
Click to expand...
Click to collapse
- For ARM 64:
Copy paste this:
#!/bin/bash
export ARCH=arm64
export CROSS_COMPILE="path to your toolchain" (it have to end by something like "nameofarch-something-")
mkdir output
make -C $(pwd) O=output "name of defconfig and variant if needed"
make -j4 -C $(pwd) O=output
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export ARCH=arm64: Defining which kernel architecture type it is (For example arm64 etc)
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- mkdir output: Create a directory for storing compiled zimage
- make -C $(pwd) O=output : Defining defconfig for guiding kernel compilation (will explain later)
- make -j4 -C $(pwd) O=output: where the building start, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
- cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage: This one is for moving image into the second path (thanks @Has.007 for this infromation)
Click to expand...
Click to collapse
Example :
#!/bin/bash
export ARCH=arm64
export CROSS_COMPILE=$(pwd)/gcc-linaro-aarch64-linux-gnu-4.8-2013.07-1_linux/bin/aarch64-linux-gnu-
mkdir output
make -C $(pwd) O=output msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_ks01_skt_defconfig SELINUX_DEFCONFIG=selinux_defconfig
make -j4 -C $(pwd) O=output
cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage
Click to expand...
Click to collapse
- For Mediatek:
Copy paste this:
#!/bin/bash
export CROSS_COMPILE="path to your toolchain" (it have to end by something like "nameofarch-something-")
export ARCH=arm ARCH_MTK_PLATFORM=
make "name of defconfig and variant if needed"
make -j4
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- export ARCH=arm ARCH_MTK_PLATFORM=: Defining which kernel architecture type it is (For example arm64 etc) "ARCH_MTK_PLATFORM=" is for specifying which mediatek platform it is
- make _defconfig : Defining which defconfig to use (will explain later)
- make -j4: where the building starts, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
Click to expand...
Click to collapse
Example :
#!/bin/bash
export CROSS_COMPILE=$(pwd)/arm-eabi-4.8/bin/arm-eabi-
export ARCH=arm ARCH_MTK_PLATFORM=mt6580
make pixi4_4_8g1g_defconfig
make -j4
Click to expand...
Click to collapse
When these step are done make sure you are in kernel folder in terminal and type ". build.sh" (the dot at the beginning is essential don't forget it!)
If it compiles without any problems:
Wait till it finishes (it'll say something like "zimage is ready")
If you followed arm and arm64:
Then go to "/Output/arch/arm/boot/" to find your zimage.
Click to expand...
Click to collapse
If you followed mediatek:
Then go to "/arch/arm/boot/" to find your zimage.
Click to expand...
Click to collapse
Caution : Not all kernel build Zimage, it can build image or other compressed image
If in case you have any errors:
Check and see what it says, generally it'll tell you where the error is.
If the text is going too fast reduce the -j number as explained above.
For reference I compile with an AMD Phenom X4 3.4GHz,Samsung HDD and 8GB of RAM and it takes around 10min to build
It is recommanded to type in the terminal "make clean && mrproper" before compiling again​
5.MAKING THE KERNEL BOOT:​
You have 2 solutions here:
1) You can use @osm0sis anykernel method, which is explainded here: "https://forum.xda-developers.com/showthread.php?t=2670512" (A huge shoutout to him!)
OR
2) You can unpack the boot.img (from the same rom (CM, touchwizz,sense etc) and android version) and swap Zimage in it explained here : "https://forum.xda-developers.com/showthread.php?t=2073775" (thanks again to @osm0sis !)
Before flashing the kernel which you've made, backup your "stock" boot.img and Then flash your kernel and see if it boots!
6.HOW TO ADD FEATURE TO KERNEL WORK:​
Here starts the most interesting part! Now let's see how it works:
Basically you can add: Governors, IO Schedulers, Overclock the CPU & Many Tweaks...
Checkout the github section (Section 7) to see how to add them properly.
Here's an exemple for adding a governor (this one is called Intellimm) : https://github.com/gugu0das/android...mmit/7186ee60c171b06ea3a027e8383be392d3186bb1
The text in the blue box is the commit description (generally tells you about the changelog, general information and who originally made the commit)
The other text boxes tell you about where and which files have been modified/changed.
Everything in green indicates what has been added.
Everything in red indicates what has been deleted.
We can see in the first 2 text boxes that in "arch/arm/configs/" "msm8974_sec_defconfig" and "cm_msm8974_sec_defconfig" have been modified.
Between the lines 140 and 141 of this files this text has been added : "CONFIG_CPU_FREQ_GOV_INTELLIMM=y"
(This line is for enabling Intellimm when you're compiling your kernel)
Same technique applies to the other text boxes (what has been added and deleted and it's location)
Depending on the features you add, more or less files can be modified, added or deleted.
So to sum it up, a Commit let's you see all the changes which have been made and everything else!
7.GUIDE TO GITHUB:​
For this, I'll direct you over to this awsome guide made by @eagleeyetom !
8.GPL (IMPORTANT !!!):​
The Rules as they apply on XDA
As XDA has no legal power to uphold the GPL (and frankly we want to stay as far away from doing so as possible), we can’t force any of our users to abide by the GPL. However it is in XDA’s interests as well as the interests of our developer-base to ensure all GPL-derived materials hosted or linked on XDA comply fully with the GPL.
GPL-derived materials that do not come with the complete sources used to compile the GPL components are considered warez, and will be treated as such under forum rule 6 and 9.
If you use GPL components, but do not make any modifications to them whatsoever, you should provide a link to the original source of your GPL code.
Sources accompanying a release should be complete, and contain all the necessary source code for any modules, scripts or definition files. Complete sources will be defined as those which compile correctly and completely against the platform for which the software is distributed, and which contain any and all modifications made to the released General Public Licenced code. The source code supplied should be the exact version for which the source code is being requested, complete with all modifications.
EXAMPLE: Here’s a bit of code that could be used as a template to post your releases
<Kernel Or Author Name> <Kernel Nr>:
<Source>|<ReadMe>|<Credits>|<Other>
The Very Quick Summary of General Public License (GPL)
The text of the GPL Licence itself will be used to reach any final conclusion regarding any disputes over GPL Licenced materials. The above is a summary of what XDA expects of members using GPL code, and the complete text can be read at the GNU website.
The GPL states that anyone who modifies GPL licenced code is required to make available the sources used to compile it. This is to further improve and encourage collaborative work, as well as to ensure that the best code possible is produced, and to encourage peer-review of all work. This benefits both developers and end users in numerous ways, including:
Allowing anyone to verify the code they are trusting with their data, and its authenticity
Encouraging community collaboration to produce faster fixes and updates, and better code
Helping bring new developments from other devices and fields to your own, letting you benefit from new code that wouldn’t have been available without this sharing.
The GPL imparts great freedom for GPL end users. It ensures innovation is never stifled and no project is dependent upon any single developer.
It is in everyone’s interest for the GPL to be adhered to, as it gives us all better ROMs, better transparency, and a better atmosphere for developers to work together to make great code.
Click to expand...
Click to collapse
THANKS :​
- @ravish_919 : For testing and correcting this guide
- @karkasss : As my friend and support
- @gugu0das : For helping me a lot when I tried to build my kernel
- @eagleeyetom : For his awsome github guide
- @kirito9 : Huge thanks to him for providing mediatek guide !
- @F4uzan : Huge thanks to him for giving me a lot of useful information to fill this guide !
- @sunilpaulmathew : For providing an advanced method to rename your kernel !
- @RendyAK and @DroidThug : For correcting me about "#!/bin/bash"
- All the developers for their hard work !
- XDA and The Community!
TIPS AND TRICKS​
1. You can use a copy of a defconfig file with different setup :
Usage : Use a "stock" one and use another one with esperimental feature for testing without altering original defconfig
Exemple : copy "stock" defconfig and in copied one add a governor see if it compile and work
How to do : Create a second build.sh with modified defconfig name !
2. Change kernel name and version :
Simple method :​Edit this line "CONFIG_LOCALVERSION="-" after - in your defconfig
Exemple : CONFIG_LOCALVERSION="-XenomTW-3.2.6"
Advanced method :​1. Add the name after "EXTRAVERSION" (e.g: EXTRAVERSION = -XenomTW-3.2.6) in the 'Makefile' (line 4) which will be found in the root folder..
2. Edit the last two sections ("const char linux_banner[] =" and "const char linux_proc_banner[] =") of 'init/version.c".
e.g. Change this to
const char linux_banner[] =
"Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@"
LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n";
const char linux_proc_banner[] =
"%s version %s"
" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
" (" LINUX_COMPILER ") %s\n";
Click to expand...
Click to collapse
To something like this :
const char linux_banner[] =
"Linux version " UTS_RELEASE " (XenomTW)"
"(" LINUX_COMPILER ") " UTS_VERSION "\n";
const char linux_proc_banner[] =
"%s version %s"
" (XenomTW)"
" (" LINUX_COMPILER ") %s\n";
Click to expand...
Click to collapse
More to come...
Placeholder
Hey, nice work to see an updated guide. Do you think it will be possible to include Mediatek(MTK) support? I'll provide details through PM how I build my kernel and how MTK differs. I'm still a noob but have compiled enough to merge this guide.
You can probably add a page dedicated to MTK . Guides aren't my forte :").
kirito9 said:
Hey, nice work to see an updated guide. Do you think it will be possible to include Mediatek(MTK) support? I'll provide details through PM how I build my kernel and how MTK differs. I'm still a noob but have compiled enough to merge this guide.
You can probably add a page dedicated to MTK . Guides aren't my forte :").
Click to expand...
Click to collapse
Of course could be really cool !
I'll credit you etc
Also I'll try later to support arm64 too
3lambda said:
Of course could be really cool !
I'll credit you etc
Also I'll try later to support arm64 too
Click to expand...
Click to collapse
Nice, I'm a bit under the weather but you can make a placeholder for MTK and send what I know when I'm feeling better.
kirito9 said:
Nice, I'm a bit under the weather but you can make a placeholder for MTK and send what I know when I'm feeling better.
Click to expand...
Click to collapse
No problem take your time hope you'll feel better soon !
@3lambda, thumbs up :good::good: for this awesome guide.
It will be of much benefit to MTK Devs & maybe porters.
Up up bro.
Hoping to share little that I got to know when I started kernel development.
Hoping for the best.
Hoping this guide go far than our expectations
What people think about videos too ?
Like a series of guide
For example one for basic build
One for explaining how to implement a feature
One that explain common issue/bug etc ?
3lambda said:
What people think about videos too ?
Like a series of guide
For example one for basic build
One for explaining how to implement a feature
One that explain common issue/bug etc ?
Click to expand...
Click to collapse
it will be very useful
highly appreciated your contribution to the community thank you
Thank you for this helpful guide! Will be waiting for the "Adding Features" section! Quite the work you have done! :good:
3lambda said:
Of course could be really cool !
I'll credit you etc
Also I'll try later to support arm64 too
Click to expand...
Click to collapse
I got some Unwinding errors related to vmlinux.o and built-in.o
Device_Lenovo A6000
Kernel Sources_ https://github.com/varunhardgamer
repo name- kernel lenovo a6000
used toolchain_ arm-linux-androideabi-4.9 from android NDK
It would be grateful if you can help me
Thanks:good:
The Hard Gamer said:
I got some Unwinding errors related to vmlinux.o and built-in.o
Device_Lenovo A6000
Kernel Sources_ https://github.com/varunhardgamer
repo name- kernel lenovo a6000
used toolchain_ arm-linux-androideabi-4.9 from android NDK
It would be grateful if you can help me
Thanks:good:
Click to expand...
Click to collapse
What error have you ?
Also is your device arm64 ?
Envoyé de mon m8 en utilisant Tapatalk
3lambda said:
What error have you ?
Also is your device arm64 ?
Envoyé de mon m8 en utilisant Tapatalk
Click to expand...
Click to collapse
Unwinding could not be possible
recipe for vmlinux.o failed
device is arm
i guess its related to toolchain and gcc
Will report back after changing toolchain
The Hard Gamer said:
Unwinding could not be possible
recipe for vmlinux.o failed
device is arm
i guess its related to toolchain and gcc
Will report back after changing toolchain
Click to expand...
Click to collapse
Try to use​ GCC 4.7 (with the link i provided in op) instead of ndk
Envoyé de mon m8 en utilisant Tapatalk
3lambda said:
Try to use​ GCC 4.7 (with the link i provided in op) instead of ndk
Envoyé de mon m8 en utilisant Tapatalk
Click to expand...
Click to collapse
Ok, And Thanks for the guide man:good:
Code:
cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage
This
Will copy the Image file from output folder to the arch/arm/boot folder so the users can find it directly from there.
cp is used to copy something from the command line.
mv is used to rename or move a file.
Anyways nice start & nice guide! :good:
Has.007 said:
This
Will copy the Image file from output folder to the arch/arm/boot folder so the users can find it directly from there.
cp is used to copy something from the command line.
mv is used to rename or move a file.
Anyways nice start & nice guide! :good:
Click to expand...
Click to collapse
Oh lol thanks
Will correct that in op
Linaro
I would appreciate it a ton if you could show us how to download and use a different toolchain (especially linaro) to compile the kernel. You did amazing work on this guide!
3lambda said:
2. Change kernel name and version :
Simply edit this line "CONFIG_LOCALVERSION="-" after - in your defconfig
Exemple : CONFIG_LOCALVERSION="-XenomTW-3.2.6"
Click to expand...
Click to collapse
Thanks for the awesome guide. I really wish to see a similar guide before few month so that I was able to save a lot of time .
Btw, few more tips for adding kernel name from my side...
1. Add the name after "EXTRAVERSION" (e.g: EXTRAVERSION = -XenomTW-3.2.6) in the 'Makefile' (line 4) which will be found in the root folder..
2. Edit the last two sections ("const char linux_banner[] =" and "const char linux_proc_banner[] =") of 'init/version.c".
e.g. Change this to
const char linux_banner[] =
"Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@"
LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n";
const char linux_proc_banner[] =
"%s version %s"
" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
" (" LINUX_COMPILER ") %s\n";
Click to expand...
Click to collapse
some thing like this
const char linux_banner[] =
"Linux version " UTS_RELEASE " (XenomTW)"
"(" LINUX_COMPILER ") " UTS_VERSION "\n";
const char linux_proc_banner[] =
"%s version %s"
" (XenomTW)"
" (" LINUX_COMPILER ") %s\n";;
Click to expand...
Click to collapse

Categories

Resources