Mount everything, Homebrew with sshfs.

This first Homebrew is a Proof of concept for mounting any filesytem network,
even through the internet.

It is not possible to add functionalities to the proprietary WDTV software interface.
The sources of this software are not distributed by Western. Nevertheless, the whole environment around the interface software is open source. We will therefore modify the scripts called by the OSD. When you select the “Local Server” and “NFS” functions,
the OSD uses the /bin/find_nfs_server.sh, then /bin/find_nfs_share_folder.sh scripts.
Modifying these scripts to return other information than the NFS servers, will allow us
to add new servers and protocols / filesystems to the OSD interface. Once all the parameters are recovered by the OSD, everything is sent to the mount command.

Now let me introduce Busybox. Busybox is a toolkit containing many Linux programs. This is a quick and effective way to get a working system. Busybox can be used in two ways: By calling the command wanted behind Busybox, or by creating a symbolic link.
The mount command is a symbolic link to the BusyBox binary.
By replacing the symbolic link mount by a script, it is possible to intercept the parameters passed by the OSD to the mount command, manipulate or override these settings, and finally call the busybox mount command with the modified settings.

This Homebrew integrates all the binaries needed to run sshfs. You don’t need to recompile all the binaries and libraries. The processor architecture is the same as the other WDTV versions, so you can re-use all binaries that do not use a specific hardware.

The /bin/find_nfs_server.sh and /bin/find_nfs_share_folder.sh scripts have been modified to read the file /conf/server and add the resulting contents to the OSD.

The symbolic link mount has been replaced to run sshfs if the server name is given in the /conf/server file. If this is not the case, the busybox mount command is called seamlessly.
Authentification is based on a rsa_id key and must be placed in /conf.
The /etc/ssh/ssh_config file automatically adds new servers in the /conf/known_hosts without prompting.

Files added to the Homebrew from the compilation 1.05.14_G base are available here. There is no need to recompile all sources : just add files in the PALACE_1.05.14_G/build/root folder then the execute the make firmware command to rebuild the firmware.

The complete firmware including sshfs and phpShell is available here.

If something goes wrong, the /tmp/mount file includes the sshfs command executed by the mount script. You can try to execute the command manually.

Warning: Changing the mount command is very dangerous. If it does not work,
your WDTV will be bricked.
Test your mount script by creating a clone of the /bin folder on a USB key. Then mount this file instead of the original /bin folder using
the mount -o bind /media/USB/nameofyourkey/bin /bin command.

By using these scripts as an operating model, you can adapt them to mount any local or network file system on any IP, yet controlled by the OSD interface.

Thanks go to Elrick for the mount script tip.

Easy shell : PHPShell

The first thing to do to when you want to start developing on the WDTV
is to connect to the shell.

Using telnet or ssh requires a fresh new compiling of Busybox and activating
many options. A much faster way is to use the integrated PHP server to add a web shell. This solution is not perfect but does not require compiling code. The base functions allow you to run most of commands. The only limitation is with commands requesting
a confirmation. The shell input must then be done using the JTAG …

PhpShell is very quick to install. Download and unzip the archive phpShell-2.4.zip in the ~ / wdtvgen3/PALACE_1_05_18_G/build/root/webserver/htdocs/ (see the post First compiled GLP code)

rename the folder phpShell-2.4 to phpShell

Edit config.php to add your login / password
[users]
admin = "wdtvgen3"

Restart the command make firmware

Flash your WDTV Live. You can now connect to the shell with the address http://ip_of_wdtv/phpshell/phpshell.php

First compiled GPL code !

This article is obselete. See the post Compiling Homebrew 1.08.17 on Ubuntu 12.04

Warning : Flashing the WDTV Live Streaming (Gen3) will void its warranty and the online streaming service functionality will not be available anymore !
!!! Do it at your own risks, I WILL NOT be taken responsible for any damage caused to your device (such as brick) !!!

Why using GPL code ?
GPL code allows to add functionnality to your WDTV box (I will add SSHFS support in a next article)

What you need ?
- A Physical or Virtual PC running Ubuntu version 8.04 or newer in 32 bits (64 bits returns an error during compiling)
- At least 6 Gb free space on your hard disk drive.
- The source from Western Digital : WDTV_LiveStreaming_GPL_Code_package_1.05.18.zip and the toolchain for cross-compiling GPL_toolchain_of_WDTV.zip
- Some A lot of time (more than 6 hours on my P4 2,4 GHz !)

Processing :
- Create a directory on your home directory and transfer your download in
mkdir wdtvgen3
cd wdtvgen3
wget http://download.wdc.com/gpl/GPL_toolchain_of_WDTV.zip
wget http://download.wdc.com/gpl/WDTV_LiveStreaming_GPL_Code_package_1.05.18.zip

- Uncompress and configure toolchain for cross-compiling
unzip GPL_toolchain_of_WDTV.zip
tar xzfv GPL_toolchain_of_WDTV/toolchain_binary/mips-4.3.tgz
sudo mv mips-4.3 /opt

- Uncrompress and configure WDTV GPL source code
unzip WDTV_LiveStreaming_GPL_Code_package_1.05.18.zip
tar xzfv PALACE_1.05.18_G.tgz
echo "export DIRECTFB_I=~/wdtvgen3/PALACE_1.05.18_G/src/libs/qt-everywhere-opensource-src/directfb" >> ~/.profile

- Exit and relog for loading environment variables, and verify
echo $DIRECTFB_I

- Edit and patch the code (Western left a trap in their code :-) )
Open PALACE_1.05.18_G/src/libs/Makefile and comment (add a # at the beginning of the line) the line 168 "#LIBS_LIST_y += libsigcpp boost libtorrent-rasterbar mdnsresponder (generates errors during compiling and i don’t want bittorrent)

cd PALACE_1.05.18_G
make distclean
make

- Go to sleep …
make install
make firmware

- Open the wdtvlivegen3.ver file and increase the version number VERSION=’1.05.18_G’ to VERSION=’2.05.18_G’ (this is useful only if you reflash a previous GPL firmware)

- Copy all files in the Palace_launch_1006 folder at the root of an USB key formatted in FAT32 (this is useful only if you flash from official firmware)

- Flash your WDTV Live Streaming, wait for the GPL Warning and remove the USB key.

- Copy the 3 wdtvlivegen3 files in PALACE_1.05.18_G/build at the root of your USB key.

- Flash your WDTV Live Streaming !

> You now have a GPL firmware !