Skip to content

Instantly share code, notes, and snippets.

@codingdave
Forked from juniorz/instructions.md
Created December 3, 2020 14:25
Show Gist options
  • Save codingdave/8c5bbd86b5e8d5603ac2061a0e759c68 to your computer and use it in GitHub Desktop.
Save codingdave/8c5bbd86b5e8d5603ac2061a0e759c68 to your computer and use it in GitHub Desktop.
Building tor on WD My Cloud EX2

How to build tor for WD My Cloud EX2

WD My Cloud EX2 has an Marvell Armada-370 CPU (Marvell PJ4Bv7 Processor rev 1 (v7l)) with 512MB RAM.

This device uses 32-bit binaries with 64K page size. WD releases a cross-compilation environment as part of its "WD My Cloud EX2 GPL Source Code". Download it from WD support page (making sure it matches your firmware version) and follow the instructions in My_Cloud_EX2_Release_Notes_GPL_*.txt to setup the environment. I recommend using a Debian OS.

The following packages are required to use the cross-compilation environment: build-essential automake lib32z1

Building dependencies

Create missing directories

$ cd Open_Source_packages
$ source source.me
$ mkdir -p ../_xinstall/${PROJECT_NAME}/include ../_xinstall/${PROJECT_NAME}/lib

zlib

$ cd Open_Source_packages
$ source source.me
$ tar -xzvf zlib-1.2.3.tar.gz
$ cd zlib-1.2.3
$ ./xbuild.sh build
$ ./xbuild.sh install

libevent

$ cd Open_Source_packages
$ source source.me
$ tar -xzvf libevent-2.0.19-stable.tar.gz
$ cd libevent-2.0.19-stable
$ ./xbuild.sh build
$ ./xbuild.sh install
# can we use Open_Source_packages/libevent-2.0.19-stable/include instead?
$ make prefix=${PWD}/xinst install
$ mkdir -p ${XINC_DIR}/ && cp -rvf xinst/include/* ${XINC_DIR}/

openssl

$ cd Open_Source_packages
$ source source.me
$ tar -xzvf openssl-1.0.1m.tar.gz
$ cd openssl-1.0.1m
$ ./xbuild.sh build
$ ./xbuild.sh install

Building tor

$ cd Open_Source_packages
$ source source.me
$ curl https://dist.torproject.org/tor-0.2.7.6.tar.gz | tar -xzv
$ cd tor-0.2.7.6
$ curl https://gist.githubusercontent.com/juniorz/df4380ce852c799ea8f4/raw/xbuild.sh -O
$ chmod +x ./xbuild.sh
$ ./xbuild.sh build

Now copy src/or/tor to your device.

## Troubleshooting

If you see source: not found errors whle running ./xbuild.sh, edit the file and change the shebang to #!/bin/bash.

#!/bin/bash
unset CFLAGS
unset LDFLAGS
unset LIBS
source ../xcp.sh
TMPINST=$(readlink -f $PWD/../_xinstall/${PROJECT_NAME})
xbuild()
{
if [ ! -e ${XLIB_DIR}/libz.so ]; then
echo "We need the zlib library to complete build."
exit 1
fi
if [ ! -e ${XLIB_DIR}/libevent.so ]; then
echo "We need the libevent library to complete build."
exit 1
fi
if [ ! -e ${XLIB_DIR}/libssl.so.1.0.0 ]; then
echo "We need the openssl library to complete build."
exit 1
fi
CFLAGS="-I${XINC_DIR}" \
LDFLAGS="-L${XLIB_DIR} -L${TMPINST}/lib -lz" \
./configure --host=arm-linux || exit 1
make
}
xinstall()
{
make install
}
xclean()
{
make clean
make distclean
}
if [ "$1" = "build" ]; then
xbuild
elif [ "$1" = "install" ]; then
xinstall
elif [ "$1" = "clean" ]; then
xclean
else
echo "Usage: xbuild.sh {build|install|clean}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment