-In this article we are going to build a kernel and join it with the AOSP or build it standalone.-The Kernel was not updated from android-5.1.0_r1->android-5.1.0_r3. It’s the same.
-Both Hardware and Software talk to each other seamlessly via the kernel.
-There are a few reasons you would want to build your own kernel.
1.) Adding features that are not available in stock.
b.) Yes that means editing source to your liking if that is your wish.
c.) Even merging with other master branches.
d.) Or you simply just want to make it your own.

3.) Check this page out for a low down of which kernel to build. Link
b.) Ours is for hammerhead device, binary location:device/lge/hammerhead-kernel, source location:kernel/msm, build config:hammerhead_defconfig

c.) From our previous AOSP build, the kernel was located in
‘workingDir/device/lge/hammerhead-kernel‘. The file is ‘zImage-dtb‘

4.) Here is the android source kernel location. Here
b.) Let’s close in a bit. Straight to the recent release. Herec.) As of this writing, 5.1.0_r1 was updated to 5.1.0_r3(3/25/2015) but the kernel is still the same -mr1.
d.) Remember your ‘workingDir‘ from previous AOSP build?
-Back out of it until you hit your $HOME directory. OR:$ cd $HOME

1.) Downloading a prebuilt gcc.
2.) Check Google’s gcc instructions. Link
3. You are still in $HOME: Issue this:$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6
b.) Once its done, a new folder named ‘arm-eabi-4.6‘ would have been created.

4.) Time to add the prebuilt toolchain to our path.
a.) You can also add these 4 lines into your .bashrc file.
b.) Issue this:$ export PATH=~/arm-eabi-4.6/bin:$PATH

5.) Building the hammerhead kernel. Build from top or jump in ‘kernel‘ and ‘make hammerhead_config‘.$ make -C kernel hammerhead_defconfig$ make -C kernel
b.) Now you wait.
c.) It should be like the image below when its done.
d.) The kernel should be in ‘kernel/arch/arm/boot/‘ named ‘zImage-dtb‘.

[[ STAGE THREE ]]

1.) Google Android source says:
“The kernel binary is output as: `arch/arm/boot/zImage` It can be copied into the Android source tree in order to build the matching boot image.”

2.) We can deal with the kernel two ways. 1) Include with new AOSP, 2) Standalone boot.img file.

b.) We include with a new AOSP build at folder: ‘workingDir/device/lge/hammerhead-kernel‘c.) Make a folder(OldKernel), move your old zImage-dtb inside there ^^^ to -> ‘~/OldKernel‘

5.) Remember ‘make clean‘ from previous article? Your out/ folder will be wiped.$ make clean << ===== THIS IS NOT NECESSARY. You can skip if you recently built aosp.$ . build/envsetup.sh$ lunch aosp_hammerhead-userdebug

6.) Build again – Remember N=# of cpus picked for VM.$ make -jN

Look at the screenshot below. Notice the kernel version: it matches my terminal.

7.) The Second way is to have ‘boot.img‘ flashed via ‘fastboot‘ by itself without redoing entire AOSP build.b.) We are going to utilize the existing Hammerhead factory images to build our new boot image.
c.) Grab factory image from Google. I’m assuming you’re in ‘workingDir‘ folder.$ wget https://dl.google.com/dl/android/aosp/hammerhead-lmy47d-factory-6c1ad81e.tgz

f.) You should still be under ‘hammerhead-lmy47d‘ folder.
– Remember that kernel we built from source? Let’s pull it to our local folder. ** Notice the single dot **$ cp ~/kernel/arch/arm/boot/zImage-dtb .

h.) Time to create your own myboot.img file. $ abootimg ––create myboot.img -f bootimg.cfg -k zImage-dtb -r initrd.img-We pulled the kernel locally, the other two files were extracted by abootimg.-After the command above you should have a myboot.img file inside hammerhead folder folder.

8.) Boot into fastboot then try the new myboot.img file.$ adb reboot-bootloader <—- If you were still at home screen.$ fastboot boot myboot.img <—- Pay close attention, there is no flash mode. You’re simply booting to test myboot.img
-Simply reboot and you’re back to your old boot.img.

9.) Test some calls, send some messages, visit the web. If it looks functional then flash it.$ fastboot flash boot myboot.img <—- Now flash makes it stick.
-This time myboot.img is permanent until you flash another.

— We are done — One or two images might not match but the point is there.*** UPDATED Jan/18/2016 ***
————————————————-

Google Apps — The Basics — Android.mk

7 Responses

garynych

im use :export CROSS_COMPILE=/home/garynych/android/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
and after build is end, in log i see error

WARNING: vmlinux.o(.data+0x8434): Section mismatch in reference from the variable msm_mpm_debug_mask to the function .init.text:mpm_irq_domain_linear_size()
The variable msm_mpm_debug_mask references
the function __init mpm_irq_domain_linear_size()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

WARNING: vmlinux.o(.data+0x844c): Section mismatch in reference from the variable msm_mpm_debug_mask to the function .init.text:mpm_irq_domain_legacy_size()
The variable msm_mpm_debug_mask references
the function __init mpm_irq_domain_legacy_size()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

how to fix?

fireNice

Make sure you have all those exports above in your path. Usually it’s in .bashrc so changes still stick after a reboot of the system. You can apply them then compile but as soon as you reboot you lose the paths.