Nexus 5를 얼마전에 중고로 구입했다.
개발용으로 세팅하기 위해 AOSP 소스를 빌드해 보았다. 세팅하는 김에 최신의 Lollipop MR1소스를 기반으로 작업하였고 prebuilt 되어 있는 kernel을 사용하지 않고 kernel source를 빌드해서 bootimage를 생성하였다.

image

1. download

* lollipop mr1 for Nexus5

$ repo init -u https://android.googlesource.com/platform/manifest -b android-5.1.0_r3
$ repo sync -j4

* kernel

$ git clone https://android.googlesource.com/kernel/msm kernel
$ cd kernel
$ git checkout android-msm-hammerhead-3.4-lollipop-mr1
$ cd ..

* vendor proprietary libraries
https://developers.google.com/android/nexus/drivers#hammerheadlmy47i

capture06[1]

Broadcom:https://dl.google.com/dl/android/aosp/broadcom-hammerhead-lmy47i-4129297c.tgz LG:https://dl.google.com/dl/android/aosp/lge-hammerhead-lmy47i-1a387ac9.tgz Qualcomm:https://dl.google.com/dl/android/aosp/qcom-hammerhead-lmy47i-41f93087.tgz

다운로드 받은 파일의 압축을 해제하면 다음과 같은 .sh파일이 생성된다.

extract-broadcom-hammerhead.sh 
extract-qcom-hammerhead.sh
extract-lge-hammerhead.sh
capture05[1]

이제 하나씩 실행해서 license를 accept하면 vendor 폴더 및에 파일들이 생성된다.

 

2. modify source

  • prebuilt되어 있는 커널 이미지 대신 다운로드 받은 커널 소스를 빌드하도록 수정한다.
  • 기본 설정되어 있는 zImage를 사용하면 부팅이 되지 않는다. 디바이스 트리가 적용된 커널을 선택하도록 변경한다.
  • user빌드시 유용하도록 selinux는 permissive로 설정해 둔다.

*  kernel 빌드
- kernel 빌드를 위해 AndroidBoard.mk파일을 생성한다
$ device/lge/hammerhead/AndroidBoard.mk

image

$ device/lge/hammerhead/device.mk

image

* device tree kernel
zImage 대신 zImage-dtb를 사용하고 , module 빌드를 사용하지 않는다.
$ kernel/AndroidKernel.mk 

image

image

* permissive 모드 설정
$ device/lge/hammerhead/BoardConfig.mk

capture01[1] 

 

3. build

$ source build/envsetup.sh
$ lunch aosp_hammerhead_userdebug
$ time make -j4 OUT_DIR=out_aosp_userdebug_k

 

4. flashing

flashing부터는 windows환경에서 진행하였다.

먼저 Nexus5를 fastboot 모드로 진입시킨다.
Power key + Volume UP + Volue Down

unlock하고
dos>fastboot oem unlock

이제 실제 flashing을 진행한다.
윈도우즈 경우 먼저 ANDROID_PRODUCT_OUT에 .img파일이 위치한 디렉토리의 패스를 설정해 준다.
dos> set ANDROID_PRODUCT_OUT=D:\vmwares\vboxshare\nexus5\out_aosp_userdebug_k
dos> fastboot -w flashall

capture02[1]

boot done:)
imageimage

Happy Coding~:)

+ Recent posts