Running MIPS on Linux using qemu

Intro

MIPS is an RISC architecture widely used by embedded devices such as routers. I had a Zyxel router and I was doing some nasty things to it but before everything else I thought learning about the environment of this piece of junk should be more classy than just hack & smash the shit out of it. Here's a quick and lazy brief about how I was running MIPS using QEMU on Linux Debian.

Install qemu

apt-get install qemu-system-mips

Grab Debian Mips & Vmlinux image

wget https://people.debian.org/~aurel32/qemu/mips/debian_wheezy_mips_standard.qcow2
wget https://people.debian.org/~aurel32/qemu/mips/vmlinux-3.2.0-4-4kc-malta

Install & link Vgabios

apt-get install vgabios
ln -s /usr/share/vgabios/vgabios* /usr/share/qemu/

Grab the efi-e1000.rom needed by qemu for network stuff

wget https://github.com/qemu/qemu/raw/master/pc-bios/efi-e1000.rom -O /usr/share/qemu/efi-e1000.rom 

Run (May be slow, around ~5mins till boot)

qemu-system-mips -M malta -kernel ./vmlinux-3.2.0-4-4kc-malta \\
-hda ./debian_wheezy_mips_standard.qcow2 -append \"root=/dev/sda1 \\
console=ttyS0\"  -device e1000,netdev=net0 -netdev user,id=net0,hostfwd=tcp::5555-:22 \\
-nographic

Connect via SSH

ssh 127.0.0.1 -p 5555

Copying files

scp -P 5555 ./myfile  [email protected]:/tmp

How to stop it

kill -15 `pidof qemu-system-mips`
Follow me on Twitter! It's free!