Building the development branch of the emulator

731 views
Skip to first unread message

peter....@plextek.com

unread,
Dec 8, 2015, 12:17:06 PM12/8/15
to Android emulator development
I am trying to use the development branch (emu-master-dev) of the emulator because I believe I have come across the bug reported in https://code.google.com/p/android/issues/detail?id=194627 and fixed in https://android-review.googlesource.com/#/c/183333/2. (The symptoms match, but I found it running the latest ARM64 AOSP prebuilt under Ubuntu.)

I've tried following the instructions in https://android.googlesource.com/platform/external/qemu/+/emu-master-dev/docs/DEVELOPMENT.TXT, but have come unstuck at the "android/scripts/build-qemu-android.sh" stage. The first problem is that there seems to be a missing include path for the following line in various source files:

#include "android/globals.h" /* for android_hw */

I found the header file and changed the invocation to:

> C_INCLUDE_PATH=$(pwd) android/scripts/build-qemu-android.sh

The next problem seems to be a missing header file:

#include "android/avd/hw-config-defs.h"

This is generated by a Python script, "gen-hw-config.py", but I've not been able to work out how to convince the build system to execute it.

At this point I'm wondering if I'm not using the right build tools or there is an additional step in the that hasn't yet been documented. (To check things I tried building the "studio-1.5" branch and it worked.)

David Turner

unread,
Dec 8, 2015, 2:37:19 PM12/8/15
to peter....@plextek.com, Android emulator development
Hello Peter,

Sorry, the DEVELOPMENT.TXT documentation is a little outdated. I've updated a refresh at https://android-review.googlesource.com/185890

build-qemu-android.sh is no longer needed to build QEMU2 binaries (android-rebuild.sh will do that for you now).
However, we need to keep this script working nonetheless to help rebase on newer versions of upstream QEMU2.
I'll try to look at this later. In all cases, you don't need this to develop.

The root of the problem is that we have modifications that depend on the AndroidEmu library, that cannot be compiled when using the original QEMU2 configure/build system. So these must be carefully encapsulated under the right #ifdefs. We probably made some modifications recently that were missing these.



--
You received this message because you are subscribed to the Google Groups "Android emulator development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-emulator...@googlegroups.com.
To post to this group, send email to android-em...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-emulator-dev.
For more options, visit https://groups.google.com/d/optout.

peter....@plextek.com

unread,
Dec 9, 2015, 11:09:31 AM12/9/15
to Android emulator development, peter....@plextek.com
David,

Thank you for this. I got the build working but the emulator wouldn't run until I had told it were to find my QT plugins and I had to set the loader path so that it could find the GPU emulation libraries. Thus my call to the emulator (from the $TOP/external/qemu/objs/qemu/linux-x86_64 directory) looks likes this:

QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins LD_LIBRARY_PATH=$TOP/external/qemu/objs/lib64 ./qemu-system-aarch64

This is probably an issue with my system (Ubuntu 14.04), but it might help someone to know what I did.

Sadly my kernel is running on the emulator, but Android isn't starting so my problem wasn't the one I thought it was (https://code.google.com/p/android/issues/detail?id=194627). However that's a different topic.

Peter

David Turner

unread,
Dec 9, 2015, 11:43:32 AM12/9/15
to peter....@plextek.com, Android emulator development
Hello Peter,

This is not an issue with your system , you also need to indicate $OUT_DIR/lib64/qt/lib in your LD_LIBRARY_PATH,. There are also other environment variables that are setup differently depending on your GPU emulation settings (best way to pass configuration data to the Emulation shared libraries without involving QEMU1 / QEMU2).

All this configuration is handled by the 'emulator' launcher, which will invoke 'qemu-system-aarch64' for you after setting up the right environment. Calling the emulation engine directly is error-prone and we don't recommend doing it.

peter....@plextek.com

unread,
Dec 9, 2015, 12:43:16 PM12/9/15
to Android emulator development, peter....@plextek.com
David,

Firstly, thank you for help in this.

I started using the direct call to "qemu-system-aarch64" because when I use the "emulator" launcher (with or without the -ranchu switch) it launches "emulator64-arm".

As the "lunch" item I've been using "aosp_arm64-eng" because I want to look at TrustZone operation and I understand that is only supported for the 64-bit architecture.

Peter

David Turner

unread,
Dec 9, 2015, 1:21:47 PM12/9/15
to peter....@plextek.com, Android emulator development
On Wed, Dec 9, 2015 at 9:43 AM, <peter....@plextek.com> wrote:
David,

Firstly, thank you for help in this.

I started using the direct call to "qemu-system-aarch64" because when I use the "emulator" launcher (with or without the -ranchu switch) it launches "emulator64-arm".


yes, that's an area that is under heavy refactoring at the moment. -ranchu doesn't do anything, you can use the new "- engine qemu2" option to force the launch of qemu-system-aarch64. Normally this should be launched automatically for arm64 though. What are you exactly trying to launch (AVD or platform build), with which version of the emulator?

- Digit


peter....@plextek.com

unread,
Dec 10, 2015, 5:44:00 AM12/10/15
to Android emulator development, peter....@plextek.com
David,

Adding "-engine qemu2" worked.

I am using an AVD, but I could not find a device for which the "android avd" tool would offer the "arm64/armeabi-v8a" CPU/ABI. I built a device based on the Nexus 9 and then edited the config.ini and set:

abi.type=armeabi-v8a
hw.cpu.arch=arm64
hw.cpu.model=cortex-a57

Ultimately I want to build a kernel that includes the "Trusty" drivers and emulate a system that includes the TLK Trusted Execution Environment so that I can understand how they work together. Do you think I am on the right track? (It has been suggested to me that the Android Qemu might not support this)

Thanks,

Peter

David Turner

unread,
Dec 15, 2015, 3:53:38 AM12/15/15
to peter....@plextek.com, Android emulator development
On Thu, Dec 10, 2015 at 11:43 AM, <peter....@plextek.com> wrote:
David,

Adding "-engine qemu2" worked.

I am using an AVD, but I could not find a device for which the "android avd" tool would offer the "arm64/armeabi-v8a" CPU/ABI.  I built a device based on the Nexus 9 and then edited the config.ini and set:

    abi.type=armeabi-v8a
    hw.cpu.arch=arm64
    hw.cpu.model=cortex-a57

Ultimately I want to build a kernel that includes the "Trusty" drivers and emulate a system that includes the TLK Trusted Execution Environment so that I can understand how they work together.  Do you think I am on the right track?  (It has been suggested to me that the Android Qemu might not support this)

 
As far as I know, the aosp_arm64-userdebug or aosp_arm64-eng AOSP builds are the best way to test ARM64 support right now.
A Nexus-9 based system image will not have the necessary support files (e.g. HAL modules, init and fstab configuration files) to run under emulation.

You should be able to rebuild a kernel by using the android-goldfish-3.10 branch on android.googlesource.com/kernel/goldfish.git, using "$AOSP/prebuilts/qemu-kernel/build-kernel.sh --arch=arm64"
I don't know enough about Trusted Execution Environment et al to tell you whether our version of QEMU2 supports it though, or if you need to configure the kernel in a specific way.
 
Reply all
Reply to author
Forward
0 new messages