yashsingh1/xdaforums huggingface dataset:
[Android Software Development] Hammerfest:
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!
[Android Software Development] krabappel2548:
EDIT: never mind, problem solved, what I need to know now won't be solved here :p
[Android Software Development] SystemErrorOne:
I wish i knew how to go about doing this..
[Android Software Development] manoranjan2050:
Thanks

Thanks For ........... i Really need It .........
[Android Software Development] Black_jackss:
If you succeed tell me how to do it in a more familiar way :P
[Android Software Development] brfield:
I get errors regading the processor not being supported?
[Android Software Development] ezterry:
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.
[Android Software Development] :
Great guide. Have the bcm4329 wireless module, so followed the tips and everything compiled and works!

Thanks!
[Android Software Development] jxxhwy:
one question,how to compiled android kernel with -O3 optimization?
[Android Software Development] ezterry:
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
[Android Software Development] jxxhwy:
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
[Android Software Development] ezterry:
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.
[Android Software Development] jxxhwy:
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!!!
[Android Software Development] ezterry:
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.
[Android Software Development] jxxhwy:
issue has been resolved by myslef.Thanks for your time.
[Android Software Development] franciscofranco:
Just want to drop a word of appreciation for the well written guide, it was most enjoyable to read. It's pretty useful for new developers so this should be a sticky.
[Android Software Development] camcory:
This is a great thread and one of the most well laid out how to's on xda. Gotta say thanks. Correct me if I'm wrong but I think there is one typo here.

From the device:

adb pull /proc/config.gz

gzip -dc config.gc > .config

Shouldn't it be gzip -dc config.gz > .config z instead of c.

Anyways like I said awesome work.
[Android Software Development] KOala888:
I fail at:

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 </path/to/>toolchain-4.6.3.cygwin.tar.bz2
[Android Software Development] ezterry:
Well if you don't know where you downloaded the file I sure don't.. really its not this guides job for the following two things:

1) teach basic posix commands (and cygwin in this case uses gnu mostly so most of these commands are identical to popular Linux distros)

2) how cygwin maps a virtual posix drive and the windows drives.

The first Google and man pages can help you out (man is the Unix manual command) the second cygwin documentation will give you all the gory details.

If you can't deal with a Unix shell with the man hint above you are not going to be able to modify the kernel code.. and most likely also fail to build a kernel unless someone already patched it for cygwin.
[Android Software Development] KOala888:
Cygwin replies to me after following instructions:

tar: option requires argument --'f'
[Android Software Development] ezterry:
Copy the text including the command you typed and the error and paste it here in a

tag... make sure the text in the code tag matches what you see on the screen, before pressing send make sure none of the argument flags are missing in your command as this sounds like a user error/typo..

also before replying view the man page for tar and see if that makes tings clear as I asked before. Hint at the cygwin prompt type 'man tar' or enter it into google..
[Android Software Development] engr_exxi:
question. i tried to make tun.ko module using this..

make modules

however there are too many errors..

any idea what went wrong?
[Android Software Development] Miche1asso:
Hi Ezterry,

great job! I downloaded the OS X versions (I am on OS X Lion), and my custom kernel already compiles and boot fine using the 4.4.3 toolchain (the one from the CM). With your toolchain I have some issues and a big problem:

The links /usr/local/toolchain-4.6.3/bin/arm-linux-androideabi-<file> point to a wrong directory:

--> toolchain/arm-linux-androideabi/bin/<file>

toolchain is actually ".." so I fixed them making them pointing to

../arm-linux-androideabi/bin/<file>

I use macport for the GNUbins and they are the first in the $PATH (like stat). The kernel DOES compile, but when I boot it after flashing.. I get the blank screen/soft brick. adb isn't working, OS X isn't even recognizing a new USB device in the console.

Did you test the toolchain with OS X (hopefully Lion)? Any idea about what I am doing wrong? The only difference I see is that my elf.h file came from somewhere and it is much more complete than the one included in the toolchain. It does the job with 4.4.3

Other than that, I don't know. I can't provide much more info, soft bricks are my worst nightmare.

PS: How did you manage to make it so small?
[Android Software Development] ezterry:
Test of course but only with my a500 kernel source code.. as soon as you are using another codebase tweaks are always sometimes required.

As for your path errors this means you did not set up your environment correctly and/or someone else made environment assumptions in your make scripts. My instructions ought to show how to set up the environment for a generic kernel (ie how official Linux releases are provided) and most venders seem to provide the code. However many devs on xda get "smart" and add environment assumptions into their distributed build scripts.. if this includes something about the compiler to be used you may have issues.

As for Lion, no, I'm multiple versions out of date.. however if the executables ran the target ought not be impacted by this. (I've mostly stopped running osx its lost most of its advantages as it threatens to become more like iOS)

Some things to look into are:

1) Did you correctly build a boot.img or equivalent for your device with any device specific requirements.

2) did you install, attempt to boot, then check for last_kmsg in recovery or when booting a similar (ie same memory mapping) kernel to see the kernel log from the failed boot and thus see any error.

Since you have no issue with running the compiler that I can see there is not much for me to do without seeing what it is you are trying to compile and any error when it tries to load.
[Android Software Development] Miche1asso:
I don't know… Honestly this is the 3rd 4.6.7 toolchain I tried and they all gave the same problem. I am starting to believe there is something wrong with the Samsung source code for my phone, it may not like the newer compiler. yes, it compiles but then it hangs at the boot time.
[Android Software Development] greeneyes2910:
Hi Terry, I hope u or another greatful Dev could help and teach me next lesson on compiling Kernel via Cygwin...

Could Someone of you explain, how to compile single wpa_supplicant, e.g. with the using of cygwin? Machine is set up by using this thread. Kernel Compiling is possible, but to get wifi working, I definitly need wpa_supplicant_6, which matches with my compiled Boot.img.

Also I need to know, how to get /compile fw_bcm4329.bin to match with my compiled kernel & in fact with the device.

Or could I take any compiled fw_bin, I found in other Roms / maybe from other devices ? And does they work also with Htc Desire & especially with every kernel, which has built.in Access for fw_bcm4329 / fw_bcm4330???

Thx for your help
[Android Software Development] ezterry:
wpa_supplement is a usersapce program.. as long as you have the same API to the kernel module you ought to be able to use the existing one in your ROM. This is the assumption on the a500 that is working so far.

If there was a change required in usersapce on Linux you can use the android build system to re-build wpa_supplement with the updated source .. the same idea may work for cygwin but some tweaks will be needed for it to find the native cygwin compiler.. and maybe to ignore java I've not tried yet.

One thing to check is dmesg to make sure you are not having any issues loading the kernel module.. if so just apply the relevant path in the op.

Last you mention the firmware.. this is a binary that is uploaded to the WiFi device and runs on that not the arm processor we use for Linux. Thus you ought to use the existing firmware unless you have a more stable update from somewhere.. these usually are not open source as its not part of the kernel.
[Android Software Development] greeneyes2910:
Looooool , it seems I´ll become your problem-child :)

So, this time I´ve fresh installed Windows 7 Pro, 32 Bit ~ Set all up,, changed regedit to 0, rebooted, but every source I fetched, or tarball I untar, there are always missing files , especially in netfilter like xt_hl.c ~ xt_HL.c.

So what could I do???

Also I wanna ask you to help me, or better said all Desire Users, in compiling Kernel 3 because of the fact, that every Dev graded up to newer Devices and only some people like me, who are learning to develop step by step, not confirm in doing this ( alltough it get better, week by week :laugh:)

thx

Dennis
[Android Software Development] ezterry:
start simple, get some source someone else already has working.. upgrading kernel versions takes much manual merging even with gits help.. and fixing code, and quite a bit of debugging, before changing code beyond minimal patches to correct the build, you just want to build a kernel already known to work first.

If you have an official code drop and a config.. and link us to them maybe someone can help make sure it builds.. but even if it builds someone with the device needs to install and test it as well.

Last: about the filesystem/case sensitivity.. if you untar the kernel with cygwin it ought to be fine (unless the person who tared it goofed) but if you untar with a windows app it may assume things are case sensitive and fail to provide any overlapping files.
[Android Software Development] manoranjan2050:
Downloading CygWin ver .. For Testing........... Hope its Great :good::good:
[Android Software Development] it's:
Hi all,

Downloaded the new toolchain to use with cygwin, but doesn't want to compile the kernel... I get the following error:

Admin@Admin-PC /cygdrive/c/cygwin/usr/src/AN8CG3/kernel

$ make

/bin/sh: arm-linux=androideabi-gcc: command not found

scripts/kconfig/conf --silentoldconfig Kconfig

/bin/sh: arm-linux=androideabi-gcc: command not found

CHK include/linux/version.h

CHK include/generated/utsrelease.h

make[1]: 'include/generated/mach-types.h' is updated.

CC kernel/bounds.s

/bin/sh: arm-linux=androideabi-gcc: command not found

/cygdrive/c/cygwin/usr/src/AN8CG3/kernel/./Kbuild:35: recipe for target `kernel/bounds.s' failed

make[1]: *** [kernel/bounds.s] Error 127

Makefile:991: recipe for target `prepare0' failed

make: *** [prepare0] Error 2

Admin@Admin-PC /cygdrive/c/cygwin/usr/src/AN8CG3/kernel

Any ideas what might be wrong here? It doesn't want to compile with the stock toolchain either, maybe because I use it on cygwin... These are the stock sources though I am using...
[Android Software Development] ezterry:
Check that you updated your PATH variable correctly in step 4 of the example build instructions

Once you update the path you ought to be able to run:

arm-linux-androideabi-gcc --version

without error

If you get an error its not found the Path is wrong
[Android Software Development] it's:
Thanks, it did the trick. (my $HOME directory was different than what I thought it would be)

Now I get the following error with the compiling:

I assume it is the bug of the kernel sources?
[Android Software Development] ezterry:
Could be a few things, but there is no source code ref in the part of the log shown..

Try running make again (optionally w/o the -j option) it sometimes makes the real error easier to find.

(The j option specifies the number of jobs running at once.. but sometimes a job will build many more files after one of the jobs fail. This causes the build to fail but there can be quite a bit of irrelevant output between the error and make exiting.. re running the command without running clean usually just spits out the real error with less other output.
[Android Software Development] trevd:
Hi There,

I'll give your linux toolchain a blast with the Archos G9 sources, it a OMAP4430 based kernel, I've got toolchains to build it alright, I've found classic "libc" toolchains ( both the standard android and a linaro optimzed ) bork because their assembler don't support the arm instruction "smc #0" which I used in arch/arm/mm/proc-v7.S. workarounds do exist and it's clearly this is not a uncommon issue in japan at least :) Archos use buildroot to fulfil their GPL License Requirements and as such a uclibc based toolchain to build it succesfully. But If I've learned anything this past year it's that the libc flavour doesn't really have any effect here, they more than like just patched the support in :)

I'll give this one a spin and report back

Nice Work By the way, you are a more patient man than I :)
[Android Software Development] maxrdlf95:
Hey man I've followed your guide I got all Setup but I got this when trying to make the config file

$ make tf700t_defconfig

HOSTCC scripts/basic/fixdep

scripts/basic/fixdep.c: In function `parse_config_file':

scripts/basic/fixdep.c:255: aviso: el subíndice de la matriz tiene tipo `char'

scripts/basic/fixdep.c: In function `parse_dep_file':

scripts/basic/fixdep.c:342: aviso: el subíndice de la matriz tiene tipo `char'

/bin/sh: scripts/basic/fixdep: no se puede ejecutar el fichero binario

scripts/Makefile.host:118: recipe for target `scripts/basic/fixdep' failed

make[1]: *** [scripts/basic/fixdep] Error 126

Makefile:412: recipe for target `scripts_basic' failed

make: *** [scripts_basic] Error 2
[Android Software Development] carl1961:
uncompress

for us Newbee's (Me)

I needed to unpack kernel source

tar xvzf file-1.0.tar.gz - to uncompress a gzip tar file (.tgz or .tar.gz)

tar xvjf file-1.0.tar.bz2 - to uncompress a bzip2 tar file (.tbz or .tar.bz2)

tar xvf file-1.0.tar - to uncompressed tar file (.tar)

x = eXtract, this indicated an extraction c = create to create )

v = verbose (optional) the files with relative locations will be displayed.

z = gzip-ped; j = bzip2-zipped

f = from/to file ... (what is next after the f is the archive file)

also unzipping with 7-zip in windows and coping to cygwin is not good (look at photo) left is 7-zip
[Android Software Development] greeneyes2910:
Hi Terry,

I hope u will have a answer for me.So if u compile a kernel , you have xy source code from which you access all needed & touched drivers, binaries and device specific files, to be compiled into kernel.

So where are all these files located on device. I mentioned out, that several directory will be store on -d.

Our Kernel Source isn´t really provided so far. Where could I find the board-files after flashing kernel to device?
[Android Software Development] ezterry:
The kernel source code isn't on the device.. As per the GPL however person giving you the kernel is responsible to give you the code.. Usually the phone carriers punt this to the phone creators who actually created the kernel for the device originally. If you don't have the source, search for it.. if you can't find it you can request per the GPL to the creator of your phone.

In some cases there will be a closed source module that you do not have the source for.. or more likely a firmware for an on board device that the kernel uploads to the device to be executed by the device and thus allow communication with the kernel.. The modules can be anywhere but. usually are in /system/lib/modules or the root of the ramdisk, but not always.. The firmware [to be run on the hardware component] is almost always in /system/etc/firmware .. If this is the case they will be in your rom or ramdisk.. and not directly in the kernel its self.

(Thus far the devices I've worked with very little in the way of proprietary modules.. of course special components and libraries may be needed for the android framework to make the hardware provide useful information to android applications. Camera APIs in particular seem to frequently just provide very low level access for the userspace library which must do the heavy lifting to make the camera actually record an image or video)
[Android Software Development] klacenas:
I knew there was always a way to do these things in cygwin :D

Good Job.
[Android Software Development] rivelta:
how to enable kernel with swap memory feature?
[Android Software Development] Thunder07:
Hi ezterry,

i've always wanted to do a bit of kernel developement, but i was too lazy to install ubuntu....

so this did the trick for me :good:

however, after installed this, i tried to compile to kernels without editing anything in them,

i keep getting this error :confused:

$ make
CHK include/linux/version.h
CHK include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
CC kernel/bounds.s
/home/Mahmood/android/Endeavor3.1.10/./Kbuild:35: recipe for target `kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 127
Makefile:990: recipe for target `prepare0' failed
make: *** [prepare0] Error 2
[Android Software Development] packhex:
HI!

I'm use os x.

receive this error

make: ccache: Command not found

HOSTCC scripts/basic/fixdep

/bin/sh: ccache: command not found

make[2]: *** [scripts/basic/fixdep] Error 127

make[1]: *** [scripts_basic] Error 2

make: Nothing to be done for `make_defconfig.sh'.

Thanks
[Android Software Development] greeneyes2910:
need some help

Hi Terry,

some time ago since I´ve contacted you. Hope you are fine and could give me new teach lesson...

Actually I am on Desire X Device, which could not set to s-off or change cid into supercid at the moment.

As I knew from my sapphire device experiences, you have hexedited 1.33.2013 Bootloader for it.

I hope you could help me or even told me , how I could do this with Desire X Bootloader. Especially how to create it with same md5 checksum as the original, or how to bypass the md5 check for flashing new hboot.

I tried a lot, but really don´t find any or right lecture on google for doing hboot development.

Also it would & could be help if you can give me some advice in bypassing emmc write protection, for changing cid into supercid , or do some help in rewriting Firerats SPL-Spoof script for Desire X Device.

Thx and Greets

Dennis
[Android Software Development] werty100:
/bin/sh: Users/huaweiselona/toolchain-4.6.3/arm-linux-androideabigcc: No such file or directory

Some one helps my
[Android Software Development] hell_lock:
You have set the wrong location for toolchain.
[Android Software Development] Noob_XDA:
Compiling in Windows

Dear OP, big thanks to your great tutorial.

I'm a windows user & was attracted to your post by the possibility of kernel compilation in windows.

Would like to share my experience with everyone.

1. Tried with cygwin but found out that my phone's kernel source fixdep files contain ELF binaries which cygwin doesn't support.

2. Contemplated using virtual machine to run Linux but my laptop spec is too low. Found out another way to run Linux

in windows by installing andLinux http://www.andlinux.org/. It is fast as everything is integrated into windows.

But installing, configuring & updating it is not easy.

3. Tried with your Linux toolchain in andLinux and found out that the Glibc version in andLinux [ubuntu 9.04] is outdated.

Again I was in a bind. Found out most toolchains were compiled on newer Linux distro and require newer Glibc version.

4. After much searching, found 2 options, use older toolchain [found a 4.4.3 that works] or use one with built in Glibc

such as Codesourcery.

5. Now I'm able to compile in Win7 running andLinux.

Thank you for your tutorial.:good: