Sign up here and you can log into the forum!

WDTVLive - Firmware unpacking / repacking

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

WDTVLive - Firmware unpacking / repacking   

Postby bovirus » Wed Nov 10, 2010 7:39 am

Hi.

I need your help.

I want to unpack WD officiale firmware 1.0.2.21 and 1.03.43.
After that I want replace in /os/mo directory it.po/it.mo file with my file because the original translation is quite bad.

I installed a Ubuntu 10.04 VMware image on my Windows.
I download the cramfs16k tools (cramfs-16k for unpack - mkcramfs-16k for packing)
I copied (as root) cramfs tool in /usr/bin folder

Unpack - which are exactly the command to strip the header from wtdvlibe.bin file? Are theese

dd if=wdtvlive.bin of=tmp.cramfs bs=32 skip=1
cramfsck-16k -x wdtvlive.bin rootfs

With theese command I extract all files in rootfs folder

in rootfs/osd/mo I replaced it.po/it.mo with my files.

Then I want to repack the firmware,. I used theese commands.

mkcramfs-16k -v rootfs1 wdtvlive.cramfs
md5sum wdtvlive.cramfs | dd bs=32 count=1 > wdtvlive.md5
cat wdtvlive.md5 wdtvlive.cramfs > wdtvlive.bin

I copied the new wdtvlive.bin file on USB key together with wdtvlive.ver (mod with higher version) and wdtvlive.ff of original firmware.

The WD TV Live recognize the new firmware and start the upgrade the process.
At the end of the upgrade WD TV Live reboot but start again the upgrade process and then.

If I remove the USB the WD TV Live didn't start and ask a fiirmware for recovery.

Probably the new wdtvlive.bin file is not right.

Could you help me?

Could you tell me which are exactly the step to unpack original firmware and repack it?

Any additional help will be usefull.

Thanks.
bovirus
Global Moderator
 
Posts: 94
Joined: Thu Apr 22, 2010 11:42 pm

Re: WDTVLive - Firmware unpacking / repacking   

Postby recliq » Wed Nov 10, 2010 10:14 am

­WDLXTV Project Maintainer
-:] If you like my contributions feel free to donate for a beer or a new flash drive. ...and always remember: RTFM! (README, FAQ, WIKI) [:-
User avatar
recliq
WDLXTV Team
 
Posts: 5356
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: WDTVLive - Firmware unpacking / repacking   

Postby avkiev » Wed Nov 10, 2010 10:23 am

bovirus wrote:Unpack - which are exactly the command to strip the header from wtdvlibe.bin file? Are theese

dd if=wdtvlive.bin of=tmp.cramfs bs=32 skip=1


Yes
But I do it more elegant - strip not only first 32 bytes, but and last 16 bytes:
dd if=wdtvlive.bin of=wdtvlive.tmp bs=16 skip=2 count="$(($(stat -c %s wdtvlive.bin)/16-3))"

bovirus wrote:
mkcramfs-16k -v rootfs1 wdtvlive.cramfs
md5sum wdtvlive.cramfs | dd bs=32 count=1 > wdtvlive.md5
cat wdtvlive.md5 wdtvlive.cramfs > wdtvlive.bin


Wrong. Your file doesn't have a signature
And, probably has wrong file /md5sum.txt
Before packing do smth like that:
cd rootfs1
cut -d" " -f3 md5sum.txt | xargs md5sum > md5sum.new
mv -v md5sum.new md5sum.txt
cd ..


bovirus wrote:Could you tell me which are exactly the step to unpack original firmware and repack it?

cramfs for Linux
avkiev
Developer
 
Posts: 155
Joined: Tue Apr 27, 2010 5:02 am
Location: Ukraine, Kiev

Re: WDTVLive - Firmware unpacking / repacking   

Postby bovirus » Wed Nov 10, 2010 11:32 am

@recliq
I had already tried but in the script teh cooamnd

signFW newFW.bin signature

I didn't find signFW command.

and also the script

#!/bin/sh
cram_missing () { echo -e "please make mkcramfs-16k and cramfsck-16k available to your PATH\ndownload it here http://forum.wdlxtv.com/viewtopic.php?f=43&t=537" && quit; }
usage () { echo "usage: $0 <pack|unpack> <firmware folder> <firmware>" && quit; }
quit () { rm -f $tmp && exit 1; }
tmp=`tempfile`
type -P cramfsck-16k &>/dev/null || cram_missing
type -P mkcramfs-16k &>/dev/null || cram_missing
[ "$1" == "" ] || [ "$2" == "" ] || [ "$3" == "" ] && usage
if [ $1 == "pack" ]; then
#pack
[ -e $3 ] && echo "firmware \"$3\" already exists" && quit
[ ! -d $2 ] && echo "firmware folder \"$3\" does not exist" && quit
echo "create md5sum.txt ..."
cwd=`pwd` && cd $2 && find -not -name "md5sum.txt" -type f -exec md5sum '{}' ';' > md5sum.txt && cd $cwd
echo "create cramfs image ..."
mkcramfs-16k $2 $tmp > /dev/null || quit
echo "sign image ..."
filesize=`printf %x \`stat -c %s $tmp\``
[ ${#filesize} -eq 7 ] && filesize="0$filesize"
sig=""
for i in 6 4 2 0 ; do
sig="$sig\x${filesize:$i:2}"
done
sig="$sig\x00\x00\x00\x00"
echo -en "\xCE\xFA\xBE\xBA\x02\x00\x00\x00" >> $tmp
echo -en $sig | head -c 8 >> $tmp
md5sum $tmp | head -c 32 > $3
cat $tmp >> $3
echo "$3 created"
elif [ $1 == "unpack" ]; then
#unpack
[ -e $2 ] && echo "firmware folder \"$2\" already exists" && quit
echo "stripping firmware ... "
dd if=$3 skip=2 count=`expr \`stat -c %s $3\` / 16 - 3` ibs=16 obs=4096 of=$tmp &> /dev/null
echo "unpack cramfs image ... "
cramfsck-16k -x $2 $tmp > /dev/null || quit
echo "unpacked to $2"
else
echo usage
fi
quit

create some errors (on ubuntu 10.04)

@avkiev
I will try tomorrow.
Thanks.
bovirus
Global Moderator
 
Posts: 94
Joined: Thu Apr 22, 2010 11:42 pm

Re: WDTVLive - Firmware unpacking / repacking   

Postby bovirus » Thu Nov 11, 2010 3:44 am

Thanks.

The unpack procedure with the new commands

dd if=wdtvlive.bin of=wdtvlive.tmp bs=16 skip=2 count="$(($(stat -c %s wdtvlive.bin)/16-3))"
cramfsck-16k -xrootfs wdtvlive.tmp

workfs fine. Two problems about packing procedure.

The command

cut -d" " -f3 md5sum.txt | xargs md5sum > md5sum.new

say that singol " are not in paired. The " has a special meaning for xarg except using -0 option

When I ran

mkcramfs-16k -v rootfs1 wdtvlive.cramfs

I obatined a warning message

warning: gid truncated to 8 bit (this may be a security reason).

Is it OK? Thanks.
bovirus
Global Moderator
 
Posts: 94
Joined: Thu Apr 22, 2010 11:42 pm

Re: WDTVLive - Firmware unpacking / repacking   

Postby avkiev » Thu Nov 11, 2010 4:04 am

bovirus wrote:The command

cut -d" " -f3 md5sum.txt | xargs md5sum > md5sum.new

say that singol " are not in paired. The " has a special meaning for xarg except using -0 option

I don't know... You can just clear file /md5sum.txt to avoiding endless rebooting

bovirus wrote:
warning: gid truncated to 8 bit (this may be a security reason).

Is it OK? Thanks.

Yes, it is normal, just a warning. Ignore it
avkiev
Developer
 
Posts: 155
Joined: Tue Apr 27, 2010 5:02 am
Location: Ukraine, Kiev

Re: WDTVLive - Firmware unpacking / repacking   

Postby bovirus » Thu Nov 11, 2010 4:59 am

Most of time the problem is regarding the translation files.
Probably the best and efficient solution is to remove all references from md5sum text file about xx.po/xx.mo fiel (language files)

In this way it's possible to upgrade language files, repack the firmware without problems about continuous reboot and firmware upgrade.

I will upgrade the first post with your sugegstion and a warning about MD5sum file.

Thanks.
bovirus
Global Moderator
 
Posts: 94
Joined: Thu Apr 22, 2010 11:42 pm

Re: WDTVLive - Firmware unpacking / repacking   

Postby b-rad.cc » Thu Nov 11, 2010 7:45 am

none of those files are md5'd in wdlxtv.
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: 3002
Joined: Sat Apr 03, 2010 9:35 am
Location: New York

Re: WDTVLive - Firmware unpacking / repacking   

Postby bovirus » Thu Nov 11, 2010 8:05 am

I know.

We are talking about "original" 1.02.21 / 1.03.43 WDTVLive firmware.

Thanks.
bovirus
Global Moderator
 
Posts: 94
Joined: Thu Apr 22, 2010 11:42 pm

Re: WDTVLive - Firmware unpacking / repacking   

Postby bovirus » Sun Nov 14, 2010 1:40 am

@avkiew
Is it possiblle to divide the command dd for striping initial and final header in two different commands without use if calation?
I think about cramfs-16k for Windows.

The command

dd if=wdtvlive.bin of=wdtvlive.tmp bs=16 skip=2 count="$(($(stat -c %s wdtvlive.bin)/16-3))"

didn't work in cramfs-16 for Windows.
bovirus
Global Moderator
 
Posts: 94
Joined: Thu Apr 22, 2010 11:42 pm

Next

Return to WDTV Live

Who is online

Users browsing this forum: No registered users and 1 guest