01-13-2010 12:27 AM - edited 01-19-2010 09:37 PM
Your Theater Plus, like other Realtek players, has a command called chroot built into its busybox. This allows it change its root to another directory as long as that directory contains a file system of the mipsel architecture. Once you're in a chrooted environment, all the things you run will be relative to that root.
This HOWTO will hopefully help you understand how chroot works so you can use it to do useful stuff like compiling your c/c++ programs, and then running them all on your player. You can also chroot into a fully fledged Linux operating system like Debian Lenny if you want to do more sophisticated things like package installation, package compilation.
-Mod firmware (version alpha8d or later)
-A USB hard drive
-An ext3 partition on the hard drive (at least 2GB)
-A swap partition (200MB in size)
You need to format your USB hard drive so that partition 1 is ext3 and partion 2 is wap. I won't go into details how to do this because I don't have a spare hard drive to do it. Use google if you don't know how to. You can also use your FAT+ to do partition and format the USB drive (Hint: fdisk, mkfs.ext3, mkswap) if you know what you're doing.
I'll assume you have formatted the first partition of your USB hard drive as ext3 and the second partition swap. I'll also assume your ext3 partition is mounted at /tmp/usbmounts/sda1. All ready? Here come the commands!
#make sda1 writable if it's read only
mount -o rw,remount /tmp/usbmounts/sda1
#turn swap on so your FAT+ have more memory to use when running out of RAM
#get a mipsel files system to chroot into
#Thanks to Consumer Electronics Hacker for generating the ext2 image.
#unzip and untar
tar tf mipsel-rootfs.tar
tar xvf mipsel-rootfs.tar
#mount proc so you can run commands like ps inside the chroot
mount -t proc none /tmp/usbmounts/sda1/mipsel-rootfs/proc
#you should see this entry
# none on /tmp/usbmounts/sda1/mipsel-rootfs/proc type proc (rw,nodiratime)
#mount dev so you can use dev devices inside the chroot
mount -t devfs none /tmp/usbmounts/sda1/mipsel-rootfs/dev
#there's a next entry in the mount list that looks like this
# none on /tmp/usbmounts/sda1/mipsel-rootfs/dev type devfs (rw)
#mount devpts in case you want to log into servers running inside the chroot
mount -t devpts none /tmp/usbmounts/sda1/mipsel-rootfs/dev/pts/
#and you should have this entry added
# none on /tmp/usbmounts/sda1/mipsel-rootfs/dev/pts type devpts (rw)
#make a note of your DNS server. We need this in /etc/resolv.conf in the chroot so we can ping by name.
#Mine has this in the file
# nameserver 192.168.0.1
#moment of truth: chroot time!
#if there's no complaint, you've chrooted successfully
#Try to ping google. Shouldn't work because there's no DNS server is set yet
#Set the DNS server. Mine (found out earlier) was nameserver 192.168.0.1
#so I used 192.168.0.1. You need to use your own number.
ls -al /etc/resolv.conf
echo "nameserver 192.168.0.1" > /etc/resolv.conf
#Now ping google again and it should work
#CTRL+C to stop it from running
#Check on the compilers
#Let's find a simple program to try and compile it
tar tf hello.c.tar
tar xvf hello.c.tar
gcc -o hello hello.c
#if there's no error during compilation let's try to run it
And it works (for me anyway). Hopefully it's the same for you. If it works, you can copy the hello binary to your FAT+ and execute it from there. I used this method to compile the UltraVNC repeater and download manager axel. You can download their sources here.
Now use your creativity to create your c/c++ programs so you can run them on your FAT+!
EXIT CHROOT CLEANLY:
Once you've finished working in your chroot, you can exit it.
#Get out of chroot like getting out of a normal terminal session
#Unmount the things we mounted earlier
01-13-2010 12:30 AM - edited 01-13-2010 01:57 AM
01-16-2010 05:51 AM
I just joined to this forum to thank you. I read all the explenations you wrote.
I am a new linux learner and trying to mod the firmware of my Egreat EG-R1 which also has a realtek 1073 chip. Firmware structure is nearly the same.
The info you provided is awesome and I managed to make some modifications by myself.
Thanks a lot for your patience and good work.
01-16-2010 05:57 AM
01-16-2010 06:16 AM
I'm sure many ppl benefit from your docs.
BTW, is it possible to use a mipsel linux image file on vmware for testing applications instead of chroot'ing? Or am I just dreaming?
01-17-2010 12:24 AM
You're not dreaming. It's possible but you have to take a few trips. If you insist on doing it in VMWARE, here's how to do it.
1. Install Debian Lenny under VMWare.
2. In Lenny, install QEMU.
3. Use QEMU to boot the Lenny mipsel image. You can download the Lenny mipsel image in the link below.
4. In the Lenny mipsel environment, chroot into the FAT+ development image as described in the HOWTO.
So in the end, you still have to chroot into it, but with this method you can comfortable do it using VMWare in Windows, everyone's comfort zone . I haven't tried it though, you can verify it yourself it you want.
01-19-2010 06:49 PM - edited 01-19-2010 09:31 PM
Deluge is a torrent client that is capable of doing sophisticated things. One of the favourite features I like about deluge is that it can queue torrents. Think of it as a meaner version of transmission that can do whatever utorrent can. If you want to see what it looks like, see this link:
So why am I telling you this? Because your FAT+ should be able to run deluge using our chroot trick. Here's how you do it.
#Assume your partition 1 is ext3 and mounted at /tmp/usbmounts/sda1/
#and your partition 2 is swap
#Get the file system. I extracted it from the mod wdtv live firmware (Thanks Brad!)
#Stop the TV GUI to claim back memory. Don't worry, we can always turn it back on.
#Unzip and untar in one go. If you have nothing else to do, enjoy watching flying text for a few minutes
unzip -p wdtvlive-rootfs.tar.zip | tar xvf -
#Check out new wdtvlive-rootfs. About 253MB I think.
ls -al wdtvlive-rootfs
du -h wdtvlive-rootfs
#Mount essential devices and check
mount -t proc none wdtvlive-rootfs/proc/
mount -t devfs none wdtvlive-rootfs/dev/
mount -t devpts none wdtvlive-rootfs/dev/pts/
#Make a note of the DNS server so we can use in our chroot later
# nameserver 192.168.0.1
#Change the crazy date to something less crazy
#Fix the timezone to match your local time
#Below is mine. It's CST and I'm 10 hours and 30 minutes ahead of GMT
#Moment of truth: chroot into the wdtvlive root file system
#Try a few basic commands inside the chroot.
#Hit q to stop top
#Try to run deluged in the foreground (switch -d) first to watch for errors.
/usr/bin/deluged --help/usr/bin/deluged -c /root/.config/deluge -d
#No errors? Hit CTR and C to stop it
#Now we can run it in the background
/usr/bin/deluged -c /root/.config/deluge
#See how much RAM and CPU deluged is using. Hit q to get out of top
#Yes, deluged is using 50% of RAM. I told you that swap partition was important!
#Now you have 2 options: access it from a GTK frontend, using its web interface
#Or you can just use both. It just means more RAM if you turn the web interface on
#Let's try to access it through the web interface first.
#Run the web interface in the foreground first
/usr/bin/deluge -u web
#No major error? Then let's run it in the background and test it and watch it with top. q to kill top.
/usr/bin/deluge -u web &
#The IP of my player is 192.168.0.18 so I access it using the http link below in Firefox.
#You have to use your IP number of course.
#The default password for the deluge web interface is deluge
#Hopefully you will see this logon screen
#Connection Manager will appear
For some reason Connection Manager says the status of 127.0.0.1 is Offline. If this happens to you to, you need to add a new entry for 127.0.0.1.
#In the console, check the auth file for deluge. Its contents are as below
To add a new entry, from the Connection Manager, click Add and and fill in these values
You may want to add one for 192.168.0.18 too. Below are its details.
Click the Close button and open Connection Manager for the new entry to appear. When it appears, the new entry should be Online. You may now delete the Offline entry.
Click Connect and you're in!
Click Logout when you're done.
So we can access it from the net. But what about connecting to it directly using a GTK interface. I've found that the easiest way to do this is installing the Windows version of deluge, which is a lot easier to set up than in Linux. Funny eh? Made for Linux but easier to install in Windows. Anyway, here's how to install it in Windows.
Have a look at the deluge Windows binaries here:
Download and install deluge-1.2.0_rc4-win32-setup.exe since it's the version we are using at the server end. By default, Windows deluge runs in Classic mode. We need to disable it by unticking option Classic Mode.
Restart Windows deluge and Connection Manager will pop up. Does it look similar to the web interface?
Since deluged is running in my player at IP address 192.168.0.18, I will add a Connection Manager entry for it. Remeber we had
in the auth file earlier. We need to use it. Below are the values for that entry. Change the host name to match the IP number of your player.
Click Add. If you see a green light then it's a good sign.
Click Connect and you're in!
Click Preferences and have a look at the settings. For optimum results, I set the maximum number of connections at 100 and the number of maximum connections for each torrent at 20. Also, check out Preferences > Queue. Total Active Downloading = 2 and Total Active Uploading = 1. This means at any given time, only 2 downloads and 1 active are running.
So if you have enough space, load about 30 torrents (I'm not kidding) and see how your player and deluged handle it.
And a few last things before I go.
#Since delugd and the web interface run in the background, they are still running after we exit chroot
#to get back to our FAT+ console
#Now we're in the FAT+ console
#Check if deluged and deluge web are running
#To kill the web interface of deluge
#To kill deluged
If you killed the TV GUI earlier with stopall, reboot your player to have it back.
03-06-2013 01:51 PM
This post from playdude is a gem for anybody who wants to compile, build extra module or tools on the FAT+/GFTV. I'm pumping it back so that we don't loose this valuable guide! Thanks playdude