Hi there, I've been messing about with this too, and ran into the same problem. I'm still working on it, but I *think* I may have found a fix. I need to get on the embedded mailing list and ask some questions to be sure I understand what is going on though.
So, to what I know:
- The message
Code: Select all
/bin/bash: /bin/bash: cannot execute binary file
means that the system can't find an appropriate interpreter for the file, or the interpreter is failing, I can't be sure which.
- I found a "raspbian" VMDK image (read ubuntu image seemingly used for raspbian development), in which an arm chroot does work: http://archive.raspbian.org/qemu/rpi-qe ... ev.tar.bz2, launch the vmdk in qemu etc. and take a look in the /chroots dir
- The difference between the debian setup and gentoo comes in the binfmt_misc handlers:
Gentoo:
Code: Select all
# cat /proc/sys/fs/binfmt_misc/arm
enabled
interpreter /usr/bin/qemu-arm
flags: P
offset 0
magic 7f454c4601010100000000000000000002002800
mask ffffffffffffff00ffffffffffff00fffeffffff
Raspbian-ubuntu-dev:
Code: Select all
# cat /proc/sys/fs/binfmt_misc/qemu-arm
enabled
interpreter /usr/bin/qemu-arm
flags: OC
offset 0
magic 7f454c4601010100000000000000000002002800
mask ffffffffffffff00fffffffffffffffffeffffff
Notice in particular that the mode flag for debian is OC, and for gentoo is P. Now I will admit that this is the part that I don't full understand, however taking a look at the kernel.org
documentation for binfmt_misc, it appears that the raspbian image is using the new mode, and gentoo is using the old legacy mode. Changing this mode on gentoo fixes the issue, but I am unsure at what cost, hence I say I need to check this out with people who know more than me, probably the embedded mailing list.
There is also a difference in one byte of the mask, which I matched in my setup also. Since I don't really have enough knowledge of the ELF format, I am not 100% sure what effect this has, apart from to say the debian version is somehow stricter in what it matches (since setting the magic to 00 and the mask to 00 effectively means "ignore this byte"), although looking at wikipedia it seems the debian form checks the last byte of the padding block is set to 0x00, the gentoo form ignores it.
In the meantime however, by patching the provided /etc/init.d/qemu-binfmt script to match the raspbian settings, I have been able to get my chroot minimally working. My next step is to provide a native binary arm compiler and a native python interpreter to the chroot, but it remains to be seen how easy that will be or when I get the time to sit down and sort it out. My intention is eventually to get a working lxc template written for this and posted to github+wiki, but at the moment I am in a very preliminary stage.
Hope this is of some help
-Telemin-
P.S watch out for the step
it can (probably will) trash your host /dev requiring a reboot. I have made do with bind mounting dev and not running mdev