View previous topic :: View next topic |
Author |
Message |
something-something-horri n00b
Joined: 23 Jun 2018 Posts: 28 Location: earth
|
Posted: Sat Sep 01, 2018 3:16 am Post subject: armv6j cross-compile/chroot register arm executables interpr |
|
|
I've probably made this in the wrong forum, sorry for double posting.
I'm trying to chroot into a sd card to cross compile for my raspberry pi zero. I'm stuck on this part
[quote]
Once done it is necessary to register ARM executables interpretatior in running kernel:
Code: |
root # 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:/usr/bin/qemu-arm:' > /proc/sys/fs/binfmt_misc/register
|
[quote
returns
Code: |
bash: echo: write error: Invalid argument
|
chmoding doesn't seem to work, I don't know what to do. |
|
Back to top |
|
|
something-something-horri n00b
Joined: 23 Jun 2018 Posts: 28 Location: earth
|
Posted: Sat Sep 01, 2018 7:21 pm Post subject: |
|
|
Okay I got through it by using -e option. not sure why that worked. but now I am stuck in not chrooting into environment.
Code: |
chroot: failed to run command '/bin/bash': no such file or directory
|
|
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54232 Location: 56N 3W
|
Posted: Sat Sep 01, 2018 7:28 pm Post subject: |
|
|
something-something-horri,
Show us all the commands you execute to prepare and get into the chroot.
At face value, /<newroot>/bin/bash or one of the dynamically linked libraries that bash needs is missing.
Have you installed qemu-arm, built with static-user inside the chroot? _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
something-something-horri n00b
Joined: 23 Jun 2018 Posts: 28 Location: earth
|
Posted: Sat Sep 01, 2018 10:55 pm Post subject: |
|
|
NeddySeagoon wrote: | something-something-horri,
Show us all the commands you execute to prepare and get into the chroot.
At face value, /<newroot>/bin/bash or one of the dynamically linked libraries that bash needs is missing.
Have you installed qemu-arm, built with static-user inside the chroot? |
I used this
then I used this
for guidance.
I have just a W95 FAT32 (lba) partition for boot and a ext4 partition for root.
I extracted stage3-armv6j_hardfp-20161205.tar.bz2
using tar xfpj <file> -C <mounted root partition>
and copied the raspberry pi firmware and linux kernel modules
cp -r /home/user/rasperrypi/firmware/boot/* /mnt/raspberrypi/boot/
cp -r /home/user/rasperrypi/firmware/modules /mnt/raspberrypi/lib/
I've basically followed the basic install guide all the way up to the unmount sd card and everything went fine (it can boot and log in as root but I need to at the very least compile wireless networking software from elsewhere for ease of native compiling without having to manually transfer source code from another machine.) |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54232 Location: 56N 3W
|
Posted: Sat Sep 01, 2018 11:27 pm Post subject: |
|
|
something-something-horri,
Which Pi do you have?
We know that your install works, so /bin/sash and its libraries exist.
On your build host, (not the Pi) what do you have in /etc/portage/package.use/qemu ?
What does Code: | emerge -pv app-emulation/qemu | return?
What about Code: | file /usr/bin/qemu-arm | on the build host?
On the Pi, booted normally, What does Code: | file /usr/bin/qemu-arm | say.
It should be the same. The key here is statically linked.
When your chroot works, this is the only program that will run on the build host.
In turn, it emulates the arm CPU to execute the arm code in the chroot.
It cannot link to any libraries ... they are all arm.
You can start the binfmt service rather than register ARM executable interpreter with the running kernel on your build host.
Do you have kernel support for BINFMT_MISC?
Its often off as its a security risk.
Code: | $ grep BINFMT_MISC /usr/src/linux/.config
CONFIG_BINFMT_MISC=y |
That step is missing from the Wiki page you linked. You may need to rebuild your build hosts kernel. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
something-something-horri n00b
Joined: 23 Jun 2018 Posts: 28 Location: earth
|
Posted: Sun Sep 02, 2018 12:10 am Post subject: |
|
|
NeddySeagoon wrote: | something-something-horri,
Which Pi do you have?
We know that your install works, so /bin/sash and its libraries exist.
On your build host, (not the Pi) what do you have in /etc/portage/package.use/qemu ?
What does Code: | emerge -pv app-emulation/qemu | return?
What about Code: | file /usr/bin/qemu-arm | on the build host?
On the Pi, booted normally, What does Code: | file /usr/bin/qemu-arm | say.
It should be the same. The key here is statically linked.
When your chroot works, this is the only program that will run on the build host.
In turn, it emulates the arm CPU to execute the arm code in the chroot.
It cannot link to any libraries ... they are all arm.
You can start the binfmt service rather than register ARM executable interpreter with the running kernel on your build host.
Do you have kernel support for BINFMT_MISC?
Its often off as its a security risk.
Code: | $ grep BINFMT_MISC /usr/src/linux/.config
CONFIG_BINFMT_MISC=y |
That step is missing from the Wiki page you linked. You may need to rebuild your build hosts kernel. |
I have a raspberry pi 0 for the armv6j stage 3 tarball but I'm also planning on doing the same to the raspberry pi 2 and raspberry pi 3 with the armv7a stage 3 tarball. currently we're focusing on the rasperry pi 0 sd card.
Code: |
grep BINFMT_MISC /usr/src/linux/.config
|
returns
Code: |
CONFIG_BINFMT_MISC=y
|
So not problem on that part.
this is what the emerge -pv says
I think this is the problem, it doesn't say qemu-arm, but the /usr/bin/qemu files exit with qemu-system-x86_64 for both.
Code: |
cd /mnt/rpi
ROOT=$PWD/ emerge --usepkgonly --oneshot --nodeps qemu
|
had run fine so I'm guessing that I didn't emerge qemu right? I did have static user as the use flag as you can see (but the arm use flag isn't selected?).
edit: I'm reading up on the qemu page, whats the difference between user_targets and softmmu_targets?
Last edited by something-something-horri on Sun Sep 02, 2018 12:17 am; edited 1 time in total |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54232 Location: 56N 3W
|
Posted: Sun Sep 02, 2018 12:16 am Post subject: |
|
|
something-something-horri,
It looks that way, You don't have an arm emulator.
You only have a QEMU_SOFTMMU_TARGETS="x86_64 and QEMU_USER_TARGETS= is empty. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
something-something-horri n00b
Joined: 23 Jun 2018 Posts: 28 Location: earth
|
Posted: Sun Sep 02, 2018 1:13 am Post subject: |
|
|
NeddySeagoon wrote: | something-something-horri,
It looks that way, You don't have an arm emulator.
You only have a QEMU_SOFTMMU_TARGETS="x86_64 and QEMU_USER_TARGETS= is empty. |
should softmmu targets be arm? |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54232 Location: 56N 3W
|
Posted: Sun Sep 02, 2018 10:40 am Post subject: |
|
|
something-something-horri,
I don't know, I set both QEMU_SOFTMMU_TARGETS and QEMU_USER_TARGETS= to the same thing. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
|