MX-760HD SimpleToolchain
From MvixCommunity
Installing the toolchain and compiling a simple "hello world" program (UNIX, MAC OS X)
Installation
The toolchain for the mvix is essentially the same as for the iPod (it's also an ARM unit). According to ipodlinux.org, to build binaries for the mvix (iPod) you will need a special version of the GNU toolchain, where the compiler is configured as a cross compiler. This is used to generate binaries on your development machine which are executable on another platform, in this case the mvix (iPod). Since it is an ARM based platform we need an ARM cross compiler. There are pre-built versions of the cross compiler available for Linux, OS X, and Windows (via Cygwin). If you need to customize the toolchain, you'll have to build it yourself. The pre-built version can be downloaded from http://ipodlinux.org/Toolchain. Make sure you download and install the three packages, otherwise there will be heaps of errors related to missing libraries. To install it, just follow the explanations on that page.
Unfortunately the uclibc included in the iPodLinux toolchain is built without large file support. Therefore all applications that need to handle files bigger than 2GB will not work. As this even effects basic file commands like mv, cp etc. that toolchain is not of too much use for the mvix.
A toolchain with large file support is supplied by the OpenEM86xx project. It can currently be downloaded via Bittorrent from http://www.mininova.org/tor/768296 or via HTTP from http://mvixcommunity.com/~jeruko/.
Invoking the compiler
Now, you're ready to use your arm compiler by invoking arm-elf-gcc. This denomination scheme applies also to the rest of the tools, i.e. there is arm-elf-ln, arm-elf-nm, and so on.
Simple "hello world" program
Let's try a simple C program like this
#include "stdio.h"
int main() {
printf("hello world\n");
}
and save it as hello.c. To compile, use arm-elf-gcc -elf2flt -o hello hello.c.
Linker flags
As indicated above, the only linker flag one has to specify is -elf2flt, which generates bflat executables that run on the mvix. Without this flag, the binaries are not working. To check that you have the correct type of binary, you can run
file hello, which should return
hello: BFLT executable - version 4 ram.
A script that sets all environment variables
To have the environment variables automatically set, you may use the following script:
#!/bin/sh export PATH=/opt/arm-uclinux-tools/bin:$PATH export CC=arm-uclinux-elf-gcc export CXX=arm-uclinux-elf-g++ export LDFLAGS=-elf2flt
Save it as arm-cross-compile-env.sh, than you can source into your current terminal session:
user@system:$ . arm-cross-compile-env.sh
Compressing executables
To reduce the size of the executable, the toolchains include an flthdr tool that can compress the executable.
Note that the arm-uclinux-elf-flthdr tool included in the iPodLinux toolchain does not work.
Either use the OpenEM86xx toolchain or download flthdr.c and flat.h from http://cvs.uclinux.org/cgi-bin/cvsweb.cgi/elf2flt/ and compile it using
gcc -o arm-uclinux-elf-flthdr flthdr.c
If you then use
arm-uclinux-elf-flthdr -z hello
the size of the executable will be reduced to around 60% of its original size and file hello will return
hello: BFLT executable - version 4 ram gzip.

