GSoC final status: porting FreeBSD to Android Emulator

Alexander Tarasikov alexander.tarasikov at gmail.com
Mon Aug 18 15:16:38 UTC 2014


Hi FreeBSD/ARM hackers!

I am reporting my status on the project.

At the start of the project in spring I have written the device
drivers for the IRQ chip, timer and framebuffer, but I was unable to
verify they work because I needed a working rootfs. I started by using
an MD_ROOT ramdisk for debugging init.

I have spent most of the summer debugging the random memory corruption
which prevented the kernel from booting on Android Emulator. I have
tried various methods, like emulating TLS/PCPU with a memory page, but
none of them helped. By trying to build a kernel for VERSATILEPB and
running in QEMU I have verified it's not the problem in
sources/compiler. By porting board code from Android Emulator to QEMU
and observing it booting I came to the conclusion that the problem was
caused by something in Android Emulator which is based on a very old
version of QEMU.

Ultimately I decided to try a "nightly" build of emulator, and that
has resolved the problem. Unfortunately, I was unable to figure out
the precise difference between Linux and FreeBSD MMU management that
prevented FreeBSD from booting on regular builds of the emulator, but
I have decided to focus on getting device drivers working first.

Today I have finished implementing the MMC driver which has allowed to
boot into the userland. I have also fixed the timer driver by adding
the call to cpu_initclocks_bsp initcall and fixing the timer
resolution. I have verified the virtual ethernet driver is also
working. I have configured a custom MAC address in qemu and verified
the kernel sees it.

I have currently pushed the changes against FreeBSD-10 to my git
repository. Later this week I plan to clean up the drivers a bit and
format the code to look like other FreeBSD driver, rebase it and then
push to the GSoC SVN repository.

https://github.com/astarasikov/freebsd/commits/android_goldfish_arm_10.0.0?author=astarasikov

I used the SD card image for Raspberry Pi which I have obtained from
http://ftp4.us.freebsd.org/pub/FreeBSD/snapshots/arm/armv6/ISO-IMAGES/10.0/FreeBSD-10.0-STABLE-arm-armv6-RPI-B-20140729-r269271.img.bz2

Here is the boot log of the first successful boot into userland:
http://pastebin.com/ZzReDjDH

It is very verbose but in the last lines we can see that it has
started init, initialized loopback device and showed and getty prompt.

You can obtain the prebuilt kernel image from the following link. I
have also updated the wiki page with this information.
https://drive.google.com/file/d/0B7wcN-tOkdeRN0lRUDJKa2pWM0U/edit?usp=sharing

Please note that the nightly builds of Android Emulator are 64-bit and
work on Linux and Mac OS X. To get them working on FreeBSD it would be
necessary to compile a 32-bit build. If you are interested in just
running Android Emulator on FreeBSD, it works just fine once you
install linux_base-f10 or some other linux library set. I will provide
the emulator binary later. If anyone wants to make a port, please note
that you have to use GCC, because QEMU's TCG is broken when compiled
with clang :(

Due to wasting a lot of time on MMU issues and debugging the MMC
driver, I was unable to write the "events" driver for keyboard input.
I plan to do it this week. I will also verify that framebuffer driver
is working correctly. I have noticed that a new interface is being
developed instead of SYSCONS, so maybe I will migrate the driver to
it.

My overall impression is positive. Although I have spend time
debugging MMU, I have learnt about the UMA memory allocator in the
process. I want to resolve the remaining issues in the next two weeks
and then I plan to add the support for the OMAP5 System-on-Chip to
FreeBSD because I have such board and I want to try out Xen DOMU.

-- 
Regards, Alexander


More information about the freebsd-arm mailing list