Running Openwrt under QEMU

Openwrt is a great distribution for various embedded products. Sometimes it's just handy to check applications on a QEMU instead of hooking the board,etc.

Lets' checkout Openwrt to Ubuntu 10.04 64bit and built it.

git clone git://nbd.name/openwrt.git
cd openwrt
make package/symlinks
#this will pop up menuconfig, I chose MIPS Malta CoreLV board (qemu) as the TARGET
#I also choose Big Endian as my target platform is a Big Endian MIPS(AR71xx).
#now save and exit.
make menuconfig
#choose any packages you want to include into the final image, in my case, I added 
#Jamvm for JVM.
#save and exit.
time make -j4

After everything is built, you will get the QEMU image at:
bin/malta/openwrt-malta-be-vmlinux.elf

To run this under QEMU, I need install QEMU on Ubuntu 10.04 64bit first:

sudo aptitude install qemu-kvm-extras

Now it's time to run this newly built OpenWRT image under QEMU:

qemu-system-mips -kernel bin/malta/openwrt-malta-be-vmlinux.elf -nographic -m 64
#after it's fully powered up(i.e. wait until you see: pcnet32 0000:00:0b.0: eth0: link up), do:
udhcpc -i br-lan #this should grab a 10.0.*.* IP address, I got 10.0.2.15
ping 10.0.2.2 #to test internal network
scp userid@my-outside-server-ip:/tmp/test.img /tmp
#now you can reach external network, however, you can not ping.

To quit QEMU, do:
CTRL-A c, then type: quit

This is it. You can also choose QEMU for ARM similarly.