There is some scattered information available on cross-compiling applications, but so far I have failed to find a very coherent source with a clear explanation. I know the information must be staring me right in the face, from various aggregated sources, but a follow-up on compiling the firmware itself on this subject would be a nice addition for those of us who have some requirements for non-mainstream patches, applications, etc.
It's so trivial you'll kick yourself for not seeing it. ;-)
Not too hard once you can successfully build Tomato itself.
Put the app in the Tomato directory tree under "src/router/", then cd to src where you ordinarily make tomato.
Then type "make -C router/whatever"
'course, it's a lot harder if the app doesn't come with a makefile but wants to create one dynamically.
This didn't work at all - the compile of TomatoUSB went fine according to the tutorial, and so did the mjpg-streamer after according to this instruction, done in same terminal directly after.
Problem is it was compiled for the running arch, not cross-compiled?
Would somebody be so kind as to make a tutorial for noobs?
example I have wmvare with ubuntu linux and a want to cross compile mjpegstream for my mips r1 router.
I'll be happy if somebody made a step by step tutorial how should I start from a default ubuntu to can make mjpegstream for my mips r1 router.
I had some success. After following the tutorial:
and doing the teddybear reset on the ~/tomato directory the tut has you create
git clean -fdxq && git reset —hard
I was able to compile the source.
Next step was to be able to compile mongoose (mini http server)
Download from http://code.google.com/p/mongoose/ and put it in the ~/tomato/release/src-rt/router directory
ran make and it compiled but of course used the wrong compiler
so added the following to the beginning of the mongoose Makefile (found in mongoose dir)
now this will change the compiler etc as needed
since I was using src-rt the file tomato_profile.mak was not in the src dir so copied it over to src dir
make linux (linux version of mongoose) worked
copied it to my router for testing
Yay it seemed to work, it would serve up a web page on 192.168.1.1:8080!
as soon as i tried to use a cgi script it failed with setbuf not found
fairly confident that this is because TCONFIG_OPTIMIZE_SHARED_LIBS=y in the config
which causes unused symbols to be removed, so the symbol for setbuf is removed from the standard tomato image
So the answer seems to be to recompile an image without the symbols being optimized out.
Sounds simple right, just tweak something and recompile. But since I don't know how the f*** this
build system works I cannot for the life of me get it to compile an image without it resetting my
config hacks and optimizing those d*mn symbols out again
Theory is that once the symbols are back, the mongoose I compiled will work on it since all the symbols are there.
Any help on configuring the make to change this optimize param would be greatly appreciated.
For those that are interested I went and read the wikipedia entry on Makefile and learned enough to decipher that the following would and did work:
make V1=9054 V2=ZZ NO_LIBOPT=y NO_CIFS=y r2s | tee logzz
specifically the NO_LIBOPT option was available inside the Makefile found in release/src-rt/ so no need to hack anything
Pretty cool, can run /bin/sh based cgi scripts with mongoose now and the binary for it is only 76K which still leaves me room to add some simple web pages to be served up on a 4MB Asus rt-n12. Think I can compile features out of mongoose to get it smaller (found a 40K version on a DD-WRT forum) but I love the simplicity and functionality of it. If you do use mongoose and are new like me to CGI scripts, URI variables are found within $QUERY_STRING inside your shell script. All that said, note that you can also place scripts inside /www/ext/cgi-bin accessed by 192.168.1/ext/cgi-bin/scriptname but I haven't figured out how or if you can pass form data to the cgi script ($QUERY_STRING doesn't work in this case).
Compiled mongoose with your procedures. Notice 2 files created mongoose and _mongoose.so
Copy to tomato router, temporarily, test in data partition, "/mnt/harddisk/mongoose". Run mongoose, result as follow:
Tomato v1.28.9055 MIPSR1-beta-git-20110502 K26 USB vpn3.6
root@BTRouter2:/tmp/home/root# cd /mnt/harddisk/mongoose
mongoose: line 1: syntax error: unexpected "("
Maybe wrong router location. Tell me where to put those 2 files for testing.
Did you verify that you can compile a full up image before you built mongoose? Did you change the mongoose makefile so that it includes ../common.mak?
If you did the above, I'm not sure that I can help but I'll try. I haven't seen an error like this. When did you see this error? Immediately after launch or was it after you opened a web page to 192.168.1.1:8080? Or was it after you tried to navigate to a cgi script? Looks like mongoose is trying to parse a file and it is getting messed up. Either that or perhaps you modified the mongoose code before you compiled it? Maybe it got corrupted during transfer from your build environment to your router?
Usage should be very simple. Put the following two files in the same directory as mongoose for testing. Do not put a mongoose.conf file in the directory. Do not put _mongoose.so in the directory (you do not need it at all).
<HEAD><TITLE>Testing 123 </TITLE></HEAD>
<BODY bgcolor="#cccccc" text="#000000">
Enable <input type="checkbox" name="enable"><BR>
Password <input name=password><BR>
<INPUT TYPE=SUBMIT value="save">
… test.cgi (don't forget to chmod 755)
echo Content-type: text/plain
#above blank line echo "" is important, do not delete it
echo "you entered: <$QUERY_STRING>"
On the command line:
root@xyz:/jffs# chmod 755 test.cgi
index.html mongoose* test.cgi*
root@xyz:/jffs# ./mongoose &
In a web browser browse to http://192.168.1.1:8080
Note that $QUERY_STRING needs to be parsed, google for more info.
If you want your mongoose pages accessible from the WAN port then in tomato browser config:
192.168.1.1 -> admin/scripts/firewall
iptables -t filter -A INPUT -p tcp —dport 8080 -j ACCEPT
If you then want to password protect these pages then on command line:
root@xyz:/jffs# ./mongoose -A ./.htpasswd mydomain.com user1 password1
leave mydomain.com (mongoose default), change user1 password1 to whatever
If you want to store mongoose & your web html/cgi files in the 200+K available on /jffs on your $30 Asus rt-n12 4MB router, and want mongoose started up on every router boot then again in tomato browser config:
192.168.1.1 -> admin/jffs
execute when mounted: /jffs/mongoose -S "html" &
(-S "html" — allows SSI include/exec for html files not just shtml files)