Page 1 of 1

Getting 'illegal instruction' when trying to chroot

Posted: Wed Feb 27, 2013 8:49 pm
by emihalac
Hello,

I'm trying to set up a cross-compiler on my laptop for the RPi. For that I need a RPi system image that I can update with all the libraries that may be necessary for compiling.

I saw that one way to do that is to mount the partition somewhere on my laptop into it and then use chroot (http://alexchamberlain.github.com/raspb ... ge%3F.html - I used 'the hard way' for Debian/Ubuntu (I'm running 32-bit Ubuntu 12.10)).

The chroot seems to work (I get a prompt and can issue basic commands), but when I try to use 'aptitude update' or 'aptitude upgrade' or even 'ping' I am getting

Code: Select all

qemu: uncaught target signal 4 (Illegal instruction) - core dumped
Illegal instruction (core dumped)
Things I have done (apart from the ones mentioned in the above link):
  • copied the /etc/hosts file to the RPi filesystem (because I was getting 'unable to resolve host' messages when running commands with sudo)
  • tried to look at the core dump file, but couldn't find any (interestingly, running 'find / -name core' from the chroot jail also produced the 'illegal instruction' error - I had to run this command from outside chroot)
  • tried to run 'dhclient eth0', eth0 being the name of my Ethernet adapter. This gives the errors:

    Code: Select all

    Unsupported setsockopt level=41 optname=49
    ../../../../lib/isc/unix/socket.c:2375: setsockopt(21, IPV6_RECVPKTINFO) failed: Protocol not available
    Unsupported setsockopt level=41 optname=24
    Unsupported setsockopt level=41 optname=23
    Unsupported setsockopt level=41 optname=26
    ../../../../lib/isc/unix/socket.c:5636: setsockopt(21, IPV6_V6ONLY) failed: �[email protected]��@
    qemu: uncaught target signal 4 (Illegal instruction) - core dumped
    Illegal instruction (core dumped)
    
DNS resolving might be working, since when I issue 'ping google.com', the first line says 'PING google.com (62.231.75.217) 56(84) bytes of data.', so the IP is there, but then I get the 'illegal instruction' again.

If anyone could provide any assistance with this, I would be grateful.

Re: Getting 'illegal instruction' when trying to chroot

Posted: Thu Feb 28, 2013 12:54 am
by SirLagz
Illegal instruction means that the binary is compiled for the wrong cpu architecture.
I'm assuming your ubuntu computer is an X86 machine ?
chrooting into the Pi environment won't work. You'll need to emulate the pi with qemu to do your thing.

Re: Getting 'illegal instruction' when trying to chroot

Posted: Thu Feb 28, 2013 8:24 am
by emihalac
SirLagz wrote:Illegal instruction means that the binary is compiled for the wrong cpu architecture.
I'm assuming your ubuntu computer is an X86 machine ?
chrooting into the Pi environment won't work. You'll need to emulate the pi with qemu to do your thing.
I'm using a statically-linked qemu to do that (qemu-arm-static), and this is supposed to work according to http://alexchamberlain.github.com/raspb ... ge%3F.html.

Also, basic commands work in the chroot environment (e.g. nano, ls) - these are definitely the commands that are compiled for arm and not the x86 ones (I checked this by specifying their exact path and determining that they can be executed from within chroot but not from the outside).

Re: Getting 'illegal instruction' when trying to chroot

Posted: Fri Mar 01, 2013 1:06 am
by SirLagz
Not sure then...if it were me I'd just start qemu with the image as the 'hard drive'

Re: Getting 'illegal instruction' when trying to chroot

Posted: Fri Mar 01, 2013 8:34 am
by emihalac
Okay, thanks for considering this. I'll post here if I make any progress with it.

Re: Getting 'illegal instruction' when trying to chroot

Posted: Tue Mar 05, 2013 12:11 am
by kalectro
same problem here

it worked on the previous image

Re: Getting 'illegal instruction' when trying to chroot

Posted: Wed Mar 13, 2013 9:58 pm
by AutoStatic
I've encountered the same problem. So I've updated an older image and that does seem to work.

Re: Getting 'illegal instruction' when trying to chroot

Posted: Thu Mar 14, 2013 10:31 am
by TheQuestor
Yup 2013-02-09 completely borks with qemu. Either chroot or qemu by itself. I read somewhere that it might have to do with sound drivers but I could not get around the issue no matter what I did. So it was back to 2012-12-16 and that one has no issues. I was able to expand it fine and chroot it to on Ubunti 12.10 with no issues [other than it being really slow :(] I haven't tried the soft float build yet but I am pretty sure it would make no difference :(. I hope somebody figures it out.

On the no resolve dns, that's pretty messed up too. I just keep populating my /etc/hosts file with the addresses I need to use, such as for apt-get and whatnot.

Code: Select all

89.16.177.202   mirrordirector.raspbian.org
93.93.128.176   archive.raspberrypi.org
76.76.28.109    raspbian.caro.net
143.215.130.220 distribution-us.hexxeh.net
207.97.227.239  github.com
212.110.166.220 mirrors.xbmc.org
193.136.38.158  mirrors.fe.up.pt
66.68.209.86    www.computerguy.ws
74.125.227.132  goo.gl
199.27.74.133   raw.github.com
is what I have in there now and it lets me do pretty much what I need :)

Re: Getting 'illegal instruction' when trying to chroot

Posted: Thu Mar 14, 2013 10:45 am
by TheQuestor
doh! I missed this part
cp /etc/network/interfaces target/etc/network/interfaces
cp /etc/resolv.conf target/etc/resolv.conf
before you chroot. seems to fix it right up :)

Re: Getting 'illegal instruction' when trying to chroot

Posted: Thu Mar 14, 2013 8:52 pm
by AutoStatic
http://xecdesign.com/qemu-emulating-ras ... -easy-way/
kinsa wrote:UPDATE (9th of March, 2013): In order to run the latest image (2013-02-09-wheezy-raspbian.img) you need to comment out the contents of /etc/ld.so.preload.

Re: Getting 'illegal instruction' when trying to chroot

Posted: Mon Dec 21, 2015 6:16 pm
by andyrblank
AutoStatic wrote:http://xecdesign.com/qemu-emulating-ras ... -easy-way/
kinsa wrote:UPDATE (9th of March, 2013): In order to run the latest image (2013-02-09-wheezy-raspbian.img) you need to comment out the contents of /etc/ld.so.preload.
Thank you, this worked with Raspbian Jessie!

Re: Getting 'illegal instruction' when trying to chroot

Posted: Sun Feb 05, 2017 11:51 pm
by mariusco
Hi,
Is 2017 and I downloaded
2017-01-11-raspbian-jessie-lite.img
I am in qemu-static change root
4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 armv7l GNU/Linux

[email protected]:/# apt-get
qemu: uncaught target signal 4 (Illegal instruction) - core dumped