From 4f11280e3d70728fba24e572428e559b7b6f8093 Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Mon, 26 Jun 2017 11:19:50 -0700 Subject: uml: initial revision Added AndroidProducts.mk, which tells the build system to find the uml makefile at uml.mk. BoardConfig.mk specifies system.img to consist only of the /system partition instead of the root. With CONFIG_BLK_DEV_INITRD=y in the kernel, it is possible to boot from ramdisk.img and mount /data and /system during init. TARGET_USER_MODE_LINUX enables uml-specific cflags. TARGET_USES_64_BIT_BINDER is set to true due to UML not supporting running 32-bit binaries in 64-bit mode. Added fstab.uml to mount /data, /system, and the host filesystem as a partition named /host. Since adb does not work with uml yet, an already mounted hostfs makes it convenient to transfer files to the uml system. Added init.uml.rc, which tells init to mount the contents of fstab.uml during the fs stage. Added basic uml.mk to inherit minimal packages from embedded.mk and copy init.uml.rc, fstab.uml, and surfaceflinger.rc into the system.img. Failing service surfaceflinger has been disabled by the inclusion of a custom surfaceflinger.rc file, which simply has `disabled' appended to it. Added vendorsetup.sh to add lunch combo uml-userdebug In order to run UML for Android, you must have built the um kernel with Android configs. To do this, run these commands from the kernel repository: $ ARCH=um SUBARCH=x86_64 scripts/kconfig/merge_config.sh arch/um/configs/x86_64_defconfig kernel/configs/android-base.config kernel/configs/android-recommended.config $ make ARCH=um SUBARCH=x86_64 CROSS_COMPILE= -j40 The output is an executable vmlinux binary. The command to run UML is: $ ./vmlinux initrd=ramdisk.img ubda=system.img ubdb=userdata.img androidboot.hardware=uml mem=256M umid= To halt the uml process, in another terminal, run `uml_mconsole ' and supply the command `halt'. Test: manual Bug: 32523022 Change-Id: I4a1cd6ceb42831a995bbefd3dd8a6ca3596d65ea Signed-off-by: Quang Luong --- AndroidProducts.mk | 18 ++++++++++++++++++ BoardConfig.mk | 22 ++++++++++++++++++++++ fstab.uml | 8 ++++++++ init.uml.rc | 2 ++ surfaceflinger.rc | 12 ++++++++++++ uml.mk | 29 +++++++++++++++++++++++++++++ vendorsetup.sh | 1 + 7 files changed, 92 insertions(+) create mode 100644 AndroidProducts.mk create mode 100644 BoardConfig.mk create mode 100644 fstab.uml create mode 100644 init.uml.rc create mode 100644 surfaceflinger.rc create mode 100644 uml.mk create mode 100755 vendorsetup.sh diff --git a/AndroidProducts.mk b/AndroidProducts.mk new file mode 100644 index 0000000..369b2d4 --- /dev/null +++ b/AndroidProducts.mk @@ -0,0 +1,18 @@ +# +# Copyright (C) 2017 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +PRODUCT_MAKEFILES := \ + $(LOCAL_DIR)/uml.mk \ No newline at end of file diff --git a/BoardConfig.mk b/BoardConfig.mk new file mode 100644 index 0000000..b6eb431 --- /dev/null +++ b/BoardConfig.mk @@ -0,0 +1,22 @@ +# +# Product-specific compile-time definitions. +# + +# The generic product target doesn't have any hardware-specific pieces. +TARGET_NO_BOOTLOADER := true +TARGET_NO_KERNEL := true +TARGET_CPU_ABI := x86_64 +TARGET_ARCH := x86_64 +TARGET_ARCH_VARIANT := x86_64 + +TARGET_USER_MODE_LINUX := true + +TARGET_USES_64_BIT_BINDER := true + +TARGET_USERIMAGES_USE_EXT4 := true +# Let UML mount userdata.img in a non-sparse format +TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true + +BOARD_SYSTEMIMAGE_PARTITION_SIZE := 786432000 +BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800 +BOARD_FLASH_BLOCK_SIZE := 512 diff --git a/fstab.uml b/fstab.uml new file mode 100644 index 0000000..1131f38 --- /dev/null +++ b/fstab.uml @@ -0,0 +1,8 @@ +# Android fstab file. +# +# The filesystem that contains the filesystem checker binary (typically /system) cannot +# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK +/dev/block/ubda /system ext4 ro wait +/dev/block/ubdb /data ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check +# When UML sees type "hostfs", it will mount the hostfs to the mount point instead of checking the +none /host hostfs defaults none diff --git a/init.uml.rc b/init.uml.rc new file mode 100644 index 0000000..e5b5d7d --- /dev/null +++ b/init.uml.rc @@ -0,0 +1,2 @@ +on fs + mount_all ./fstab.uml diff --git a/surfaceflinger.rc b/surfaceflinger.rc new file mode 100644 index 0000000..0f2cb32 --- /dev/null +++ b/surfaceflinger.rc @@ -0,0 +1,12 @@ +# This custom surfaceflinger.rc simply has `disabled' appended to it. +# Since we are using UML without a screen, and embedded.mk is the +# smallest mk file but still contains surfaceflinger, including this +# custom surfaceflinger.rc will disable surfaceflinger from running. + +service surfaceflinger /system/bin/surfaceflinger + class core + user system + group graphics drmrpc readproc + onrestart restart zygote + writepid /dev/stune/foreground/tasks + disabled diff --git a/uml.mk b/uml.mk new file mode 100644 index 0000000..a7fa7f7 --- /dev/null +++ b/uml.mk @@ -0,0 +1,29 @@ +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk) +$(call inherit-product, $(SRC_TARGET_DIR)/product/embedded.mk) + +PRODUCT_NAME := uml +PRODUCT_DEVICE := uml +PRODUCT_BRAND := Android +PRODUCT_MODEL := UML for x86_64 + +# default is nosdcard, S/W button enabled in resource +DEVICE_PACKAGE_OVERLAYS := device/generic/x86/overlay +PRODUCT_CHARACTERISTICS := nosdcard + +PRODUCT_COPY_FILES += $(LOCAL_PATH)/fstab.uml:root/fstab.uml +PRODUCT_COPY_FILES += $(LOCAL_PATH)/init.uml.rc:root/init.uml.rc +PRODUCT_COPY_FILES += $(LOCAL_PATH)/surfaceflinger.rc:system/etc/init/surfaceflinger.rc diff --git a/vendorsetup.sh b/vendorsetup.sh new file mode 100755 index 0000000..fd5fc0b --- /dev/null +++ b/vendorsetup.sh @@ -0,0 +1 @@ +add_lunch_combo uml-userdebug -- cgit v1.2.3