【发布时间】:2021-05-13 18:24:03
【问题描述】:
我编译了自己的 AOSP 映像并得到了这个:
lz@vm:/mnt/android-dev-3/aosp/grapheneos-lz_experiments/out/target/product/generic_x86_64$ ls *.img
cache.img ramdisk.img system.img vendor_boot-debug.img
dtb.img ramdisk-qemu.img system-qemu.img vendor_boot.img
encryptionkey.img super_empty.img userdata.img vendor.img
ramdisk-debug.img super.img vbmeta.img vendor-qemu.img
然后我compiled my own Android emulator。
我知道我不需要自己指定 .img,AOSP 预构建的模拟器可以正常工作,但我想用于其他目的。
所以我做了DIR_OUT = /mnt/android-dev-3/aosp/grapheneos-lz_experiments/out/target/product/generic_x86_64
./emulator -sysdir $DIR_OUT/system -datadir $DIR_OUT/data -kernel $DIR_OUT/kernel-ranchu -ramdisk $DIR_OUT/ramdisk.img -system $DIR_OUT/system.img -data $DIR_OUT/userdata.img -cache $DIR_OUT/cache.img -vendor $DIR_OUT/vendor.img
emulator: ERROR: No AVD specified. Use '@foo' or '-avd foo' to launch a virtual device named 'foo'
emulator: WARNING: userdata partition is resized from 550 M to 800 M
emulator: WARNING: encryption is off
Segmentation fault (core dumped)
您可以通过评论return 看到我忽略了 AVD 错误
if (!avdName && !avdArch && !androidOut && !forceEngineLaunch && !queryVersion) {
derror("No AVD specified. Use '@foo' or '-avd foo' to launch a virtual"
" device named 'foo'\n");
//return 1;
}
因为没有它我什么都做不了。由于我的怪癖,它可能是 segfaulting,但没有它,我自己看不到如何使用 .img 运行。
以下是 android 模拟器关于指定我自己的 .img 文件的说明:
./emulator -help-disk-images
The emulator needs several key image files to run appropriately.
Their exact location depends on whether you're using the emulator
from the Android SDK, or not (more details below).
The minimal required image files are the following:
kernel-qemu the emulator-specific Linux kernel image
ramdisk.img the ramdisk image used to boot the system
system.img the *initial* system image
vendor.img the *initial* vendor image
userdata.img the *initial* data partition image
It will also use the following writable image files:
userdata-qemu.img the persistent data partition image
system-qemu.img an *optional* persistent system image
vendor-qemu.img an *optional* persistent vendor image
cache.img an *optional* cache partition image
sdcard.img an *optional* SD Card partition image
snapshots.img an *optional* state snapshots image
If you use a virtual device, its content directory should store
all writable images, and read-only ones will be found from the
corresponding platform/add-on directories. See -help-sdk-images
for more details.
If you are building from the Android build system, you should
have ANDROID_PRODUCT_OUT defined in your environment, and the
emulator shall be able to pick-up the right image files automatically.
See -help-build-images for more details.
If you're neither using the SDK or the Android build system, you
can still run the emulator by explicitely providing the paths to
*all* required disk images through a combination of the following
options: -sysdir, -datadir, -kernel, -ramdisk, -system, -data, -cache
-sdcard and -snapstorage.
The actual logic being that the emulator should be able to find all
images from the options you give it.
没有说明如何克服这个错误
更新:
分段错误就在这一行:
sysImagePath = std::string(
avdInfo_getSystemImagePath(m_avd)
?: avdInfo_getSystemInitImagePath(m_avd));
更新:
我试过了
./emulator -sysdir $DIR_OUT/system -datadir $DIR_OUT/data -kernel /home/project/disk/aosp/grapheneos-lz_experiments/prebuilts/qemu-kernel/x86_64/5.4/kernel-qemu2 -ramdisk $DIR_OUT/ramdisk-qemu.img -system $DIR_OUT/system.img -data $DIR_OUT/userdata-qemu.img -cache $DIR_OUT/cache.img -vendor $DIR_OUT/vendor.img
(我在名称中包含 qemu 的一些 .img 中添加了 -qemu)
但问题依然存在
【问题讨论】:
标签: android emulation android-source qemu