Emulator: Difference between revisions

From AsteroidOS
(Add Emulator page from current wiki)
 
m (Fixed broken link)
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[Category:Developers]]
If you don't have a supported smartwatch or if you want to develop an app without having to touch your device you can try AsteroidOS in an emulator.
If you don't have a supported smartwatch or if you want to develop an app without having to touch your device you can try AsteroidOS in an emulator.


Line 4: Line 5:
== Get a qemux86 build of AsteroidOS ==
== Get a qemux86 build of AsteroidOS ==


Nightly builds of AsteroidOS for QEMU can be found [https://release.asteroidos.org/nightlies/qemux86/ here]. You will need to download a [https://release.asteroidos.org/nightlies/qemux86/asteroid-image-qemux86.ext4 prebuilt rootfs] and [https://release.asteroidos.org/nightlies/qemux86/bzImage-qemux86.bin kernel].
Nightly builds of AsteroidOS for QEMU can be found [https://release.asteroidos.org/nightlies/qemux86/ here]. You will need to download a [https://release.asteroidos.org/nightlies/qemux86/asteroid-image-qemux86.rootfs.ext4 prebuilt rootfs] and [https://release.asteroidos.org/nightlies/qemux86/bzImage-qemux86.bin kernel].


If you want more control over your asteroid image, you can also [[Building AsteroidOS | build AsteroidOS] yourself using the "qemux86" machine codename (the resulting rootfs and kernel will then be located in your <code>build/tmp-glibc/deploy/images/qemux86/</code> directory).
If you want more control over your asteroid image, you can also [[Building AsteroidOS|build AsteroidOS]] yourself using the "qemux86" machine codename (the resulting rootfs and kernel will then be located in your <code>build/tmp-glibc/deploy/images/qemux86/</code> directory).


== Get an appropriate version of QEMU ==
== Get an appropriate version of QEMU ==
The AsteroidOS emulator image requires a paravirtualized GPU only offered by QEMU when built with support for Virgil3D. Recent distribitions (such as Fedora 27 and later) offer QEMU packages built with Virgil and can be used directly to run AsteroidOS.
The AsteroidOS emulator image requires a paravirtualized GPU only offered by QEMU when built with support for Virgil3D. Recent distributions (such as Fedora 27 and later) offer QEMU packages built with Virgil and can be used directly to run AsteroidOS.


Unfortunately, most Linux distributions (such as Debian) still do not provide QEMU packages with support for this setup. Moreover, OpenEmbedded currently offers no clean way to build a host QEMU binary with Virgil due to various constraints. You then need to compile QEMU yourself.
Unfortunately, most Linux distributions (such as Debian) still do not provide QEMU packages with support for this setup. Moreover, OpenEmbedded currently offers no clean way to build a host QEMU binary with Virgil due to various constraints. You then need to compile QEMU yourself.
Line 19: Line 20:
     -device virtio-vga-gl \
     -device virtio-vga-gl \
     -net nic -net user,hostfwd=tcp::2222-:22 \
     -net nic -net user,hostfwd=tcp::2222-:22 \
     -drive format=raw,file="asteroid-image-qemux86.ext4" \
     -drive format=raw,file="asteroid-image-qemux86.rootfs.ext4" \
     -m 512 \
     -m 512 \
     -display sdl,gl=on \
     -display sdl,gl=on \
     -cpu qemu64,+ssse3,+sse4.1,+sse4.2 \
     -cpu qemu64,+ssse3,+sse4.1,+sse4.2 \
     -device usb-mouse -machine usb=on \
     -usb -device usb-tablet \
     --append "verbose root=/dev/sda rw mem=512M video=800x800"
     --append "verbose root=/dev/sda rw mem=512M video=800x800"
</pre>
</pre>
Line 30: Line 31:


<code>ssh -p 2222 ceres@localhost</code>
<code>ssh -p 2222 ceres@localhost</code>
Note that versions of the image prior to 11 August 2024 did not have "rootfs" as part of the file name, so the effect is that that portion of the line would be <code>file="asteroid-image-qemux86.ext4"</code>instead.


= Troubleshooting =
= Troubleshooting =


Here are some common problems and their solutions.
Here are some common problems and their solutions.
* Unable to accurately select buttons or items
*: Versions of the emulator image prior to 11 August 2024 did not include the <code>ceres</code> user in the <code>input</code> group, causing the emulator to ignore mouse input.  To fix that, log in to the watch remotely as root (or use the serial console) and issue the command <code>usermod -a -G input ceres</code> and then <code>systemctl restart user@1000</code>.  This should make it possible for the mouse input to be received.
*: Even with the fix applied, sometimes a click does not seem to select the right thing.  Most typically, a click registers as an item above where the user actually clicked.  The way around this is to resize the qemu window to be taller.  When this is done, even though the display is not square, clicks on screen are closer to where the user actually clicks.  It may also be helpful to show the mouse cursor.  This can be done by altering the display line to <code>-display gtk,gl=on,show-cursor=on</code>.


* Errors with -virtio-vga
* Errors with -virtio-vga
Line 45: Line 52:
failed to complete framebuffer 0x8cd7 asteroid-launch
failed to complete framebuffer 0x8cd7 asteroid-launch
</pre>
</pre>
*: Other symptoms include video artifacts (smearing, double screens) and crashing, usually with a message <code>Segmentation fault (core dumped)</code>. If you're experiencing these and are using a proprietary NVIDIA driver, using <code>gtk</code> instead of <code>sdl</code> may work better. An example command line:
*: Other symptoms include video artifacts (smearing, double screens) and crashing, usually with a message <code>Segmentation fault (core dumped)</code>. If you're experiencing these and are using a proprietary NVIDIA driver, either updating the driver or using <code>gtk</code> instead of <code>sdl</code> may work better. An example command line:
<pre>
<pre>
qemu-system-i386 -enable-kvm -kernel bzImage-qemux86.bin \
qemu-system-i386 -enable-kvm -kernel bzImage-qemux86.bin \
Line 59: Line 66:


* Watch seems to lock up after a few seconds
* Watch seems to lock up after a few seconds
*: It's possible that the display is no longer updating but that the watch is actually still running. To make sure that the emulator continues to update the screen you can enter [[Useful Commands#Screen | demo mode] to keep the screen on. If you have followed this guide and the watch is listening on port 2222, this command will turn on demo mode.
*: It's possible that the display is no longer updating but that the watch is actually still running. To make sure that the emulator continues to update the screen you can enter [[Useful Commands#Screen|demo mode]] to keep the screen on. If you have followed this guide and the watch is listening on port 2222, this command will turn on demo mode.
: <code> ssh -t -p2222 root@localhost mcetool -D on </code>
: <code> ssh -t -p2222 root@localhost mcetool -D on </code>

Latest revision as of 23:37, 3 September 2024

If you don't have a supported smartwatch or if you want to develop an app without having to touch your device you can try AsteroidOS in an emulator.

Note: The emulator has some known issues under x11 sessions. Make sure that you run it in a wayland session. You can check your session type with echo $XDG_SESSION_TYPE.

Get a qemux86 build of AsteroidOS

Nightly builds of AsteroidOS for QEMU can be found here. You will need to download a prebuilt rootfs and kernel.

If you want more control over your asteroid image, you can also build AsteroidOS yourself using the "qemux86" machine codename (the resulting rootfs and kernel will then be located in your build/tmp-glibc/deploy/images/qemux86/ directory).

Get an appropriate version of QEMU

The AsteroidOS emulator image requires a paravirtualized GPU only offered by QEMU when built with support for Virgil3D. Recent distributions (such as Fedora 27 and later) offer QEMU packages built with Virgil and can be used directly to run AsteroidOS.

Unfortunately, most Linux distributions (such as Debian) still do not provide QEMU packages with support for this setup. Moreover, OpenEmbedded currently offers no clean way to build a host QEMU binary with Virgil due to various constraints. You then need to compile QEMU yourself.

Run AsteroidOS

Once you have a correct version of QEMU, a rootfs and a kernel, you can start AsteroidOS in an emulator using:

qemu-system-x86_64 -enable-kvm -kernel bzImage-qemux86.bin \
    -device virtio-vga-gl \
    -net nic -net user,hostfwd=tcp::2222-:22 \
    -drive format=raw,file="asteroid-image-qemux86.rootfs.ext4" \
    -m 512 \
    -display sdl,gl=on \
    -cpu qemu64,+ssse3,+sse4.1,+sse4.2 \
    -usb -device usb-tablet \
    --append "verbose root=/dev/sda rw mem=512M video=800x800"

The previous command sets up a port forwarding so that you can connect to the emulator using SSH with the following command:

ssh -p 2222 ceres@localhost

Note that versions of the image prior to 11 August 2024 did not have "rootfs" as part of the file name, so the effect is that that portion of the line would be file="asteroid-image-qemux86.ext4"instead.

Troubleshooting

Here are some common problems and their solutions.

  • Unable to accurately select buttons or items
    Versions of the emulator image prior to 11 August 2024 did not include the ceres user in the input group, causing the emulator to ignore mouse input. To fix that, log in to the watch remotely as root (or use the serial console) and issue the command usermod -a -G input ceres and then systemctl restart user@1000. This should make it possible for the mouse input to be received.
    Even with the fix applied, sometimes a click does not seem to select the right thing. Most typically, a click registers as an item above where the user actually clicked. The way around this is to resize the qemu window to be taller. When this is done, even though the display is not square, clicks on screen are closer to where the user actually clicks. It may also be helpful to show the mouse cursor. This can be done by altering the display line to -display gtk,gl=on,show-cursor=on.
  • Errors with -virtio-vga
    Newer versions of QEMU use -device virtio-vga-gl instead of -device virtio-vga,virgl=on, so if you get an error message complaining about virtio-vga-gl, you have an earlier version of QEMU. You can either use -device virtio-vga,virgl=on instead or upgrade to a newer version of QEMU.
  • Video corruption using NVIDIA drivers
    There have been reported problems on machines using proprietary NVIDIA drivers. One symptom is a black screen instead of the AsteroidOS screen which may or may not also show messages like these:
gl_version 46 - core profile enabled
GLSL feature level 460
failed to complete framebuffer 0x8cd7 asteroid-launch
  • Other symptoms include video artifacts (smearing, double screens) and crashing, usually with a message Segmentation fault (core dumped). If you're experiencing these and are using a proprietary NVIDIA driver, either updating the driver or using gtk instead of sdl may work better. An example command line:
qemu-system-i386 -enable-kvm -kernel bzImage-qemux86.bin \
  -device virtio-vga-gl \
  -net nic -net user,hostfwd=tcp::2222-:22 \
  -drive file=asteroid-image-qemux86.ext4,format=raw \
  -m 512 \
  -display gtk,gl=on \
  -cpu qemu64,+ssse3,+sse4.1,+sse4.2 \
  -usb -device usb-tablet -device usb-mouse \
  --append "verbose root=/dev/sda rw mem=512M video=800x800"
  • Watch seems to lock up after a few seconds
    It's possible that the display is no longer updating but that the watch is actually still running. To make sure that the emulator continues to update the screen you can enter demo mode to keep the screen on. If you have followed this guide and the watch is listening on port 2222, this command will turn on demo mode.
ssh -t -p2222 root@localhost mcetool -D on