[Q] How can I build my own Kernel? - Nexus 7 Q&A, Help & Troubleshooting

Ok, so I believe I downloaded the correct kernel source (if I even downloaded the source that is) for this device.
My question now is, how do I edit the source files (where are they) and how do I build them?
I used the command:
Code:
git clone https://android.googlesource.com/kernel/tegra.git
to download the source, however all I have is a .git folder - where is the source?
Thanks to anyone that can help me

Try this: http://forum.xda-developers.com/showthread.php?t=1748297

Related

[Q] Help needed compiling Android from source

Hi folks,
I'm trying to compile Android from source. I'm doing this just for learning purposes. I'm trying to compile Android 2.1. I read here and did whatever it said. Now my first question is:
When initializing Repo client, what I should enter:
repo init -u git://android.git.kernel.org/platform/manifest.git
or
repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair​
After doing Repo sync, I need to extract LG drivers into the main directory. After that I compiled the Kernel and obtained the zImage file. Then when I started building the system, I got too many warnings. Anyhow the build was completed. But it wasn't working on the emulator itself.
I asked Joe.stone for help. He said that I need to create the device config files in the /device/lg/swift folder. Neither I found the device folder, nor I know how to create the device config files. I'm a damn noob when it comes to such complex things.
Please help me out. If I'm able to create a successful build, the I promise I'll write a tutorial for you all. Help needed!!
tejasdj12 said:
Hi folks,
I'm trying to compile Android from source. I'm doing this just for learning purposes. I'm trying to compile Android 2.1. I read here and did whatever it said. Now my first question is:
When initializing Repo client, what I should enter:
repo init -u git://android.git.kernel.org/platform/manifest.git
or
repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair​
After doing Repo sync, I need to extract LG drivers into the main directory. After that I compiled the Kernel and obtained the zImage file. Then when I started building the system, I got too many warnings. Anyhow the build was completed. But it wasn't working on the emulator itself.
I asked Joe.stone for help. He said that I need to create the device config files in the /device/lg/swift folder. Neither I found the device folder, nor I know how to create the device config files. I'm a damn noob when it comes to such complex things.
Please help me out. If I'm able to create a successful build, the I promise I'll write a tutorial for you all. Help needed!!
Click to expand...
Click to collapse
I don't know how to create the files,but you can use the lg gt540 source uploaded by LG.
Well, "device" folder will not work with eclair source, it using "vendor" folder to make a device - specific build. Also, zImage from builded kernel is not the only thing you need, bcos you need also ramdisk image.
Thanks for your replies guys,
I compiled the system successfully (Eclair 2.1) and got it running perfectly on emulator. But, I have sent my phone to the LG Service coz my computer restarted during the KDZ process. I'll be uploading the system.img file tonight. I just need some guys to test it out with the Quarx Kernel.
@pebe94:
I would rather extract any prebuilt boot.img and replace the zImage file. Is that OK?
@up
Yes. If you using extractor from bt.zip, you have to move (or delete) boot.img-kernel from extracted boot, and paste zImage and rename to boot.img-kernel. After that you will able to build boot.img

compiling android (CM)

hi,
I'm wondering if someone can help me with compiling android from source. I've set up the build environment as described here: http://developer.android.com/guide/index.html
and downloaded the CM sources via repo.
the biggest question that I have at the moment is, how do I merge the code from our devs with the CM sources and then start compiling the whole thing? e.g. if I downloaded CM10 and want to merge it with marcellusbe's git development files..
I'm a bit confused about all the shell scripts in the CM sources..
do I need the kernel sources? or can I use for example one of the flashable zip files?
maybe someone can lead me through this step by step, or make a step by step tutorial, which would be great.
I do have linux experience but I'm not really into development stuff.
thanks in advance
sharukins said:
hi,
I'm wondering if someone can help me with compiling android from source. I've set up the build environment as described here: http://developer.android.com/guide/index.html
and downloaded the CM sources via repo.
the biggest question that I have at the moment is, how do I merge the code from our devs with the CM sources and then start compiling the whole thing? e.g. if I downloaded CM10 and want to merge it with marcellusbe's git development files..
I'm a bit confused about all the shell scripts in the CM sources..
do I need the kernel sources? or can I use for example one of the flashable zip files?
maybe someone can lead me through this step by step, or make a step by step tutorial, which would be great.
I do have linux experience but I'm not really into development stuff.
thanks in advance
Click to expand...
Click to collapse
1. Download sources from CM
Code:
# mkdir cm10
# cd cm10
cm10 # repo init -u git://github.com/CyanogenMod/android.git -b jellybean
cm10 # repo sync -j4
2. Take my cm10 device config from git and put it in device/samsung folder. It is not updated yet with all the fixes but good to start compiling.
there are problems in compiling with external/valgrind and external/regex-re2 : thanks to aaa801, he gave me link to a valgrind patch that solves the compile failure for armv6.
For regex-re2, for now, just delete the folder.
then you can compile jellybean :
Code:
cm10 # . build/envsetup.sh
cm10 # lunch
You're building on Linux
Lunch menu... pick a combo:
1. full-eng
2. full_x86-eng
3. vbox_x86-eng
4. mini_armv7a_neon-userdebug
5. mini_armv7a-userdebug
[B]6. cm_apollo-userdebug[/B]
7. full_panda-userdebug
8. cm_grouper-userdebug
9. cm_maguro-userdebug
10. cm_toro-userdebug
11. cm_toroplus-userdebug
Which would you like? [full-eng] [B]6[/B]
cm10 # make -j4
Jellybean needs modifications in the initial ramdisk ... I can provide you the kernel until I upload the changes to github.
providing the kernel would be great
but I can wait until you upload the latest changes and fixes, too

Help compiling Nexus 4 kernel from sources

Hi, I'm trying to compile the Nexus 4 kernel from the sources following the android.developers tutorial:
http://source.android.com/source/building-kernels.html
And also this guides:
[Tutorial] Building Your First Kernel: http://forum.xda-developers.com/showthread.php?t=1748297
Getting Started: Building a Kernel from source: http://xda-university.com/as-a-developer/getting-started-building-a-kernel-from-source
My goal is to learn to compile from AOSP, but I'm failing hard. After doing this step:
Code:
$ git clone https://android.googlesource.com/device/lge/mako-kernel
And after downloading the sources:
Code:
$ git clone https://android.googlesource.com/kernel/msm.git
All I get is a "kernel" file (without extension) and a folder .git folder. Inside that folder there aren't the files I assume I need, because I can't do "make mako_defconfig" as there isn't such file.
I don't know what I'm doing wrong as I'm not getting the files I need, althought download was nearly 1GB (I think they should be like this android tree):
https://android.googlesource.com/kernel/msm.git/+/android-msm-mako-3.4-jb-mr1.1
I'll appreciate your help, and sorry if this is the wrong section. Thanks in advance.
PS: I forgot, I already have the toolchain 4.6 and know how to call it, I tried it after clonning the trinity kernel git, I just wonder why I don't get similar files when clonning mako kernel from google source.
I solved it. I had to add the desired branch to the end of the command:
$ git clone https://android.googlesource.com/kernel/msm.git -b "brand"
Doubt is solved, thread can be closed.

[Q] Question on Building

Hey guys, I downloaded the LG D800 lollipop source files from the opensource LG site, and I was trying to build it.
From my understanding, the instructions.
Code:
1. Android build
- Download original android source code ( Lollipop 5.0.1_r1 ) from http://source.android.com
- Untar opensource packages of LGD800_L_Android.tar.gz into downloaded android source directory
a) tar -xvzf LGD800_L_Android.tar.gz
- And, merge the source into the android source code
- Run following scripts to build android
a) source build/envsetup.sh
b) lunch 1
c) make -j4
- When you compile the android source code, you have to add google original prebuilt source(toolchain) into the android directory.
- After build, you can find output at out/target/product/generic
2. Kernel Build
- Uncompress using following command at the android directory
tar xvzf LGD800_L_Kernel.tar.gz
- When you compile the kernel source code, you have to add google original prebuilt source(toolchain) into the android directory.
- Run following scripts to build kernel
a) cd kernel
b) export PATH=$PATH:tools/lz4demo
c) make ARCH=arm CROSS_COMPILE=../prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin/arm-eabi- g2-att-perf_defconfig zImage -j4
* "-j4" : The number, 4, is the number of multiple jobs to be invoked simultaneously.
* lz4demo : More information can be found at "https://code.google.com/p/lz4/"
- After build, you can find the build image(zImage) at arch/arm/boot/
3. how to build chromium34_lge (vendor\lge\external\chromium34_lge\src),
please refer to README.txt at the folder mentioned above.
say to build the AOSP_ARM generic image.
I am building it now, and it did include the make files for the vendor directories. But I am wondering if this is actually going to work, and if it's missing anything?
If someone has ever done this before, and can accurately describe the process I would appreciate it.
I understand it as download android>extract the files to that directory and "Merge"(Overwrite?) the files, then run the envsetup, lunch for AOSP_ARM and make.
I don't understand what this line means "When you compile the android source code, you have to add google original prebuilt source(toolchain) into the android directory."
I also don't understand what the Chromium34_LGE thing is, and what it's for.
If anyone can shine some information on this, I would really appreciate it. Thanks!
Download site instructions, file size, and Linux knowledge
Silentwidow said:
Hey guys, I downloaded the LG D800 lollipop source files from the opensource LG site, and I was trying to build it.
- Download original android source code ( Lollipop 5.0.1_r1 ) from http://source.android.com
Click to expand...
Click to collapse
Go to http://opensource.lge.com, and search for LGD800. The downloaded file named LGD800_Lollipop_Android_D800_v30f.zip is a 633,894KB file containing LGD800_L_Android.tar.gz 505,244 KB and LGD800_L_Kernel.tar.gz 133,042 KB. When both are extracted the result is over 2GB of files and folders.
To build you'll need a Linux OS and be very knowledgeable with Linux commands and file structures.
As for a prebuilt, there is one buried in the folders at LGD800_L_Android.tar.gz\LGD800_L_Android.tar\android\vendor\lge\prebuilt\LGBackup\tar\LGBackup_tar.zip\
I don't know if there is another prebuilt in the LGD800_L_Kernel.tar.gz because I didn't look. Linux is far out of my reach, so I'll stay away from build scripts and makefiles...etc..

[GUIDE] Porting Kernel Source to Snapdragon Device

Some OEMs violating GPL licenses and won't publish linux kernel sources for their Android devices.
On this post I’ll explain how to port kernel source to any android device.
Maybe you can port kernel sources to other SoCs with similiar ways but I've explained qcom way.
What do we need ?
A Computer which has Linux or Mac installation.
Device to test.
Let’s Start, Shall we ?
First of all we need to take dmesg of stock kernel using adb shell dmesg > dmesg.txt command. (I recommend you to take it while device is booting)
You got dmesg ? Nice. Open it with any text editor and search for “hardware” or “machine” and note the result to somewhere. By doing this we’ll get the name of device-tree-blobs.
Download android image kitchen and extract it to somewhere.
Now hold and move your device’s stock boot.img to unpackimg.(bat/sh)
Now your stock kernel got extracted to split_img/boot.img-zImage. After this line I will referance this file as “stock kernel”
Fetch split-appended-dtb using git clone https://github.com/MacTavishAO/split-appended-dtb-mac command. We’ll use this tool to extract dtb from stock kernel.
Copy stock kernel to split-appended-dtb-mac folder.
Now we will extract dtb(device-tree-blobs) from stock kernel. If you are on Linux use ./split-appended-dtb boot.img-zImage command for Mac use ./split-appended-dtb-mac boot.img-zImage command.
Now we have bunch of files named dtbdump_xx.dtb. We have to find out which one our device uses. Use grep -r <machine name that we found at step 2> . to find out which dtb our device using. (Write different parts of machine name to find out)
Install dtc using apt install device-tree-compiler command.
Let’s say it turns out dtbdump_21.dtb is the right one. We have to decompile dtb file to dts using dtc -I dtb -O dts -o extracted.dts dtbdump_21.dtb command.
Now we have to extract defconfig from stock kernel.
Use wget https://github.com/torvalds/linux/raw/master/scripts/extract-ikconfig && chmod a+x extract-ikconfig command to download necessary tool.
Use ./extract-ikconfig boot.img-zImage > extracted_defconfig to get defconfig from stock kernel.
Now we got what we need, we need to download kernel source to start porting to our device.
After this point I’ll start to explain as porting to Qualcomm device but almost same on other system-on-chips.
Go to Settings -> About Phone -> and note “Kernel version”
We need to download soc manufacturer’s sources. From here find msm-X.X that matching with your phone and copy link of it.
And from here find tag matching your chipset and write it down somewhere.
Use git clone <sources from 2 steps up> -b <tag>
Now enter to msm-X.X folder.
Copy extracted_defconfig to arch/<your device's architecture>/configs/ folder.
If your device is arm64 copy extracted.dts to arch/arm64/boot/dts/qcom/ if this directory doesn’t exist copy to arch/arm/boot/dts/qcom/ folder. (If you have 3.x qcom device skip the arm64 part and copy it directly into arm)
Open “Makefile” file in arch/arm(64)/boot/dts/qcom/ and add extracted.dts to the line matching with your chipset.
It’s time to import drivers. After this step I cannot help you because every devices’ hardware isn’t same but I can give some tactics.
To get driver names you can read dts file or install any device info app from Google Play Store etc.
Search these names and GitHub you can find files and commits which will help you to add drivers.
You did all of these without my help ? Excellent! Now it’s time to build kernel. I suggest you to use @natchanchance 's kernel compilation guide.
After compiling kernel. Copy compiled kernel to split_img folder which mentioned at early of this tutorial. rename it to boot.img-zImage and double click repackimg.(bat.sh) and you have new file named image-new.img.
Boot it using fastboot boot image-new.img command and if everything is working you can use fastboot flash boot image-new.img to use it permanently.
Leave a comment here about your questions. I'll try to reply all of them.
Planned to make a guide video about it but I don't have much time. Keep checking this thread may I post soon.
Reserved
Reserved.
Reserved
Thanks Dude!
This is very useful guide especially fir those who want to port the kernel source.
Thanks man. I am following your guide.
Thanks ?
While looking for matching dtbdump file I got a match in all four files for PMI8996, which file should I use?
"We have to decompile dtb file to dts using dtc" stuck at this step.
Any help on which "App" to use to find driver names..
Thanks
CPUZ / AIDA64
ataberkozen said:
It’s time to import drivers. After this step I cannot help you because every devices’ hardware isn’t same but I can give some tactics.
To get driver names you can read dts file or install any device info app from Google Play Store etc.
Search these names and GitHub you can find files and commits which will help you to add drivers.
Click to expand...
Click to collapse
I've found another way to find hardware info using hwinfo tool inside termux. The trick is to use it with root permissions.
Install hwinfo in termux:
Code:
apt-get install hwinfo
Run it with root permission tee into a text file:
Code:
su -c $(which hwinfo) | tee hwinfo.txt

Categories

Resources