Sign up here and you can log into the forum!

Compiling on the WDTV ?

Have a question about devices internals, memory layout, reverse engineering, etc---This is the place for anything so technical that it would cause a n00b's head to 'splode

Re: Compiling on the WDTV ?   

Postby b-rad.cc » Sun May 16, 2010 7:38 pm

Here is a Debian squeeze filesystem image:

http://rapidshare.com/files/388207119/debian-squeeze.img.tgz


Here is a script to chroot into it, which also cleans up when you exit. Copy it somewhere to your system, and then execute it with the arguments it asks for:
Code: Select all
#!/bin/sh

if [ ! -f "$1" -o -z "$2" ] ; then
   echo 'Proper usage is:'
   echo '     runSqueeze /path/to/debian-squeeze.img /desired/location'
   exit 1
fi

[ ! -d "$2" ] && mkdir -p "$2"
busybox mount -o loop "$1" "$2"

busybox mount -t proc none "$2/proc"
busybox mount -t sysfs sysfs "$2/sys"
busybox mount -t usbfs usb "$2/proc/bus/usb"
busybox mount -t tmpfs none "$2/tmp"

cp /etc/resolv.conf "$2/etc"
cp /etc/hosts "$2/etc"
ln -s /proc/mounts "$2/etc/mtab"

echo 'Type exit to quit, and help for help'
echo '    run makeDevs to populate /dev and /dev/pts'
chroot "$2"
echo 'cleaning up...'
umount "$2/tmp" "$2/proc/bus/usb" "$2/dev/pts" "$2/dev" "$2/sys" "$2/proc" "$2" 2>/dev/null


don't forget to chmod a+x it ;)


Now how to use it?

This is a vanilla Debian system, which comes with nothing included. Once you are inside of it you use apt-get to install whatever you want. Look up any standard tutorial on compiling in Debian and you'll see the base packages you need. Probably something like this should get you started:
Code: Select all
apt-get update
apt-get install build-essential automake autoconf aclocal libtool


For anything you want to compile, just apt-get install the dev package of any dependent libraries and you're good to go.

TIP: enable NTP so your network connection is brought up, then rm /tmp/init.d/S70dmoasd from S00user-script or S00custom-options. This gives you an extra 70MB+ memory to help in compilation. ;)

The filesystem image is only 800MB, which you might chew through quickly. In that case refer to this tutorial on increasing its size:

http://b-rad.cc/170/wdtv-optware-tips-resizing-optbin/
PM's are for private matters only, please post public matters on the forum to help others who might have the same issue.
:mrgreen:
User avatar
b-rad.cc
WDLXTV Team
 
Posts: 3003
Joined: Sat Apr 03, 2010 9:35 am
Location: New York

Re: Compiling on the WDTV ?   

Postby sailort » Tue May 18, 2010 4:02 am

BRILLIANT!!!
Was about to PM you with ask for this, but you are one step ahead as usual :D
THANKS!!!
T.
If you like my work and want to buy me a bottle of wine, you can do it this way. Thanks for your support.
sailort
Developer
 
Posts: 365
Joined: Sat Apr 24, 2010 6:42 am

Re: Compiling on the WDTV ?   

Postby player_sct » Thu May 20, 2010 1:00 pm

one mistake :)

Code: Select all
apt-get install build-essential automake autoconf libtool
User avatar
player_sct
Beta Tester
 
Posts: 90
Joined: Sun Apr 11, 2010 6:29 am
Location: Poland

Re: Compiling on the WDTV ?   

Postby thespecialist » Thu May 20, 2010 4:26 pm

Ok, tried to get this going but this Linux n00b is having some trouble :) What I did:

extract that img to my usb drive, together with that script, named it 1.sh. Then inserted that stick in the WDTV, and via telnet typed:
bash 1.sh

However it doesnt work, it says something about an unexpected end ..
thespecialist
Developer
 
Posts: 410
Joined: Sat Apr 24, 2010 6:59 am

Re: Compiling on the WDTV ?   

Postby thespecialist » Thu May 20, 2010 4:27 pm

bash 1.sh
: command not found
1.sh: line 25: syntax error: unexpected end of file
#
thespecialist
Developer
 
Posts: 410
Joined: Sat Apr 24, 2010 6:59 am

Re: Compiling on the WDTV ?   

Postby cabe2001 » Thu May 20, 2010 5:13 pm

try copy/paste the script in nano, notepad and other windows text editor insert CR/LF chars, unix text editor don't. (sorry my english)
cabe2001
Donor
 
Posts: 46
Joined: Mon Apr 12, 2010 7:45 am
Location: Buenos Aires, Argentina.

Re: Compiling on the WDTV ?   

Postby b-rad.cc » Thu May 20, 2010 5:44 pm

Code: Select all
chmod a+x 1.sh
./1.sh debian-squeeze.img /tmp/squeeze
PM's are for private matters only, please post public matters on the forum to help others who might have the same issue.
:mrgreen:
User avatar
b-rad.cc
WDLXTV Team
 
Posts: 3003
Joined: Sat Apr 03, 2010 9:35 am
Location: New York

Re: Compiling on the WDTV ?   

Postby thespecialist » Thu May 20, 2010 7:19 pm

cabe2001 wrote:try copy/paste the script in nano, notepad and other windows text editor insert CR/LF chars, unix text editor don't. (sorry my english)

Yup, this indeed solved it. Saved the script in Linux this time (so it has now unix style CR/LF) and it worked, thanks guys.
thespecialist
Developer
 
Posts: 410
Joined: Sat Apr 24, 2010 6:59 am

Re: Compiling on the WDTV ?   

Postby thespecialist » Thu May 20, 2010 7:45 pm

Hehe, this is kinda cool. Ok, so I issued those 2 apt-get commands, which worked. Now, I have a directory with source code, how do I get that onto this 'new' system ? I can't access the 'old' one ('the 'real' WDTV filesystem), can I ? If I ftp to the wdtv, I'm of course not inside this 'new' system. I tried to mount the usb drive but I guess that's not possible either ?
thespecialist
Developer
 
Posts: 410
Joined: Sat Apr 24, 2010 6:59 am

Re: Compiling on the WDTV ?   

Postby b-rad.cc » Thu May 20, 2010 8:08 pm

You'll need some Linux experience, which will come to you as you play ;)

Say your squeeze is at /tmp/squeeze and you're 'stuck' there in shell #1.

Start up shell #2 (telnet/ssh) and do ls /tmp/squeeze. That is the root of that filesystem. Now you just have to prepend /tmp/squeeze to anything you see in shell #1 to run and test whatever. Just be warned that libraries might not exist in the fw that are required for you run them. ldd will tell you what libs are dependent and what you're missing, if anything. If you're not missing any libs then you can run from inside the fw itself and not in squeeze. If you're missing libs then you'll need to either add an extra path to /etc/ld.so.cache and rescan with ldconfig -C /tmp/ld.so.cache, or copy the missing libs to /usr/lib. You might get conflicts just adding an extra path to /etc/ld.so.cache because the fw uses glibc-2.8 while squeeze uses glibc-2.10.

If you're wanting to use gdb or any system tools though, then theres no need really to leave the squeeze environment because /proc is mounted from the fw and therefore you have access to all pids from inside squeeze to attach to.

Is this clear enough? If you need to know anything else just say. :ugeek:
PM's are for private matters only, please post public matters on the forum to help others who might have the same issue.
:mrgreen:
User avatar
b-rad.cc
WDLXTV Team
 
Posts: 3003
Joined: Sat Apr 03, 2010 9:35 am
Location: New York

Next

Return to WDTV Live

Who is online

Users browsing this forum: No registered users and 1 guest