PhotoBridge home at frequal.comfrequal.com

Fast PhotoBridge Builds with Distcc

Summary

While the PhotoBridge SDK installs easily on a CompactFlash card, the 300 MHz processor takes a long time to compile all but the smallest files.

Distcc offers an elegant solution. After installing a cross-compiler on a fast computer on the same network, you can use distcc to send the compilation work to that server from the PhotoBridge. However, since preprocessing still takes place on the PhotoBridge, there is no need to copy the SDK files onto the server. This solution really provides the best of both worlds -- easy installation of the SDK as provided by Roku, and fast compilation on a server instead of the slow PhotoBridge processor.

Requirements

You should have:
  • Roku PhotoBridge HD with the SDK installed
  • At least one fast server
  • A network connecting the two

Procedure

Step 1: Install the Cross-Compiler on the Server

On the server, install a gcc cross-compiler that targets the MIPS instruction set used on the PhotoBridge. I found one created by Jon Lech Johansen that comes in an RPM called rokutools-20020423-1.src.rpm. Installation is a two-step process described here. In short, as root:
  • rpmbuild --rebuild rokutools-20040423-1.src.rpm
  • cd /usr/src/redhat/RPMS/i386
  • rpm -ivh --nodeps rokutools-20020423-1.i386.rpm rokutools-mipsel-20020423-1.i386.rpm
Also, setup a gcc symlink in the folder where the cross-compiler is installed:
  • cd /usr/tools/roku/bin
  • ln -s mipsel-linux-gcc gcc

Step 2: Install Distcc on the Server

Download distcc and compile it. On my server it compiled cleanly using the usual steps:
  • ./configure
  • make

Step 3: Install Distcc on the PhotoBridge

Take the same version of distcc that you installed on the server and place it in a folder accessible to the PhotoBridge. The same steps as above should be performed, but with some extra steps.
  • ./configure --with-included-popt
  • Change config.h to say #define HAVE_WAITPID 1 (Should not be necessary)
  • Remove strndup from hosts.c (Should not be necessary)
  • Comment out this section of backoff.c:
        if (difftime(time(NULL), mtime) < (double) dcc_backoff_period) {
            rs_trace("still in backoff period for %s", host->hostdef_string);
            return EXIT_BUSY;
        }
      
  • make

Step 4: Start Distccd on the Server

First, add the cross-compiler directory (/usr/tools/roku/bin) to the front of the path. Then launch the server, allowing lots of simultaneous builds and allowing connections from the local network.
distccd --jobs 8 --allow 10.1.1.1/8

Step 5: Setup "volunteer" list on the PhotoBridge and Build

On the PhotoBridge, setup the DISTCC_HOSTS environment variable to include the server address. Add "/2" or "/3" if the server can handle 2 or three simultaneous builds.

Then, when you run make, tell make to do parallel builds and use distcc:

make -j4 CC="distcc gcc" CPP="distcc gcc" CXX="distcc gcc"
All .c and .cpp files should now be built on your fast server. Enjoy your vastly shortened build times!

Last modified on 23 Nov 2006 by AO

Copyright © 2016 Andrew Oliver