[DEV][GUIDE] Kernel Building Instructions for Xperia L - Sony Xperia L

What you need to know beforehand?
1. You'll need an unlocked device.
2. Device Info :
Official name - Xperia L
Codename - TaoShan/sa77
Model no - C2104/C2105/S36h
Chipset - Qualcomm Snapdragon MSM8230
Sources can be found on official open source archive website.
Let's take 15.0.A.1.36 for now.
I'm now assuming that you've set your toolchain path beforehand. I would recommend editing .bashrc.
For example I've set my toolchain (Google gcc 4.7) path like this -
Code:
export PATH=$PATH:/home/rachit/android/toolchains/google/bin
Alternatively, you can define it in your build script or enter everytime you plan to compile ( which is hefty ).
It's better if you remove werror/wall flags beforehand.
You can also suppress all warnings with -w flag ( Not recommended )
Step 1. Getting the defconfig
You can get defconfig in 2 ways.
From device;
Code:
adb pull /proc/config.gz
From source:
Code:
sa77_defconfig
Step 2. Import defconfig
Code:
ARCH=arm CROSS_COMPILE=arm-linux-androideabi- make [COLOR="Red"]sa77_defconfig[/COLOR]
Step 3. Build zImage
Code:
ARCH=arm CROSS_COMPILE=arm-linux-androideabi- make -j[COLOR="Red"]x[/COLOR] (Replace x with twice the number of cores your processor has)
In case you get error like :
Code:
error : /scripts/gcc-wrapper.py
Set permissions to executable
Code:
chmod +x ./scripts/gcc-wrapper.py
Building boot.img :
Currently only .img format is supported. You can also make an elf but device doesn't accept it.
Code:
mkbootimg --base 0x80200000 --kernel kernel/arch/arm/boot/zImage --ramdisk_offset 0x02000000 --cmdline "console=ttyHSL0,115200,n8 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3F ehci-hcd.park=3" --ramdisk ramdisk.img --pagesize 4096 -o boot.img
Flashing instructions :
Code:
fastboot flash boot boot.img
Unpacking instructions :
Use my boot.img unpack/repack tool from here
* Use pack-sa77.sh while repacking

Defconfig should be in the sources

Hello, I bought Xperia L today...Are you working on any ROM for this device?

linaro toolchain
Does that matter if my toolchain is (linaro) prefixed linaro-arm-linux-gnueabihf rather than arm-linux-androideabi
What does the "hf" at the end of my toolchain symbolize ?
I downlaoded the toolchain from http://www.linaro.org/downloads/

jayaura said:
Does that matter if my toolchain is (linaro) prefixed linaro-arm-linux-gnueabihf rather than arm-linux-androideabi
What does the "hf" at the end of my toolchain symbolize ?
I downlaoded the toolchain from http://www.linaro.org/downloads/
Click to expand...
Click to collapse
You can use exact same command as I've used with google gcc
arm-linux-androideabi-

Rachit Rawat said:
You can use exact same command as I've used with google gcc
arm-linux-androideabi-
Click to expand...
Click to collapse
Well. Sure I can. I think you didnt get my question. I just wanted to know if there is any serious technical difference with andriod eabi from google and linux eabi from linaro? I mean both of these are *NOT* bare metal toolchains right? I believe a kernel built with either of the two toolchains shoul work on the same device. Or am I wrong?
Sent from my C2105 using xda app-developers app

jayaura said:
Well. Sure I can. I think you didnt get my question. I just wanted to know if there is any serious technical difference with andriod eabi from google and linux eabi from linaro? I mean both of these are *NOT* bare metal toolchains right? I believe a kernel built with either of the two toolchains shoul work on the same device. Or am I wrong?
Sent from my C2105 using xda app-developers app
Click to expand...
Click to collapse
This will clear all your doubts
Linaro GCC is performance focused branch of the current GCC stable release and includes backports of the improvements and bug fixes that Linaro and others have done upstream.
Click to expand...
Click to collapse
As you can see, linaro is just a patched GCC with some optimizations. A kernel built with any android toolchain viz Google, linaro, code sourcery, sabermod etc will work on the same device ( In most cases )

Thank you very much boss!
Sent from my C2105 using xda app-developers app

Where is the RAMDISK files

yajnab said:
Where is the RAMDISK files
Click to expand...
Click to collapse
You can extract ramdisk from stock kernel.

How much a msm8227 is different from msm8230 ?
Is portinv possible from 8230 to 8227 ?
sent from my tipo ss

Related

[GUIDE] How to compile Sidekick 4G Kernel [Ubuntu]

1) download source code from https://opensource.samsung.com/index.jsp. You are looking for source code for SGH-T839.
2) Get initramfs (Need to make a kernel package)
Extract it using extract boot http://www.mediafire.com/?lc12eceeh617b97.
This is why I am looking for a boot.img
extract it
Code:
tar -xvf extractboot.tar.gz
now move into directory with extract boot and copy your boot.img into here and do
Code:
./extractboot boot.img
3) Get mkboot tools
http://www.mediafire.com/?w06d1m6n1dgo4op
untar it by doing
Code:
tar -xvf $FILENAMEHERE
Add the bin directory to your path by moving to the bin directory and copying down the path then
Now you will add this to your path by editing your .bashrc file.
Go to your bashrc file
Code:
gedit ~/.bashrc
and adding this
Code:
PATH=$PATH:/FULLDIRECTORYYOUWROTEDOWN/
export PATH
4) Download the ARM toolchain
https://sourcery.mentor.com/sgpp/lite/arm/portal/package5385/public/arm-none-linux-gnueabi/arm-2009q3-67-arm-none-linux-gnueabi.bin
and
https://sourcery.mentor.com/sgpp/lite/arm/portal/package5355/public/arm-none-eabi/arm-2009q3-68-arm-none-eabi.bin
5) Install the ARM Toolchain
create the directory /opt/toolchains/arm-2009q3/
Code:
sudo mkdir /opt/toolchains/arm-2009q3/
then install the toolchain using /opt/toolchains/arm-2009q3/
as the install directory
Code:
sudo chmod +x arm-2009q3-68-arm-none-eabi.bin
sudo chmod +x arm-2009q3-67-arm-none-linux-gnueabi.bin
sudo ./arm-2009q3-67-arm-none-linux-gnueabi.bin -i console
sudo ./arm-2009q3-68-arm-none-eabi.bin -i console
6) Compile
Extract your source code and go to the directory Kernel and do the following
WARNING: MAKE SURE THERE ARE NO SPACES IN YOUR FILEPATH BECAUSE THE MAKEFILE DOESNT LIKE THEM.
Code:
make clean
make arch=arm sidekick_rev02_defconfig
make ARCH=arm HOSTCFLAGS="-g -O3" -j8 CROSS_COMPILE=/opt/toolchain/bin/arm-none-eabi-
Now copy any of the resulting compiled ko files into the initramfs file you have extracted and you should have what you need to package a kernel.
you forget initramfs
windxixi said:
you forget initramfs
Click to expand...
Click to collapse
yeah I kept it out so that somebody would post a boot.img then could do steps related to that. I am looking for a boot.img to get initramfs from
unpack zImage
Sent from my SGH-T839 using XDA
---------- Post added at 08:46 AM ---------- Previous post was at 07:49 AM ----------
and how to pack a boot.img?
A request to anyone building SK4G kernels.
Please disable the keystroke logging printk statements in the file:
Code:
drivers/input/keyboard/s3c-keypad.c
The lines look like this:
Code:
//printk("\nkey Pressed : key %d map %d\n",i, pdata->keycodes[i]);
and
Code:
//printk("\nkey Released : %d map %d\n",i,pdata->keycodes[i]);
It is possible to recover the actual keystrokes from the numerical codes those statements log, and the messages go into the dmesg buffer. So it's pretty easy to extract them and determine exactly what the user typed.
In the latest Samsung sources I've seen, those lines were already commented out. It makes sense to enable them while debugging a new ROM build, but please do disable them prior to building a kernel intended for general consumption.
Do you guys know if the available source code will produce a kernel that will work with kj2? the kernel version in SGH-T839_Opensource_Update1 looks to match up, but I compilied a zImage and it didn't boot on stock kj2. but I could very well be missing something.
I have done a small amount of kernel work on an HTC device, but I basically just used the Rom Kitchen to pack up my zImages with a boot.img-ramdisk to create a boot.img. I guess I might need a little more instruction for packing up a Samsung kernel. Is it also an option to just tar up the zImage and flash it with Odin/Heindall?
Thanks for this thread, and for any other advice!
Sent from my SGH-T839 using Tapatalk 2
In case it might be useful to someone else working on building a kernel.
The official and Bali_SK4G sources both seem to insist on building with debug symbols enabled for some of the modules. In particular, i was ending up with dhd.ko being 2.4 MB in size, where it should have been less than 400 KB.
The ideal case would be to determine why the debug symbols are being included -- commenting out the labelled debug options in the bcm4329 Makefile didn't accomplish this.
But a workaround is to strip the modules after the build is finished, before assembling the initramfs.
Has anyone been able to build a working zImage for KJ2 using Dr. Honk's Bali sources [1] and sduvick's KJ2 ramdisk files [2]?
I have been able to build a zImage of a reasonable size (6520 KB). But when I flash this to the KERNEL partition using heimdall, the device boot loops to the B&W Sidekick logo. It doesn't get far enough to show any adb log output.
I can then use the same heimdall flashing procedure to flash the Platypus Egg v1 zImage, or other KJ2-compatible zImage files, and the device boots and works properly.
So I'm trying to figure out what I'm doing wrong in building my zImage. If anyone has any advice I would be appreciative.
[1] https://github.com/drhonk/Bali_SK4G
[2] https://github.com/sduvick/SK4g_KJ2_Ramdisk
I got an updated Bali_SK4G kernel booting using the ramdisk from GenericGinger 2.0.
I have worked up some patches to disable the logging of keystrokes and other more trivial debug spew in dmesg. Also included is a Makefile patch that was required for the compile to complete with my toolchain.
https://carbon.flatlan.net/nxd/patches_Bali_SK4G_nxd.tar.bz2
md5sum: 5d14ac32de155cdca0fd82f14bc4ceca
These patches are GPL licensed, in compliance with the license for the Linux kernel itself. I make no guarantees about their suitability for any purpose. I grant permission to use them to anyone who would like to do so, so long as they comply with the GPL.
I'd like to make a compiled kernel available with these changes, but XDA's rules can be interpreted to mean that I must obtain permission from a series of upstream contributors, some of whom may not be reachable. Perhaps a moderator will clarify the parameters of the permission rule.

[R+D]Native GCC 4.6.0 + Binutils 2.22 ----- Bionic Arms Attached :)

Hi Folks
Here's a native Bonic GNU GCC ( 4.6.0 ) + BinUtils ( 2.22 ) compiled for armv7-a with c and c++ support!
Testing:
I used an HTC Sensation running CM9 for testing
[EDIT:] Using JB 4.2.1 on a Nexus 7 causes a segmentation fault when trying to compile...... Investigation Continues!
Installing:
Download and unpack this archive [ bionic_gcc_binutils.7z ]
copy the directories to the /system directory ,
adb push whilst in the directory you extracted the download to should do the trick
adb push . /system
Test the gcc
Code:
adb shell gcc /system/usr/src/hello.c -o /system/bin/hello
adb shell hello
HELLO OUTPUT: Hello Bionic
Check the Dynamic Linker
Code:
adb shell readelf -l /system/bin/hello | grep 'linker'
OUTPUT: [Requesting program interpreter: /system/bin/linker]
The GNU linker - ld
ld currently only has one search path by default, that is /system/lib, you must manually set links to other location ( i.e /vendor/lib )
Getting Help - RTFM ( Read The F***king Manual )
No seriously the man and info pages can be found in the share directory in the archive
Personal Thoughts
Although GCC is a very mature project, I'd still consider this as PRE-ALPHA R&D as I'm certainly not an expert when it comes to toolchains etc. I basically used a bruteforce attack to build this. which involves compile - test - tweak/fix - rinse - repeat and stop when it looks about right So I could have quite easily misconfigured a compiler flag or patch a file in an inappropriate manner which may manifest itself further down the line.
I suppose the acid test would be to try and compile the linux kernel using this toolchain.
I had a search around to see if this had already been covered, It looks like the C4Droid project has it covered, at a cost!! but I do see the question on native compilation come up every now and again so hopefully this should help some folks out at least.
I'm curious, although this is old by now, what CFLAGS (and other environment variable settings) and configure options did you use in order to get that to compile? I've messed around with gcc 4.9.1 and binutils 2.24 using the android toolchain from NDK version r9d, and haven't had any luck.
jdmanley87 said:
I'm curious, although this is old by now, what CFLAGS (and other environment variable settings) and configure options did you use in order to get that to compile? I've messed around with gcc 4.9.1 and binutils 2.24 using the android toolchain from NDK version r9d, and haven't had any luck.
Click to expand...
Click to collapse
Are you still curious about this? I did this just recently and it took quite a while to find the right configurations and flags.
I'd be happy to post the output of 'gcc -v' or show what config parameters I used
Surge1223 said:
Are you still curious about this? I did this just recently and it took quite a while to find the right configurations and flags.
I'd be happy to post the output of 'gcc -v' or show what config parameters I used
Click to expand...
Click to collapse
please share

[KERNEL] Stock Kernel (no write protection)

This is the stock kernel without system write protection. Completely stock configuration, completely stock ramdisk. The only difference is it allows write to system
Uses Telstra 3.17.841.2 source from htcdev.com:
http://dl4.htc.com/RomCode/Source_and_Binaries/evitaul-jb-crc-3.4.10-240d4d5.zip
Devs who need a vanilla kernel are free to modify or include with ROMs
installer: http://goo.gl/64HJc
boot.img: http://goo.gl/IRZ9m
Does this also uninstall any old modules?
Sent from my VENOMized HoxL
area51avenger said:
Does this also uninstall any old modules?
Sent from my VENOMized HoxL
Click to expand...
Click to collapse
The installer deletes /system/lib/modules/wp_mod.ko and /system/lib/wp_mod.ko
There is no init.d support either, so it won't load any init scripts.
Nice job, this should be useful! :good:
On my side, I had some problems. I have tried to compile the kernel, but I went a little bit further with the modifications:
disabled the /system write protection.
integrated the prima_wlan source tree in drivers/staging. The sources were downloaded from the codeaurora.org site and the driver version was 3.1.7.16 (I have specifically chosen this version because it was the closest to the 3.1.7.0 version that exists in the stock ROM).
compressed the vmlinux image with LZMA instead of gzip (this is an option in the configuration) to obtain the zImage file.
compressed the ramdisk image with LZMA instead of gzip (in the configuration file, I have seen 3 enabled options: gzip, LZMA and XZ and I thought recompressing the ramdisk might not hurt).
The toolchain I have used was downloaded from android.googlesource.com. Then I have unpacked the original boot.img like this: trimmed the first 128 bytes from the file (up to the ANDROID magic label), then used the unpackbootimg tool (this was a tool I have found in a Gingerbread source tree). Then, I have used the new zImg, the LZMA compressed ramdisk and mkbootimg (this was also picked from the same Gingebread source tree) to build a new boot.img. I have booted in the recovery, flashed the new modules, then booted in fastboot mode and flashed the boot.img. The result was an annoying boot loop and it wasn't very easy to put the phone in fastboot mode again.
I have some questions about what I have done so far. Could you, please, tell me if there was a wrong manoeuvre/setting/thingie? I suspect the unpacking process has not produced the proper data (command line, base address ...). What tool have you used to unpack the original boot.img file? I also suspect the packing process. Is a new mkbootimg required?
And some questions about your work. What prima_wlan driver have you used in your boot.img? Have you modified the suffix added to the 3.4.10 version when you have configured the kernel in order to make it work?
AlxMAX said:
On my side, I had some problems. I have tried to compile the kernel, but I went a little bit further with the modifications:
disabled the /system write protection.
integrated the prima_wlan source tree in drivers/staging. The sources were downloaded from the codeaurora.org site and the driver version was 3.1.7.16 (I have specifically chosen this version because it was the closest to the 3.1.7.0 version that exists in the stock ROM).
compressed the vmlinux image with LZMA instead of gzip (this is an option in the configuration) to obtain the zImage file.
compressed the ramdisk image with LZMA instead of gzip (in the configuration file, I have seen 3 enabled options: gzip, LZMA and XZ and I thought recompressing the ramdisk might not hurt).
The toolchain I have used was downloaded from android.googlesource.com. Then I have unpacked the original boot.img like this: trimmed the first 128 bytes from the file (up to the ANDROID magic label), then used the unpackbootimg tool (this was a tool I have found in a Gingerbread source tree). Then, I have used the new zImg, the LZMA compressed ramdisk and mkbootimg (this was also picked from the same Gingebread source tree) to build a new boot.img. I have booted in the recovery, flashed the new modules, then booted in fastboot mode and flashed the boot.img. The result was an annoying boot loop and it wasn't very easy to put the phone in fastboot mode again.
I have some questions about what I have done so far. Could you, please, tell me if there was a wrong manoeuvre/setting/thingie? I suspect the unpacking process has not produced the proper data (command line, base address ...). What tool have you used to unpack the original boot.img file? I also suspect the packing process. Is a new mkbootimg required?
And some questions about your work. What prima_wlan driver have you used in your boot.img? Have you modified the suffix added to the 3.4.10 version when you have configured the kernel in order to make it work?
Click to expand...
Click to collapse
use dsi xda kitchen to pack the boot.img for easy use
or
use this
unpackbootimg -i boot.img -o /directoryfordump
mkbootimg --cmdline 'console=ttyHSL0,115200,n8' --kernel zImage --ramdisk ramdisknew.gz --base 80400000 --ramdiskaddr 81900000 -o newboot.img
Where have you got that ramdisk address from? unpackbootimg doesn't report it.
Zarboz said:
mkbootimg --cmdline 'console=ttyHSL0,115200,n8' --kernel zImage --ramdisk ramdisknew.gz --base 80400000 --ramdiskaddr 81900000 -o newboot.img
Click to expand...
Click to collapse
Edit: I have done some research on mkbootimg and unpackbootimg and their usage is a little bit confusing. The boot image header contains a kernel address, a ramdisk address and some other data (including the command line provided to the kernel by the bootloader). The mkbootimg tool like it is in the Android repository uses more measures: a base address, a kernel offset, a ramdisk offset etc. The kernel address is base + kernel offset and so on. When unpacking the boot image with unpackbootimg, one must suppose one of the parameters fixed, usually the kernel offset (0x00008000). Consequently, the base address is computed as the kernel address - the kernel offset. To conclude, the command line to use should be:
Code:
mkbootimg --cmdline 'console=ttyHSL0,115200,n8' --base 80400000 --ramdisk_offset 1408000 --kernel boot.img-zImage --ramdisk boot.img-ramdisk.gz -o boot-2.img
This produces the same boot.img as the one posted by flar2, except for the command line.
Edit 2: I have recompiled the kernel, disabled the /system protection, used the mkbootimg command line right above and now my phone boots and runs well. The prima_wlan.ko that I have compiled together with the kernel (3.1.7.16 from codeaurora source repository) doesn't work. It might be a matter of wi-fi firmware. Fortunately, the stock prima_wlan.ko (proprietary 3.1.7.0) module works well.
AlxMAX said:
Where have you got that ramdisk address from? unpackbootimg doesn't report it.
Edit: I have done some research on mkbootimg and unpackbootimg and their usage is a little bit confusing. The boot image header contains a kernel address, a ramdisk address and some other data (including the command line provided to the kernel by the bootloader). The mkbootimg tool like it is in the Android repository uses more measures: a base address, a kernel offset, a ramdisk offset etc. The kernel address is base + kernel offset and so on. When unpacking the boot image with unpackbootimg, one must suppose one of the parameters fixed, usually the kernel offset (0x00008000). Consequently, the base address is computed as the kernel address - the kernel offset. To conclude, the command line to use should be:
Code:
mkbootimg --cmdline 'console=ttyHSL0,115200,n8' --base 80400000 --ramdisk_offset 1408000 --kernel boot.img-zImage --ramdisk boot.img-ramdisk.gz -o boot-2.img
This produces the same boot.img as the one posted by flar2, except for the command line.
Edit 2: I have recompiled the kernel, disabled the /system protection, used the mkbootimg command line right above and now my phone boots and runs well. The prima_wlan.ko that I have compiled together with the kernel (3.1.7.16 from codeaurora source repository) doesn't work. It might be a matter of wi-fi firmware. Fortunately, the stock prima_wlan.ko (proprietary 3.1.7.0) module works well.
Click to expand...
Click to collapse
you have to do some haxxing to get the CAF prima to load up
Zarboz said:
you have to do some haxxing to get the CAF prima to load up
Click to expand...
Click to collapse
I am interested of that hack. Could you, please, send me a link to some documentation about it?
AlxMAX said:
I am interested of that hack. Could you, please, send me a link to some documentation about it?
Click to expand...
Click to collapse
There isn't any I have found just trial and error
Sent from my HTC One X using xda app-developers app
Zarboz said:
There isn't any I have found just trial and error
Click to expand...
Click to collapse
If you are referring to the code enclosed by #ifdef CONFIG_HTC_WIFI_NVS ... #endif in wlan_hdd_main.c, then it is not simple trial and error. Have you picked the code from somewhere else and integrated into the prima sources or have you found the prima sources containing already that piece of code?

[GUIDE] How to Build and Package a Kernel [D2]

This thread aims to be a comprehensive guide to building and packaging kernels for US Variant Samsung Galaxy SIIIs
In my opinion, a kernel is a great way to get into building things for your device and its pretty easy to do too.
Intro
What is a kernel?
http://en.wikipedia.org/wiki/Kernel_(computing)
This guide is for US SGSIII's (d2att,d2cri,d2mtr,d2spr,d2tmo,d2usc,d2vzw,others?)
It may be possible to adapt this to other devices, but I am not responsible for anything that happens should you try to do this.
This guide assumes you have a general knowledge of the Linux operating system. If you've never used it, you might consider playing around
with it for awhile before attempting this guide.
Click to expand...
Click to collapse
Prerequisites
On all devices you must be rooted, on Verizon SGS3 (d2vzw) you must also have the unlocked (VRALE6) bootloader installed.
This is not the thread for figuring out how to do this. You can use the forum's search function to figure out how to do this on your device.
You'll need a computer or a virtual machine running ubuntu. You may be able to figure out how to get this working on other distributions,
but since ubuntu is generally the most accepted distribution to use for building android things, I'll stick to using that here.
At the time of this writing, I'm using ubuntu 12.10, 64-bit.
You'll need to install some packages on your ubuntu machine:
Code:
sudo apt-get install build-essential git zip unzip
On 64-bit you'll also need some multilib and 32-bit compatibility packages:
Code:
sudo apt-get install gcc-multilib g++-multilib lib32z1-dev
Click to expand...
Click to collapse
Setting up the Build Environment
Next, you'll need a toolchain which is used to actually build the kernel. You may download one of these:
GCC 4.4.3: Download || Mirror
GCC 4.6: Download || Mirror
GCC 4.7: Download || Mirror
If you aren't sure, go for 4.4.3 or 4.6.
4.7 requires some code changes to work. The original kernel developer may or may not have made these changes.
Here is what I needed to do in order for 4.7 to build, boot and have wifi work:
https://github.com/invisiblek/linux-msm-d2/commit/f8d7199d37cfbfa1bcb6b4bcae3fc15ae71fbdea
https://github.com/invisiblek/linux-msm-d2/commit/ea58076501e5874db7b934c215c4dae81ddfd0a6
The toolchains are also available in the android NDK.
*** There are many toolchains out there, some of you may know of the Linaro toolchain which is aimed to optimize your binary even further ***
*** If you choose to use a different toolchain, that is fine. Keep in mind that you may run into issues depending on the toolchain you use ***
You can check what your currently running kernel was built with by issuing these commands:
Code:
adb root
adb shell cat /proc/version
It should return something like:
Linux version 3.4.0-cyanogenmod-gc4f332c-00230-g93fb4aa-dirty ([email protected]) (gcc version 4.7 (GCC) ) #134 SMP PREEMPT Thu Feb 28 00:22:41 CST 2013
Click to expand...
Click to collapse
This shows my particular kernel here was built with GCC 4.7
You can use wget to download one of the links from above, in this instance we'll download version 4.4.3 from the first link:
Code:
wget http://invisiblek.org/arm-eabi-4.4.3.tar.bz2
Extract this to somewhere you will remember, probably your home directory.
Code:
mkdir arm-eabi-4.4.3
tar -xf arm-eabi-4.4.3.tar.bz2 -C arm-eabi-4.4.3/
Click to expand...
Click to collapse
Obtaining Source
Find someone's source to use as a base. This can be a source archive from Samsung, a kernel tree from CyanogenMod, or any other developer around that makes kernels for your device.
TIMEOUT
This is a good spot to stop and take note that the Linux kernel is licensed under the GNU General Public License (GPL): http://www.gnu.org/licenses/gpl-2.0.html
What does this mean you ask? It means that if you plan to share your kernel with the community (if it's good, please do so!) then you MUST share your
source code as well. I am not liable for what you choose to do once you start building kernels, but know this: if you share your kernel and do not
provide source code for it, you will get warnings from XDA for a determined amount of time, after that you may have your threads closed, deleted and
possibly your user account terminated. This is extremely important!
Also, you may run into more problems than just XDA. There are organizations out there that do take action if you consistently refuse to comply with the GPL.
I recommend you read this: http://www.gnu.org/licenses/gpl-2.0.html so that you are familiar with what legalities you are getting yourself into.
The main thing to remember is to share your source code if you decide to share your built kernel.
Click to expand...
Click to collapse
In this instance, we will use CyanogenMod's kernel source for the US Galaxy S3's. You may browse the source code here:
https://github.com/CyanogenMod/android_kernel_samsung_d2
You'll notice that the branch there is cm-10.1
This is the default branch of this repository on github. This means that if you intend to build this branch, you'll need to use it on CM version 10.1. Most
likely it will not function on another version.
To obtain the source code:
Code:
git clone https://github.com/CyanogenMod/android_kernel_samsung_d2
This will take a little while, be patient.
When done, you'll have a directory called android_kernel_samsung_d2, cd into this directory.
Code:
cd android_kernel_samsung_d2
Next, you'll need to set up a couple environment variables. These tell the system two things:
1. What CPU architecture to build for, in this case arm
2. Where to find the toolchain we downloaded earlier, so that the system can cross compile for arm
Code:
export ARCH=arm
export CROSS_COMPILE=~/arm-eabi-4.4.3/bin/arm-eabi-
You'll need to set these variables on each new session. You can modify your Makefile in the root of your kernel tree in order to have these set permanently.
Click to expand...
Click to collapse
Building
At this point you can make any changes to the source code that you want. If this is your first time, I recommend not making any changes and make sure you have a
sane build environment before adding any complications.
When you build a kernel, you need to choose a defconfig. This is a specialized configuration file, specifically tailored for your device.
CyanogenMod names their defconfigs for their devices like so: cyanogen_<device>_defconfig and they are located in arch/arm/configs/
Code:
ls arch/arm/configs/cyanogen*
In this example, we will build for d2vzw.
Set up your tree to build for the d2vzw:
Code:
make cyanogen_d2vzw_defconfig
(do this in your kernel's root directory, in this example it was android_kernel_samsung_d2/ )
Now you are ready to build:
First, determine how many cpu's your computer has. You'll use this number to determine how many jobs the compiler command will use. The more jobs you can use, the more
cpu threads the compile will take advantage of, thus you'll get faster builds. If you don't know, just assume you'll use the number 2. We'll use 2 as an example here.
Code:
make -j2
Where 2 is the number of CPU cores your build system has.
And now we wait...until it's done compiling...
You'll know it successfully compiled when you have this line when it stops:
Kernel: arch/arm/boot/zImage is ready
Click to expand...
Click to collapse
PROTIP:
If it stops somewhere other than "zImage is ready" then you had build errors. Try running the 'make' command with no options after it. This will run the compile on a single thread
and will cause it to stop compiling as soon as it hits an error. When you run it on multiple threads, it definitely goes much faster, but if an error occurs, the console doesn't stop
until it finishes all of its threads. Causing you to have to scroll up and search around for an error
Click to expand...
Click to collapse
Now, assuming the build completed successfully, you have two things you are concerned with: A zImage (the kernel binary itself) and your kernel modules, which get built based
on what was configured in your defconfig.
You'll find your zImage at: arch/arm/boot/zImage
Code:
ls arch/arm/boot/zImage
The modules are scattered all over the place, depending on where the source existed that they were compiled from. We can easily search for them using this command:
Code:
find . -name "*.ko"
If both of the previous commands completed, you are now ready to package your kernel up for testing.
Move up a directory before continuing.
Code:
cd ..
Click to expand...
Click to collapse
Packaging
You may know of an awesome developer by the name of koush.
Well, once upon a time, koush created a rather simple zip, called AnyKernel, that would flash a kernel on a device, regardless of what ramdisk the kernel has on it.
I've taken his zip and modified it for d2 devices and to work with the newer recoveries out there.
This has a script in it that will dump your current boot.img (kernel+ramdisk), unpack it, replace the kernel, repack it and flash it.
It'll also copy any modules to the proper directory (/system/lib/modules) and set permissions appropriately.
You can get a zip here: Download || Mirror
(You can get it here as well: https://github.com/invisiblek/AnyKernel )
(Everyone is invited to use this zip, it'll probably make your life easier to not have to worry about the ramdisk. Enjoy!)
IMPORTANT
This AnyKernel package is for US variations of the Galaxy S3.
NOT the international (I9300) or any other device.
There are checks in the updater-script that will ensure you are running a d2 device before it does anything.
If you were to remove these checks, and not modify the partition that it flashes to later, you could end up with a brick.
If you intend to adapt this package for another device (please, do this! its a very handy script!), make sure you know it well, or ask someone to help you determine your device's
partition scheme before using it.
The risk here is due to the fact that the script doesn't know your device's partition scheme. It is configured specifically for the d2 devices. Flashing it on something else, who's boot
partition is somewhere else, might cause a bad flash to the bootloader partition (bad bad news if this happens).
Just be careful if you want to use this on another device. You won't run into problems if you use this on a d2 device.
EDIT: I made modifications that should make this less likely, but please, if you intend to use this on a different device (which is completely fine!) make sure you configure
the scripts to flash to the proper partitions.
Click to expand...
Click to collapse
Download and extract one of the above, we'll again use the first link for this example:
Code:
wget http://invisiblek.org/AnyKernel_samsung-d2.zip
unzip AnyKernel_samsung-d2.zip -d AnyKernel/
Now we'll copy our newly compiled zImage (still referring to the same kernel directory we used above, your repo might be called something different)
Code:
cp android_kernel_samsung_d2/arch/arm/boot/zImage AnyKernel/kernel/
cp `find android_kernel_samsung_d2 -name "*.ko"` AnyKernel/modules/
Finally we are ready to zip this up and test out flashing it.
Code:
cd AnyKernel
zip ../MyAwesomeKernel.zip -r *
cd ..
You'll now have a file named MyAwesomeKernel.zip which you should be able to flash via custom recovery (TWRP or CWM)
Click to expand...
Click to collapse
Extra Credit/Protips
Learn to use git. It's very powerful and great way to store your code.
Learn to use adb. It's an invaluable tool for any android developer.
Touchwiz and AOSP-based kernels are different. This means you cannot take CyanogenMod's source, build a kernel and expect it to work on a Touchwiz-based ROM.
Build a ROM next: http://wiki.cyanogenmod.org/w/Build_for_d2vzw
Crackflash your own stuff!
ALWAYS NANDROID!
Click to expand...
Click to collapse
Source code for all of my projects can be found here: http://github.com/invisiblek
FAQ
Q: How do I update my source tree to the latest that is available from where I downloaded it?
A: This can be handy if, for instance, you are building a CyanogenMod kernel and they added some patches, after you downloaded the source, that you want to include in your next build. You'll want to cd to your kernel tree and issue a git pull:
Code:
cd android_kernel_samsung_d2
git pull
You may then continue with the building instructions.
This may, however, have other problems if you've made changes to files. You might run into conflicts. I won't cover fixing any of this here, its not in the scope of this thread.
Q: I'm using X as a kernel base, but Y has a patch that I really like. How do I get it in my kernel easily?
A: I'll let you check Google for this answer, but I'll give you a hint use: git cherry-pick
Nice tutorial bro! Always good to learn something new everyday
Really is a good thread,thanks
This guide would have made things too easy for me.
Too easy, indeed. haha
Great job, invisiblek! AnyKernel is the beez neez.
Ok so this is a noob question but I gotta ask anyway lol. Ok so I cloned the kernel source, I made my edits, now how do I push all this to my github?
I already have a github account, I already made a new repo for the kernel. Here's a link to my github if you need it...
https://github.com/ghicks12/d2vzw_kernel.git
spc_hicks09 said:
Ok so this is a noob question but I gotta ask anyway lol. Ok so I cloned the kernel source, I made my edits, now how do I push all this to my github?
I already have a github account, I already made a new repo for the kernel. Here's a link to my github if you need it...
https://github.com/ghicks12/d2vzw_kernel.git
Click to expand...
Click to collapse
git remote add origin git_location_you_created_on_github.git
git push -u origin somebranch
The -u is for first time run only, you can just git push afterwards.
Sent from my SCH-I535
GideonX said:
git remote add origin git_location_you_created_on_github.git
git push -u origin somebranch
The -u is for first time run only, you can just git push afterwards.
Sent from my SCH-I535
Click to expand...
Click to collapse
Thanks! When I run
Code:
git remote add origin https://github.com/ghicks12/d2vzw_kernel.git
I get this back:
Code:
fatal: remote origin already exists.
I'm editing a CM based kernel, not sure if that matters or not?
That just means you added the remote already. Just issue the push command then.
Sent from my SCH-I535
Why is this happening? I don't know what i did wrong
[email protected]:~/cm$ make VARIANT_DEFCONFIG=cyanogen_d2att_defconfig
scripts/kconfig/conf --silentoldconfig Kconfig
drivers/media/video/msm/Kconfig:123:warning: choice value used outside its choice group
drivers/media/video/msm/Kconfig:128:warning: choice value used outside its choice group
***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[2]: *** [silentoldconfig] Error 1
make[1]: *** [silentoldconfig] Error 2
make: *** No rule to make target `include/config/auto.conf', needed by `include/config/kernel.release'. Stop.
[email protected]:~/cm$
Hey. I'm having some problems with some GIT terminology and procedures. I'm a .NET developer and I use TFS and SVN on a daily basis. Forgive me if this is complete off basis from what you'd do with GIT.
What I want to do is merge one branch into another branch. In other words I want to take the latest kernel source from my favorite dev and merge in the latest from cyanogen's 4.3 d2 branch. Is this a rebase thing? It doesn't seem like cherrypicking to me.
I have successfully compiled kernel and made modules.I inserted zImage and modules inside any kernel updater,flashed via TWRP.When reboot stuck in odin and it says could not do normal boot.

[Q] How and where to get linaro patches for CM kernel/ROM build

Hello
I've been trying to build my own cyanogenmod 11 build using the linaro toolchains on a galaxy S (i9000), with mixed success. At the moment I can compile the kernel with linaro 4.7 and the rest of the ROM with 4.8. Using 4.8 for the kernel will not boot the device, and using any extra optimisation flags in 4.8 will result in the same behaviour. I would preferably like to add strict-aliasing, and the -fmodulo-sched -fmodulo-sched-allow-regmoves.
I know linaro is releasing patches to compile the ASOP kernel/ROM with gcc 4.8. Also I hear the linaro has some library patches to improve memory operations, and maybe optimisations to other libraries. Is there a link or tutorial or a list of what I need to get in order to get a successful build with most optimisations in?
For people who are looking for similar information and to point what I have done so far is the following. (Unfortunately XDA forum does not allow me to post links yet) I put in a quote to differentiate.
mkdir ~/android
cd ~/android
Download the latest linaro gcc 4.7 and 4.8
Google 'linaro downloads 13.12' and find in the page the links for android-toolchain 4.8 and android-toolchain 4.7 (ICS, JB)
tar -xjf android-toolchain-eabi-4.8-2013.12-x86.tar.bz2
mv android-toolchain-eabi android-toolchain-eabi-4.8
tar -xjf android-toolchain-eabi-4.7-2013.12-x86.tar.bz2
mv android-toolchain-eabi android-toolchain-eabi-4.7
Follow the cyanogenmod wiki up the point of running the 'lunch <device command>'
Google 'How to Build CyanogenMod for the Galaxy S galaxysmtd' to get the link (XDA does not let me post it)
It is for galaxy S i9000 but every other device should be similar
After that there were a couple of choices, but what I prefer is doing the following (its maybe the least clean choice)
in the directory ~/android/system//prebuilts/gcc/linux-x86/arm
I run the following commands to link the linaro gcc tools to the default gcc-4.7 used by cyanogenmod
mv arm-eabi-4.7 arm-eabi-4.7.old
mv arm-linux-androideabi-4.7 arm-linux-androideabi-4.7.old
ln -s ~/android/android-toolchain-eabi-4.7 arm-eabi-4.7
ln -s ~/android/android-toolchain-eabi-4.8 arm-linux-androideabi-4.7
in file ~/android/system/system/vold/Android.mk
for variable common_cflags
add the flag -Wno-error=unused-parameter
so it should look like
common_cflags += -Werror -Wno-error=unused-parameter
in file ~/android/system/bootable/recovery/voldclient/Android.mk
for variable LOCAL_CFLAGS
add the flag -Wno-error=unused-parameter
it should look like
LOCAL_CFLAGS := -DMINIVOLD -Werror -Wno-error=unused-parameter
then to finish the build
croot
brunch galaxysmtd
Click to expand...
Click to collapse
I would really appreciate some help, and hope my post helps some newbies like me

Categories

Resources