메뉴 건너뛰기

그외 개발정보


Raspberry Pi 3에서 운영하기 위한 Android의 소스 코드를 내려 받고 빌드하기 위한 방법입니다.

인터넷의 자료들을 참고하며 진행하다가 아쉬운 부분들을 보완하여 정리 했습니다.

(The way how to download Android source and build it for Raspberry Pi 3.)


- CentOS 7 환경에서 진행하였습니다.

- 16GB 이상의 Micro SD CARD가 필요합니다.

(Environment : CentOS 7, 16GB+ Micro SD CARD)


+ Git과 Git정보, 환경을 최신 상태로 설정. (Git 버전이 2.0 미만이면 빌드시 '-C' 옵션을 처리하지 못해 오류 발생) 

(Update your environment to the latest version. Git version should be >= 2.0)

$ sudo yum update
$ sudo rpm -Uvh http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm
$ sudo yum --enablerepo=WANdisco-git --disablerepo=base,updates install git
$ git config --global user.name "Name"
$ git config --global user.email "email@email.com"

+ 빌드를 위해 필요한 도구와 라이브러리 설치 (Install several tools and libraries that you might need)

$ sudo yum install gcc-arm-linux-gnu
$ sudo yum install java-1.8.0-openjdk-devel java-1.8.0-openjdk java-1.8.0-openjdk-headless
$ sudo yum install libstdc++.i686


+ 작업할 계정의 루트 경로에서 bin 폴더를 생성하고 다운로드 스크립트를 내려받아 실행 권한 부여 후 작업 디렉토리 생성

(Create directories for downloading Android source. Additionally, create a working directory too.) 

$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY


+ Android 소스 다운로드 (Download Android source)

$ repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.2_r19
$ git clone https://github.com/android-rpi/local_manifests .repo/local_manifests
$ repo sync
$ make clobber


+ ./device/brcm/rpi3/BoardConfig.mk 파일에 아래 내용 추가 (Add the following line to ./device/brcm/rpi3/BoardConfig.mk file)

ANDROID_JACK_VM_ARGS := -Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m


+ 커널 빌드 (Build a kernel source)

$ cd kernel/rpi
$ ARCH=arm scripts/kconfig/merge_config.sh arch/arm/configs/bcm2709_defconfig android/configs/android-base.cfg android/configs/android-recommended.cfg
$ ARCH=arm CROSS_COMPILE=arm-linux-gnu- make zImage
$ ARCH=arm CROSS_COMPILE=arm-linux-gnu- make dtbs
$ cd ../../


+ 아래 링크의 내용대로 아래 소스 파일들 수정 (Change the source files as follow)

- https://github.com/android-rpi/device_brcm_rpi3/wiki#use-hal_pixel_format_bgra_8888
- https://github.com/android-rpi/device_brcm_rpi3/wiki/Runtime-Errors


frameworks/native/opengl/libs/EGL/eglApi.cpp 
frameworks/base/opengl/java/android/opengl/GLSurfaceView.java 
frameworks/av/media/libstagefright/colorconversion/SoftwareRenderer.cpp 
frameworks/base/core/java/android/os/StrictMode.java 
frameworks/base/packages/SettingsLib/src/com/android/settingslib/drawer/SettingsDrawerActivity.java


+ Framework 소스 빌드 (Build a framework source)

$ sudo yum install python-mako
$ source build/envsetup.sh
$ lunch rpi3-eng
$ make -j2 ramdisk systemimage


+ 이미지들을 복사할 SD CARD의 파티션 설정을 위한 fdisk 실행  (SD CARD가 '/dev/sdb'이름으로 표시되고 있다는 가정에서 작성됨)

(Set the partitions to copy output images. (Change '/dev/sdb' to your SD CARD device name))

$ sudo fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): 


+ 아래의 순서대로 입력 (Input commands in the following order)

n -> p -> 1 -> <enter> -> +512M
n -> p -> 2 -> <enter> -> +512M
n -> p -> 3 -> <enter> -> +512M
n -> p -> <enter> -> <enter>


+ 첫번째 파티션을 BOOTABLE, FAT32 (LBA) 로 설정 (Command (m for help) : 옆의 입력들을 따라서 입력해 주세요)

(Input commands in the following order)

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): c
Command (m for help): a
Partition number (1-4, default 4): 1


+ 파티션 상태 확인

(Check a status of SD CARD partition)

Command (m for help): p

Disk /dev/sdb: 15.9 GB, 15931539456 bytes, 31116288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000925ad

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048     1050623      524288    c  W95 FAT32 (LBA)
/dev/sdb2         1050624     2099199      524288   83  Linux
/dev/sdb3         2099200     3147775      524288   83  Linux
/dev/sdb4         3147776    31116287    13984256   83  Linux


+ 설정 반영후 fdisk 종료

(Apply the setting and quit from fdisk)

Command (m for help):  w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

$


+ 파티션들을 라벨링 하면서 포멧

(Format all partitions and set names for label)

$ sudo mkfs.vfat -F 32 /dev/sdb1 -n BOOT
$ sudo mkfs.ext4 /dev/sdb2 -L system
$ sudo mkfs.ext4 /dev/sdb3 -L cache
$ sudo mkfs.ext4 /dev/sdb4 -L userdata


+ 파티션 상태 확인

(Check a status of SD CARD partition)

$ sudo lsblk -o name,mountpoint,label,size

NAME            MOUNTPOINT LABEL     SIZE
sdb                                 14.9G
├─sdb1                     BOOT      512M
├─sdb2                     system    512M
├─sdb3                     cache     512M
└─sdb4                     userdata 13.3G


+ SD 카드에 이미지 복사

(Copy every images to SD CARD)

$ sudo dd if=out/target/product/rpi3/system.img of=/dev/sdb2 bs=1M
$ mkdir ~/temppart
$ sudo mount /dev/sdb1 ~/temppart
$ sudo cp kernel/rpi/arch/arm/boot/zImage ~/temppart
$ sudo cp device/brcm/rpi3/boot/* ~/temppart
$ sudo cp kernel/rpi/arch/arm/boot/dts/bcm2710-rpi-3-b.dtb ~/temppart
$ sudo mkdir ~/temppart/overlays
$ sudo cp kernel/rpi/arch/arm/boot/dts/overlays/vc4-kms-v3d.dtbo ~/temppart/overlays
$ sudo cp out/target/product/rpi3/ramdisk.img ~/temppart
$ sudo umount ~/temppart




+ 참고경로:

- https://www.lesstif.com/pages/viewpage.action?pageId=14745759

- https://github.com/android-rpi

- http://alnova2.tistory.com/1124


이 게시물이  
AiRPAGE가  
위로