Booting Android (Samsung) Kernel in QEMU - android

Trying to boot a Samsung S7 Edge Kernel 3.18.x using QEMU
/usr/local/bin/qemu-system-aarch64 -M virt -cpu cortex-a57 -kernel $HOME/s7boot/boot.emmc.win-zImage -initrd $HOME/s7boot/boot.emmc.win-ramdisk.gz -nographic
Nothing happens
Screen remains as it was.
CPU is at 100% for QEMU process
Using QEMU
/usr/local/bin/qemu-system-aarch64 --version
QEMU emulator version 4.1.0
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
Trying it with -s -S
/usr/local/bin/qemu-system-aarch64 -M virt -cpu cortex-a57 -kernel $HOME/s7boot/boot.emmc.win-zImage -initrd $HOME/s7boot/boot.emmc.win-ramdisk.gz -nographic -s -S
GDB
Type "apropos word" to search for commands related to "word".
(gdb) target remote:1234
Remote debugging using :1234
warning: while parsing target description (at line 1): Target description specified unknown architecture "aarch64"
warning: Could not load XML target description; ignoring
0x00000000 in ?? ()
(gdb) cont
Continuing.
^C
Program received signal SIGINT, Interrupt.
0x40080000 in ?? ()
(gdb) cont
Continuing.
So I guess it get stuck at 0x4008000
Anynway .... I tried serveral Kernels (downloaded from device, LineageOS, Some other custom, also compiled one from Samsung Sources) with no luck.
Questions:
Anybody booted Samsung/Android Kernel in QEMU?
Thanks,
Related to:
Booting Kernel in QEMU - PFLASH: Possible BUG - Write block confirm

This is the same question as Boot Sasmsung S7 Edge extraced Kernel from Device in Android Emulator but for QEMU proper rather than the Android emulator, and the answer is the same -- you need a kernel that's been built to run on the machine type you're using, which in this case is the "virt" board. Trying to boot a random kernel pulled off a different hardware device is never going to work.

Related

How to boot Android Emulator with more than 16 cpus

I'd like to boot Android on Emulator with more than 16 cpus.
Debug step:
I configured Kernel Features-->Maximum number of CPUs to 128. Then I changed android qemu hw/arm/ranchu.c mc->max_cpus to 128 too.
Start Android with:
emulator -avd test_wzh -show-kernel -skip-adb-auth -no-snapshot -kernel /root/wangzhh/image/Image -no-window -writable-system -partition-size 65536 -verbose -gpu host -qemu -enable-kvm -m 16384 -realtime mlock=off -smp 32,sockets=32,cores=1,threads=1
Check cpu in the guest:
adb -s emulator-5554 shell
Only 16 cpus online, all the cpu after index 16 shows same error log
Printk to debug kernel
I traced the kernel code and found the error report by
psci_to_linux_errno case PSCI_RET_INVALID_ADDRESS
Kernel log:
...
Detected VIPT I-cache on CPU15
CPU15: found redistributor f region 0:0x0000000008280000
Invalid sched_group_energy for CPU15
CPU15: update cpu_capacity 1024
CPU15: Booted secondary processor [481fd010]
psci: failed to boot CPU16 (-22)
CPU16: failed to boot: -22
...
Thanks to anyone who can help!
Also, I guess it related to the dts, but I don't know which dts used by android emulator, who knows this problem?
As explained here (https://github.com/intel/haxm/issues/195) HAXM supports up to 16 VCPUs, but you can download source code from GitHub (https://github.com/intel/haxm/releases), change specific variable/constant in the Source, recompile it and replace existent binary/library.
Or you have to change Emulator to something different (KVM?).
As far as I know - you can only set a max of 4 sockets. So you might wanna change from:
-smp 32,sockets=32,cores=1,threads=1
to:
-smp 32,sockets=1,cores=32,threads=1

How to launch android emulator with my own .img partitions?

I compiled my own AOSP image and got this:
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
I then compiled my own Android emulator.
I know I dont need to specify the .img myself, the AOSP prebuilt emulator just works, but I want to for other purposes.
So I did 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)
You can see that I ignored the AVD error by commenting the return
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;
}
because without it I couldn t get anything to work. It could be segfaulting because of my quirk, but without it I dont see how to run with the .img myself.
Here s what the android emulator says about specifying my own .img files:
./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.
There s nothing saying how to overcome that error
UPDATE:
Segmentation fault is in this exact line:
https://android.googlesource.com/platform/external/qemu.git/+/refs/heads/aosp-emu-30-release/android-qemu2-glue/main.cpp#476
sysImagePath = std::string(
avdInfo_getSystemImagePath(m_avd)
?: avdInfo_getSystemInitImagePath(m_avd));
UPDATE:
I tried with
./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
(I added -qemu to some .img that had the qemu in the name)
But the problem persists the same
try this.
https://source.android.com/setup/create/avd
To build and run an AVD system image:
Download the Android source:
mkdir aosp-master; cd aosp-master
repo init -u
repo sync -j24
If you want to build other Android versions, you can find their branch names in the public Android repository. They map to Android Codenames, Tags, and Build Numbers.
Build an AVD system image. This is the same process as building an Android device system image. For example, to build a x86 32-bit AVD:
mkdir aosp-master; cd aosp-master
source ./build/envsetup.sh
lunch sdk_phone_x86
make -j32
If you prefer to build an x86 64-bit AVD, run lunch for the 64-bit target:
lunch sdk_phone_x86_64
Run the AVD system image in the Android Emulator:
emulator
See the Command-line startup options for more details about running the emulator. Figure 2 shows an example of the Android Emulator running an AVD.

"Guest has not initialized the display yet" (Raspberry Pie on QEMU)

I am a newbie student.
I am trying to run a Raspberry Pi Emulator on QEMU.
PC specs are Intel q8200, quad-core 2,4 GHz, Nvidia GeForce 1 GB. 4GB RAM
https://prnt.sc/uvpi0h
The above image is where you can see the commands and the state of the running QEMU. And other things.
https://prnt.sc/uvplco
This is in my download folder for this project.
I've tried to run different kernels (stretch and booster), even different Pi Emulator images, but the same mistake.
I've seen that in some solutions, a guy said that he hadn't included his BIOS in commands and that helped him, but I dunno how to include or specify BIOS in CMP.
All files inside the Qemu folder (images and kernel) are matching the start.bat commands folder, so that is all ok.
I've tried to do all of that through this channel instructions, but since it is outdated, I've just downloaded the latest software.
https://www.youtube.com/watch?v=xiQX0YXYuqU&t=138s&ab_channel=TechWizTime
What could be the solution and what is the problem?
Thanks in advance!
EDIT: Windows10 pro is the OS
UPDATE 1: Added this command: -boot no -display gtk,gl=of
still the same.
UPDATE 2:
qemu-system-arm -kernel kernel-qemu-4.4.12-jessie -cpu arm1176 -m 256 -M versatilepb \
-no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \
-redir tcp:5022::22 \
-hda 2016-05-27-raspbian-jessie-lite.img
I've used this to solve the problem. Although it is another version of the Raspberry Pi, for my needs it is not relevant now.
The important error message in the output is the one from the guest kernel which reads:
Error: unrecognized/unsupported machine ID (r1 = 0x00000183)
and then lists the machine types it is capable of booting on. (As a side note, providing error messages as screenshot images is rather awkward -- copying the text itself into the question makes it searchable and copyable.)
It looks like you're trying to boot a guest kernel which requires a device tree, but you haven't passed it a device tree. You need to give QEMU also a -dtb option whose argument is the correct dtb for this kernel and for the machine type ('versatilepb') that you are running it on.

Blank emulator after compililing Android 7.1.1 using Source code, how to get the emulator to work?

I have been trying to get the source code to compile from some time and finally got it compiled. However I am having issues with the emulator where it shows a pop up screen but is quite blank.
I am using Ubuntu Server Xenial and Android 7.1.1 for Nexus6P (but I dont own a Nexus6P so I need to run this on the emulator)
I have tried specifying all the directories such as (-sysdir,-sysdir, -datadir, -kernel, -ramdisk, -system, -data, -cache, -sdcard) although I know that these are supposed to be auto populated by the envsetup.sh file.
The command I used is this:
emulator -kernel ./prebuilts/qemu-kernel/arm64/kernel-qemu -ramdisk ./out/debug/target/product/angler/ramdisk.img -sysdir ./out/debug/target/product/angler/ -cache ./out/debug/target/product/angler/cache.img -system ./out/debug/target/product/angler/system.img -data ./out/debug/target/product/angler/userdata.img -memory 4096 -partition-size 4096 -sdcard sdcard.img -skindir ./sdk/emulator/skins/ -skin WVGA800
I changed the kernel to others such as for ARM/ARM64 but to no avail. All I see is a blank emulator and after changing it to ARM following error:
http://pastebin.com/A04NmNLn
I am at a loss as to why the emulator wont work. Also where is the "image" file with which we can install the Android on Genymotion-type external emulator.
Any help is appreciated!
In order to build AOSP to be run in emulator, there is no need to download any additional binaries. At the same time, emulator cannot run images build for real devices. Therefore, it is required to only download the sources of Android and execute the following commands within the directory with the downloaded sources:
source build/envsetup.sh
lunch aosp_arm-eng #or aosp_x86_64-eng, etc. for details see documentation
make -j4
After the sources are build in the same terminal run the emulator command and the emulator should appear.

emulator errors for hpet and create sensors port

I got 1 emulator error from the latest Andriod SDK(on both Ubuntu11.10 and CentOS6.2):
[#localhost ~]$/android-sdks/tools/emulator -avd api15&
emulator: WARNING: Unable to create sensors port: Connection refused
On CentOS6.2, there is also an HPET error.(even though my HPET was set to 1024 already):
[#localhost ~]$ cat /proc/sys/dev/hpet/max-user-freq
1024
[#localhost ~]$/android-sdks/tools/emulator -avd api15&
Could not configure '/dev/hpet' to have a 1024Hz timer. This is not a fatal error, but for better emulation accuracy type: 'echo 1024 > /proc/sys/dev/hpet/max-user-freq' as root.
emulator: WARNING: Unable to create sensors port: Connection refused
I am at my wits end. What is it trying to tell me? Any help would be greatly appreciated!
Here are the background info:
[#localhost ~]$ emulator -version
Android emulator version 16.0 (build_id ICS_MR0-234950)
Copyright (C) 2006-2011 The Android Open Source Project and many others.
This program is a derivative of the QEMU CPU emulator (www.qemu.org).
...
[#localhost ~]cat /etc/issue.net
CentOS release 6.2 (Final)
Kernel \r on an \m
[#localhost ~]uname -a
Linux localhost.localdomain 2.6.32-220.4.1.el6.x86_64 #1 SMP Tue Jan 24 02:13:44 GMT 2012 x86_64 x86_64 x86_64 GNU/Linux
The first is not a real problem. In the emulator you do not have sensors that's why there is an error here. This a common error for all emulators for all versions.
As for the second case I've never noticed such error.

Categories

Resources