본문 바로가기
HACKING/mobile_Android

Custom Android#1 Kernel build

by asdf12345 2020. 8. 24.

자신만의 Custom Android kernel 만들고 싶으신가요?

Do you want to get Custom Android kernel?

 

 

 

드루와요 드루와요

Let's make it happen~!

 

 

 

 

[ Custom Android#1 Kernel build ]

Table of contents

#0 Configure

#1 Choosing repository

#2 Downloading kernel sourcecode

#3 Downloading cross-compiler 

#4 Setting arch version & compiler 

#5 Build

#6 Checking kernel binary

 

 

 

 

#0 Configure

준비물 : VMWare, Ubuntu 14.04 이미지, Nexus 5X

Use VMWare, Ubuntu 14.04, Nexus 5X.

sudo apt-get update
sudo apt-get install git git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip bison libssl-dev

 

 

#1 Choosing repository

기기에 따른 Android Kernel Code 저장소를 설정한다.

After checking Android device, we should choose an Android kernel sourcecode repository.

->Nexus 5X 내부 칩들(SoC)의 맞는 동작을 위하여 퀄컴에서 만든 msm(Mobile Station Modem)플젝 소스코드를 이용한다.

I must choose msm project to work on Qualcomm MSM chipsets.

https://source.android.com/setup/build/building-kernels-deprecated#downloading-sources

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

 

 

#2 Downloading kernel sourcecode

다운로드 받을 코드 저장소 설정 후, 기기, kernel version 정한 후 소스코드를 다운받자. 

After choosing repository, we must check codename of the binary hardware support files and choose it and kernel version.

->Nexus 5X LG 폰의 코드 이름은 "bullhead"이다.

nexus 5X is codenamed bullhead.

적합한 kernel 선택을 위해 이 페이지를 참고하여 branch를 선택하면 된다.

To choose proper kernel, we can reference this page.

https://source.android.com/setup/start/build-numbers

https://developers.google.com/android/drivers#bullhead

브랜치 선택 후, 소스코드를 다운로드 한다.

After choose the branch, Download sourcecode.

git branch -a | grep bullhead
git checkout remotes/origin/android-msm-bullhead-3.10-oreo-m5

 

 

#3 Downloading cross-compiler 

Linux 에서 android 에 플랫폼에 맞는 실행 파일을 생성하기 위해서는 android에 맞는 컴파일러가 필요하다.

we need a Cross-compiler to create executable code for Android platform on the Linux.

->Nexus 5X의 컴파일러는 aarch64이다.

Nexus5X Android's compiler is aarch64.

Nexus5X Android 플랫폼에 맞는 컴파일러를 다운받자.

Let's download a proper compiler. 

git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
git checkout remotes/origin/oreo-m5-release

 

 

#4 Setting arch version & compiler 

정상 빌드를 위해, Makefile내 ARCH와 CROSS_COMPILE을 명시해준다.

To build properly it, we should let a build tool named make know ARCH and Cross_compiler by modifying Makefile. 

export ARCH=arm64
export SUBARCH=arm64
export CROSS_COMPILE=aarch64-linux-android-
export PATH=$PATH:/home/asdf/aarch64-linux-android-4.9/bin

 

 

#5  Build

기기의 맞는 빌드 환경을 구성하기 위해, make ($codename)_defconfig명령어를 실행한 후, 빌드한다.

->Nexus 5x의 codename은 bullhead이므로 make bullhead_defconfig 명령어를 실행하면 된다.

To make configuration in nexus5X kernel build, run "make bullhead_defconfig" command and build it.

make bullhead_defconfig
make -j2

 

 

#6 Checking kernel binary

이후 빌드 시, 정상적으로 Image파일이 생성됨을 확인 할 수 있다.

After building, we can check creating normal kernel image file.

make -j2

 

 

 

 

 

 

 

 

 

참 쉽죠잉?

That is too easy.

이제 우리,,커널 설치하러 가볼래요?^/////^

Now, Let's install kernel on Android.

 

 

Reference

https://source.android.com/setup/build/building-kernels-deprecated