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

Compile C code for Tomato

Discussion in 'Tomato Firmware' started by mss1988, Jun 26, 2013.

  1. mss1988

    mss1988 Serious Server Member

  2. lancethepants

    lancethepants Network Guru Member

    There's a few different ways you could go about this.

    1. Download the TomatoUSB git repo. Check out one of the dev's branches. (Probably could checkout 'tomato-shibby' since you're using his firmware). Grab the toolchain, and put the bin directory in your $PATH. Cross compile using mipsel-linux-gcc mipsel-linux-g++ etc.
    This will utilize the router's libraries already included in TomatoUSB, unless you compile it statically (see below).

    2. You could grab the entware toolchain too. I like to compile things statically with entware (like my curl binary), so throw in
    LDFLAGS="-Wl,-static -static -static-libgcc"
    to make it static and fairly portable. Also cross-compile using the mipsel-linux- prefix.
    (pre-compiled chain work on Ubuntu distros. If you're using Debian, you'll need to compile the toolchain from entware's compiling instructions, running 'make toolchain').

    3. If you like to compile on the router itself there is optware. Install the 'buildroot' and 'optware-devel' packages. Optware is a bit outdated, but should be good enough for your purposes. You'll have to have optware installed to run it, unless you make the binary static with the help of the LDFLAGS above.

    4. You could also try out my own home-grown native compiling solution called tomatoware.

    You can download the latest version at lancethepants.com/files.
    Extract opt.tgz in a clean directory of /opt. Tomatoware is a barebones router native compiling environment based on the entware toolchain (so newer than optware). You can also create static binaries using the LDFLAGS parameters.

    Let me know if you need more detailed instructions or help.
    diman82, RobbieW and mss1988 like this.
  3. MercuryV

    MercuryV Networkin' Nut Member

    FYI: "x86" toolchain was compiled on Debian and works fine on Debian 6+
    I'm 100% sure :)
    mss1988 likes this.
  4. lancethepants

    lancethepants Network Guru Member

    Ah, I've always used the x64 version. Thanks for that clarification.
    mss1988 likes this.
  5. mss1988

    mss1988 Serious Server Member

    I was asking today for cURL installation without optware. Reading both of my questions together can be a little confusing so let me explain the whole situation.

    I am ADSL user. Here in my country wires are in pretty bad condition, so my ISP often alter the bandwidth limit. There is a status page on my ADSL modem, where current bandwidth limits can be founded. Setting QoS in conditions like that is almost pointless. But since I am not the only user of my home internet (mother, father, sister, wife are users too), using internet without QoS is pain in the ass.
    So I needed to make a script that will update bandwidth limits dynamically. The script need to download the status page from the ADSL modem, parse it, and finally update the QoS.
    I have 2 Asus routers with Tomato installed (RT-N12 without optware, this is the main router, and RT-N10U with optware since it have an USB port, I use the second router as additional access point and in combination with USB HDD as NAS).
    I made the shell script that do:
    1. cURL download to RAM ADSL modem status page.
    2. The C program I wrote parses the page and check the download and upload limits.
    3. If the limits are different from the previous ones, the script sets new limits.
    The script is scheduled to run every 15 minutes, so now 99% of the time I have the right QoS limits.

    I found 3rd option for compiling the C code the simplest one. I only downloaded the "buildroot" package, and compiled my code on the RT-N10U router. I compiled it statically so I didn't have any problems running the program on my RT-N12 router.

    Thank you again very very much :)
    lancethepants likes this.
  6. lancethepants

    lancethepants Network Guru Member

    Clever QOS work around, glad you got it to work :)
    mss1988 likes this.
  7. RobbieW

    RobbieW Reformed Router Member

    Thanks for the tomatoware links and description - I've been using a little piece of code, kplex, that I'd cross compiled but with a couple of issues. Using tomatoware it compiles and runs straight out the box ... excellent.

    Had a problem setting it up to compile statically, to do with multiple definitions, but need to do some more testing before worrying about that.
  8. lancethepants

    lancethepants Network Guru Member

    Throw '-zmuldefs' in LDFLAGS, or LFLAGS in the case of kplex.

    edit: Using this little trick, I'm now able to compile static Transmission packages with entware toolchain.
    Last edited: Aug 19, 2013
  9. HunterZ

    HunterZ LI Guru Member

    Sorry for the necropost, but what is the difference between mipsel-linux-* and mipsel-linux-uclibc-*?

    Edit: Nevermind, looks like one symlinks to the other. The brcm toolset is symlink'd all over the place!
    lancethepants likes this.

Share This Page