android_packages_modules_Vi.../microdroid
Jooyung Han c36b18a443 Apexd runs in microdroid
Previously, we ran only 'apexd-bootstrap' because 'apexd' crashes due to
the lack of /data/apex in microdroid.

Now apexd runs in "vm" mode. In vm mode, apexd only activates built-in
apexes and block apexes. No data apexes, no session handling.

Bug: 179342589
Test: MicrodroidTestCase
Change-Id: I8c6a16c3b08010fcb008d822d0ba0e311c0a9985
2021-04-21 23:19:04 +09:00
..
signature Add lib_microdroid_signature_proto with proto-full 2021-04-21 23:19:03 +09:00
Android.bp Remove unused module 2021-04-21 21:34:20 +09:00
README.md Move uboot_env.img to a new composite disk 2021-04-13 17:44:44 +09:00
build.prop Add build.prop for microdroid 2021-04-06 21:25:57 +09:00
dummy_dtb.img Build vendor_boot image for microdroid 2021-02-04 23:39:09 +09:00
empty_kernel Add MicrodroidHostTestCases 2021-03-12 13:36:15 +09:00
fstab Reland "Add microdroid_vendor" 2021-03-03 14:56:18 +00:00
init.rc Apexd runs in microdroid 2021-04-21 23:19:04 +09:00
linker.config.json Microdroid is built using android_system_image module type 2021-04-20 13:23:37 +09:00
microdroid_cdisk.json Partitions are by default read-only. 2021-04-13 17:46:54 +09:00
microdroid_cdisk_env.json Partitions are by default read-only. 2021-04-13 17:46:54 +09:00
microdroid_file_contexts Add microdroid_file_contexts to build image 2021-02-03 14:50:28 +09:00
microdroid_vendor_file_contexts Reland "Add microdroid_vendor" 2021-03-03 14:56:18 +00:00
plat_sepolicy_vers.txt Reland "Add microdroid_vendor" 2021-03-03 14:56:18 +00:00
uboot-env-x86_64.txt Enable verified boot for microdroid 2021-04-14 16:48:27 +09:00
uboot-env.txt Enable verified boot for microdroid 2021-04-14 16:48:27 +09:00

README.md

Microdroid

Microdroid is a (very) lightweight version of Android that is intended to run on on-device virtual machines. It is built from the same source code as the regular Android, but it is much smaller; no system server, no HALs, no GUI, etc. It is intended to host headless & native workloads only.

Building

You need a VIM3L board. Instructions for building Android for the target, and flashing the image can be found here.

Then you install com.android.virt APEX. All files needed to run microdroid are included in the APEX, which is already in the yukawa (VIM3L) target. You can of course build and install the APEX manually.

$ source build/envsetup.sh
$ choosecombo 1 aosp_arm64 userdebug // actually, any arm64-based target is ok
$ m com.android.virt
$ adb install $ANDROID_PRODUCT_OUT/system/apex/com.android.virt.apex
$ adb reboot

Running

Copy the artifacts to the temp directory, create the composite image using mk_cdisk, and run it via crosvm. For now, some other files have to be manually created. In the future, you won't need these, and this shall be done via virtmanager.

$ adb shell 'cp /apex/com.android.virt/etc/microdroid_bootloader /data/local/tmp/bootloader'
$ adb shell 'cp /apex/com.android.virt/etc/fs/*.img /data/local/tmp'
$ adb shell 'cp /apex/com.android.virt/etc/uboot_env.img /data/local/tmp'
$ adb shell 'dd if=/dev/zero of=/data/local/tmp/misc.img bs=4k count=256'
$ adb shell 'cd /data/local/tmp; /apex/com.android.virt/bin/mk_cdisk /apex/com.android.virt/etc/microdroid_cdisk.json os_composite.img'
$ adb shell 'cd /data/local/tmp; /apex/com.android.virt/bin/mk_cdisk /apex/com.android.virt/etc/microdroid_cdisk_env.json env_composite.img'
$ adb shell 'cd /data/local/tmp; /apex/com.android.virt/bin/crosvm run --cid=5 --disable-sandbox --bios=bootloader --serial=type=stdout --disk=os_composite.img --disk=env_composite.img'

The CID in --cid parameter can be anything greater than 2 (VMADDR_CID_HOST).

ADB

$ adb forward tcp:8000 vsock:5:5555
$ adb connect localhost:8000

5 in vsock:5 should match with the CID number that was given to crosvm. 5555 must be the value. 8000 however can be any port in the development machine.

Done. Now you can log into microdroid. Have fun!

$ adb -s localhost:8000 shell