Building freenet for MIPS ------------------------- The freenet stuff is has some external deps for the CPU architecture, coming with the freenet-ext.jar file. To add MIPS support, I've used a MIPS box with an ecj and a gcc-libc6 compiler as well as a Kubuntu gutsy x86 laptop. Note, that my MIPS box is little endian (mipsel) I've fiddeled a while with ecj-3.2.1 on the MIPS box (debian etch), but the bdb database stuff requires java-1.5 which is obvioulsy buggy with that old ecj. So I've used a newer ecj-3.3.1 coming with ubuntu gutsy to compile java and a native MIPS compiler to make arch dep objs/libs We start on the ubuntu-gutsy laptop, since we need the resulting jar files for (cross) compiling on MIPS later. Kubuntu Laptop ============== (Install the java compiler) apt-get install java-gcj-compat-dev ant-optional junit subversion (We grab freenet sources - the orig svn repos is passwd protected) mkdir -p /usr/src/freenet-v1123 && cd /usr/src/freenet-v1123 svn co --ignore-externals http://freenet.googlecode.com/svn/trunk/freenet svn co --ignore-externals http://freenet.googlecode.com/svn/trunk/contrib svn co https://wrapper.svn.sourceforge.net/svnroot/wrapper/trunk/wrapper contrib/wrapper #svn co http://freenet.googlecode.com/svn/trunk/freenet/src/freenet/support/io/ contrib/NativeThread/java ln -sf ../../freenet/src/freenet/support/io contrib/NativeThread/java patch -p1 < ../001-freenet-v1123-gcjcompat.patch patch -p1 < ../002-freenet-v1123-mips.patch cd .. (Compile freenet jars) cd freenet-v1123/contrib/freenet_ext ant cd - cd freenet-v1123/freenet mkdir lib cp ../contrib/freenet_ext/freenet-ext.jar lib/ ant cd - (Transfer the result to the MIPS box) tar cvzf bla.tgz freenet-v1123 scp bla.tgz root@mood3-mesh:/usr/src rm bla.tgz MIPS Box ======== (We continue on the mips box, unpacking our sourc) cd /usr/src tar xvzf bla.tgz rm bla.tgz (Prevents /tmp from overflowing during ipkg install) mkdir /newtmp mount -t tmpfs none /newtmp cp -a /tmp/* /tmp/.* /newtmp rm /tmp ln -s /tmp /newtmp (Now install some softs. In case you wonder about coreutils, that's necessary to replace the busybox shell commands with debian variants) ipkg -force-overwrite install coreutils gcc libc6-dev g++ subversion gcj ecj-bootstrap java-gcj-compat-dev ant-optional junit (libstdc++6-4.1-dev does not install correctly, so we do this) cd /tmp/ wget ftp://192.168.65.69/upload/mood-300/feed/libstdc++6-4.1-dev_4.1.1-21_mipsel.deb ar x libstdc++6-4.1-dev_4.1.1-21_mipsel.deb tar tvzf data.tar.gz) (javac has too many links, because on the mood /usr is a link. Make shorter linkpath:) cp -a /etc/alternatives/ecj /etc/alternatives/javac (Make a MIPS fec*.so variant - already ref'd in fec/lib/native.properties) cd freenet-v1123/contrib/fec jar xvf fec-1.0.3.zip (cd fec-1.0.3 && ant) (cd fec-1.0.3/src/csrc && make) # check your system with 'gcc -dumpmachine' and copy to mips or mipsel # cp -a fec-1.0.3/lib/fec-linux-x86/lib/linux/x86 lib/linux/mips cp -a fec-1.0.3/lib/fec-linux-x86/lib/linux/x86 lib/linux/mipsel cd - (Compile the math stuff for MIPS) cd freenet-v1123/contrib/NativeBigInteger # check your system with 'gcc -dumpmachine' and copy to mips or mipsel # sh ./build.sh mips sh ./build.sh mipsel cd - (Compile the thread lib for MIPS) cd freenet-v1123/contrib/NativeThread/ mkdir -p freenet/support/io CLASSPATH=../../freenet/lib/freenet-cvs-snapshot.jar:../../freenet/lib/freenet-ext.jar make # check your system with 'gcc -dumpmachine' and copy to mips or mipsel # cp libNativeThread.so lib/freenet/support/io/libNativeThread-mips.so cp libNativeThread.so lib/freenet/support/io/libNativeThread-mipsel.so cd - (Compile the wrapper for MIPS) cd freenet-v1123/contrib/wrapper (Note: the MIPS javah version is incompat to MIPS ant, so you need to disable the jni h-file generation. Remove the ... markup in build.xml first. Manual start of javah is ok but not required) ant -Dbits=32 (Now revert the change in build.xml, the we strip outcome) # check your system with 'gcc -dumpmachine' and copy to mips or mipsel # strip bin/wrapper-mips-linux-gnu strip bin/wrapper-mipsel-linux-gnu cd - (Tranfer back to laptop) tar cvf bla.tar freenet-v1123 scp bla.tar sven-ola@104.198.65.69:/usr/src rm bla.tar Back to Ubuntu Laptop ===================== (Unpack from MIPS box) rm -rfv freenet-v1123 tar xvf bla.tar rm bla.tar (Grab a recent freenet tgz installer as a place to put compiler output) wget http://downloads.freenetproject.org/alpha/installer/freenet07.tar.gz tar xvzf freenet07.tar.gz patch -d freenet -p1 < freenet07-mips.patch (Recompile freenet-ext to add the *mips*.so files to freenet-ext.jar) cd freenet-v1123/contrib/freenet_ext ant jar tf freenet-ext.jar | grep \\.so | grep mips cd - (Copy the wrapper and jars to install dir. Note that the "run.sh" shell script currently does not differentiate between mips and mipsel...) # check your system with 'gcc -dumpmachine' and copy to mips or mipsel # cp freenet-v1123/contrib/wrapper/bin/wrapper-mipsel-linux-gnu freenet/bin/wrapper-linux-mips-32 # cp freenet-v1123/contrib/wrapper/lib/libwrapper-mipsel-linux-gnu.so freenet/lib/libwrapper-linux-mips-32.so cp freenet-v1123/contrib/wrapper/bin/wrapper-mipsel-linux-gnu freenet/bin/wrapper-linux-mipsel-32 cp freenet-v1123/contrib/wrapper/lib/libwrapper-mipsel-linux-gnu.so freenet/lib/libwrapper-linux-mipsel-32.so cp freenet-v1123/contrib/freenet_ext/freenet-ext.jar freenet cp freenet-v1123/freenet/lib/freenet-cvs-snapshot.jar freenet ln -s freenet-cvs-snapshot.jar freenet/freenet.jar (Write a freenet.ini file to prevent the 1run.sh to download things, transfer to MIPS box) echo End > freenet/freenet.ini tar cvzf freenet07-mipsel.tgz freenet scp freenet07-mipsel.tgz sven-ola@mood3-mesh:~ (Login to the MIPS box wile starting a tunnel, unpack and start with "./run.sh console") ssh -L 8883:localhost:8888 sven-ola@mood3-mesh (on laptop) browse to http://localhost:8883/ For the rest, you need to RTFM. Here's the output: sven-ola@pcacer:/srv/ftp/upload/freenet$ scp freenet07-mipsel.tgz sven-ola@mood3-mesh:~ sven-ola@mood3-mesh's password: freenet07-mipsel.tgz 100% 5145KB 643.1KB/s 00:08 sven-ola@pcacer:/srv/ftp/upload/freenet$ ssh -L 8883:localhost:8888 sven-ola@mood3-mesh sven-ola@mood3-mesh's password: Last login: Sun Mar 9 22:09:41 2008 from 104.198.65.109 sven-ola@MH03N648R5A00003157792:~$ tar xzf freenet07-mipsel.tgz sven-ola@MH03N648R5A00003157792:~$ cd freenet sven-ola@MH03N648R5A00003157792:~/freenet$ ./run.sh console Running Freenet 0.7... wrapper | --> Wrapper Started as Console wrapper | Java Service Wrapper Community Edition 3.3.0 wrapper | Copyright (C) 1999-2008 Tanuki Software, Inc. All Rights Reserved. wrapper | http://wrapper.tanukisoftware.org wrapper | wrapper | Launching a JVM... jvm 1 | WrapperManager: Initializing... jvm 1 | freenet.jar built with freenet-ext.jar Build #19 r@custom@ jvm 1 | jvm 1 | Created log files jvm 1 | Detected MIPS Little-endian CPU! jvm 1 | INFO: Optimized native BigInteger library 'net/i2p/util/libjbigi-linux-mipsel.so' loaded from resource jvm 1 | Attempting to load the NativeThread library [jar:file:freenet-ext.jar!/freenet/support/io/libNativeThread-mipsel.so] jvm 1 | Using the NativeThread implementation (base nice level is 12) jvm 1 | Initializing Node using Freenet Build #1121 r@custom@ and freenet-ext Build #19 r@custom@ with Free Software Foundation, Inc. JVM version 4.1.2 20061115 (prerelease) (Debian 4.1.1-20) running on mips Linux 2.4.30 jvm 1 | Starting FProxy on 127.0.0.1,0:0:0:0:0:0:0:1:8888 jvm 1 | FNP port created on 0.0.0.0:12751 jvm 1 | Testnet mode DISABLED. You may have some level of anonymity. :) jvm 1 | Note that this version of Freenet is still a very early alpha, and may well have numerous bugs and design flaws. jvm 1 | In particular: YOU ARE WIDE OPEN TO YOUR IMMEDIATE PEERS! They can eavesdrop on your requests with relatively little difficulty at present (correlation attacks etc). jvm 1 | Trying to read node file backup ... jvm 1 | Creating new cryptographic keys... jvm 1 | Creating PeerManager jvm 1 | Starting database... jvm 1 | Initializing CHK Datastore (15344 keys) jvm 1 | Opened main database for chk-store- jvm 1 | Opening access times database for chk-store- jvm 1 | Opened access times database for chk-store- jvm 1 | Opening block db index jvm 1 | Opened block number database for chk-store- jvm 1 | Keys in store: db 0 file 0 / max 15344 jvm 1 | Initializing CHK Datacache (15344:15344 keys) jvm 1 | Opened main database for chk-cache- jvm 1 | Opening access times database for chk-cache- jvm 1 | Opened access times database for chk-cache- jvm 1 | Opening block db index jvm 1 | Opened block number database for chk-cache- jvm 1 | Keys in store: db 0 file 0 / max 15344 jvm 1 | Initializing pubKey Datastore jvm 1 | Opened main database for pubkey-store- jvm 1 | Opening access times database for pubkey-store- jvm 1 | Opened access times database for pubkey-store- jvm 1 | Opening block db index jvm 1 | Opened block number database for pubkey-store- jvm 1 | Keys in store: db 0 file 0 / max 15344 jvm 1 | Initializing pubKey Datacache (15344 keys) jvm 1 | Opened main database for pubkey-cache- jvm 1 | Opening access times database for pubkey-cache- jvm 1 | Opened access times database for pubkey-cache- jvm 1 | Opening block db index jvm 1 | Opened block number database for pubkey-cache- jvm 1 | Keys in store: db 0 file 0 / max 15344 jvm 1 | Initializing SSK Datastore jvm 1 | Opened main database for ssk-store- jvm 1 | Opening access times database for ssk-store- jvm 1 | Opened access times database for ssk-store- jvm 1 | Opening block db index jvm 1 | Opened block number database for ssk-store- jvm 1 | Keys in store: db 0 file 0 / max 15344 jvm 1 | Initializing SSK Datacache (15344 keys) jvm 1 | Opened main database for ssk-cache- jvm 1 | Opening access times database for ssk-cache- jvm 1 | Opened access times database for ssk-cache- jvm 1 | Opening block db index jvm 1 | Opened block number database for ssk-cache- jvm 1 | Keys in store: db 0 file 0 / max 15344 jvm 1 | Deleted 0 of 0 temporary files (0 non-temp files in temp directory) in 0 jvm 1 | Initializing USK Manager jvm 1 | Initializing Plugin Manager jvm 1 | Node constructor completed jvm 1 | Starting DNSRequester jvm 1 | Starting PacketSender jvm 1 | Using wrapper correctly: freenet.node.NodeStarter@2d36c3d0 jvm 1 | Freenet 0.7 Build #1121 r@custom@ jvm 1 | FNP port is on 0.0.0.0:12751 jvm 1 | Starting FCP server on 127.0.0.1,0:0:0:0:0:0:0:1:9481. jvm 1 | Extra peer data reading and processing completed jvm 1 | Node initialization completed.