1.
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
cat /proc/sys/fs/binfmt_misc/status
If it says enabled, you’re good to go.
2. create a directory to hold your chroot environment:
export LFS=/lfs
mkdir $LFS
cd $LFS
wget http://circu.it/pilfs/ch5-tools-20141203.tar.xz
tar xvf ch5-tools-20141203.tar.xz
3. Install qemu to get qemu-arm binary
apt-get install qemu binfmt-support qemu-user-static
Copy qemu-arm-static to Emulation system.
mkdir -pv $LFS/usr/bin
cp -v /usr/bin/qemu-arm-static $LFS/usr/bin
4. Make a wrapper binary that will call qemu-arm-static with the correct arguments to emulate the same CPU family and kernel version as that of a Raspberry Pi.
wget http://www.intestinate.com/pilfs/patches/qemu-arm-wrapper.c
gcc -static qemu-arm-wrapper.c -s -o qemu-arm-wrapper
cp -v qemu-arm-wrapper $LFS/usr/bin
5. Register a binfmt_misc handler for our ARM binaries
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-wrapper:" > /proc/sys/fs/binfmt_misc/register
6. trying to chroot into your /lfs directory:
chroot "$LFS" /tools/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin /tools/bin/bash --login +h
7. See a prompt that reads “I have no name!”, everything is working correctly.
Reference:
1. QEMU User Emulation
2. Linux From Scratch on the Raspberry Pi
0 意見:
張貼留言