Saturday, November 8, 2014

Ranchu where are you, kernel and emulator aarch64 (arm64)

With the release of lollipop Android L, few things have changes. First emulator64-arm64 is not included in the AOSP any more, it's a project on its own.

Find it here, git clone and compile:
https://qemu-android.googlesource.com/qemu-ranchu

As soon as a dedicated team of engineer will perform proper testing, one day or another expect to see it back. For the time being, it's kept in a different source repo.

Once you get it, you may wonder how to compile proper kernel, where is ranchu (beside the version you have on linaro), guess where it is? ranchu as natural successor of goldfish, Linux Kernel 3.10 is available (do not expect to see older versions)

1) get a proper toolchain (4.9 at least to have support for arm64, the one that ships in ubuntu repo aarch64-linux-gnu- should work fine too)

2) get the kernel source (you need this specific repo)

git clone -b android-goldfish-3.10 https://android.googlesource.com/kernel/goldfish

3) compile

make ARCH=arm64 ranchu_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j8
(prerequisite install arm64 compiler toolchain from your repos or from google, NDK with compiler 4.9)

A working kernel is built and available as explained in my previous post
http://restart-thinking.vitorallo.com/2014/11/android-l-preview-under-arm64-aarch64.html

Second the build for arm64 is kind of screwed on AOSP 5.0 r2.
The vendorsetup for a full aosp 64 bit ranchu is not there, but funny enough the make script is!
Another good useful point is the mini_emulator which allows to have a running shell only mini version of android running on qemu. If your goal is to work with low level os stuff, this is your way.

mini emulator arm64

makefile are literally wrong, they point to armv7 build, thus you build the mini_emulator_arm64 and get out the armv7 32 bit version... woaahhh

so I fixed the files, you need also to include proper init.rc for ranchu, fstab and other bits.
this file contains my fixed scripts.

https://dl.dropboxusercontent.com/u/2930979/fixit.tar.gz

- just untar it in the AOSP/device/generic
on AOSP root folder, source the build env

source build/environment.sh
lunch mini_emulator_arm64-userdebug 
m -j8

wait... you'll get out/products/mini-emulator-arm64 with *.img files to run the emulator like described in my previous article, it works!

full AOSP arm64 on qemu

here it's even easier, google was a bit more kind and left the make files there, you just miss the vendorsetup to get the lunch bundle. in the file above, download it, you have it. it extracts the file in the device/generic/qemu folder. just do it and select the new entry:

source build/environment.sh
lunch ranchu_arm64-eng
m -j8



7 comments:

  1. fixed the make command for compiling the kernel which was, of course, wrong!

    ReplyDelete
    Replies
    1. I was unable to get a zImage generated from "make ranchu_defconfig" target using the following kernel.

      GIT: https://android.googlesource.com/kernel/goldfish
      BRANCH: android-goldfish-3.10

      I see that arch/arm64/boot/Makefile is missing definition of zImage target. Were you able to fix this? If so, can you please share?

      Delete
    2. yes, zImage is not available in this type of build, you'll get Image instead! use it as usual, that's the kernel image, just make ARCH=arm64 CROSS_COMPILE=youtoolchain- after defconfig

      Delete
    3. Question on AOSP front - I applied your fixit... patch on android-5.0.0_r3 and could not get mini-emulator-arm64 or ranchu_arm64 builds boot properly. I am using stock kernel from /prebuilts/qemu-kernel/arm64/....

      On preview-l-r2, mini-emulator-arm64 did work but ranchu_arm64 never worked for me.

      My goal is to get full UI and browser working on any branch of Android 5.0 using ARM 64-bit flavor of emulator. Any suggested recipe?

      Delete
    4. Bit more info on failures in booting mini-emulator-arm64 build using aosp=android-5.0.0_r3:

      (1) During dex2oat there are numerous asserts from boot_class_path_ = nullptr hits in runtime.cc. Eventually the scrolling errors stop.

      (2) Then Zygote complains about not having emulated storage (detailed logcat below). However I did not any difference between the mounted shares/devices between preview-l-r2 vs android-5.0.0_r3.

      ==============================================
      W/Zygote ( 2207): Storage environment undefined; unable to provide external storage
      W/Zygote ( 2207): Failed to mount emulated storage: 22
      E/Zygote ( 2207): Cannot continue without emulated storage
      F/art ( 2207): art/runtime/jni_internal.cc:771] JNI FatalError called: RuntimeAbort
      W/libbacktrace( 2207): virtual bool BacktraceThread::Unwind(size_t, ucontext_t*): tgkill 788 failed: No such process
      W/libbacktrace( 2207): virtual bool BacktraceThread::Unwind(size_t, ucontext_t*): tgkill 788 failed: No such process
      F/art ( 2207): art/runtime/runtime.cc:284] Runtime aborting...
      F/art ( 2207): art/runtime/runtime.cc:284] Aborting thread:
      F/art ( 2207): art/runtime/runtime.cc:284] "main" prio=5 tid=1 Native
      F/art ( 2207): art/runtime/runtime.cc:284] | group="" sCount=0 dsCount=0 obj=0xf0ef0000 self=0xf5207800
      F/art ( 2207): art/runtime/runtime.cc:284] | sysTid=788 nice=0 cgrp=default sched=0/0 handle=0xf7129ec8
      F/art ( 2207): art/runtime/runtime.cc:284] | state=? schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100
      F/art ( 2207): art/runtime/runtime.cc:284] | stack=0xff574000-0xff576000 stackSize=8MB
      F/art ( 2207): art/runtime/runtime.cc:284] | held mutexes= "abort lock" "mutator lock"(shared held)
      F/art ( 2207): art/runtime/runtime.cc:284] kernel: (couldn't read /proc/self/task/788/stack)
      F/art ( 2207): art/runtime/runtime.cc:284] native: (backtrace::Unwind failed for thread 788)
      F/art ( 2207): art/runtime/runtime.cc:284] at com.android.internal.os.Zygote.nativeForkAndSpecialize(Native method)
      F/art ( 2207): art/runtime/runtime.cc:284] at com.android.internal.os.Zygote.forkAndSpecialize(Zygote.java:93)
      F/art ( 2207): art/runtime/runtime.cc:284] at com.android.internal.os.ZygoteConnection.runOnce(ZygoteConnection.java:246)
      F/art ( 2207): art/runtime/runtime.cc:284] at com.android.internal.os.ZygoteInit.runSelectLoop(ZygoteInit.java:784)
      F/art ( 2207): art/runtime/runtime.cc:284] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:690)
      F/art ( 2207): art/runtime/runtime.cc:284] Dumping all threads without appropriate locks held: thread list lock mutator lock
      F/art ( 2207): art/runtime/runtime.cc:284] All threads:
      F/art ( 2207): art/runtime/runtime.cc:284] DALVIK THREADS (1):
      F/art ( 2207): art/runtime/runtime.cc:284] "main" prio=5 tid=1 Native


      Delete
    5. I got it working with full UI but I didn't test the browser honestly, at that time. the UI was buggy and wrong size, difficult to use it properly but working!

      Delete
    6. I fix the bug about building kernel by change ranchu_defconfig SELinux。but adb shell offline !

      Delete