-
Notifications
You must be signed in to change notification settings - Fork 0
Getting started with MIPS Dartino
If you have already installed following packages skip this step:
$ sudo dpkg --add-architecture i386
$ sudo apt-get update
$ sudo apt-get install gcc-multilib
$ sudo apt-get install g++-multilib
$ sudo apt-get install lib32stdc++6
Confirm git is installed. git 2.2.1+ recommended.
Fetch depot tools
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
Add depot_tools to your PATH:
$ export PATH='pwd'/depot_tools:"$PATH"
If you have already built the qemu skip this step.
Install required packages:
$ sudo apt-get install git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev
Get the source:
$ git clone git://git.qemu-project.org/qemu.git
$ cd qemu
$ ./configure
$ make -j8
Suggest using Codescape SDK 2015.06-05.
$ wget http://codescape-mips-sdk.imgtec.com/components/toolchain/2015.06-05/Codescape.GNU.Tools.Package.2015.06-05.for.MIPS.MTI.Linux.CentOS-5.x86_64.tar.gz
Install the binfmt misc package on Ubuntu 14.04 with the following command:
$ sudo apt-get install binfmt-support
Write a script (mips32_qemu.sh) to run MIPS32 little endian binaries.Replace the qemu variable with the path to the mipsel-linux-user/qemu-mipsel previously built QEMU binary.
#!/bin/bash
qemu=/path/to/qemu/mipsel-linux-user/qemu-mipsel
exec $qemu $*
Change the access permissions of a script:
$ sudo chmod +x /path/to/mips32_qemu.sh
The script should be able to take a MIPS32 little endian binary and all it's options and run it under QEMU. A simple test is to cross compile "hello world" for MIPS32 little endian. Then, use your script to see that it correctly prints out "hello, world".
Setup binfmt misc to run your script when the kernel detects it's trying to run a MIPS32 little endian binary. Here is the command to setup binfmt for MIPS32 little endian using your MIPS32 little endian script:
$ sudo update-binfmts --install mipsel-qemu /path/to/mips32_qemu.sh --magic '\x7fELF\x01\x01\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08' --mask '\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' --credentials yes --package qemu-user-static
Build hello_world.c for MIPS:
$ /path/to/Codescape/SDK/2015.06-05/bin/mips-mti-linux-gnu-gcc -EL -static -o hello hello_world.c
If binfmt is configured correctly, you should be able to run this program:
$ ./hello
$ mkdir dartino
$ cd dartino
$ fetch dartino
$ cd sdk
$ git checkout c65dc26
$ export PATH=/path/to/Codescape/SDK/2015.06-05/bin/:$PATH
$ export LDSO_PATH=/path/to/Codescape/SDK/2015.06-05/sysroot/mipsel-r2-hard/lib/ld.so.1
$ export LD_R_PATH=/path/to/Codescape/SDK/2015.06-05/sysroot/mipsel-r2-hard/lib:/path/to/Codescape/SDK/2015.06-05/sysroot/mipsel-r2-hard/usr/lib:/path/to/Codescape/SDK/2015.06-05/mips-mti-linux-gnu/lib/mipsel-r2-hard/lib
$ ninja -t clean
$ ninja
$ ninja -C out/DebugXMIPS -t clean
$ ninja -C out/DebugXMIPS
$ tools/test.py --build-before-testing=0 --run-gclient-hooks=0 -axmips