Microdroid runs on cuttlefish_x86_64

This CL includes x86_64 specific changes that are required to run
microdroid on cuttlefish_x86_64.

1) Unsigned bootloader is used. (b/185115783)
2) androidboot.boot_devices is correctly set for the architecture
3) uboot-env.txt is customized to set loadaddr
4) MicrodroidTestCase is revised to handle the case when multiple
devices are connected.

Bug: 185115783
Bug: 185082754
Test: atest MicrodroidHostTests with aosp_cf_x86_64_phone

Change-Id: I1baebedd392f742f9a9cd064d63a8c3741e46daa
This commit is contained in:
Jiyong Park 2021-04-13 13:13:55 +09:00
parent ebc3a37b3e
commit 89e81cb889
3 changed files with 55 additions and 9 deletions

View File

@ -132,6 +132,14 @@ logical_partition {
], ],
} }
// TODO(jiyong): change the name to init, cause it's confusing
microdroid_boot_cmdline = "rdinit=/bin/init_vendor " +
"panic=-1 " +
// TODO(b/181936135) make the ratelimiting conditional; ratelimiting on prod build
"printk.devkmsg=on " +
"androidboot.first_stage_console=1 " +
"androidboot.hardware=microdroid "
bootimg { bootimg {
name: "microdroid_boot-5.10", name: "microdroid_boot-5.10",
ramdisk_module: "microdroid_ramdisk-5.10", ramdisk_module: "microdroid_ramdisk-5.10",
@ -141,19 +149,16 @@ bootimg {
arch: { arch: {
arm64: { arm64: {
kernel_prebuilt: ":kernel_prebuilts-5.10-arm64", kernel_prebuilt: ":kernel_prebuilts-5.10-arm64",
cmdline: microdroid_boot_cmdline +
"androidboot.boot_devices=10000.pci",
}, },
x86_64: { x86_64: {
kernel_prebuilt: ":kernel_prebuilts-5.10-x86_64", kernel_prebuilt: ":kernel_prebuilts-5.10-x86_64",
cmdline: microdroid_boot_cmdline +
"pci=noacpi " +
"androidboot.boot_devices=pci0000:00/0000:00:01.0",
}, },
}, },
// TODO(jiyong): change the name to init, cause it's confusing
cmdline: "rdinit=/bin/init_vendor " +
"panic=-1 " +
// TODO(b/181936135) make the ratelimiting conditional; ratelimiting on prod build
"printk.devkmsg=on " +
"androidboot.first_stage_console=1 " +
"androidboot.hardware=microdroid " +
"androidboot.boot_devices=10000.pci ",
dtb_prebuilt: "dummy_dtb.img", dtb_prebuilt: "dummy_dtb.img",
header_version: "4", header_version: "4",
partition_name: "boot", partition_name: "boot",
@ -227,6 +232,14 @@ prebuilt_etc {
prebuilt_etc { prebuilt_etc {
name: "microdroid_bootloader", name: "microdroid_bootloader",
src: ":microdroid_bootloader_gen", src: ":microdroid_bootloader_gen",
arch: {
x86_64: {
// For unknown reason, the signed bootloader doesn't work on x86_64. Until the problem
// is fixed, let's use the unsigned bootloader for the architecture.
// TODO(b/185115783): remove this
src: ":cuttlefish_crosvm_bootloader",
},
},
filename: "microdroid_bootloader", filename: "microdroid_bootloader",
} }
@ -262,6 +275,11 @@ genrule {
prebuilt_etc { prebuilt_etc {
name: "microdroid_uboot_env", name: "microdroid_uboot_env",
src: ":microdroid_uboot_env_gen", src: ":microdroid_uboot_env_gen",
arch: {
x86_64: {
src: ":microdroid_uboot_env_gen_x86_64",
},
},
filename: "uboot_env.img", filename: "uboot_env.img",
} }
@ -273,6 +291,14 @@ genrule {
cmd: "$(location mkenvimage_host) -s 4096 -o $(out) $(in)", cmd: "$(location mkenvimage_host) -s 4096 -o $(out) $(in)",
} }
genrule {
name: "microdroid_uboot_env_gen_x86_64",
tools: ["mkenvimage_host"],
srcs: ["uboot-env-x86_64.txt"],
out: ["output.img"],
cmd: "$(location mkenvimage_host) -s 4096 -o $(out) $(in)",
}
// sepolicy sha256 for vendor // sepolicy sha256 for vendor
prebuilt_etc { prebuilt_etc {
name: "microdroid_precompiled_sepolicy.plat_sepolicy_and_mapping.sha256", name: "microdroid_precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",

View File

@ -0,0 +1,13 @@
# Static u-boot environment variables for microdroid. See b/180481192
# Boot the device following the Android boot procedure
bootcmd=boot_android virtio 0#misc
bootdelay=0
# U-Boot in x86_64 by defaults loads kernel at 0x20000000 (512MB), which is
# out of the physical memory when the VM is launched with the default memory
# size of 256MB. To avoid that, explicitly set the kernel load addresss using
# loadaddr variable.
loadaddr=0x02000000
fdtaddr=0x40000000

View File

@ -112,7 +112,14 @@ public class MicrodroidTestCase extends BaseHostJUnit4Test {
Thread.sleep(MICRODROID_BOOT_TIMEOUT_MILLIS); Thread.sleep(MICRODROID_BOOT_TIMEOUT_MILLIS);
// Connect to microdroid and read a system property from there // Connect to microdroid and read a system property from there
executeCommand("adb forward tcp:" + TEST_VM_ADB_PORT + " vsock:" + TEST_VM_CID + ":5555"); executeCommand(
"adb -s "
+ getDevice().getSerialNumber()
+ " forward tcp:"
+ TEST_VM_ADB_PORT
+ " vsock:"
+ TEST_VM_CID
+ ":5555");
executeCommand("adb connect " + MICRODROID_SERIAL); executeCommand("adb connect " + MICRODROID_SERIAL);
String prop = executeCommand("adb -s " + MICRODROID_SERIAL + " shell getprop ro.hardware"); String prop = executeCommand("adb -s " + MICRODROID_SERIAL + " shell getprop ro.hardware");
assertThat(prop, is("microdroid")); assertThat(prop, is("microdroid"));