Android-x86 Project Marshmallow Porting

https://docs.google.com/presentation/pub? id=1mUQDFaERipwQQWHiZxmkvwPXNPlqtdv9lXrY5hPoUJ4 黃志偉 [email protected] 2015/11/28 http://cwhuang.info

android-x86.org Agenda

●Introduction: what, why, how? ●History and milestones, current status ●How to develop android-x86 ●Inside android-x86 ●App compatibility issues ●What we contributed? ●Difficulties and challenges ●Live Demo?

android-x86.org Introduction

●What's Android-x86? ●Why needs Android-x86? ●How can we do it?

android-x86.org What's Android-x86 ?

●An open source project aimed to provide a complete solution for Android on x86 devices. ●At first we use Eee PC and virtual box as the reference platform. ●Some vendors donate tablets to us, like Tegatech Tegav2, 4tiitoo AG WeTab and AMD. ●BSP (Board support Package) for x86 platform

android-x86.org Why needs Android for x86?

●Android is an open source operating-system designed for arm platform ●But it's open source, we can port it to other platforms? ● Mips porting (MIPS Technology) ● PowerPC porting ● Mentor Graphics ● Power.org ● x86 porting

android-x86.org But what are the benefits?

●Understanding Android porting process ●The x86 platform is widely available ●As a test platform, much faster than SDK emulator ●Android-x86 on vbox / vmware ●Suitable for tablet apps

android-x86.org Android architecture

android-x86.org How to do that?

●Toolchains – already in AOSP, but old... ●Kernel – almost works, except power management, drivers ●Libraries – bugfixes or improvements ● Building time – bionic, llvm, ppp, v8, ... ● Runtime – , vold, ... ●HAL (hardware abstraction layer) ●Framework / app ●Android 4.0 (ICS) is the first Android version that can be built for x86 without patches. However, to make it run on a real x86 device, there are still a lot of work to do.

android-x86.org History (2009)

●Mar: Not maintained, need patches ●Apr: Patch hosting for android x86 support by Yi Sun ●May: Hard to maintain and sync with upstream ●Jun: Need a common, complete code base ●Jul: android-x86.org, release v0.9 ●Aug: Build 20090820 ●Sep: Build 20090916 ●Oct: Build 20091024 ●Nov: Android-x86 1.6 released ●Dec: Eclair 2.0 porting

android-x86.org History (2010)

●Jan: Build 20100115 (Android 2.0) ●Feb: Create eclair-x86 branch (Android 2.1) ●Mar: Android-x86 1.6-r2 released ●Apr: Eclair-x86 updated to 2.1-update1 ●Jul: Working on froyo-x86 ●Aug: A test iso for vm released ●Sep: target eeepc, i915 HAL, 3G support ●Oct: 3D hardware acceleration ●Nov: Improved vold, target viewpad10 ●Dec: Installer read-write support, i965 support

android-x86.org History (2011)

●Jan: Android-x86 2.2 released ●Feb: Gingerbread-x86 branch (Android 2.3) ●Mar: Honeycomb-x86 porting (private) ●Jul: Android-x86 2.2-r2 released ●Aug: Android-x86 2.3-RC1 released ●Nov: Android-x86 3.2-RC2 released ●Dec: ICS-x86 branch (Android 4.0)

android-x86.org History (2012)

●Jan: Build 20120101 ●Feb: Android-x86 4.0-RC1 released ●Apr: Update ics-x86 to 4.0.4 ●Jul: Android-x86 4.0-RC2 released ●Nov: Jb-x86 porting based on Android 4.2 ●Jul: Build 20121225 (Android 4.2)

android-x86.org History (2013)

●Feb: Build 20130228 (Android 4.2) ●Jun: Android-x86 4.0-r1 released ●Jul: Build 20130725 (Android 4.3) ●Nov: Kitkat-x86 porting based on Android 4.4

android-x86.org History (2014)

●Feb: Android-x86 4.4-RC1 released ●Apr: Add ntfs/exfat/ext4 support to vold ●May: Android-x86 4.4-RC2 released ●Aug: Android-x86 4.4-r1 released ●Nov: Lollipop-x86 porting based on Android 5.0 ●Dec: Kernel 3.18 porting

android-x86.org History (2015)

●Jan: Android-x86 4.4-r2 released ●Mar: Lollipop-x86 updated to Android 5.1 ●Apr: Kernel 4.0 porting ●Oct: Android-x86 5.1-rc1 released ●Oct: Marshmallow-x86 porting for Android 6.0 ●Oct: Move git server to SourceForge

android-x86.org Analytics: www.android-x86. org

android-x86.org Visitors map overlay

android-x86.org Statistics (2009/08-2012/04)

●Visits: 7,212,717 ●Unique Visitors: 4,447,993 ●Pageviews: 15,503,549 ●Top 5 Country/Territory ● United States ● South Korea ● Germany ● Russia ● China

android-x86.org Features of lollipop-x86

●Android 5.1.1 (Lollipop-MR1) based ●Support both 32-bit and 64-bit systems ●Kernel 4.0.9, KMS enabled, support /tablet native resolution ●Live CD & disk installer, support ext4/ext3/ext2/ntfs/fat32 ●Provide hybrid iso image and EFI image ●Hardware 3D acceleration (/radeon/nvidia ) ●Wifi, Bluetooth and Audio support ●Auto-detect drivers ●Touchscreen support, including calibration ●Compressed filesystem (squashfs) ●Support virtual machine like Virtual Box, Qemu and VMware ●Debug mode (busybox, mksh, …)

android-x86.org Screenshots

android-x86.org Develop android-x86

●Get the source tree ●Create a target (optional) ●Customize kernel (optional) ●Build an iso ●Test on target device

android-x86.org Get source

●The git server ● git.androidx86.org ● android-x86.git.sf.net

$ repo init -u git://gitscm.sf.net/gitroot/android- x86/manifest \ -b marshmallow-x86 $ repo sync

android-x86.org Generic target

●Device tree under ■ device/generic/x86 ■ device/generic/x86_64 ■ device/generic/common ●BoardConfig.mk

android-x86.org BoardConfig.mk

●BOARD_GPU_DRIVERS := i915 i965 r600g swrast i915g nouveau r300g vmwgfx

●WPA_SUPPLICANT_VERSION := VER_0_8_X or VER_0_6_X

●TARGET_ARCH_VARIANT:= x86 or x86-atom

●include $(GENERIC_X86_CONFIG_MK)

android-x86.org Build kernel

●Building rules under $(TOP)/build/core/tasks/kernel.mk

●Each target can specify its own kernel config ●Kernel image and modules are built on-fly ●Build kernel solely: make kernel ➔ out/target/product/$TARGET/kernel ➔ out/target/product/$TARGET/system/lib/modules/

android-x86.org Customize kernel

●$ source build/envsetup.sh ●$ lunch android_x86(_64)-userdebug ●$ make -C kernel O=$OUT/obj/kernel \ ARCH=x86 menuconfig

●$ cp $OUT/obj/kernel/.config kernel/arch/x86/configs/ ●DO NOT make in kernel/ directly. If you do so, try $ make -C kernel distclean $ rm -rf $OUT/obj/kernel

android-x86.org Build an iso image

●$ source build/envsetup.sh ●$ lunch $target-userdebug ●$ make -jN iso_img ● out/target/product/$target/$target.iso {kernel,initrd.img,installer.img,ramdisk.img,system.sfs}

●Compress filesystem if mksquashfs is available (Disable it by USE_SQUASHFS=0)

android-x86.org Test the iso image

●Hybrid iso format ●Create a bootable USB ● dd if=target.iso of=/dev/sdX ● Unetbootin ● Live USB Creator ( LiLi ) ●Boot from the USB disk ● Live mode ● VESA mode ● Debug ● Installer

android-x86.org Inside android-x86

●Bootstrap ●Peripherals support ● Graphic hardware acceleration ● Wifi ● Touchscreen ● Audio ● Bluetooth ● GPS ● G-sensor ● 3G modem ● Storage

android-x86.org Bootstrap android-x86

●Bootloader (grub) loads kernel & initrd.img ●init script (bootable/newinstaller/initrd/init) ● Detect android-x86 filesystem ● Unpack ramdisk.img, mount /android/system ● Load scripts (/scripts, /src/scripts) ● Run installer if INSTALL=1 ● Load modules (auto-detect) ● mount /android/data, /android/sdcard ● Run ts_calibrate if BOARD_USES_TSLIB=true ● Set DPI ● Post detect ● switch_root (chroot) /android

android-x86.org Init hook scripts

●Default scripts ● 0-auto-detect ● 1-install ● 2-mount ● 3-tslib ● 4-dpi ●Target script ●Customize scripts

android-x86.org Revise booting

●Boot parameters can be put to cmdline ● ROOT ● SRC ● DATA, SDCARD ● EXTMOD ● DEBUG ● UVESA_MODE ● HWACCEL ● BOARD_USES_TSLIB ● DPI ●Put scripts in $SRC/scripts/

android-x86.org Debug mode

●Boot by DEBUG=1 ●Write boot log to /tmp/log ●Enter interactive shell twice ● After mount android filesystem ● Before chroot ●Another two virtual consoles at Alt-F2 / F3 ●Run android-x86 in chroot ● Be able to access files outside android filesystem at Alt-F2 / F3 (e.g., /mnt/grub/menu.lst) ●Auto start logcat (/data/log.txt)

android-x86.org Graphic system

●Android uses framebuffer driver, no X ● vesa driver ● uvesa driver ● hardware driver - KMS or non-KMS ●Use soft rendering by default ● Buggy for 1366x768 ● Very slow in 32-bit color depth ●Implements hardware rendering by Mesa library ● Needs KMS driver

android-x86.org How to change resolution?

●vesa driver vga=xxx, vga=ask

●uvesa driver UVESA_MODE=

●hardware driver, no Mesa video=1280x800-32

●KMS + Mesa setprop debug.drm.mode 1024x768

android-x86.org Mesa porting for HW acceletion

Android graphic system ●Version 11.0.3 ●~ 60 fps ●Support drm_gralloc (HAL) ● Intel integrated graphic chip ● AMD radeon/radeonsi libGLES_mesa ● Nvidia (nouveau) ● Vmware? (vmwgfx) libdrm ●Not support ● Zxxx, E6xx (PowerVR) Kernel KMS driver

GPU hardware

android-x86.org Wifi

●Android-x86 adds patches to auto-detect wifi driver ● /sys/class/net/*/wireless ●WPA_SUPPLICANT_VERSION := ● VER_0_8_X ● VER_0_6_X ●BOARD_WPA_SUPPLICANT_DRIVER := ● NL80211 (0_8) ● AWEXT (0_6) ●BOARD_WPA_SUPPLICANT_PRIVATE_LIB := ● private_lib_driver_cmd (0_8)

android-x86.org Touchscreen

●ICS needs an idc file for touchscreen ● VID & PID ● Device name ●Android-x86 uses a default GenericTouch.idc if no special idc found for a touchscreen. ●Most touchscreens should just work if drivers are available.

android-x86.org Touchscreen driver

●May need to load driver by EXTMOD ●May need to calibrate by setting BOARD_USES_TSLIB=true ●Most new multi-touch touchscreens are supported by hid-multitouch driver. echo 3 03eb 201c 1 > \ /sys/module/hid_multitouch/drivers/hid:hid-multitouch/new_id

●Multi-touch issues can be reported to Benjamin Tissoires, who has great help to android-x86.org.

android-x86.org Audio

●Audio HAL has been changed in ICS. WindRiver’s implementation alsa_sound doesn’t work anymore. ●Use a hacked version from Linaro. ●BoardConfig.mk BOARD_USES_GENERIC_AUDIO := false BOARD_USES_ALSA_AUDIO := true BUILD_WITH_ALSA_UTILS := true

●Some audio chips don’t work?

android-x86.org Bluetooth

●Android searches /sys/class/rfkill/rfkillX where X starts from 0 ●Not always true if devices reconnect ●Android-x86 modified it to search /sys/class/rfkill/ directly ●Tested drivers: btusb, ath3k ●Some issues are reported for ath3k

android-x86.org GPS

●HAL hardware/gps contributed by a volunteer to support GPS input from tty ● setprop ro.kernel.android.gps ttyS3 ● setprop ro.kernel.android.gpsttybaud 9600 ●Bluetooth GPS also works (need an app from Market)

android-x86.org G-sensor

●HAL Kbdsensor: Support G-sensor inputs from keyboard driver: Ctrl-Alt-arrow keys ● BOARD_USES_KBDSENSOR := true ● BOARD_USES_KBDSENSOR_ROTKEY1 := true (F9-F12) ● BOARD_USES_KBDSENSOR_ROTKEY2 := true (F5-F8) ●HDAPS accelerometer sensor (thinkpad) ● BOARD_USES_HDAPS_ACCEL := true

android-x86.org 3G modem

●Two implementations of RIL ● reference-ril ● huaweigeneric-ril ●setprop rild.libpath /system/lib/libhuaweigeneric-ril.so ●setprop rild.libargs "-d /dev/ttyUSB2 -v /dev/ttyUSB1" ●Only tested OK on Huawei modem ●Internet, SMS work ●Phone also works, but no sound

android-x86.org Storage

●Support internal storage since 4.0-RC1 ● Use internal storage to simulate /mnt/sdcard ● Share the same space as /data ●MMC/SD/USB auto-mount ● A modified vold daemon ● No vold.fstab needed ●Fake sdcard is considered obsolete

android-x86.org App compatibility?

●Use arm native code (jni) ● NDK r6 support x86 ●Need special peripherals ● Sensors, GPS, NFC ●Resolution issue ● Not design for tablet ●Force portrait mode

android-x86.org Make the app friendly for x86

●Do not use jni, or build x86 libs ■ MoboPlayer for x86, Dolphin player ●Consider larger resolution ●Allow landscape mode ●Design tablet mode

android-x86.org Open source activities

●www.android-x86.org ● code.google.com/p/android-x86 ● sourceforge.net/projects/android-x86 ●Over 2,800,000 downloads ● Over 320,000 downloads for ics-x86 ●twitter.com/android_x86 ●IRC at irc.freenode.net #android-x86

android-x86.org Discussion group

●groups.google.com/group/android-x86 ●[email protected] ●Over 3600 subscribers ●~ 1000 emails/month

android-x86.org Cowork with upstream AOSP

●Submit patches to review.source.android.com ●19 patches are accepted and merged (2010): ●9779, 10065, 10066, 11443, 11444, 13251,13272, 13467, 13468, 14078, 14117, 15209, 15599, 15664, 15702, 15975, 16034, 16979, 16980 ●Patches review in progress ●16035, 16162, 16163, 16318, 17233, 17234, 17273

android-x86.org Open source partners

●0xdroid - 0xlab ●CyanogenMod ●MirOS (mksh) ●OESF ●Open Invention Network (OIN) ●LIME

android-x86.org What we contributed?

●Modified build system to customize kernel ●Open source OpenGL ES implementation ●New style Android installer ●MMC/SD/USB auto-mount ●Configurable keyboard layouts ●Soft mouse cursor (obsolete) ●Ethernet support (deprecated)

android-x86.org Soft mouse cursor & Ethernet

●Handle mouse events and draw cursor on Canvas ●Support wheel for scrolling, right button ●Obsolete since honeycomb ●Ethernet status tracker (like Wifi status tracker) ●Monitor the Ethernet status ●Configurable via Settings ●Considered deprecated ●Simulate by libril-ethernet?

android-x86.org Challenges

●Too many platforms, peripherals ●auto-detect, target specified scripts ●Android is originally designed for ARM ●Some are optimized for ARM only ●Some apps only provide ARM version ●Optimization for x86 ●Art, bionic, llvm, v8, ... ●Hardware acceleration (2D/3D, codec, ...) ●Power management

android-x86.org Vendors

●Google ●No interesting before, but may changed since ICS ●Difficulty: don't use AOSP tree ●Intel ●At first no interesting, no help ●Begin their own porting recently ●Criticize?

android-x86.org Call for developers

●Google group: Android-x86 http://groups.google.com/group/android-x86

●IRC channel at irc.freenode.net #android-x86

●Issue tracker http://code.google.com/p/android-x86/issues/list

android-x86.org