Author Topic: WDTV LIVE FW 1.01.17 Unpack-Pack-Flash success  (Read 14977 times)

January 28, 2010, 12:28:02 PM
Read 14977 times

godissexy

  • Newbie

  • Offline
  • *

  • 4
Hi there fellas !
I successfully unpacked, packed & flashed official 1.01.17 firmware using b33rm4t pibos instructions.
So, what i used:

patched cramfs-1.1
Code: [Select]
diff -urN cramfs-1.1.orig/cramfsck.c cramfs-1.1/cramfsck.c
--- cramfs-1.1.orig/cramfsck.c  2002-02-23 03:00:42.000000000 +0300
+++ cramfs-1.1/cramfsck.c       2010-01-28 09:11:16.000000000 +0300
@@ -65,7 +65,7 @@
 #define FSCK_LIBRARY     128   /* Shared library error */

 #define PAD_SIZE 512
-#define PAGE_CACHE_SIZE (4096)
+#define PAGE_CACHE_SIZE (4096 * 4)

 static const char *progname = "cramfsck";

@@ -85,7 +85,7 @@
 static unsigned long end_data = 0;     /* end of the data */

 /* Guarantee access to at least 8kB at a time */
-#define ROMBUFFER_BITS 13
+#define ROMBUFFER_BITS 14
 #define ROMBUFFERSIZE  (1 << ROMBUFFER_BITS)
 #define ROMBUFFERMASK  (ROMBUFFERSIZE-1)
 static char read_buffer[ROMBUFFERSIZE * 2];
diff -urN cramfs-1.1.orig/mkcramfs.c cramfs-1.1/mkcramfs.c
--- cramfs-1.1.orig/mkcramfs.c  2002-02-20 11:03:32.000000000 +0300
+++ cramfs-1.1/mkcramfs.c       2010-01-28 09:10:54.000000000 +0300
@@ -45,7 +45,7 @@
 #define PAD_SIZE 512

 /* The kernel assumes PAGE_CACHE_SIZE as block size. */
-#define PAGE_CACHE_SIZE (4096)
+#define PAGE_CACHE_SIZE (4096 * 4)

 /*
  * The longest filename component to allow for in the input directory tree.


Some handy script
Code: [Select]
#! /bin/sh
CRAMFS_TOOLS=/opt/wdtv/bin

do_unpack () {
rm -rf ./unpacked tmp.cramfs
dd if=wdtvlive.bin of=tmp.cramfs bs=32 skip=1
$CRAMFS_TOOLS/cramfsck -x unpacked tmp.cramfs
}

do_pack () {
rm wdtvlive.cramfs wdtvlive.md5 wdtvlive.new.bin
$CRAMFS_TOOLS/mkcramfs -v unpacked wdtvlive.cramfs
md5sum wdtvlive.cramfs | dd bs=32 count=1 > wdtvlive.md5
cat wdtvlive.md5 wdtvlive.cramfs > wdtvlive.new.bin
}

do_clean () {
rm -rf wdtvlive.cramfs wdtvlive.md5 wdtvlive.new.bin ./unpacked tmp.cramfs
}


case "$1" in
  pack)
        do_pack
        ;;
  unpack)
        do_unpack
        ;;
  clean)
        do_clean
        ;;
  *)
        echo "Usage: $0 [pack|unpack|clean]" >&2
        exit 3
        ;;
esac

:

So i flashed repacked wdtvlive.bin from flash drive, and it boot correctly.
Hope it helps.
« Last Edit: January 29, 2010, 01:40:35 AM by godissexy »

January 29, 2010, 01:06:02 AM
Reply #1

pibos

  • Full Member

  • Offline
  • ***

  • 235
Congrats, but your source of info is a bit wrong.
check here for the author
http://wdtvforum.com/main/index.php?topic=2922.0
Wanna help WDTVExt for WDTVLive and RemoteView?

January 29, 2010, 01:44:15 AM
Reply #2

godissexy

  • Newbie

  • Offline
  • *

  • 4
Oh, sorry man !
I was very tired, when wrote this post.
Thanks for info, all works like champ  ;D
Congrats, but your source of info is a bit wrong.
check here for the author
http://wdtvforum.com/main/index.php?topic=2922.0

January 29, 2010, 03:59:26 AM
Reply #3

lilibabe

  • Hero Member

  • Offline
  • *****

  • 1462
    • http://wdtv.free.fr/
Good to know ! I didn't want to be the 1st to try this... Thank you !  ;)
If you appreciate my work and want to contribute, feel free to donate at http://wdtv.free.fr/

January 29, 2010, 06:09:13 AM
Reply #4

cgmark

  • Full Member

  • Offline
  • ***

  • 107
Congrats.
Until we get a working jtag on the box I wouldn't advise others to start playing with the flash. Right now there is only two ways to recover without sending the box back to the manufacturer. Flash the chip on the board with external programmer, I will post a walk through on how to do that if anyone is interested. Remove the chip and flash it ( not advised unless you have a ton of experience with smd ) . Jtag , I'm still working on this one.

January 29, 2010, 06:21:26 AM
Reply #5

godissexy

  • Newbie

  • Offline
  • *

  • 4
Probably it should be possible to implement some kind of recovery loader, as done in FlashMe for Nintendo DS.
I tried to access jtag using old nokia cable as adapter. Console output is messy and garbled, but there's kernel & booting messages. Maybe, wrong cable or baudrate.

January 29, 2010, 06:36:23 AM
Reply #6

cgmark

  • Full Member

  • Offline
  • ***

  • 107
Probably it should be possible to implement some kind of recovery loader, as done in FlashMe for Nintendo DS.
I tried to access jtag using old nokia cable as adapter. Console output is messy and garbled, but there's kernel & booting messages. Maybe, wrong cable or baudrate.

They are using NAND for the flash, same stuff in usb sticks, to store the flash. It has a boot block but you cannot alter it in any way or the box will not boot. The Sigma chip has a hardware key inside that it expects the boot loader to match, if not, no boot :(

The port CN4 is not a jtag. That is a serial debug port,  it works fine if you have the wiring and baud set correctly. It will not give you access to anything though as input is disabled until after the kernel boots.


January 29, 2010, 06:45:52 AM
Reply #7

godissexy

  • Newbie

  • Offline
  • *

  • 4
Thanks for info, cgmark ! It will be cool to have some JTAG access & recovery howto  :)

January 30, 2010, 04:27:23 AM
Reply #8

lilibabe

  • Hero Member

  • Offline
  • *****

  • 1462
    • http://wdtv.free.fr/
Just a question godissexy, does the file 'wdtvlive.fff' still must be put on the usb stick with the new wdtvlive.bin created ?
If you appreciate my work and want to contribute, feel free to donate at http://wdtv.free.fr/

January 30, 2010, 04:55:58 AM
Reply #9

rezmus

  • Sr. Member

  • Offline
  • ****

  • 418
it;s kernel update, if u did it before by flashing original 1.01.17 u don't have to use it again.

January 30, 2010, 05:09:40 AM
Reply #10

lilibabe

  • Hero Member

  • Offline
  • *****

  • 1462
    • http://wdtv.free.fr/
it;s kernel update, if u did it before by flashing original 1.01.17 u don't have to use it again.

Tnahk you ! Actually I have the very fisrt firmware installed, so I have to put all the files for the update ?
If you appreciate my work and want to contribute, feel free to donate at http://wdtv.free.fr/

January 30, 2010, 05:12:49 AM
Reply #11

rezmus

  • Sr. Member

  • Offline
  • ****

  • 418
yep, if they update kernel with new fw u have to update it as well. it's needed once, then u can just flash modded .bin without kernel update.

anyway i strongly advice using ext3-boot style fw to load those .bin files as live is easier to brick then old wdtv and hard to recover.

January 30, 2010, 05:16:05 AM
Reply #12

lilibabe

  • Hero Member

  • Offline
  • *****

  • 1462
    • http://wdtv.free.fr/
yep, if they update kernel with new fw u have to update it as well. it's needed once, then u can just flash modded .bin without kernel update.

anyway i strongly advice using ext3-boot style fw to load those .bin files as live is easier to brick then old wdtv and hard to recover.

Thank you rezmus, I will try not to brick a WDTV a second time !  ;)
If you appreciate my work and want to contribute, feel free to donate at http://wdtv.free.fr/

February 06, 2010, 08:57:51 AM
Reply #13

lilibabe

  • Hero Member

  • Offline
  • *****

  • 1462
    • http://wdtv.free.fr/
I tried to repack the .bin file using these instructions and these one (http://wdtvforum.com/main/index.php?topic=2922.msg22806#msg22806) but it seems there's a problem ! The WDTV stops on the logo screen...

What's wrong ?!

I used the files provided by pibos (cramfsck/mkcramfs). Do these files are already modified according to the instructions above ?

On my usb stick, I put the files wdtvlive.bin, wdtvlive.ver (modified) and my Live is already version 1.01.17

Thank you for your help !

Edit : I think cramfsck is the good one but not mkcramfs (4096*4). So, I modified the file mkcramfs.c, then 'make -f GNUmakefile', but here is what I get :

gcc -W -Wall -O2 -g -I.   mkcramfs.c  -lz -o mkcramfs
mkcramfs.c:37:18: error: zlib.h: Aucun fichier ou dossier de ce type
mkcramfs.c: In function ‘parse_directory’:
mkcramfs.c:245: warning: passing argument 4 of ‘scandir’ from incompatible pointer type
/usr/include/dirent.h:252: note: expected ‘int (*)(const struct dirent **, const struct dirent **)’ but argument is of type ‘int (*)(const void *, const void *)’
mkcramfs.c:287: warning: pointer targets in assignment differ in signedness
mkcramfs.c: In function ‘write_superblock’:
mkcramfs.c:392: warning: implicit declaration of function ‘crc32’
mkcramfs.c:392: error: ‘Z_NULL’ undeclared (first use in this function)
mkcramfs.c:392: error: (Each undeclared identifier is reported only once
mkcramfs.c:392: error: for each function it appears in.)
mkcramfs.c:399: warning: pointer targets in passing argument 1 of ‘strncpy’ differ in signedness
/usr/include/bits/string3.h:119: note: expected ‘char * __restrict__’ but argument is of type ‘u8 *’
mkcramfs.c:401: warning: pointer targets in passing argument 1 of ‘strncpy’ differ in signedness
/usr/include/bits/string3.h:119: note: expected ‘char * __restrict__’ but argument is of type ‘u8 *’
mkcramfs.c: In function ‘write_directory_structure’:
mkcramfs.c:480: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness
/usr/include/string.h:397: note: expected ‘const char *’ but argument is of type ‘unsigned char *’
mkcramfs.c: In function ‘do_compress’:
mkcramfs.c:598: warning: implicit declaration of function ‘compress2’
mkcramfs.c:598: error: ‘Z_BEST_COMPRESSION’ undeclared (first use in this function)
mkcramfs.c:599: error: ‘Z_OK’ undeclared (first use in this function)
mkcramfs.c:600: warning: implicit declaration of function ‘zError’
mkcramfs.c: In function ‘write_data’:
mkcramfs.c:647: warning: pointer targets in passing argument 3 of ‘do_compress’ differ in signedness
mkcramfs.c:578: note: expected ‘const char *’ but argument is of type ‘unsigned char *’
mkcramfs.c: In function ‘main’:
mkcramfs.c:824: error: ‘Z_NULL’ undeclared (first use in this function)
make: *** [mkcramfs] Erreur 1


Please help me, I really I don't know anything about linux !  :-\
« Last Edit: February 06, 2010, 09:09:09 AM by lilibabe »
If you appreciate my work and want to contribute, feel free to donate at http://wdtv.free.fr/

February 07, 2010, 07:15:05 PM
Reply #14

thumper42

  • Newbie

  • Offline
  • *

  • 22
hey, lilibabe.

Did you see this post:  http://wdtvforum.com/main/index.php?topic=3594.0

Its possible your problem is related to the signature and not with compiling cramfs, i also had several warnings when i compiled, but the compiled files are good.

I used thecramfs source from pibos post:
 http://wdtvforum.com/main/index.php?topic=2922.msg22806#msg22806

I edited mkcramfs.c following b33rm4t post:
 http://wdtvforum.com/main/index.php?topic=2922.msg27200#msg27200


I repacked using info from the same post by b33rm4t, with one big exception!

The original firmware has the signature added before the md5sum is calculated and added!!


I don't understand the signature well enough to sign modified firmware. So i tested by simply unpacking and repacking the original firmware and copying the original firmware signature to the newly packed firmware before calculating and adding the new md5sum.

Using what b33rm4t posted and changing to account for signature, i repacked using...
Code: [Select]
mkcramfs rootfs wdtvlive.cramfs
tail --bytes=16 >> wdtvlive.cramfs
md5sum wdtvlive.cramfs | dd bs=32 count=1 > wdtvlive.md5
cat wdtvlive.md5 wdtvlive.cramfs > wdtvlive.bin.new


I tested this method with version 1.01.00, 1.01.11 and 1.01.17, And my repacked firmware was identical to the original firmware, md5sum and all!

I don't know if the signature is actually vital or if it's even related to your problem! But the original firmware is signed and if you account for the signature the instructions on repacking are accurate.