# GXemul: EVBmips (Malta) emulation

Back to the index.

The EVBmips mode emulates a Malta evaluation board with a 5Kc (MIPS64) CPU, or optionally, a 4Kc (MIPS32) processor by adding `-C 4Kc` to the command line.

NetBSD/evbmips is the only guest OS that can be considered working, but there are instructions on this page for experimenting with Linux/malta and HelenOS/malta too.

### NetBSD/evbmips:

One way to install the NetBSD/evbmips distribution onto a disk image is to install the files using another (emulated) machine.

The following instructions will let you install NetBSD/evbmips onto a disk image, from an emulated DECstation 3MAX machine:

1. Download a NetBSD/pmax (DECstation) install RAMDISK kernel:

       	ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-8.0/pmax/binary/kernel/netbsd-INSTALL.gz

2. Create an empty harddisk image, which will be the disk image that you will install NetBSD onto:

       	dd if=/dev/zero of=nbsd_malta.img bs=1024 count=1 seek=4000000

3. Download the Malta kernel and the ISO image:

       	ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-8.0/evbmips-mipsel/binary/kernel/netbsd-MALTA.gz
       	ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-8.0/iso/NetBSD-8.0-evbmips-mipsel.iso

4. Start the emulated DECstation machine like this:

       	gxemul -x -e 3max -d nbsd_malta.img -d NetBSD-8.0-evbmips-mipsel.iso netbsd-INSTALL.gz

5. At the `Terminal type? [vt100]` prompt, type CTRL-C and execute the following commands:

   `` |
       newfs /dev/sd0c
       mount -t cd9660 /dev/cd0c /mnt
       mkdir /mnt2; mount /dev/sd0c /mnt2
       cd /mnt2; sh
       for a in /mnt/*/binary/sets/[bcemt]*.tgz; do echo $a; tar zxfp $a; done
       exit
       cd dev; sh ./MAKEDEV all; cd ../etc
       echo rc_configured=YES >> rc.conf
       echo "/dev/wd0c / ffs rw 1 1" > fstab
       cd /; umount /mnt; umount /mnt2; halt

You should now be able to boot NetBSD/evbmips using this command:

    	gxemul -x -e malta -d nbsd_malta.img netbsd-MALTA.gz

NOTE 1: There may be long delays during bootup, such as when NetBSD detects the clock. On my machine, I had to wait almost 3 minutes.

NOTE 2: To select a 4Kc (MIPS32) CPU instead of the default 5Kc (MIPS64) CPU, add `-C 4Kc` to the command line. There are at least two things that differ:

1. The dynamic translation core runs faster when emulating 32-bit processors, so `-C 4Kc` might make things go faster.
2. 4Kc only has 16 TLB entries, whereas 5Kc has 48. This makes 4Kc emulation slower in general, because there are more TLB misses.

The installation instructions above create a filesystem without a disklabel, so there is only one ffs partition and no swap. You will need to enter the following things when booting with the generic kernel:

    	root device (default wd0a): wd0c
    	dump device (default wd0b):		(just press enter)
    	file system (default generic):		(just press enter)
    	init path (default /sbin/init):		(just press enter)

There may be long delays also at this stage, before reaching the login prompt. If it sleeps for too long after printing "Updating motd.", try typing CTRL-C in the terminal window.

The clock is wrong (showing the year 2119 instead of 2019), and it goes too fast inside the emulator. If it hangs during boot-up, before the login prompt has appeared, type CTRL-C in the xterm window.

NOTE 3: There is actually a kernel for Malta with the installer ramdisk (ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-8.0/evbmips-mipsel/installation/netbsd-INSTALL_MALTA.gz), but there is a bug which causes the second IDE channel to not be detected, so it is currently not possible to boot with both the `nbsd_malta.img` disk image and the CD-ROM image at the same time.

### Linux/Malta (variant 1):

The Malta emulation mode is best suited for running NetBSD/evbmips, however, it is possible to experiment with Linux/Malta as well.

The general idea behind Linux/Malta seems to be that the end user always compiles his/her own kernel, applies patches, downloads userland separately, etc. For that reason, Linux/Malta support in the emulator is not tested for every release (sometimes it works, sometimes it doesn't work), and these instructions are kind of "fuzzy".

1. Create an empty harddisk image, which will be the root disk that Linux/Malta will be installed onto:

       	dd if=/dev/zero of=linux.img bs=1024 count=1 seek=5000000

2. Download a MIPS root filesystem tree:

       	ftp://ftp.linux-mips.org/pub/linux/mips/mipsel-linux/root/mipsel-root-20011216.tgz
       	19486676 bytes, md5 = 5bcb725c90209479cd7ead8ad0c4a414

   This is an old Redhat tree from 2001, but it seems to almost work.

3. Download one precompiled Malta kernel, with ramdisk, and one without ramdisk (which will be used later on when booting from disk):

       	TODO

4. Start the emulator with the ramdisk kernel, create a MS-DOS style MBR on the disk, create the filesystem, and extract the userland files:

       	gunzip vmlinux_2.*
       	gunzip mipsel-root-20011216.tar
       	gxemul -xemalta -d linux.img -d mipsel-root-20011216.tar vmlinux_2.4.33.2-ide-pci-ramdisk.elf
       	Inside GXemul: Log in as root and execute the following commands:
       	fdisk /dev/hda
       	(enter suitable commands, e.g. n, p, 1, 1, 9921, w)
       	mkfs /dev/hda1
       	mount /dev/hda1 /mnt
       	cd /mnt; tar -xf /dev/hdb; cd ..
       	umount /mnt; sync; reboot

It should now be possible to boot from the disk image, using the following command:

    	gxemul -xemalta -d linux.img -o "root=/dev/hda1 rw" vmlinux_2.6.18-rc4-ide-pci-novty.elf

There's a slight problem with this specific Redhat tree, so when you see the message "Configuring kernel parameters: [ OK ]", press CTRL-C once.

### Linux/Malta (variant 2):

The Malta emulation mode is best suited for running NetBSD/evbmips, however, it is possible to experiment with Linux/Malta as well.

It is also possible to experiment with much newer Linux userland, compared to the Linux/Malta variant 1 above, by using a kernel and disk image from http://people.debian.org/~aurel32/qemu/mipsel/. THIS DOES NOT WORK YET!

1. Download the Malta kernel and disk image:

       	wget http://people.debian.org/~aurel32/qemu/mipsel/vmlinux-2.6.26-1-4kc-malta
       	wget http://people.debian.org/~aurel32/qemu/mipsel/debian_lenny_mipsel_small.qcow.gz (142 MB)

2. The disk image is both compressed and in QEMU format, so we need to extract it:

       	gunzip debian_lenny_mipsel_small.qcow.gz
       	qemu-img convert -f qcow -O raw debian_lenny_mipsel_small.qcow debian_lenny_mipsel_small.raw

   (`qemu-img` actually requires that you have QEMU installed.)

It should now be possible to boot from the disk image, using the following command:

    	gxemul -e malta -d debian_lenny_mipsel_small.raw -o "root=/dev/hda1 console=ttyS0" vmlinux-2.6.26-1-4kc-malta

NOTE: IT DOES NOT WORK YET!

### HelenOS/malta:

Modern versions of HelenOS can run in GXemul, using the Malta emulation mode, but without a graphical framebuffer.

The PCI devices in GXemul do not seem to be correctly emulated yet.

To run HelenOS for Malta in GXemul:

1. Download the HelenOS kernel:

       	http://www.helenos.org/releases/HelenOS-0.9.1-mips32-malta-be.boot
           or
       	http://www.helenos.org/releases/HelenOS-0.9.1-mips32-malta-le.boot

2. Start GXemul using the following command line:

         	gxemul -e maltabe HelenOS-0.9.1-mips32-malta-be.boot
           or
         	gxemul -e malta HelenOS-0.9.1-mips32-malta-le.boot