Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a |make config-emu| target for android emulator #25

Closed
joneschrisg opened this issue Aug 24, 2011 · 13 comments
Closed

Add a |make config-emu| target for android emulator #25

joneschrisg opened this issue Aug 24, 2011 · 13 comments

Comments

@joneschrisg
Copy link
Collaborator

B2G should be testable on top of (an) emulator for folks who don't have compatible hardware. Right now using the android emulator seems like the quickest path to success, but unfortunately it only supports up to ARMv6. That's a problem because Gecko is officially unsupported on ARMv6 and below.

The other complications can be dealt with indepedently of the build-system work to support the emulator target though.

@ThinkerYzu
Copy link
Contributor

I got an error message to complain that `stmfd sp!,{r0-r4}' is not supported by ARMv5 when I try to build Gecko for qemu. It is a line of inline assembly in linker.c. Why we need a copy of linker (from bionic?) here? Is it for implementing plugin? 'stmfd' and 'ldmia' in the linker.c:plt_reloc() should be replaced by other instructions supported by ARMv5.

Submodule boot/kernel-android-qemu is not in goldfish branch for Android emulator.

@joneschrisg
Copy link
Collaborator Author

The reason we use a custom linker in Gecko is long and complicated; ask @michaelwu to tell you the story sometime ;).

To fix that particular bug, you need to make a custom .mozconfig for the emulator that disables use of THUMB (and also forces ARMv5, IIRC). It needs to include these options

ac_add_options --disable-thumb2
ac_add_options --with-thumb=no

This new mozconfig can live in config/gecko-emulatorv5-gonk.

Alternatively, if you run into a lot of ARM bugs inside the emulator, it might be a better use of time to import a newer ARMv7-compatible version of qemu.

@ThinkerYzu
Copy link
Contributor

I have booted B2G with Android emulator. But, it stop at "Setting up Fennec...", it hanged. Current configuration is with ARMv7 for Gecko, but Android image was built for ARMv5. It seems workable. I will figure out what make it hanged later.

@ThinkerYzu
Copy link
Contributor

Gonk is now ARMv6 + vfpv2 for Android emulator. But, gdb and gdbserver seem having no consensus on architecture of a debugged target. I am trying to find out a solution for remote debugging and will go back to hanging issue later.

@joneschrisg
Copy link
Collaborator Author

Nice work!

@ThinkerYzu
Copy link
Contributor

I have a resolution for GDB issue, now. gdb-7.x provides a way to specify architecture features. You should set a target description file for GDB when you debug B2G for Android emulator. For example,

set tdesc filename /path/to/gdb-src/gdb/features/arm-with-iwmmxt.xml

arm-with-iwmmxt.xml is provided by gdb in the gdb/features/ sub-directory. It makes gdb to support XScale features. Without this, gdbserver would send more data than expected when gdb requests for register values.

To enable target description, you must build gdb-7.x with --with-expat option. I use gdb-7.3 from moz-gdb @ https://wiki.mozilla.org/Mobile/Fennec/Android/GDB. But, this version has a litte bug in configure/configure.ac that you can not cross-compile without dirty hacking. I have a fixed version @ git://github.com/ThinkerYzu/android-gdb.git. Following is my configuration command

../configure --target=arm-linux-androideabi --with-python=yes --prefix=/root/moz-gdb --with-gdb-datadir=/root/moz-gdb/utils --with-system-gdbinit=/root/moz-gdb/utils/gdbinit --with-expat

@ThinkerYzu
Copy link
Contributor

Get SIGILL with si_code == ILL_ILLOPC. It means running an illegal instruction. I will try to add these instructions for Android emulator.

@ThinkerYzu
Copy link
Contributor

I have switched Android emulator to tools_r13 branch. There is ARMv7 supporting code in the branch. But, it hangs at some place once boot it with any CPU model other than "arm926" (default one).

@ThinkerYzu
Copy link
Contributor

Kernel can not recoganize CPU type for cortex-a8. Try to add proc_info for it from existing ones.

@ThinkerYzu
Copy link
Contributor

It is successful to run B2G on Android emulator with ARMv7. Use goldfish_armv7_defconfig instead of goldfish_defconfig to config Linux. After building B2G with config-qemu, you can run Android emulator with following command for B2G.

$B2G_HOME/glue/gonk/out/host/linux-x86/bin/emulator \
    -kernel $B2G_HOME/boot/kernel-android-qemu/arch/arm/boot/zImage \
    -sysdir $B2G_HOME/glue/gonk/out/target/product/generic/ \
    -data $B2G_HOME/glue/gonk/out/target/product/generic/userdata.img \
    -memory 512 \
    -verbose \
    -qemu -cpu 'cortex-a8'

This command runs Android emulator with 'cortex-a8'.
You can pull changes, of B2G for Android emulator, from git://github.com/ThinkerYzu/B2G.git.

@joneschrisg
Copy link
Collaborator Author

Fantastic, nice work! :)

Would you like to create a pull request for these changes? Andreas and I will be in the office this afternoon so we can discuss this in person.

@joneschrisg
Copy link
Collaborator Author

@ThinkerYzu want to close this issue? This works great for me! :)

@ThinkerYzu
Copy link
Contributor

ok... Let's close it.

@arky arky mentioned this issue Apr 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants