# Setting up a build environment for MIPS(el)

When compiling userspace tools for the EdgeRouter models (I’m using the same method when compiling the kernel for the ER-X), I’ve been using the QEMU emulator to emulate the MIPS architecture, as opposed to typical cross-compiling. But it’s a pain to set up, and in my case it’s been horribly slow to run.

Recently I found a tutorial over at the Debian wiki that shows how to set up a debootstrap environment for another architecture. ARM is used in that particular example, but the same methods apply for MIPS too.

Please note, this method still uses QEMU to emulate the MIPS architecture, but it does so transparently when chrooting into the debootstrapped environment, so it’s a lot easier to use.

Note: Remember to replace mips with mipsel if your platform is using little endian.

First install QEMU and debootstrap:

Now we’ll bootstrap the new system:

The QEMU emulator for the target architecture needs to be available in the bootstrapped system for chrooting to work:

Run second stage of debootstrap:

Finally trigger post install scripts:

Now it’s time to chroot into our new environment:

When I started using my new environment I quickly noticed that the locales weren’t properly set up, so I got a lot of warnings, especially when running apt-get. This is easily fixed by installing the locales package and then configuring it with the locales you need.