View previous topic :: View next topic |
Author |
Message |
musv Advocate
Joined: 01 Dec 2002 Posts: 3337 Location: de
|
Posted: Sat Aug 13, 2016 9:13 pm Post subject: [solved] Need help for cross-building ARM |
|
|
Hi there,
I'm really struggling to install my NAS (ARMv7-a Marvell Armada 380), but I'm failing already in the first steps. OK, let's start:
As base I took Compiling with qemu_user_chroot
My steps:
- Create the crosscompiler with
Code: | crossdev -t armv7a-hardfloat-linux-gnueabi | - works
Unpack ARM-Stage 3 to /usr/armv7a-hardfloat-linux-gnueabi - works
Start compiling the system according to the Gentoo-Wiki with Code: | armv7a-hardfloat-linux-gnueabi-emerge -uva --keep-going @system | - works as described for about 60 of 90 packages (unfortunately no gcc).
Installing qemu user - got working after discovering a nasty missing USE-Flag and opening a bug report.
modprobe and mount binfmt_misc and registering the handler in the proc system - works
starting the binfmt-service - works
Mounting the directories (dev, proc, portage) - works
Code: | chroot . /bin/bash --login | - fails
I don't understand the logic of the last point. If we do a chroot we use the bash from the arm-system. This should fail due to the different architecture. And if I do so I get the expected:
Code: | chroot . /bin/bash --login
chroot: failed to run command '/bin/bash': No such file or directory |
If I insert the previously compiled qemu-wrapper script (qemu-arm -cpu cortex-a9) I get:
Code: | chroot . /usr/local/bin/qemu-wrapper /bin/bash --login
bash: /usr/bin/dircolors: No such file or directory
bash: /bin/grep: No such file or directory
bash: /usr/bin/cut: No such file or directory |
That's at least partly working. Some tests:
Code: | ls
bash: /bin/ls: No such file or directory
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/armv7a-hardfloat-linux-gnueabi/gcc-bin/4.9.3
root /> /usr/local/bin/qemu-wrapper ls
Error while loading ls: No such file or directory
root /> /usr/local/bin/qemu-wrapper /bin/ls
bin boot dev etc home lib lost+found media mnt opt packages proc root run sbin sys tmp usr var
root /> /usr/local/bin/qemu-wrapper /usr/bin/emerge
emerge emerge-webrsync
root /> /usr/local/bin/qemu-wrapper /usr/bin/emerge
emerge emerge-webrsync
root /> /usr/local/bin/qemu-wrapper /usr/bin/emerge -puND world
Error while loading /usr/bin/emerge: Exec format error
root /> /usr/bin/emerge -puNd world
bash: /usr/bin/emerge: /usr/lib/python-exec/python-exec2-c: bad interpreter: No such file or directory |
Questions:
- The chroot command: Am I doing something wrong or is the handbook wrong at this point?
- Do I have to call qemu-wrapper before every command? Or how do I proceed to compile the rest of the system within the qemu-target chroot?
Last edited by musv on Sun Aug 21, 2016 9:15 am; edited 1 time in total |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54239 Location: 56N 3W
|
Posted: Sat Aug 13, 2016 9:27 pm Post subject: |
|
|
musv,
The chroot should work.
When the system tries to run the arm format binary, it will call the binfmt_misc handler for that format which in turn will start qemu to deal with the arm format.
You don't mention the Code: | Install the static qemu into the chroot: | step.
That's the result of Code: | quickpkg app-emulation/qemu |
Code: | ROOT=$PWD/ emerge --usepkgonly --oneshot --nodeps qemu | so that the hosts statically built qemu is installed inside the chroot.
Its installed outside the chroot too but its the copy inside the chroot that will be used to run your arm code. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
musv Advocate
Joined: 01 Dec 2002 Posts: 3337 Location: de
|
Posted: Sun Aug 14, 2016 8:13 am Post subject: |
|
|
Thanks for your explanation. I guess my problem is located in the binfmt section. Something is there still wrong in my config.
If I try to install qemu I get a lot of warnings. But I think, that's still ok:
Code: | ROOT=$PWD/ emerge --usepkgonly -1 --nodeps qemu
* IMPORTANT: 10 news items need reading for repository 'gentoo'.
* Use eselect news read to view new items.
>>> Running pre-merge checks for app-emulation/qemu-2.6.0
* qemu-2.6.0.tbz2 MD5 SHA1 size ;-) ... [ ok ]
* Determining the location of the kernel source code
* Found kernel source directory:
* /usr/src/linux
* Found kernel object directory:
* /lib/modules/4.5.0-gentoo/build
* Found sources for kernel version:
* 4.5.0-gentoo
* Checking for suitable kernel configuration options...
* If you have an AMD CPU, you must enable KVM_AMD in your kernel configuration.
* Please check to make sure these options are set correctly.
* Failure to do so may cause unexpected problems.
>>> Emerging binary (1 of 1) app-emulation/qemu-2.6.0::gentoo for /usr/armv7a-hardfloat-linux-gnueabi/
* qemu-2.6.0.tbz2 MD5 SHA1 size ;-) ... [ ok ]
>>> Extracting info
>>> Extracting app-emulation/qemu-2.6.0
>>> Installing (1 of 1) app-emulation/qemu-2.6.0::gentoo to /usr/armv7a-hardfloat-linux-gnueabi/
* QA Notice: Symbolic link /usr/share/qemu/vgabios.bin points to /usr/share/vgabios/vgabios.bin which does not exist.
* QA Notice: Symbolic link /usr/share/qemu/vgabios-vmware.bin points to /usr/share/vgabios/vgabios-vmware.bin which does not exist.
* QA Notice: Symbolic link /usr/share/qemu/vgabios-stdvga.bin points to /usr/share/vgabios/vgabios-stdvga.bin which does not exist.
* QA Notice: Symbolic link /usr/share/qemu/vgabios-qxl.bin points to /usr/share/vgabios/vgabios-qxl.bin which does not exist.
* QA Notice: Symbolic link /usr/share/qemu/vgabios-cirrus.bin points to /usr/share/vgabios/vgabios-cirrus.bin which does not exist.
* QA Notice: Symbolic link /usr/share/qemu/sgabios.bin points to /usr/share/sgabios/sgabios.bin which does not exist.
* QA Notice: Symbolic link /usr/share/qemu/pxe-virtio.rom points to /usr/share/ipxe/1af41000.rom which does not exist.
* QA Notice: Symbolic link /usr/share/qemu/pxe-rtl8139.rom points to /usr/share/ipxe/10ec8139.rom which does not exist.
* QA Notice: Symbolic link /usr/share/qemu/pxe-pcnet.rom points to /usr/share/ipxe/10222000.rom which does not exist.
* QA Notice: Symbolic link /usr/share/qemu/pxe-ne2k_pci.rom points to /usr/share/ipxe/10500940.rom which does not exist.
* QA Notice: Symbolic link /usr/share/qemu/pxe-eepro100.rom points to /usr/share/ipxe/80861209.rom which does not exist.
* QA Notice: Symbolic link /usr/share/qemu/pxe-e1000.rom points to /usr/share/ipxe/8086100e.rom which does not exist.
* QA Notice: Symbolic link /usr/share/qemu/bios.bin points to /usr/share/seabios/bios.bin which does not exist.
/sbin/ldconfig: /lib/libprocps.so.4.0.0 is for unknown machine 40.
/sbin/ldconfig: /lib/libc-2.22.so is for unknown machine 40.
/sbin/ldconfig: /lib/libkmod.so.2.3.0 is for unknown machine 40.
/sbin/ldconfig: /lib/libcrack.so.2 is for unknown machine 40.
/sbin/ldconfig: /lib/libip4tc.so.0.1.0 is for unknown machine 40.
/sbin/ldconfig: /lib/libpthread-2.22.so is for unknown machine 40.
/sbin/ldconfig: /lib/librt-2.22.so is for unknown machine 40.
…
* app-emulation/qemu is using the deprecated readme.gentoo.eclass.
* Please use readme.gentoo-r1 instead.
* Messages for package app-emulation/qemu-2.6.0 merged to /usr/armv7a-hardfloat-linux-gnueabi/:
* If you have an AMD CPU, you must enable KVM_AMD in your kernel configuration.
* Please check to make sure these options are set correctly.
* Failure to do so may cause unexpected problems.
>>> Auto-cleaning packages...
>>> Using system located in ROOT tree /usr/armv7a-hardfloat-linux-gnueabi/
>>> No outdated packages were found on your system. |
My host cpu is a Intel Xeon. So I didn't enable the KVM_AMD, which isn't used anyway for ARM emulation.
The binfmt stuff - Kernel:
Code: | zgrep -i binfmt /proc/config.gz
CONFIG_BINFMT_ELF=y
CONFIG_COMPAT_BINFMT_ELF=y
CONFIG_BINFMT_SCRIPT=y
CONFIG_BINFMT_MISC=y |
Should be ok. Or is it necessary to build as a module?
Registering the the handler:
Investigating the init-script, it doesn't to anything else than
Code: | if [ $cpu != "arm" -a -x "/usr/bin/qemu-arm" ] ; then
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\x00\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi |
As a difference to the handbook it calls qemu-arm and not the qemu-wrapper. About the QEMU_BINFMT_FLAGS I'm not sure.
Code: | la /proc/sys/fs/binfmt_misc/
-rw-r--r-- 1 root root 0 14. Aug 09:20 arm
--w------- 1 root root 0 14. Aug 09:20 register
-rw-r--r-- 1 root root 0 14. Aug 09:19 status
cat /proc/sys/fs/binfmt_misc/status
enabled
cat /proc/sys/fs/binfmt_misc/arm
enabled
interpreter /qemu-wrapper
flags:
offset 0
magic 7f454c4601010100000000000000000002002800
mask ffffffffffffff00fffffffffffffffffeffffff |
Found the error:
/qemu-wrapper could not be found. It was located in /usr/local/bin. So I changed the path and it seems to work. Thanks a lot. |
|
Back to top |
|
|
musv Advocate
Joined: 01 Dec 2002 Posts: 3337 Location: de
|
Posted: Sun Aug 21, 2016 9:19 am Post subject: |
|
|
Just for information, if someone wants to use it:
I'm using systemd. There's a way not to be forced to build a static qemu-arm.
http://blog.oddbit.com/2016/02/07/systemd-nspawn-for-fun-and-well-mostly-f/
Instead of chroot, you can also use systemd-nspawn and mount the required libdir and the qemu-arm inside the chroot-environment. Nevertheless it's the same principle. |
|
Back to top |
|
|
|