2017년 12월 5일 화요일

how to build kernel for nexus5x

kernel howto

//
// (1) host environment
//
- os : ubuntu 14.04.5 LTS 64bit
- kernel : 4.4.0-31-generic
- gcc : gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

//
// (2) target environment
//
- android : 7.1.1 (N4F26O, Feb 2017)
- kernel : 3.10.73-gfe160e5

//
// (3) build environment
//

// misc
sudo apt-get update
sudo apt-get install build-essential

// cross compiler
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9

// build unmkbootimg (made by Pete)
wget https://raw.github.com/pbatard/bootimg-tools/master/mkbootimg/unmkbootimg.c
wget https://raw.github.com/pbatard/bootimg-tools/master/mkbootimg/bootimg.h

gcc -o unmkbootimg unmkbootimg.c
cp unmkbootimg /usr/local/bin/

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

cd bootimg-tools/libmincrypt/
gcc -c *.c -I../include
ar rcs libmincrypt.a *.o
cd ../mkbootimg
gcc mkbootimg.c -o mkbootimg -I../include ../libmincrypt/libmincrypt.a -std=c99

cp mkbootimg /usr/local/bin/
cd ../cpio

//
// (4) kernel build
//

// download sources
git clone https://android.googlesource.com/kernel/msm.git

git show
git branch -a
git checkout android-msm-bullhead-3.10-nougat-mr1.1

// build
export ARCH=arm64
export SUBARCH=arm64
export CROSS_COMPILE=/home/criny/nexus5x/gcc/aarch64-linux-android-4.9/bin/aarch64-linux-android-
make bullhead_defconfig
make -j4


//
// (5) make boot.img
//

// extract boot.img
unmkbootimg -i boot.img
!!!
kernel written to 'kernel' (10812900 bytes)
ramdisk written to 'ramdisk.cpio.gz' (1480005 bytes)

To rebuild this boot image, you can use the command:
mkbootimg --base 0 --pagesize 4096 --kernel_offset 0x00008000 --ramdisk_offset 0x02000000 --second_offset 0x00f00000 --tags_offset 0x01e00000 --cmdline 'console=ttyHSL0,115200,n8 androidboot.hardware=bullhead boot_cpus=0-5 lpm_levels.sleep_disabled=1 msm_poweroff.download_mode=0 buildvariant=user' --kernel kernel --ramdisk ramdisk.cpio.gz -o boot.img
!!!

// remake boot.img
cp /home/criny/nexus5x/kernel_src/msm/arch/arm64/boot/Image.gz-dtb .

mkbootimg --base 0 --pagesize 4096 --kernel_offset 0x00008000 --ramdisk_offset 0x02000000 --second_offset 0x00f00000 --tags_offset 0x01e00000 --cmdline 'console=ttyHSL0,115200,n8 androidboot.hardware=bullhead boot_cpus=0-5 lpm_levels.sleep_disabled=1 msm_poweroff.download_mode=0 buildvariant=user' --kernel Image.gz-dtb --ramdisk ramdisk.cpio.gz -o myboot.img

//
// (6) flashing boot.img
//
fastboot flash boot boot_.img

댓글 없음:

댓글 쓰기