First a little history...
On the original WDTV and other similar devices before it kernel page size was a standard 4KB. 4KB is used as kernel page size in most modern systems, and therefore standard cramfs tools worked just fine with the firmware images. This all changed however when Sigma released their 2.0 SDK, which changed the kernel page size to 16KB...only thing is they didn't publish this little factoid due to their extreme security policies. Now when the WDTV Live came out it used the 2.0 SDK...and when I got my hands on a device when it hit the market I instantly hit a roadblock trying to port over wdlxtv-live. Well luckily I don't give up very easily so I got to reverse engineering. It was really a mystery at first, because while cramfs images mounted and were read fine on the device itself--those same images were invalid off the device. Was their some sort of encryption at play here? I couldn't see how their could be, unless it applied specifically to cramfs as all other filesystem images mounted correctly on the device. So what did I do? I spent pretty much the next 100hours, straight, mapping out the cramfs file structure by hand. Talk about the hard way. What did I find? Well cramfs is a sort've dictionary based filesystem, you have all the filenames listed at the start of the filesystem and each one has an address and an offset. The address is basically the block number and the offset is where the filecontents start. Note: completely laymanizing the description.
- Code: Select all
cat /proc/meminfo | grep Mapped
cat /proc/vmstat | grep nr_map
Divide the two and you get ~16KB page size, which coincidentally
Ok, I'll shut up now--just figured I might as well finally make public exactly how I figured it all out
firmware structure is as follows:
- Code: Select all
[32 Byte md5sum][fw cramfs image][16 Byte signature]
the 32 Byte md5sum is the last part of the firmware generated. The signature details you can find here.
Heres the run down:
You have a wdtvlive.bin (WDTV Live) or wdtvhd.bin (WDTV G2) in front of you.
- Code: Select all
tail -c +33 wdtvlive.bin > wdtvlive.stripped.bin
cramfsck-16k -x dump wdtvlive.stripped.bin
There, simple as that.
Now in the opposite direction.
- Code: Select all
mkcramfs-16k dump/ newFW.bin
signFW newFW.bin signature
cat newFW.bin signature > newFWx.bin
md5sum newFWx.bin | head -c 32 > wdtvlive.bin
cat newFWx.bin >> wdtvlive.bin
rm newFW.bin newFWx.bin
Voila, ez pz lemon cheezie.
Now if you're rebuilding a firmware and have modified files do not forget to update the modified files md5sums in /md5sum.txt.
Attached are the binaries & source files modified to 16k block size. Compile the source on your own to produce binaries or use the actual 32bit binaries I use, its your choice.



Android app-> 

