Skip to content

Instantly share code, notes, and snippets.

@juniorz
Last active December 3, 2020 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save juniorz/df4380ce852c799ea8f4 to your computer and use it in GitHub Desktop.
Save juniorz/df4380ce852c799ea8f4 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
@codingdave
Copy link

Hi @juniorz, I am on the journey to install debian buster on the WD MyCloud Ex2 to install openmediavault on that machine and reliably provide NFS and other services.
I am currently having some systemd failures left and thought I will have to compile a new kernel for that machine.
Looks you have some experience in this regard. Did you manage what I am trying to accomplish?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment