1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to compile apps for Tomato?

Discussion in 'Tomato Firmware' started by bimmerm3m5, Jul 18, 2009.

  1. bimmerm3m5

    bimmerm3m5 Network Guru Member

    Bear with me, I'm a noob to compiling but I've done a little searching and can't seem to find any info about compiling applications for the Tomato firmware.

    Specifically, I want to compile these 2 apps and get them running:

    http://thomer.com/howtos/nstx.html
    http://thomer.com/icmptx/

    I don't think I need to compile a firmware with these apps included, because I would imagine they could be created just like srelay.

    Thanks.
     
  2. bogderpirat

    bogderpirat Network Guru Member

    nstx' source doesn't appear to be downloadable from anywhere - every download link seems to be a 404.

    in the case of icmptx, you'd have to download linksys' firmware for the WRT54GL which includes a crosscompiler for mipsel under ./tools/brcm/hndtools-mipsel-<uclibc|linux>/bin.
    you'd have to set your path to include either of these directories.
    afterwards, you could just go into the directory containing icmptx' source and edit the Makefile, replacing occurrences of "gcc" by "mipsel-linux-gcc", or "mipsel-uclibc-gcc".
    the last step should consist of a simple "make" which should produce a binary that works if you transfer it to your tomato.
    i compiled igmpproxy v0.1-b4 in a similar manner.
     
  3. bimmerm3m5

    bimmerm3m5 Network Guru Member

    You lost me...am I to find this cross compiler somewhere on the official linksys ftp? Are there multiple versions of the cross compiler? I have a v2 WRT54G...
     
  4. bogderpirat

    bogderpirat Network Guru Member

  5. Assman

    Assman Addicted to LI Member

    bimmerm3m5, when you brick your router can I have it? :biggrin:
     
  6. bimmerm3m5

    bimmerm3m5 Network Guru Member

    Sure Assman....but I have a JTAG connection built in now, so I can supposedly recover from quite a mess.
     
  7. bimmerm3m5

    bimmerm3m5 Network Guru Member

    Well, Assman is out of luck. I got the compiler working, but now I'm a bit lost with compiling certain apps, such as iodine ( http://code.kryo.se/iodine/ ). I assume i need to change the first line:

    CC = gcc
    COMMONOBJS = tun.o dns.o read.o encoding.o login.o base32.o base64.o md5.o common.o
    CLIENTOBJS = iodine.o
    CLIENT = ../bin/iodine
    SERVEROBJS = iodined.o user.o fw_query.o
    SERVER = ../bin/iodined

    OS = `echo $(TARGETOS) | tr "a-z" "A-Z"`
    ARCH = `uname -m`

    LIBPATH = -L.
    LDFLAGS = -lz `sh osflags $(TARGETOS) link` $(LIBPATH)
    CFLAGS = -c -g -Wall -D$(OS) -pedantic `sh osflags $(TARGETOS) cflags`

    all: stateos $(CLIENT) $(SERVER)

    stateos:
    @echo OS is $(OS), arch is $(ARCH)

    $(CLIENT): $(COMMONOBJS) $(CLIENTOBJS)
    @echo LD $@
    @mkdir -p ../bin
    @$(CC) $(COMMONOBJS) $(CLIENTOBJS) -o $(CLIENT) $(LDFLAGS)

    $(SERVER): $(COMMONOBJS) $(SERVEROBJS)
    @echo LD $@
    @mkdir -p ../bin
    @$(CC) $(COMMONOBJS) $(SERVEROBJS) -o $(SERVER) $(LDFLAGS)

    .c.o:
    @echo CC $<
    @$(CC) $(CFLAGS) $< -o $@

    clean:
    @echo "Cleaning src/"
    @rm -f $(CLIENT){,.exe} $(SERVER){,.exe} *~ *.o *.core
     
  8. fyellin

    fyellin LI Guru Member

    Assuming you've already downloaded the appropriate toolset:

    /opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
     
  9. bimmerm3m5

    bimmerm3m5 Network Guru Member

    I did, installed it....is there any way I can know if it is setup properly?
     
  10. fyellin

    fyellin LI Guru Member

    I wrote myself a little hello world, and then
    ...../mipsel-uclibc-gcc test.c -o test
    I copied the file "test" onto /tmp/test on the router, then ran /tmp/test on the router.

    It printed out "hello world."

    You're going to then want to compile and link bigger programs and copy them over.

    -
     
  11. mstombs

    mstombs Network Guru Member

  12. rhester72

    rhester72 Network Guru Member

    Bear in mind that all three mentioned apps (nstx, icmptx and iodine) all require the kernel to be compiled with tun support, which (stock) Tomato's is not. This would be a better target for one of the OpenVPN-supporting builds (which must have tun by default).

    In short, these are non-trivial at best and will never work as "drop-ins" for official Tomato.

    Rodney
     
  13. ceckin

    ceckin LI Guru Member

    Yeah better download the source from one of the other mods and import NSTX etc., this way you'll be able to add GUI for them.
     

Share This Page