Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # How to get the brainfish IZ2S sd image running in qemu-user on mint-debian.
- # This is my take on the instructions provided here: (I need it all spelled out)
- # http://brainfisheatfishbrain.com/2013/11/using-qemu-user-to-cross-compile-for-arm-on-ubuntu.html
- # Do all this manually. Do NOT run this as a script. (maybe small pieces are ok)
- # First install qemu
- #apt-get install qemu-user
- #apt-get install qemu-user-static
- # And install some sort of chroot
- #apt-get install debootstrap
- # Check whether the binfmt entries were successfully registered:
- sudo update-binfmts --display
- # Check for zipit Z2 in qemu support (should be last entry).
- qemu-system-arm -M ?
- # Setup qemu for arm dev
- [ -d /proc/sys/fs/binfmt_misc ] || modprobe binfmt_misc
- [ -f /proc/sys/fs/binfmt_misc/register ] || mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
- # Register the arm handler:
- # su to root, then echo this to register
- #
- # Wait. Do I really want to do this? I think we can skip it.
- # (update-binfmts shows /usr/bin/qemu-arm-static as the interpretor for qemu-arm.
- #
- #sudo 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-static:' > /proc/sys/fs/binfmt_misc/register
- # Create a chroot (./sd for example)
- # NOTE: This should start out as an x86 chroot
- # with \bin\bash and all libs required by ldd /bin/bash
- # and with \bin\mount and all libs required by ldd /bin/mount
- # Then we replace it with an arm chroot after registering qemu in it.
- mkdir sd/bin
- cp /bin/bash sd/bash
- mkdir -p sd/lib/i386-linux-gnu
- # Copy libs required by bash to sd/lib
- cp /lib/i386-linux-gnu/libncurses.so.5 sd/lib/i386-linux-gnu/
- cp /lib/i386-linux-gnu/libtingo.so.5 sd/lib/i386-linux-gnu/
- cp /lib/i386-linux-gnu/libtinfo.so.5 sd/lib/i386-linux-gnu/
- cp /lib/i386-linux-gnu/libdl.so.2 sd/lib/i386-linux-gnu/
- cp /lib/i386-linux-gnu/libc.so.6 sd/lib/i386-linux-gnu/
- cp /lib/ld-linux.so.2 sd/lib/
- # Copy mount and libs required by mount to sd/lib
- cp /bin/mount sd/bin/
- cp /lib/i386-linux-gnu/libblkid.so.1 sd/lib/i386-linux-gnu/
- cp /lib/i386-linux-gnu/libselinux.so.1 sd/lib/i386-linux-gnu/
- cp /lib/i386-linux-gnu/libmount.so.1 sd/lib/i386-linux-gnu/
- cp /lib/i386-linux-gnu/libuuid.so.1 sd/lib/i386-linux-gnu/
- cp /lib/i386-linux-gnu/libpcre.so.3 sd/lib/i386-linux-gnu/
- # Mount proc in the chroot;
- # Maybe use -o bind with mount to point my chroot proc at the real proc
- # That should be ok since I'm using chroot for qemu, not security purposes.
- #
- # cd sd
- # mkdir proc
- # mount -o bind /proc proc
- # cd ..
- # Make proc and populate it.
- mkdir sd/proc
- mount -t proc sd/proc sd/proc
- sudo chroot sd
- # Setup qemu in the chroot.
- [ -f /proc/sys/fs/binfmt_misc/register ] || mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
- # Exit the chroot
- exit
- #Fetch the really nice IZ2S filesystem tgz from here:
- #http://brainfisheatfishbrain.com/2013/11/zipit-cross-compiling-real-life-apps-progress.html
- cd sd
- tar -xzvf ~/Downloads/iz2s_fat_buildenv_openmsxasm_291113.tgz
- cd ..
- # Make an ls available (it's quite a challenge without ls).
- cd sd/bin
- ln -s busybox ls
- cd ../..
- # The gcc-4.2.4 from the brainfish tarball is not quite built right for IZ2S.
- # So I don't recommend using it.
- # Unfortunately it looks for the glibc dynamic linker instead of uclibc,
- # Which requires you to do this.
- # Make dynamic arm executables work (and x86 executables not work) in the chroot.
- ##### cp sd/lib/ld-uClibc.so.0 sd/lib/ld-linux.so.2
- # Only the binutils and the 4.2.4 gcc on the tarball were compiled this way.
- # So if we replace them with gcc-4.4.7 and new binutils, we should be ok.
- # Then we can drop some things into the chroot from the x86 host linux for speed.
- # I'm thinking maybe x86 bash and make could speed things up a little.
- # Copy the required qemu binaries into the chroot;
- #cp /usr/bin/qemu-arm ./sd/usr/bin;
- cp /usr/bin/qemu-arm-static ./sd/usr/bin/
- # Give qemu-arm-static a few aliases, for good luck.
- cp /usr/bin/qemu-arm-static ./sd/usr/bin/qemu-arm
- cp /usr/bin/qemu-arm-static ./sd/qemu-wrapper
- # Now step into the IZ2S chroot and get busy.
- sudo chroot sd
- # Do some extra setup make the chroot useable.
- cd bin
- busybox ln busybox ln
- ln bash sh
- # Set up normal IZ2S busybox links.
- busybox.sh
- # IZ2S skips some busybox apps that are preinstalled on the internal ramdisk.
- # There is no ramdisk in qemu, so link them to this busybox.
- ln -s busybox chmod
- ln -s busybox rm
- ln -s busybox cp
- ln -s busybox mv
- ln -s busybox cat
- ln -s busybox mkdir
- ln -s busybox uname
- ln -s busybox ash
- ln -s busybox dd
- ln -s busybox df
- ln -s busybox echo
- ln -s busybox ls
- ln -s busybox mknod
- ln -s busybox mount
- ln -s busybox ping
- ln -s busybox ps
- ln -s busybox pwd
- ln -s busybox rmdir
- ln -s busybox sleep
- ln -s busybox sync
- ln -s busybox tar
- ln -s busybox umount
- ln -s busybox vi
- # I don't think we want this one. Use binutils instead?
- rm /mnt/sd0/bin/ar
- cd /
- mkdir mnt
- ln / mnt/sd0
- mkdir dev
- sudo mount -o bind /dev dev
- mkdir tmp
- sudo mount -o bind /tmp tmp
- #############################################################################
- # Now get a compiler toolchain working. Skip this if gcc-4.4.7 already built.
- # Or install the 100MB tarball with gcc-4.4.7 already built.
- #############################################################################
- # We need the make program available to build things.
- cp /mnt/sd0/share/gcc/bin/make /usr/local/bin
- # Need some non-stripped libs, AND INCLUDES.
- ln -s /usr/local/lib /usr/lib
- # These were supplied with (or by) uclibc and are needed to build a compiler.
- cp /share/gcc/lib/*crt*.o /lib
- cp /share/gcc/lib/libc.so /lib
- cp /share/gcc/lib/uclibc_nonshared.a /lib
- cp /share/gcc/lib/libpthread.* /lib
- cp /share/gcc/lib/libm.* /lib
- export LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
- ln -s /share/gcc/include /usr/include
- export CPATH=/usr/include:/usr/local/include
- cd gcc-4.4.7
- # Manually apply the "index" patch for uclibc. (#undef index in rope, ropeimpl.h)
- #./configure --prefix=/mnt/sd0/usr/local --target=arm-linux-uclibc --enable-languages=c,c++
- . ./env.sh
- ./cfg.sh
- make
- make install
- # I made the mistake of using the gcc-4.2.4 to build my gcc-4.4.7, which
- # meant it could compile executables for IZ2S, but required ld-linux.so.2 for
- # itself in the chroot.
- # So I did a make depclean and had 4.4.7 rebuild itself for ld-uclibc.so.0
- #
- # I also discovered binutils had been built with gcc-4.2.4 for ld-linux.so.2
- # so I rebuilt them with the same env and config settings as gcc-4.4.7.
- cd /binutils*
- ../gcc-4.4.7/cfg.sh
- make
- make install
- #############################################################################
- # At this point I cleaned up by removing all the various gcc-4.*.* directories.
- # I also deleted the source tarballs (*.gz) from / in the chroot.
- # Then I tracked down any installed gcc-4.2.4 stuff and deleted it.
- find / -print |grep "4\.2\.4"
- # Also delete the binutils compiled with 4.2.4 (on Nov 28) from /share/gcc/lib
- cd /share/gcc/lib
- rm ranlib
- rm objdump
- rm ar
- rm strip
- rm objcopy
- rm nm
- rm as
- rm ld.bfd
- rm ld
- # I still need to figure which libs in /share/gcc/lib belong to uclibc.
- # These must eventually be copied to /usr/local/lib for gcc-4.4.7 to find them.
- # Remove old gcc from paths
- export CPLUS_INCLUDE_PATH=
- export LD_LIBRARY_PATH=/mnt/sd0/usr/local/lib:/mnt/sd0/lib
- export C_INCLUDE_PATH=/mnt/sd0/usr/local/include
- export PATH=/mnt/sd0/bin:/mnt/sd0/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- #############################################################################
- # To test I went into the stella directory and configured it like this.
- cd /stella-3.9.2
- ./configure --prefix=/usr/local --disable-windowed --disable-gl --disable-joystick --disable-debugger --x-libraries=
- # It still wanted X11 so edited config.mak
- # Removed -DHAVE_X11 from DEFINES and remove -lX11 from LIBS
- # Hopefully it really only needs SDL.
- make
- # Patched Settings.cxx to add some #ifdef DEBUGGER_SUPPORT
- make
- # Hit some more extensive debugger issues. Gave up on --disable-debugger
- ./configure --prefix=/usr/local --disable-windowed --disable-gl --disable-joystick --x-libraries=
- # Remove X11 from config.mak again
- make
- # This was moving along ok so...
- # I visited the stella web site, looked at some screenshots, and aborted.
- # There's no way that enormous debugger screen is gonna fit on the zipit.
- # I think it'd be better to build from the dingux or gcw-zero stella code.
- # So I tried to build openmsx instead.
- cd /openmsx-0.9.1
- ./compile
- # It complained about python.
- # So I ran python and discovered it wanted libutil.so.0.
- cp /share/gcc/lib/libutil.* /usr/local/lib
- ./compile
- # Warning! Do not interrupt this or you will have to start over from scratch.
- # The idiotic compile script does not resume from where it was interrupted.
- # And naturally it complained about librt after 2 hours of compiling...
- cp /share/gcc/lib/librt.* /usr/local/lib
- ./compile
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement