I occasionally get asked to test out FreeBSD/MIPS patches for people, as they don't have physical hardware present. I can understand that - the hardware is cheap and plentiful, but not everyone wants to have a spare access point around just to test out MIPS changes on.
However QEMU does a pretty good job of emulating MIPS if you're just testing out non-hardware patches. There's even instructions on the FreeBSD wiki for how to do this! So I decided to teach my wifi build system about the various QEMU MIPS emulator targets so it can spit out a kernel and mfsroot to use for QEMU.
Thus:
https://github.com/freebsd/freebsd-wifi-build/wiki/MipsQemuEmulatorImages
It turns out that it wasn't all that hard. The main trick was to use qemu-devel, not qemu. There are bugs in the non-development QEMU branch that mean it works great for Linux but not FreeBSD.
The kernel configurations in FreeBSD had bitrotted a little bit (they were missing the random device, for example) but besides that the build, install and QEMU startup just worked. I now have FreeBSD/MIPS of each variety (32 bit, 64 bit, Little-Endian, Big-Endian) running under QEMU and building FreeBSD-HEAD as a basic test.
Next is figuring out how to build gdb to target each of the above and have it speak to the QEMU GDB stub. That should make it very easy to do MIPS platform debugging.
I also hear rumours about this stuff working somewhat for ARM and PPC, so I'll see how hard it is to run QEMU for those platforms and whether FreeBSD will just boot and run on each.
Building gdb using "./configure --enable-targets=all" is trivial.
ReplyDelete(gdb) set architecture # and when I hit TAB
Display all 288 possibilities? (y or n)
.
.
mips:7000
mips:8000
mips:9000
mips:isa32
mips:isa32r2
mips:isa32r3
mips:isa32r5
mips:isa64
mips:isa64r2
mips:isa64r3
mips:isa64r5
.
.
powerpc:750
powerpc:EC603e
powerpc:MPC8XX
powerpc:a35
powerpc:common
powerpc:common64
powerpc:e500
powerpc:e500mc
powerpc:e500mc64
powerpc:e5500
.
.