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.
REQUIREMENTS:
-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)
PREPARATIONS:
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.
EXECUTION:
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
cd /tmp/usbmounts/
mount
mount -o rw,remount /tmp/usbmounts/sda1
mount
#turn swap on so your FAT+ have more memory to use when running out of RAM
free
swapon /dev/sda2
free
If you want to use deluge to download torrents, click here to continue.
#get a mipsel files system to chroot into
#Thanks to Consumer Electronics Hacker for generating the ext2 image.
cd sda1
wget http://fatplus.googlecode.com/files/mipsel-rootfs.
#unzip and untar
unzip mipsel-rootfs.tar.zip
tar tf mipsel-rootfs.tar
tar xvf mipsel-rootfs.tar
#mount proc so you can run commands like ps inside the chroot
mount
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
#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
#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)
mount
#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
cat /etc/resolv.conf
#moment of truth: chroot time!
chroot mipsel-rootfs
#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
ping google.com
#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
ping google.com
#Check on the compilers
cd /root/
which gcc
which c++
#Let's find a simple program to try and compile it
wget http://fatplus.googlecode.com/files/hello.c.tar
tar tf hello.c.tar
tar xvf hello.c.tar
#compilation time
gcc -o hello hello.c
#if there's no error during compilation let's try to run it
ls -al
./hello
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.
http://downloads.openwrt.org/sources/vncrepeater-0
http://alioth.debian.org/frs/download.php/3015/axe
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
exit
#Unmount the things we mounted earlier
mount
umount /tmp/usbmounts/sda1/mipsel-rootfs/dev/pts
umount /tmp/usbmounts/sda1/mipsel-rootfs/dev
umount /tmp/usbmounts/sda1/mipsel-rootfs/proc
mount
01-13-2010 12:30 AM
01-13-2010 12:30 AM - edited 01-13-2010 01:57 AM
01-16-2010 05:51 AM
Hi playdude,
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.
Best Regards
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?
BR.
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.
http://people.debian.org/~aurel32/qemu/mipsel/
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:
http://dev.deluge-torrent.org/wiki/Screenshots
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
cd /tmp/usbmounts/sda1/
#Get the file system. I extracted it from the mod wdtv live firmware (Thanks Brad!)
wget http://fatplus.googlecode.com/files/wdtvlive-rootf
#Stop the TV GUI to claim back memory. Don't worry, we can always turn it back on.
free
stopallfree
#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
mount -t proc none wdtvlive-rootfs/proc/
mount -t devfs none wdtvlive-rootfs/dev/
mount -t devpts none wdtvlive-rootfs/dev/pts/
mount
#Make a note of the DNS server so we can use in our chroot later
#Here's mine
# nameserver 192.168.0.1
cat /etc/resolv.conf
#Change the crazy date to something less crazy
date
rdate ntp.internode.on.net
#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
env
export TZ=CST-10:30:00
date
#Moment of truth: chroot into the wdtvlive root file system
chroot wdtvlive-rootfs
#Try a few basic commands inside the chroot.
#Hit q to stop top
free
ps
top
#Try to run deluged in the foreground (switch -d) first to watch for errors.
which deluged
/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!
top
#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
which deluge
/usr/bin/deluge --help
/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 &
top
#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
http://192.168.0.18:8112
#Hopefully you will see this logon screen
http://img233.imageshack.us/img233/5748/delugeweb0
#Connection Manager will appear
http://img233.imageshack.us/img233/2518/delugeweb0
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
# localclient:9b13c65615a049f61f699d34ecc55cf0b5a0ad
# root:debian
cat /root/.config/deluge/auth
To add a new entry, from the Connection Manager, click Add and and fill in these values
Host: 127.0.0.1
Port: 58846
Username: localclient
Password: 9b13c65615a049f61f699d34ecc55cf0b5a0ad0c
http://img407.imageshack.us/img407/4487/delugeweb0
You may want to add one for 192.168.0.18 too. Below are its details.
Host: 192.168.0.18
Port: 58846
Username: root
Password: debian
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.
http://img407.imageshack.us/img407/6955/delugeweb0
Click Connect and you're in!
http://img512.imageshack.us/img512/4613/delugeweb0
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:
http://download.deluge-torrent.org/windows/
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.
http://img511.imageshack.us/img511/9935/delugegtk0
Restart Windows deluge and Connection Manager will pop up. Does it look similar to the web interface?
http://img511.imageshack.us/img511/4010/delugegtk0
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
root:debian
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.
Hostname: 192.168.0.18
Username: root
Password: debian
http://img8.imageshack.us/img8/880/delugegtk03.jpg
Click Add. If you see a green light then it's a good sign.
http://img16.imageshack.us/img16/6712/delugegtk04.
Click Connect and you're in!
http://img145.imageshack.us/img145/4484/delugegtk0
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.
http://img228.imageshack.us/img228/9392/delugegtk0
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
exit
#Now we're in the FAT+ console
#Check if deluged and deluge web are running
ps
#To kill the web interface of deluge
killall deluge
#To kill deluged
killall 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 ![]()
©2012 Seagate Technology LLC