yashsingh1/xdaforums huggingface dataset:
[Desire Android Development] Droidzone:
I like explaining stuff and sharing.. :)

This guide was written specifically because of your request, and I have never forgotten how you helped when I was a newbie to development.. I wouldnt probably have started developing if not for good responses from Firerat and you.
[Desire Android Development] Alex-V:
and now i learn from you :) lol :) thx

with kind regards..Alex
[Desire Android Development] ZoneX:
Fantastic guide!!!!!!!
[Desire Android Development] Droidzone:
Did some more work on the first post. It now includes a flashable zip template and instructions on how to easily create your own flashable zip after compilation is over.
[Desire Android Development] Kalashnikitty:
maybe some improvments to your making a flashable zip.

i did this with my kernels.. it took the version infos from the config files.. and put it into a folder... after this u can make zip.

ive stolen this from manus source :)

localVersion=`cat .your-config | fgrep CONFIG_LOCALVERSION= | cut -f 2 -d= | sed s/\"//g`
linuxVersion=`cat .your-config | fgrep "Linux kernel version:" | cut -d: -f 2 | cut -c2-`
VERSION=$linuxVersion$localVersion
echo "Kernel version=$VERSION"

rm -rf flash/system/lib/modules/*
mkdir flash/system/lib/modules/$VERSION
mkdir flash/system/lib/modules/$VERSION/kernel
tar czf modules.tgz `find . -name '*.ko'`
cd flash/system/lib/modules/$VERSION/kernel
tar xzf ../../../../../../modules.tgz
cd - > /dev/null
rm modules.tgz
[Desire Android Development] Droidzone:
This is good..Actually when I generate kernels I test too many versions that I dont usually change the local version number in the menuconfig. Instead I use the date and time (including second) to name the kernel dir and kernel zip name...

Like this..

date_str=`date '+%d%m%y_%H%M%S'`
dirname="kernel_"$nameflag"_"$date_str
pckdir="$packagedir/$dirname"
mkdir $pckdir

lastfolder=$pckdir
cd $outdir/
echo
zipnoname="kbase_"$nameflag"_"$date_str
zipaddnoname="kmods_"$nameflag"_"$date_str
zipname=$zipnoname".zip"
zipaddname=$zipaddnoname".zip"
zip -r $zipnoname ./
mv $zipname $pckdir/

As you can see, its part of my script which does a lot of things..

But getting the localversion too is a good thing..I'd put it into a textfile in the zip which users can read.. :)
[Desire Android Development] SquallLTT:
Great guide. Thanks a lot :)
[Desire Android Development] sixstringsg:
A link to our build script: https://github.com/GlitchKernel/Glitch/blob/V13/cappy.sh
[Desire Android Development] sixstringsg:
If anyone needs kernel hosting, let me know. I have a helluva dedicated server that people are welcome to a piece of.
[Desire Android Development] Kalashnikitty:
thx for sharing this script droidzone, this is awesome!
[Desire Android Development] Chaqmol:
I'v read 3 instructions with the same subject before...none of them were this much clear and usefull...tnx a lot
[Desire Android Development] Droidzone:
I'm glad to hear that! I'm working on a bigger project on the same topic, integrating a Boot.img kitchen along with the other kernel menus. It has a lot of logic within and hence is proving very difficult to script. If all goes well, I may release it today. :)
[Desire Android Development] Kalashnikitty:
im on work now and cant test your script, but i found this function in your source:

function menuconf {
cd $kstartpath
echo
echo "Entering Menuconfig..."
#Working on Kubuntu
#make ARCH=arm CC="arm-linux-gcc" LD="arm-linux-ld" AR="arm-linux-ar" RANLIB="arm-linux-ranlib" AS="arm-linux-as" -j10 -i all
if [ ! -e ./Makefile ]
then
echo "This script should be executed from within the root directory of kernel"
echo "Makefile could not be located in your current location. Aborting..."
exit 1
fi
make ARCH=arm CROSS_COMPILE=$toolchain menuconfig
menu
}

is this only a workaround for kubuntu? - because im working on mint (ubuntu)
[Desire Android Development] Droidzone:
Nope..the script works equally good on both kde and gnome...the $kstartpath is actually only the kernel start path.. Note that the script isnt self contained. For generation of flashable zip, you'll need to extract the zip template to $anykdir..

The only difference b/w kde and gnome is in opening the file managers-nautilus for gnome, dolphin for kde; similiarly text editors-kate for kde and gedit for gnome.. Newer script is even more intelligent! So much more syntax errors atm... :D
[Desire Android Development] coolexe:
Hi,

Awesome bro. very useful for noobs...:D
[Desire Android Development] Droidzone:
I'll be delighted if noobs start building kernels with this info! :)
[Desire Android Development] Droidzone:
Updated Script with Boot.img kitchen (Beta)

Note-Some options are still under construction.

Unpacking/repacking is an alpha, and I can test only after I get back my Desire from HTC Service.
[Desire Android Development] pRo_lama:
I know that it is stupid question, but how flash kernel ??? Just via CWM (install zip from sdcard > choose zip from sdcard > zip file of kernel )or any other way ??
[Desire Android Development] Droidzone:
DEV thread -> Thread for developers only/newbies with development related intelligent questions. You're right about your question.
[Desire Android Development] backfromthestorm:
Well I'd like to try and make an aosp(oxygen) kernel with siberes batfix.. Or something similar of my own.. Soon as I get my laptop I'll give it a try.

Thanks.
[Desire Android Development] Alex-V:
ok :)

after i must make this

sudo apt-get install ncurses-dev

i get the options menu :) before i get a error

with kind regards
[Desire Android Development] Droidzone:
Ah yes, I forgot to mention that it's required for menuconfig :)
[Desire Android Development] Alex-V:
yes...but no problem for such a good how to...it was a 2 min google search :)

with kind regards
[Desire Android Development] coutts99:
An answer without the 'I'm a dev' God complex, yes just flash the zip
[Desire Android Development] Alex-V:
mmhh...next prob...(sorry have said that iḿ a noob with kernel compile)

arm-linux-androideabi-gcc: command not found...

Did this means the path in bashrc is not right..? Or must i simple restart the laptop...did not rebootet after i set the line

with kind regards..Alex

EDIT...Sorry what i thought...a simple reboot did the trick...now compile... :) :)

but now i must go to bed :( but tomorrow :)
[Desire Android Development] Alex-V:
mmhh...sorry again...compile seems to be fine...but where is the zImage...? maybe it was a error and i did not see..will try tomorrow again

with kind regards
[Desire Android Development] Droidzone:
It should be in arch/arm/boot

The modules can be collected with this:

find . -name '*ko' -exec cp '{}' ~/somewhere

If you copy the zip template to a dir ~/kernel_flashable, then the following command makes a flashable zip automatically for you:

cp arch/arm/boot/zImage ~/kernel_flashable
find . -name '*ko' -exec cp '{}' ~/kernel_flashable/system/lib/modules/ \;
cd ~/kernel_flashable
zip -r mykernel ./
[Desire Android Development] Droidzone:
True.. I usually answer every qn asked on my Rom threads. But resisted the impulse to do that because if such qns fill up these threads meant to teach advanced users, then it becomes difficult for these very same people to find answers to genuine compilation related queries answered before.. I have some threads on Q & A for newbies teaching them adb, and tutorials on recovering a Desire..There, I try to politely answer every qn asked. I even hangout at Q & A occasionally to answer unanswered qns..

No complex here, coutts.. We're still saplings compared to real devs like snq-, you, richardtrip and others. :) The Recognized Developer logo be damned.. It doesnt mean a thing when it's not given for pioneers like you guys.
[Desire Android Development] Droidzone:
That's because the path set in .bashrc becomes active only in the next terminal opened. So, if you opened a new terminal, it ought to have worked. It would also work if you manually typed the command to add PATH at the terminal, like:

PATH=$PATH:/pathto/NDK/bin
[Desire Android Development] Alex-V:
Thx for the infos...will try again today...as all is set up..i only must make it :)
[Desire Android Development] Alex-V:
Still miss you ...coutts :) ;)
[Desire Android Development] Alex-V:
So ...now i need a bit help...i get this error:

CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
CC lib/decompress_bunzip2.o
LD lib/built-in.o
cc1: warnings being treated as errors
lib/decompress_bunzip2.c: In function 'get_next_block':
lib/decompress_bunzip2.c:511: error: the frame size of 1896 bytes is larger than 1024 bytes; see http://go/big_stack_frame
make[1]: *** [lib/decompress_bunzip2.o] Fehler 1
make: *** [lib] Fehler 2

have googled a bit...but no clear answer

with kind regards...Alex
[Desire Android Development] Droidzone:
I'm not on Linux right now, but can you see if you have a file at lib/Makefile

If you dont, upload your Makefile from main kernel directory
[Desire Android Development] Alex-V:
yep...its in :

lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
[Desire Android Development] Droidzone:
:) I was asking if you could upload the makefile here..I could modify it to make it work and give it back..

Give me the main Makefire from the main kernel directory
[Desire Android Development] Alex-V:
ah...ok...here are the files from main and lib folder...and thx for help :)
[Desire Android Development] Droidzone:
Ok, try using this Makefile in your lib directory. I'll explain what I did soon.. Let me know if it works
[Desire Android Development] Alex-V:
mmmhh...still the same..

here are some searches i did :

http://vanilla.slitaz.org/index.php?p=/discussion/1032/kernel-2.33.2-fails-to-build.../p1

liblzma-dev is installed

http://comments.gmane.org/gmane.linux.kernel/990416

http://modmymobile.com/forums/558-m...ror-when-building-new-kernel.html#post4103642
[Desire Android Development] Droidzone:
Ok, now time for radical measures :)

Replace your main Makefile with this one
[Desire Android Development] Alex-V:
ok...this should be usefull or..?

http://us.generation-nt.com/patch-fix-checkstack-warning-bunzip2-library-help-198519051.html
[Desire Android Development] Alex-V:
seems to run fine :)

so whats the difference..?

thx
[Desire Android Development] Droidzone:
When we compile anything with gcc we send it special flags to tell it what warnings we want to know, and what not..

Warnings are less serious than errors. They are just to help us fix any possible bugs in the code. They may not even be real bugs either. In case of gcc, compilation takes an additional paramter (option) called -o2 meaning optimization with level 2. Optimization leads to additional warnings.

So when it builds, there is one more paramater for gcc passed from KBUILD_CFLAGS, called -Werror. This is what causes gcc to stop compiling even if there was a warning while compiling, this is called making a warning a hard error. Whether we want it to make it an error or not is decided by the KBUILD_CFLAGS flag called -Werror. If -Werror is set, warnings become errors. So code stops even if the warning is due to optimization of gcc. There are two fixes-one is to turn off the "Make warnings errors" option in Menuconfig. The other option is to search and locate "-Werror" flag within the Makefiles and remove it.

A third and more drastic solution is to tell gcc that we want all warnings to be ignored, and to build even if there are warnings. That's what I did in the second file. I changed this:

KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common \
-Werror-implicit-function-declaration \
-Wno-format-security \
-fno-delete-null-pointer-checks

to this:

KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common \
-Werror-implicit-function-declaration \
-Wno-format-security \
-fno-delete-null-pointer-checks \
-w

Notice the additional -w option. So gcc ignores all warnings. So it builds. :)

It will still stop building if there are real errors, so no need to worry :D
[Desire Android Development] kkrraazzyy:
@ droidzone

hey buddy did this tutorial will also work for other devices
[Desire Android Development] Alex-V:
ah...ok...that i understand... :) big thx for all the good and clear answers...

PS: have now a zImage :) :)
[Desire Android Development] Droidzone:
I have also explained this in my blog here:

http://blog.droidzone.in/2011/12/03/kernel-compilation-flags-a-pain-in-the-a/
[Desire Android Development] Droidzone:
It should work for all Android devices. There are a few places where you need to modify code to change the name to your device's name.. like bravo_defconfig. bravo is Desire.
[Desire Android Development] sthbr82:
Sourcing the bashrc did the trick for me :)

source ~/.bashrc
[Desire Android Development] Alex-V:
running my own kernel now (only thing is a wifi error) anyway :) :) runs great... :)

so one thing again...how can i activate trackball wake..?

with kind regards..Alex
[Desire Android Development] Droidzone:
try running this on your zimage and report back:

file zImage

Hope u copied bcm4329.ko as I explained.

You can add tp wake by adding the patch for that.

wget https://github.com/droidzone/bravo_2.6.35_gb-mr-1/commit/d0e2ce7a98cd606f0dabd512e129593ff6adb91a.patch
patch -p1<d0e2ce7a98cd606f0dabd512e129593ff6adb91a.patch

Now compile again

Credits: snq/bananacakes
[Desire Android Development] Alex-V:
ah..yeah...think not as you explain :o (whats the background..?)

this both things..i will test tomorrow :)

and i say it very often :p but ...thx :)

edit: but running with batt fix
[Desire Android Development] vua777:
must try

bookmark now
[Desire Android Development] Droidzone:
Didnt get that part... :)

Modules are copied like this
[Desire Android Development] Alex-V:
Ok :)

Did you know...how to change the name from the kernel (i mean what you see in info from rom settings)..?

With kind regards..Alex
[Desire Android Development] Droidzone:
It's in menuconfig->general->localversion
[Desire Android Development] Droidzone:
So how did it go? Flashed your own kernel? :)
[Desire Android Development] Alex-V:
yeah...found it :) ;) :p (and also some good and usefull patches from your github..lol...but just make one..with not to much things in...step by step

with kind regards...
[Desire Android Development] Alex-V:
mmmhh...all works perfect...except wifi...logcat says...error in load modul....what can it be...(kernel setup is with modul load)
[Desire Android Development] Droidzone:
Try the file command I told you about:

file zImage
[Desire Android Development] Droidzone:
Ah..Credits for that goes to bananacakes..It's a clone of his git.
[Desire Android Development] Alex-V:
it says : no file...

if i copy the zImage to main folder....it says zImage

what should it say..?

edit: not complete correct...it says zImage data
[Desire Android Development] Droidzone:
Ah..Apparently file doesnt seem to provide info about kernel. I just thought you may have built for a different target architecture. I think you may have to use a different toolchain rather than the latest NDK. Try searching if you can find old NDK with gcc 4.4.0..I have had this issue once a few months back.
[Desire Android Development] DooMLoRD:
good thread!

great work buddy!!!
[Desire Android Development] Droidzone:
I appreciate the feedback, mate!
[Desire Android Development] Alex-V:
Ok..tried with ndk 6...no luck...just downloaded nd 5 with gcc 4.4.0 hope this solves the wifi error...just building a stock kernel (only with ext4 suppurt...to boot)

with kind regards
[Desire Android Development] Alex-V:
mmmhhh...also error on wifi...so what i do wrong (any ideas)

all i did this time....a stock kernel...only add ext4....before i delete the kernel source...copy in not touched kernel source...copied in your makefile (main folder)..delete the ndk ....copy in older v6/5...with gcc 4.40...maked a new bravo_defconfig....and add ext4 over the menu...after that i use:

make ARCH=arm CROSS_COMPILE=arm-linux-androideabi- -j10

and kernel compile without any error or warning.....also if i use some patches-....all work good including trackpad to wake and so...but wifi...gives me error...the ko is from drivers/net/wireless/bcm4329_204/bcm4329.ko

so ..what can be the reason...did i must use a special bcm 4329 or is the default load init scripts...?

with kind regards
[Desire Android Development] ShadowReaperGR:
Thank you for the guide... I have one question. Why it has to be an Ubuntu box? Other distros are not suitable for this?
[Desire Android Development] Droidzone:
Install bananacakes kernel, then get config.gz from his file, then use it as your .config (See first post). That might fix it.

It can be any distro. Ubuntu was the one I wrote the guide for, and it already has all dependencies preinstalled except ncurses. That's all.
[Desire Android Development] Alex-V:
Done...but the same....next try was with your interactive menu...and with this...i saw this:

alexander@alexander:~/android/kernel/bravo_2.6.35_gb-mr$ make
make: arm-eabi-gcc: Kommando nicht gefunden
CHK include/linux/version.h
CHK include/generated/utsrelease.h
make[1]: »include/generated/mach-types.h« ist bereits aktualisiert.
CC kernel/bounds.s
/bin/sh: arm-eabi-gcc: not found
make[1]: *** [kernel/bounds.s] Fehler 127
make: *** [prepare0] Fehler 2
alexander@alexander:~/android/kernel/bravo_2.6.35_gb-mr$

exact look at the picture...(this i saw not without the menu....anyway....can it be the ground why my wifi not work..? also i think my ko is a bit bigger...always over 300kb (most are under 300kb) )

with kind regards
[Desire Android Development] Droidzone:
arm-bravo-gcc is my toolchain. You will have to change the name to the default NDK toolchain (Option: Pick a toolchain).

Can you just see what this command does:
[Desire Android Development] Alex-V:
Mmmh..i'm sure that i select the one from ndk..because i only have this one..if i select the other it dont compile....

I have downloaded a other toolchain..how can i use this instead..?

Will look what : file bcm says if i add home...

Sorry for my many qustions...compile and the kernel itself run without a problem...only the wifi not...
[Desire Android Development] Droidzone:
Use its name in the command line, like "arm-bravo-". You can see the required prefix in bin/ directory of toolchain. Also add that directory to PATH.
[Desire Android Development] Alex-V:
this is the output of find bcm4329.ko

file bcm4329.ko
bcm4329.ko: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped
alexander@alexander:~/android/kernel/bravo_2.6.35_gb-mr/drivers/net/wireless/bcm4329_204$

what you think..?

with kind regards
[Desire Android Development] Alex-V:
ok..will try this..

with kind regards
[Desire Android Development] Droidzone:
It's been compiled for Android.. Sorry, Alex. I dont know of a solution to your issue.
[Desire Android Development] Alex-V:
but thx :)

will try with a other gcc :) its strange as all other things run good :)

with kind regards..Alex
[Desire Android Development] Droidzone:
Yes, try that. I had the exact same issue which was solved only by compiling a new toolchain. But Sibere who used gcc 4.4.0 from old NDK had no issues. Compiling a toolchain can be done with theGanymedes guide, but it's not easy.
[Desire Android Development] Alex-V:
ok ;) i was given gcc 4.4.0 a second chance after i read this...and before i was trying to make a complete toolchain

....and what i should say.,..it works now...no wifi error...will make a package and upload it (i only delete whats in folder toolchain/arm-linux-androideabi-4.4.3 and copy in the files from 4.4.0...)

instead of :

make ARCH=arm CROSS_COMPILE=arm-linux-androideabi- menuconfig / j10 / etc)

i use :

make ARCH=arm CROSS_COMPILE=arm-abi- menuconfig / j10 / etc

so i just want to say...thx :)

with kind regards...Alex
[Desire Android Development] Droidzone:
So it worked with gcc 4.4.0. Excellent! :)
[Desire Android Development] Alex-V:
yes...work :)

so here is the toolchain folder i use...for people who want try...

just delete the toolchain folder from ndk7 and copy this instead....

and use the commends i posted

http://www.multiupload.com/G558AMQZAG

with kind regards
[Desire Android Development] Alex-V:
hey, :)

some github source works just great...and with other i have hunks error...(like add vdd levels)

must i compare all rej file (reject) with the kernel source files....or is there a easier way...?

edit:

i see most its only a space...if i delete the space on eg. _#include from the first error..the file can be patched...is it right..?!?

with kind regards...Alex
[Desire Android Development] D@rekills4:
I yet have to read this whole tutorial but is it necessary to install Ubuntu on a virtual machine or a direct installation would do?
[Desire Android Development] Alex-V:
i have also thought about this...but i have ubuntu as second system...think it would be better
[Desire Android Development] sakindia123:
hey,can u help me a bit?

how does one compile ,say,specific modules like tun.ko?

Regards
[Desire Android Development] Droidzone:
Add the following to .config:

CONFIG_TUN=m
[Desire Android Development] sakindia123:
Hey,does Cyanogen Mod 7 require a special ramdisk,or the stock one would work?
[Desire Android Development] Droidzone:
I'm afraid I have no idea about that..I dont work on Cyanogen.
[Desire Android Development] sakindia123:
oh.....

Do u know how to get the propeitary files from a device?
[Desire Android Development] Droidzone:
That's again an aosp/cyanogen thing, and the instructions on the cyanogen compilation page should give you details as to which script to run. It's really not related to kernels at all. ;)
[Desire Android Development] Alex-V:
for get the ramdisk you can use a working boot.img from cm7 and use the tool from droidzone or the android kitchen from dsixda to unpack boot.img and get ramdisk :)

with kind regards
[Desire Android Development] Droidzone:
I recommend installing it as a seperate OS and dual boot it..You can use VM but compiling is a processor intensive task and it's best to give all cores to it.
[Desire Android Development] Droidzone:
Debugging a running kernel -Error messages

You can get debug messages from a running kernel with:

adb shell
dmesg

If you have reboots due to kernel panic, you should make users capture the last_kmsg log from /proc immediately on the reboot.

adb shell
cat /proc/last_kmsg > /sdcard/last_kmsg

Should be done immediately after the reboot..Otherwise it will just get overwritten by newer kernel message.

Of course you should add your own debug output lines if you're testing some new code.
[Desire Android Development] sakindia123:
@Alex-V:of course i know!i m doing it for a different phone

@Droidzone:HEy,i oc'ed a phone to 1.996 Ghz,it boots and is pretty stable.Now,it also boots @ 2.106 Ghz,but is quite unstable,causes freezeups...

I want to set my kernel in such a way that on boot,frequency will be set @ 1.996 Ghz,i.e. not the max. frequency?

ANy help will be appreciated :)

Github for reference- https://github.com/sakindia123/Cranium_Kernel
[Desire Android Development] Droidzone:
If you're using Adaptive Voltage Scaling (AVS), that parameter is present in the source, namely something like MaxFreqonBoot....open a file avs.c
[Desire Android Development] dhruvbatra205:
Will this work for other devices too?
[Desire Android Development] Droidzone:
Yes it will. Specifics may vary, of course.
[Desire Android Development] ironjon:
Thank you very much for this guide @droidzone, finally I have built my own kernel :D

Only one thing,how can I apply more governors?

Thxx

Tapatalking
[Desire Android Development] Droidzone:
Usually you port them from another kernel of the same/different device. If already implemented by another dev, visit their github and view the diff/patch.
[Desire Android Development] Alex-V:
we know multiupload is down...so here again the toolchain zip

http://alexv.singularity.ro/alex-v-roms/toolchains.zip

with kind regards
[Desire Android Development] ironjon:
Thanks Alex this link works.

Let´s try :)