Raspberry Android Source

安裝repo

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a
+x ~/bin/repo

安裝Java 7.0 SE

Raspberry 只能使用openjdk-7進行編譯,不可使用Oracle的Jdk

sudo apt-get install openjdk-7-jdk

下載Android Source

mkdir /data/rpi2
cd /data/rpi2
~/bin/repo init -u https://android.googlesource.com/platform/manifest -b android-6.0.1_r13
cd .repo
git clone https://github.com/peyo-hd/local_manifests -b marshmallow
repo sync

備份

若要進行最原始的程式碼備份, 使用如下指令
tar zcvf rpi2.tar.gz rpi2

解壓原始碼
tar xvf rpi2.tar.gz

Build Kernel

安裝 gcc-arm-linux-gnueabihf
sudo apt-get install gcc-arm-linux-gnueabihf

core=$(cat /proc/cpuinfo | grep processor | wc -l)
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-gnueabihf- make zImage -j$core
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make dtbs -j$core

*-j$(core) : 全速使用所有的cpu資源

Install python mako module

sudo apt-get install python-mako

Patch frameworks/base

Do https://github.com/peyo-hd/device_brcm_rpi2/wiki#avoid-logcat-flood

Apply following patch under frameworks/base, to avoid logcat flood by mouse event.

 framework/base/core/java/android/view/GestureDetector.java
 @@ line 490 @@ public class GestureDetector {
     public boolean onTouchEvent(MotionEvent ev) {
 +        switch(ev.getAction() & MotionEvent.ACTION_MASK) {
 +        case MotionEvent.ACTION_HOVER_MOVE:
 +        case MotionEvent.ACTION_HOVER_ENTER:
 +        case MotionEvent.ACTION_HOVER_EXIT:
 +        case MotionEvent.ACTION_BUTTON_PRESS:
 +        case MotionEvent.ACTION_BUTTON_RELEASE:
 +        case MotionEvent.ACTION_SCROLL:
 +            return false;
 +        }
          if (mInputEventConsistencyVerifier != null) {

Enable GLSurfaceView

Currently mesa3d vc4 build is supporting only following formats.

RGB 565, Alpha 0, Depth 24 or 0, Stencil 8 or 0
RGB 888, Alpha 8, Depth 24 or 0, Stencil 8 or 0
Then apply following patch under frameworks/base, to modify default EGL config.

opengl/java/android/opengl/GLSurfaceView.java
@@ line 976 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
         public SimpleEGLConfigChooser(boolean withDepthBuffer) {
-            super(8, 8, 8, 0, withDepthBuffer ? 16 : 0, 0);
+            super(8, 8, 8, 8, withDepthBuffer ? 24 : 0, 0);
         }

Avoid screen flashing

On eng build, Strict mode behavior – flash screen when apps do long operations on main thread – is enabled by default. We can avoid it by applying following patch under frameworks/base. This option could be turned on via Settings -> Developer options -> Strict mode enabled.

core/java/android/os/StrictMode.java
@@ line 1068 @@ public final class StrictMode {
     if (IS_ENG_BUILD) {
-            doFlashes = true;
     }

Enable SW video decoder

HW video decoder is not ready yet. SW mode could be used by applying following patch under frameworks/av – with limited size & performance.

frameworks/av/media/libstagefright/colorconversion/SoftwareRenderer.cpp
@@ line 113 @@ void SoftwareRenderer::resetFormatIfChanged(const sp<AMessage> &format) {
     case OMX_TI_COLOR_FormatYUV420PackedSemiPlanar:
     {
-            halFormat = HAL_PIXEL_FORMAT_YV12;
-            bufWidth = (mCropWidth + 1) & ~1;
-            bufHeight = (mCropHeight + 1) & ~1;
         break;
     }

Build Android source

Continue build with http://source.android.com/source/building.html
source build/envsetup.sh
lunch rpi2-eng
make -j$(core)

Prepare sd card

Partitions of the card should be set-up like followings.
p1 512MB for BOOT : Do fdisk : W95 FAT32(LBA) & Bootable, mkfs.vfat
p2 512MB for /system : Do fdisk, new primary partition
p3 512MB for /cache : Do fdisk, mkfs.ext4
p4 remainings for /data : Do fdisk, mkfs.ex4
Set volume label for each partition – system, cache, userdata
: use -L option of mkfs.ext4, e2label command, or -n option of mkfs.vfat

Write system partition

cd out/target/product/rpi2
sudo dd if=system.img of=/dev/<p2> bs=1M

Boot partition, kernel & ramdisk

device/brcm/rpi2/boot/* to p1:/
kernel/rpi/arch/arm/boot/zImage to p1:/
kernel/rpi/arch/arm/boot/dts/bcm2709-rpi-2-b.dtb to p1:/
out/target/product/rpi2/ramdisk.img to p1:/

Pi3 Android 7.0 source code

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



# Download Android source with patches(local_manifests)
 Refer to http://source.android.com/source/downloading.html
 $ repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.1_r6
 $ cd .repo
 $ git clone https://github.com/peyo-hd/local_manifests -b nougat
 $ repo sync

# Build for Raspberry Pi3
 See https://github.com/peyo-hd/device_brcm_rpi3

Build PI3

# Build Kernel
 Install gcc-arm-linux-gnueabihf
 $ cd kernel/rpi
 $ ARCH=arm scripts/kconfig/merge_config.sh arch/arm/configs/bcm2709_defconfig kernel/configs/android-base.config kernel/configs/android-recommended.config
 $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make zImage
 $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make dtbs

# Install python mako module
  sudo apt-get install python-mako

# Build Android source
 Continue build with http://source.android.com/source/building.html
 $ source build/envsetup.sh
 $ lunch rpi3-eng
 $ make ramdisk systemimage
 
# Help for build failure :
   https://github.com/android-rpi/device_brcm_rpi3/wiki/Build-Errors

# Prepare sd card
 Partitions of the card should be set-up like followings.
  p1 512MB for BOOT : Do fdisk : W95 FAT32(LBA) & Bootable, mkfs.vfat
  p2 512MB for /system : Do fdisk, new primary partition
  p3 512MB for /cache  : Do fdisk, mkfs.ext4
  p4 remainings for /data : Do fdisk, mkfs.ext4
 Set volume label for each partition - system, cache, userdata
  : use -L option of mkfs.ext4, e2label command, or -n option of mkfs.vfat
 
# Write system partition
  $ cd out/target/product/rpi3
  $ sudo dd if=system.img of=/dev/<p2> bs=1M
  
# Copy kernel & ramdisk to BOOT partition
  device/brcm/rpi3/boot/* to p1:/
  kernel/rpi/arch/arm/boot/zImage to p1:/
  kernel/rpi/arch/arm/boot/dts/bcm2710-rpi-3-b.dtb to p1:/
  kernel/rpi/arch/arm/boot/dts/overlays/vc4-kms-v3d.dtbo to p1:/overlays/vc4-kms-v3d.dtbo
  out/target/product/rpi3/ramdisk.img to p1:/

# HDMI_MODE : If DVI monitor does not work, try followings for p1:/config.txt
  hdmi_group=2
  hdmi_mode=85

# How to put Android-TV launcher :
  https://github.com/android-rpi/device_brcm_rpi3/wiki#how-to-apply-android-tv-leanback-launcher

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *