MegaZeux Development VMs
This page contains VM images for testing MegaZeux (and potentially other software) for non-x86 architectures via QEMU. Each image contains a cloned copy of the MegaZeux Git repository, all tools required to build a local copy of MegaZeux, and a minimalist window environment (i3 in Debian or CTWM in NetBSD) to run MegaZeux in.
The login for all VMs is mzx with the password mzx, and the MegaZeux Git repository is typically located at /megazeux.
This page is currently a work-in-progress. Because of this, they are behind a password; ask Lachesis for it on Discord.
Linux/BSD (main architectures)
These architectures usually correspond to existing or future MegaZeux ports and are fairly well-supported by Linux and/or BSD distributions. The x86_64 and i686 architectures are omitted because there is currently no point in maintaining development VMs for them.
Build times provided were observed using an i7-7700 running QEMU from a hypervisor guest, and are mainly intended to give a sense of scale. These may vary significantly depending on your machine and setup.
The current head in /megazeux
should be the most recent head a full build was tested with.
Architecture | Related Ports | Distribution | Options | make unit testworlds |
Fails | Other Issues | Image | Links |
---|---|---|---|---|---|---|---|---|
ARMel qemu-system-arm 5.2.0 |
|
Debian Unstable[1] | -M versatilepb -m 256M -cpu arm1176 -kernel [...] -dtb [...] -append "root=/dev/sda1 panic=10" -hda [...] -no-reboot |
9m24s 2m44s 27s |
— | Testing MZX should be done in system emulation, as several vio tests and the test worlds fail with chroot.sh due to a QEMU bug. The red and blue video components are reversed. | 340MB | QEMU Raspberry Pi kernels and scripts. |
ARMhf qemu-system-arm 5.2.0 |
|
Debian 10.10 | -M virt -m 2048 -cpu cortex-a15 -smp 4 -kernel [...] -initrd [...] -append "root=/dev/vda2" -drive [...] -device virtio-blk-device,drive=hd0 -netdev user,id=eth0 -device virtio-net-device,netdev=eth0 -usb -device usb-ehci,id=ehci -device usb-mouse,bus=ehci.0 -device usb-kbd,bus=ehci.0 |
2m13s (-j4) 53s (-j4) 17s |
— | No working video. Use run.serial.sh. | 413MB | See ARM64. |
ARM64 qemu-system-aarch64 5.2.0 |
|
Debian 10.10 | -M virt -m 2048 -cpu cortex-a57 -smp 4 -kernel [...] -initrd [...] -append "root=/dev/vda2" -drive [...] -device virtio-blk-device,drive=hd0 -netdev user,id=eth0 -device virtio-net-device,netdev=eth0 -device VGA -usb -device usb-ehci,id=ehci -device usb-mouse,bus=ehci.0 -device usb-kbd,bus=ehci.0 |
2m47s (-j4) 59s (-j4) 23s |
— | — | 427MB | Debian Wiki (archived) Blog post with more detailed info. (archived) |
MIPSeb qemu-system-mips 5.2.0 |
— | Debian 10.10 | -M malta -m 256 -kernel [...] -initrd [...] -append "root=/dev/sda1 console=tty0" -drive [...] -device usb-mouse -device usb-kbd -vga std |
33m21s 9m42s 43s |
— | — | 424MB | Setup (archived) |
MIPSel qemu-system-mipsel 5.2.0 |
|
Debian 10.10 | -M malta -m 256 -kernel [...] -initrd [...] -append "root=/dev/sda1 console=tty0" -device usb-mouse -device usb-kbd -vga std |
45m52s 15m06s 46s |
— | — | 408MB | Setup (archived) |
MIPS64el qemu-system-mips64el 5.2.0 |
— | Debian 10.10 | -M malta -m 256 -cpu 5KEc -kernel [...] -initrd [...] -append "root=/dev/sda1 console=tty0" -device usb-mouse -device usb-kbd -vga std |
35m20s 9m08s 39s |
— | RAM values above 256M don't work, may be a QEMU 5.2 bug or a kernel bug. | 414MB | Setup (archived) |
PowerPC qemu-system-ppc 6.0.0 |
|
Debian Unstable 10.0[2] | -L pc-bios -boot c -M mac99,via=pmu -m 1G -prom-env "boot-device=hd:,\yaboot" -prom-env "boot-args=conf=hd:,\yaboot.conf" -drive [...] -serial stdio -g 1024x768x32 |
4m50s 1m26s 17s |
— | — | 459MB | QEMU Wiki (archived) |
PowerPC 64 qemu-system-ppc64 6.0.0 |
|
Debian Unstable 10.0[3][4] | -L pc-bios -boot c -M mac99,via=pmu -m 2048 -cpu 970fx -prom-env "boot-device=hd:,\yaboot" -prom-env "boot-args=conf=hd:,\yaboot.conf" -drive [...] -serial stdio -g 1024x768x32 |
3m36s 59s 14s |
— | — | 483MB | QEMU Wiki (archived) |
RISC-V RV64GC qemu-system-riscv64 5.2.0 |
— | Debian Unstable[5] | -M virt -smp 4 -m 2048M -bios opensbi/generic/fw_jump.elf -kernel u-boot/qemu-riscv64_smode/uboot.elf -append "console=ttyS0 rw root=/dev/vda1" -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-device,rng=rng0 -device virtio-blk-device,drive=hd0 -drive file=[...],format=qcow2,id=hd0 -device virtio-net-device,netdev=usernet -netdev user,id=usernet,hostfwd=tcp::22222-:22 -device VGA \ -usb -device usb-ehci,id=ehci \ -device usb-mouse,bus=ehci.0 -device usb-kbd,bus=ehci.0 \ |
2m04s (-j4) 48s (-j4) 18s |
— | Serial terminal is required to boot even with a VGA device (Ctrl+Alt+3). | 481MB | Debian Wiki RISC-V article (archived) |
Linux/BSD (secondary architectures)
These architectures do not correspond to any current MegaZeux ports (Alpha, m68k, PA-RISC, SPARC) or are generally more effort to get set up than the rest (SH-4). MegaZeux will probably never run on actual hardware several of these architectures.
Architecture | Related Ports | Distribution | Options | make unit testworlds |
Fails | Other Issues | Image | Links |
---|---|---|---|---|---|---|---|---|
DEC Alpha qemu-system-alpha 5.2.0 |
— | Debian Unstable 2021-04-17 | -m 2048 -kernel [...] -initrd [...] -append "root=/dev/sda3 rw" -drive [...] -device VGA |
4m15s 1m09s 14s |
— | Use --disable-stack-protector . D-Bus and X11 currently do not work correctly due to alignment issues, so use run.serial.sh.
|
455MB | QEMU Wiki (archived) |
Motorola 68000 qemu-system-m68k 5.2.0 |
— | Debian Unstable 2021-04-17 | -M q800 -m 1000M -kernel [...] -initrd [...] -append "root=/dev/sda1 rw console=ttyS0 console=tty" -drive [...] -net nic,model=dp83932 -net user -g 800x600x16 |
4m34s 1m20s 20s |
— | — | 355MB | QEMU Wiki (archived) |
PA-RISC qemu-system-hppa 5.2.0 |
— | Debian Unstable 10.0[6] | -m 2048 -accel tcg,thread=multi -smp 4 -drive [...] -global artist.width=800 -global artist.height=600 -serial mon:stdio |
34m51s (-j4) 13m02s (-j4) 1m51s |
— | Use --disable-stack-protector . Emulation is SLOW! Video doesn't work yet; use run.serial.sh (see setup notes).
|
432MB | QEMU Wiki (archived) PA-RISC Linux Wiki - QEMU (archived) |
SPARC qemu-system-sparc 6.0.0 |
— | NetBSD 9.2[7] | -M SS-20 -m 512M -drive [...] -net nic -net user |
5m50s 1m26s 25s (a173946a) |
— | Use --prefix /usr/pkg --disable-libsdl2 . SDL2 works headless but can't find a texture format and is missing -Wl,-rpath. force_bpp=16 will match colors to the nearest indexed colors. May hang during IO operations, but so far this has only happened with pkgsrc.
|
358MB | QEMU Wiki (archived) |
SPARC64 qemu-system-sparc64 6.0.0 |
— | NetBSD 9.2[8] | -m 2048M -drive [...] -serial mon:stdio |
14m50s 3m38s 33s (a173946a) |
— | Use --prefix /usr/pkg --disable-libsdl2 . SDL2 works headless but can't find a texture format and is missing -Wl,-rpath. force_bpp=16 will match colors to the nearest indexed colors.
|
439MB | QEMU Wiki (archived) |
SuperH SH-4 qemu-sh4-static 5.2.0 |
|
Debian Unstable[9] | n/a | 1m21s (-j4) 26s (-j4) 22s |
— | Only works using user emulation right now; use chroot.sh. Since this VM does boot it might be an issue with newer kernels. | 414MB | Building Debian VMs with debootstrap (archived) |
Setup
If (for whatever reason) you want to set up your own VM images or a similarly configured machine, this is how the VM images above were generated.
Common
Debian is assumed in most of these steps, but they can be adapted to other distros. If one of the alternate setups is required, skip the installer steps in this section.
-
Set up initial QEMU disk image.
qemu-img create -f qcow2 arch.debian10.qcow2 20G
- Extract installation media vmlinux/initrd from ISO (if needed) and set up initial install.sh script.
- Run installer. Leave root password blank, create user mzx with password mzx and sudo access. Do not install a desktop environment.
-
If needed, extract runtime vmlinux/vmlinuz/initrd from the virtual machine (required for ARM, MIPS, RISC-V, Alpha, m68k, and SH-4). The easiest way to do this is to use the guestfish utility from libguestfs.
guestfish --ro -a arch.debian10.qcow2 -i
Then:
copy-out /boot/vmlinux-X.XX.X-X-ARCH . copy-out /boot/initrd.img-X.XX.X-X-ARCH .
- Set up run.serial.sh script and run.
-
Set up ~/.Xresources from here. This is required to make urxvt not look awful.
cd ~ wget https://www.digitalmzx.com/lachesis/.Xresources
-
Set up /bin/l (chmod a+x).
#!/bin/sh LC_COLLATE="C" \ ls -la --color=always --group-directories-first "$@"
-
Block the installation of dmenu. In Debian, this is done by creating a file called /etc/apt/preferences.d/no_goosesteppers with the contents:
Package: suckless-tools Pin: origin * Pin-Priority: -1
Update packages.
sudo apt update sudo apt upgrade
-
Install packages:
# Tools and dependencies required to build MegaZeux. sudo apt install build-essential gdb git zlib1g-dev libpng-dev libogg-dev libvorbis-dev libsdl2-dev # Graphical environment and browser. sudo apt install xorg i3 i3lock i3status rofi lynx # Sway might work better on some setups (encountered on AML-S905X-CC v1). sudo apt install sway xwayland i3status rofi lynx # Extra tools for building libxmp and xmp-cli from source. sudo apt install autoconf automake libtool pkg-config cmake # clang may be useful for its sanitizers and built-in fuzzer, but it is quite large. sudo apt install clang clang-tools llvm # If this machine or VM is going to be shelled into: sudo apt install openssh-server # If memory compression is required: sudo apt install zram-tools
Debian makes xterm default instead of urxvt, so fix that:
sudo update-alternatives --config x-terminal-emulator
-
Set up MegaZeux repository:
cd ~ git clone https://github.com/AliceLR/megazeux
-
Build MegaZeux:
./config.sh --platform unix-devel --enable-fps [any other flags here. release builds are NOT recommended.] time make [use -jX with -smp] time make unittest [use -jX with -smp] time testworlds/run.sh unix-devel
- Set up run.sh script and make sure the VM can start up with graphics and run MegaZeux with the software renderer. This may take some trial and error to get right, which is why the QEMU options are provided in the above tables.
-
If preparing a VM tarball, some steps should be taken to reduce the size of the image.
From the guest OS, clear the apt package cache:
sudo apt clean
Using guestfish from the host OS, fill all unused space in the image with 0s. This will increase the size of the image to its maximum size. (This method seems to be faster than using the
dd if=/dev/zero
trick some places cite or usingzerofree
from a guest rescue disk.)guestfish --rw -a arch.debian10.qcow2 -i
zero-free-space /
To shrink your working copy of the image, compact it using
qemu-img
(and then test it):mv arch.debian10.qcow2 arch.debian10.old.qcow2 qemu-img convert -O qcow2 arch.debian10.old.qcow2 arch.debian10.qcow2
Finally, generate a compressed tarball containing the image and scripts:
mkdir arch/ cp *.sh arch.debian10.qcow2 arch/ tar -cJf vm-mzx-arch-debian-10.0.tar.xz arch/ # If you have several cores and don't mind using them all, this # makes xz use parallel compression to speed things up. XZ_OPT="-T0" tar -cJf vm-mzx-arch-debian-10.0.tar.xz arch/
PowerPC/PPC64 (Debian Unstable)
Setting up working Debian Unstable builds for PowerPC/PPC64 currently requires a little bit of extra work.
- 1. ^^ An old image supporting Yaboot is currently required because all Debian Unstable PPC/PPC64 installers based on grub-ieee1275 have major installation issues (as of 2021-05-09). Skip setting up an apt repository, then add this to
/etc/apt/sources.list
,sudo apt update
, andsudo apt dist-upgrade
:
deb [trusted=yes] http://ftp.debian.org/debian-ports sid main
Install the following packages afterward to get the installation roughly equivalent to a standard install.
sudo apt install wget curl ftp gnupg debian-keyring debian-archive-keyring
Remove the old kernel and some large dependencies pulled in by mailutils (not required for these VMs):
sudo apt remove linux-image-4.16.0-1-* sudo apt remove mailutils --purge sudo apt autoremove --purge
- 2. ^ The version of Yaboot in older Debian Unstable PPC64 installers does not support ext4 (even though the equivalent PowerPC installer Yaboot does). Use manual partitioning instead of guided partitioning to create an ext2
/boot
partition:
#1 Apple #2 1.0 MB boot #3 256.0 MB ext2 /boot #4 (drive size - 2GB - 258MB) ext4 / #5 2.0 GB swap
PA-RISC (Debian Unstable)
- 1. ^ The Debian Installer in newer installer images crashes prior to partitioning. Like PowerPC, an older image needs to be installed, followed by a dist-update and cleanup. Follow the PowerPC instructions above. Make sure you back up the installed image once you've verified that the installation worked. The upgrade process is slow and will involve trial and error.
- 2. Optional: upgrading systemd may cause the VM to get stuck in an endless boot loop while attempting to run systemd-timesyncd. It may be beneficial to place holds on the relevant systemd packages until after the initial update.
sudo apt-mark hold libpam-systemd sudo apt-mark hold libsystemd0 sudo apt-mark hold systemd sudo apt-mark hold systemd-sysv sudo apt-mark hold systemd-timesyncd
- 3. If the
sudo apt dist-upgrade
fails because of libgcc-s4, do the following, then repeat thesudo apt dist-upgrade
.
sudo apt install -o Dpkg::Options::="--force-overwrite" libgcc-s4
- 4. TODO: due to either Artist emulation bugs in QEMU or a lack of driver support in Linux, running this VM in graphical mode will result in the graphical terminal freezing at a certain point. The boot process will continue as usual and the VM can be used from the serial terminal in this situation. This Xorg config fragment can at least get X to successfully start, but the Artist window will still be frozen.
Section "Device" Identifier "Artist" Driver "fbdev" Option "ShadowFB" "off" EndSection Section "Screen" Identifier "Screen0" Device "Artist" DefaultDepth 8 DefaultFbBpp 8 SubSection "Display" Depth 8 Modes "800x600_60.00" EndSubSection EndSection
ARMel, RISC-V, and SH-4 (Debian Unstable)
^^^ No Debian Installer image is available for this architecture and it must be set up manually. Overview:
- Install debootstrap, qemu-user-static, and debian-ports-archive-keyring. If you aren't using Debian as a host, debian-ports-archive-keyring is available here.
qemu-img create -f qcow2 [arch here].debian10.qcow2 16G
- As root:
modprobe nbd qemu-nbd -c /dev/nbd0 [arch here].debian10.qcow2 parted -s -a optimal -- /dev/nbd0 mklabel msdos mkpart primary ext4 1MiB -2GiB mkpart primary linux-swap -2GiB -0 mkfs -t ext4 -L root /dev/nbd0p1 mkswap -L swap /dev/nbd0p2 mount /dev/nbd0p1 /mnt # For ARMel: debootstrap --arch armel --keyring=/usr/share/keyrings/debian-archive-keyring.gpg unstable /mnt http://ftp.debian.org/debian # For RISC-V: debootstrap --arch riscv64 --keyring=/usr/share/keyrings/debian-ports-archive-keyring.gpg unstable /mnt http://ftp.ports.debian.org/debian-ports # For SH-4: debootstrap --arch sh4 --keyring=/usr/share/keyrings/debian-ports-archive-keyring.gpg unstable /mnt http://ftp.ports.debian.org/debian-ports
- Mount and chroot:
cp /usr/bin/qemu-[arch here]-static /mnt/bin mount -o bind,ro /dev /mnt/dev mount -t proc none /mnt/proc mount -t sysfs none /mnt/sys chroot /mnt uname -a # Verify machine name is armv7l (ARMel), riscv64 (RISC-V), or sh4 (SH-4).
- Edit
/etc/fstab
:LABEL=swap none swap sw 0 0 LABEL=root / ext4 defaults 0 1
Create
/etc/network/interfaces.d/eth0
:# This is the device name used by Debian and is needed for QEMU system emulation. allow-hotplug eth0 iface eth0 inet dhcp
Create
/etc/network/interfaces.d/enp1s0
:# This allows networking to work from a chroot from Fedora. allow-hotplug enp1s0 iface enp1s0 inet dhcp
Create
/etc/network/interfaces.d/lo
:# This configures the loopback interface. # This breaks booting in ARMel and can be omitted for that platform. auto lo iface lo inet loopback
- Install and configure some required packages:
apt install debian-ports-archive-keyring apt install sudo man locales console-setup wget curl ftp gnupg # These images generally use US/Mountain but the specific timezone isn't that important. dpkg-reconfigure tzdata # Only select en_US.UTF-8 here; others can be added later if needed. dpkg-reconfigure locales systemctl enable serial-getty@ttyS0.service
RISC-V only: install a kernel (the ~860MB install size is normal).
apt install linux-image-riscv64 # Also, some extra things to do here (see Debian Wiki RISC-V page): apt install u-boot-menu openntpd ntpdate sed -i 's/^DAEMON_OPTS="/DAEMON_OPTS="-s /' /etc/default/openntpd echo ' UBOOT_PARAMETERS="rw noquiet root=/dev/vda" U_BOOT_FDT_DIR="noexist"' >> /etc/default/u-boot u-boot-update
SH-4 only: install a kernel.
apt install linux-image-sh7751r
- Setup user:
adduser mzx usermod -a -G sudo mzx passwd -l root
- ARMel only: get a Raspberry Pi Linux kernel (4.19.50) and versatile-pb-buster.dtb here.
- RISC-V only: get the latest copy of OpenSBI and U-Boot for QEMU from the Debian packages repository. Extract OpenSBI and the U-Boot riscv64_smode kernel; these are required to boot the virtual machine.
Setup (NetBSD)
^^ Setting up NetBSD is a little more involved than Debian. Note NetBSD also isn't aware of power management for some architectures and will use a full core while its VM is running.
-
Set up initial QEMU disk image.
qemu-img create -f qcow2 arch.netbsd.qcow2 20G
- For whatever reason, the QEMU -kernel option doesn't seem to work with any BSD kernels, so right now any QEMU that requires -kernel should use a Linux instead.
- Run installer. Leave root password blank, create user mzx with password mzx and sudo access (if it doesn't give you the option, set the root password). Install all packages, including the X window system. Enable xdm and nptdate. If network autodetection doesn't work here (SPARC 32-bit), pkgin and pkgsrc will need to be set up manually after reboot. Otherwise, install both.
- Set up run.serial.sh script and run.
-
As root, set up /bin/l:
echo '#!/bin/sh LC_COLLATE="C" \ ls -la "$@"' > /bin/l chmod a+x /bin/l
-
As root, set a hostname, disable IPv6, enable DHCP (if it isn't already), and reboot:
# Set a hostname for this architecture e.g. SPARC, SPARC64, ARMv6. echo "SPARC" > /etc/myname # Disable IPv6 for DHCP. # This prevents issues where all downloads can hang for a long time before # the download starts (due to attempting IPv6 first and it timing out). cp /etc/dhcpcd.conf ~/ echo ' # Disable IPv6 Support. noipv6rs noipv6' >> /etc/dhcpcd.conf # If it wasn't enabled during install, you can enable DHCP like this. cp /etc/rc.conf ~/ echo "dhcpcd=yes" >> /etc/rc.conf # Reboot for these changes to take effect. reboot
-
If network wasn't available during installation, manually install pkgsrc. As root:
ftp http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.gz tar -xzf pkgsrc.tar.gz -O /usr chown root:wheel -R /usr/pkgsrc
-
If network wasn't available during installation, manually install pkgin. As root:
# Replace ARCH and VERSION for the applicable architecture (e.g. sparc) and version (e.g. 9.2). pkg_add http://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/ARCH/VERSION/All/pkgin
-
As root, install packages with pkgin:
pkgin install sudo bash gmake git nano p7zip pkgin install zlib png libogg libvorbis SDL SDL2 pkgin install lynx openssl ca-certificates
If precompiled packages aren't available for this architecture, use pkgsrc to build and install these packages instead. WARNING: this will take a while.
- When configuring MegaZeux, make sure to use /usr/pkg as the prefix and to use gmake to invoke Makefile targets.
-
Preparing the image is a little different from Debian, mainly since the Linux kernel does not have write support for NetBSD's filesystem by default. As root, clear the pkgin cache and zero free space.
pkgin clear cat /dev/zero >delet_this sync rm delet_this
If pkgsrc was used, make sure there are no work directories leftover in the pkgsrc tree (TODO).
The image is now ready to be shrunk with qemu-img.