How to build Android kernel and flash it to the target

0) Pre-requirement

0-1) Download the build-essential.

$ sudo apt-get update

$sudo apt-get install build-essential

0-2) Activate developer mode && Enable USB debugging

– Activate developer mode : Setting – Build number – Tap ‘Build number’ seven times

– Enable USB Debugging : (After activate developer mode) Setting – Developer option – Check ‘USB debugging’

1) Build Kernel

 1-1) tool-chain download

$ mkdir tool-chain-path

$ cd tool-chain-path

$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6

$ export  PATH=tool-chain-path/bin:$PATH

1-2) kernel download

$ git clone https://android.googlesource.com/kernel/msm.git

$ cd msm

$ git branch -r

$ git checkout origin/android-msm-flo-3.4-marshmallow-mr2

1-3) environment setup & build

$ export ARCH=arm

$ export SUBARCH=arm

$ export CROSS_COMPILE=arm-eabi-

$ make flo_defconfig

$ make -j4


http://dayntimes.tistory.com/plugin/CallBack_bootstrapperSrc?nil_profile=tistory&nil_type=copied_post

* if no error occurs, msm/arch/boot/zImage will be created.

2) making boot.img

 2-1) image generation tool download

$  git clone https://github.com/pbatard/bootimg-tools.git

$ cd bootimg-tools

$ make

$ cd mkbootimg

$ cp mkbootimg unmkbootimg tool-chain-path

 2-2) google factory image download

factory image url : https://developers.google.com/android/nexus/images#razorkot49h

 2-3) factory 에서 boot.img 추출

$ mkdir tmp

$ mkdir repack

$ cd tmp

$ wget https://dl.google.com/dl/android/aosp/razor-mob30x-factory-52684dff.zip

$ unzip razor-mob30x-factory-52684dff.zip

$ cd razor-mob30x

$ unzip image-razor-mob30x.zip

$ cp boot.img ../repack

 2-4) create new boot.img

 $ cd repack

 $ unmkbootimg -i boot.img

 kernel written to ‘kernel’ (6690056 bytes)

ramdisk written to ‘ramdisk.cpio.gz’ (492371 bytes)

To rebuild this boot image, you can use the command:

  mkbootimg –base 0 –pagesize 2048 –kernel_offset 0x80208000 –ramdisk_offset 0x82200000 –second_offset 0x81100000 –tags_offset 0x80200100 –cmdline ‘console=ttyHSL0,115200,n8 androidboot.hardware=flo user_debug=31 msm_rtb.filter=0x3F ehci-hcd.park=3’ –kernel kernel –ramdisk ramdisk.cpio.gz -o boot.img

$ cp <kernel-build-path>/msm/arch/arm/boot/zImage ./zImage

$ mkbootimg –base 0 –pagesize 2048 –kernel_offset 0x80208000 –ramdisk_offset 0x82200000 –second_offset 0x81100000 –tags_offset 0x80200100 –cmdline ‘console=ttyHSL0,115200,n8 androidboot.hardware=flo user_debug=31 msm_rtb.filter=0x3F ehci-hcd.park=3’ –kernel zImage –ramdisk ramdisk.cpio.gz -o boot.img

3. flash

$ adb reboot-bootloader

$ sudo fastboot oem unlock  (if flash is LOCKED)

$ sudo fastboot flash boot boot.img

$ sudo fastboot reboot 

4. Check update

 – Setting -About tablet – ‘Kernel version’

 

 

PS.

for kernel config file, usualy it’s located at <kernel_source>/arch/arm/configs directory

to build a kernel to match the specified target, you can extract the kernel config from the kernel Image or boot.img.

Simply usomg following command:

extract-ikconfig kernelImage

 

 

 

Ref.:

http://dayntimes.tistory.com/1278

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s