[[gentoo-on-n8x0:|Back]]
====== Running in QEMU ======
If you have powerfull desktop/server box, you can run n8x0 stage on it. Main reasons to do so are CPU speed (and quantity) and RAM amount (several packages cannot be built on N8X0 due to insufficient RAM). We'll use [[http://qemu.org/|QEMU]] user emulation + [[wp>binfmt_misc]]. Due to the need to pass additional args to QEMU (cpu model), we'll create wrapper script that'll call QEMU with it.
- [[gentoo-on-n8x0:#resources|Download]] and unpack stage to ''/usr/armv6j-unknown-linux-gnueabi/''
- [[http://wiki.qemu.org/Download|Download latest qemu release]]
- Unpack and cd into it
- Compile QEMU: ./configure --target-list=arm-linux-user --static && make
- Copy compiled ''arm-linux-user/qemu-arm'' to ''/'' and ''/usr/armv6j-unknown-linux-gnueabi/''
- Save following code as ''qemu-wrapper.c'':
#include
#include
int main(int argc, char *argv[], char *envp[]) {
char *newargv[argc + 3];
newargv[0] = argv[0];
newargv[1] = "-cpu";
newargv[2] = "arm1136";
memcpy(&newargv[3], &argv[1], sizeof(*argv) * (argc - 1));
newargv[argc + 2] = NULL;
return execve("/qemu-arm", newargv, envp);
}
and compile it:
gcc -static qemu-wrapper.c -o qemu-wrapper
- Copy compiled ''qemu-wrapper'' to ''/'' and ''/usr/armv6j-unknown-linux-gnueabi/''
- Create setup script with following contents (its effect doesn't persist across reboot). Run it.
#!/bin/bash
CHOST="armv6j-unknown-linux-gnueabi"
QEMU="/qemu-wrapper"
modprobe binfmt_misc && mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
[ -e /proc/sys/fs/binfmt_misc/arm ] || echo ":arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:${QEMU}:" > /proc/sys/fs/binfmt_misc/register
mount --bind /usr/portage/ "/usr/${CHOST}/usr/portage/"
mount --bind /sys/ "/usr/${CHOST}/sys/"
mount -t proc proc "/usr/${CHOST}/proc/"
mount -o rbind /dev/ "/usr/${CHOST}/dev/"
- With everything set up, chroot into arm system: chroot /usr/armv6j-unknown-linux-gnueabi/
Same approach can be used for any QEMU-supported machine. For binfmt ELF magic see ''qemu-binfmt-conf.sh'' from QEMU tarball.