1. Download image - 2012-12-16-wheezy-raspbian.zip
2. Mount the image using loopback
$ sudo kpartx -a -v 2012-12-16-wheezy-raspbian.img
add map loop0p1 (252:8): 0 114688 linear /dev/loop0 8192
add map loop0p2 (252:9): 0 5763072 linear /dev/loop0 122880
$ sudo mount /dev/mapper/loop0p2 ~/test3
3. Copy qemu-arm-static to Emulation system and
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. Change to root. 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. mount the special directories:
if no mount this, the interface of net won't work.
sudo mount -o bind /dev /mnt/temp/dev
sudo mount -o bind /proc /mnt/temp/proc
sudo mount -o bind /sys /mnt/temp/sys
7. Jump into the emulation environment of pi
sudo chroot ~/test3
8. nano /etc/ld.so.preload
Put a # in front of the first line so that it looks like this:
Because emulation work on X86 machine not on arm machine.
After comment out the line which can use any command.
#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so
9. Test command work
apt-get update
if no error that mean success. Reference:
1. Faster compiling on an emulated Raspberry Pi on Linux
2. chroot to ARM
3. QEMU-Emulating Raspberry Pi the easy way (Linux or Windows!)
4. [QEMU][Raspberry Pi] Building With QEMU User Mode Emulation 5. 在 x86 下 chroot 到 ARM 平台的 rootfs
0 意見:
張貼留言