Creating a cross-compilation toolchain from Cygwin (a.k.a. i686-pc-cygwin) to a
mipsel-linux platform such as the BR6104K/KP is fairly time consuming. Three
separate methods were tried--making the toolchain from scratch with
gcc/binutils/gdb, using crosstool, and using buildroot--and it turns out the
easiest is using buildroot. A great instruction set for building the toolchain
is available
here. To the
steps listed there, add the following recommendations:
- Use a daily snapshot of uClibc: chances are it's going to work
better.
- If running midge, don't build any of the rootfs
tools; all that's needed is the toolchain. This will significantly
cut compile time.
- Under Cygwin, directories can get messy since Windows
deals poorly with whitespace in paths; be sure to do the build
in a simple directory (i.e. /tmp) rather than one which will cause
problems (i.e. anything under Documents and Settings, as $HOME
probably is).
- A strange compilation error happen with a bad definition of
the _uint32 type occurred once. It got fixed by
changing the name of the offending file slightly, and the build
completed successfully. The filename was changed back afterward and
everything still worked.
Once compilation is done the complete toolchain to work with is available
at $PREFIX/buildroot/build_mipsel/staging_dir/bin, as is a set of mipsel
libraries to link to at $PREFIX/buildroot/build_mipsel/staging_dir/lib. Those
libraries come in handy when building software for the router, as you can just
transfer them to /lib and make an appropriate link (i.e. /lib/libpthread.so.0
-> /lib/libpthread-0.9.28.so).
With this working toolchain, it's fairly easy to compile and run custom
applications on the router. The easiest way found to move files to the router
and test them was with a fairly simple set of scripts that took advantage of
wget. This required an HTTP server (FTP would work just as well),
and an FTP client which supports file input (as lftp does).
On the host side, one line like
lftp -f ftp_commands
should be added to the Makefile, where ftp_commands is a file containing all the
commands necessary to upload your newly compiled program to your FTP/HTTP
server. It probably looks something like this:
open server.com
user username password
cd remote_directory_to_put_file_in
put name_of_compiled_program
quit
On the router, meanwhile, it's trivial to create a script to get files from
the server using wget, change their permissions, and execute them. For example:
#!/bin/sh
wget http://1.2.3.45/edimax_software/$1
chmod a+x $1
./$1
Then, compiling and running stuff on the router takes only two commands instead
of twenty. Just 'make' on the host, and on the router run
$ ./retrieval-script newly-compiled-program
and everything should work fine.