The tips are:
- Install qemu-sh4-static (yaourt -S qemu-static)
- setup binfmt_misc kernel module
- Install chroot environment (Arch Linux sh4 rootfs)
STEP 1. Install qemu-sh4-static simulate sh4 program
yaourt -S qemu-static ( build glib2-static, glibc-static and pcre-static at first)qemu-static 1.6.1-2
# test
wget http://linux.fjfi.cvut.cz/\~zub/blog/foreign-chroot/hello_world/hello_world-sh4-static
qemu-sh4-static ./hello_world-sh4-static
STEP 2. Setup binfmt_misc Kernel Module
zgrep BINFMT_MISC /proc/config.gz # check if kernel support itsudo modprobe binfmt_misc # load module
wget http://linux.fjfi.cvut.cz/\~zub/blog/foreign-chroot/binfmt-misc-sh.sh
chmod +x binfmt-misc-sh.sh hello_world-sh4-static
sed -ie 's:usr/local:usr:' binfmt-misc-sh.sh # patch the path to fit Arch's convention
sudo ./binfmt-misc-sh.sh
# check status
ls /proc/sys/fs/binfmt_misc # it should display 'register sh4 status'
cat /proc/sys/fs/binfmt_misc/status
cat /proc/sys/fs/binfmt_misc/sh4
./hello_world-sh4-static # it should display 'Hello world!'
STEP 3. Install Arch Linux sh4 Rootfs
wget http://sh4twbox.googlecode.com/files/target.arch.20130416.tgz
sudo tar xpf target.arch.20130416.tgz
sudo mv mnt_system arch
sudo cp /usr/bin/qemu-sh4-static arch/usr/bin # should be same path as host linux
yaourt -S arch-install-scripts
sudo arch-chroot arch
Problems:
I can only run one command.References:
- https://bbs.archlinux.org/viewtopic.php?id=171054
- http://www.gentoo.org/proj/en/base/embedded/handbook/?part=1&chap=5&style=printable
- https://www.kernel.org/doc/Documentation/binfmt_misc.txt
- https://wiki.archlinux.org/index.php/Chroot
- https://wiki.archlinux.org/index.php/DeveloperWiki:Building_in_a_Clean_Chroot
#"mount -t binfmt_misc none /proc/sys/fs/binfmt_misc" command, or you can add
#a line "none /proc/sys/fs/binfmt_misc binfmt_misc defaults 0 0" to your
#/etc/fstab so it auto mounts on boot.
#There are some restrictions:
# - the whole register string may not exceed 255 characters
# - the magic must reside in the first 128 bytes of the file, i.e.
# offset+size(magic) has to be less than 128
# - the interpreter string may not exceed 127 characters
# name:type:offset:magic:mask:interpreter:flags
沒有留言:
張貼留言