 |
The Zaurus Message Board Zaurus forum and FAQ.
|
| View previous topic :: View next topic |
| Author |
Message |
StuBear
Joined: 04 Aug 2003 Posts: 137 Location: Osaka, JAPAN
|
Posted: Sun Feb 08, 2004 4:00 pm Post subject: Extracting files from NAND backup |
|
|
For reasons of stupidity, I overwrote my latest NAND backup with one that wont boot - I deleted the /sbin/ dir by mistake
The thing is the non-booting NAND contains backups of files I'd really like to get back.
I can mount ROM images and extract files from them, but when I tried
this with a NAND it wouldn't work, I assume that the NAND file contains
several images, but I don't know how to extract them from the NAND.
Anyone ?? |
|
| Back to top |
|
 |
tz
Joined: 30 Jul 2003 Posts: 123
|
Posted: Tue Feb 10, 2004 4:25 pm Post subject: |
|
|
On a linux machine with JFFS, you might be able to use the loopback device.
You can add an offset so you can say something like "losetup -o
4096 SYSC760.DBK /dev/loop0", then something like "mount -t jffs2
/dev/loop0 /mnt/image -o ro".
The DBK files aren't perfect backups. Also, you may be able to boot
into the updater (modified update.sh) where you could reinstall the
contents of /sbin from somewhere else like a CF or SD card.
I have a kernel that does something similar - it boots into single user
mode where I can just type exit to proceed, or otherwise access things
to fix them. |
|
| Back to top |
|
 |
StuBear
Joined: 04 Aug 2003 Posts: 137 Location: Osaka, JAPAN
|
Posted: Tue Feb 10, 2004 5:35 pm Post subject: |
|
|
Thanks for the sugggestion, but unfortunately it isn't quite as simple as that
Here is what I have learnt so far.
To mount jffs2 images you need to use mtdram and mtdblock on linux
| Code: | modprobe mtdram total_size=131072
modprobe mtdblock
dd if=<jffs2.image> of=/dev/mtdblock/0
mount -t jffs2 /dev/mtdblock/0 /mnt/flash |
However it looks like the NAND file contains at least 2 (possible 3 or
more) partitions. There are 3 mtd devices on the C760 - SMF, HOME, and
ROOT. They however make up 128Mb in space on the Z, but the NAND is
over 10Mb larger.
When I try to mount the whole image I can see a number of
directories, but acessing many of then gives an "illegal i/o" error and
on several ocassions has crashed my linux desktop
The image I have won't boot as init (and possibly other important files
are missing) instead I get a kernel panic - so I can't get in that way.
More info as it comes to hand |
|
| Back to top |
|
 |
iain_benson
Joined: 10 Apr 2004 Posts: 6
|
Posted: Fri Aug 06, 2004 1:48 pm Post subject: |
|
|
| I was just wondering if you got anywhere with this ....... |
|
| Back to top |
|
 |
StuBear
Joined: 04 Aug 2003 Posts: 137 Location: Osaka, JAPAN
|
Posted: Sat Aug 07, 2004 6:32 am Post subject: |
|
|
| iain_benson wrote: | | I was just wondering if you got anywhere with this ....... |
Actually, I did.
Solved the problem in 2 ways, I found a script that extracted the
rom from a 64Mb NAND and adapted it for the larger NAND on the Cx60.
Was able to mount the extracted rom and get some but not all of the
files I wanted.
After this nominal success, I found that there is a key combo to
boot into single use mode (D+B) so I was able to rescue the original
NAND by copying the files back to /sbin
There is a thread on this forum about the D+B dingle boot - it's
probably your best bet unless you are trying to extract stuff from a
NAND not designed for your hardware (SL6000 etc). If you want the
script let me know and I'll post it
Stu _________________ SL-C760, Sharp Qtopia Rom (hand converted)
Dual booting Cacko and pdaX 1.20 from SD |
|
| Back to top |
|
 |
iain_benson
Joined: 10 Apr 2004 Posts: 6
|
Posted: Sat Aug 07, 2004 7:25 am Post subject: |
|
|
| A copy of the script would be appreciated ... the reason I was was asking was for purposes of 'playing' with a NAND backup file. |
|
| Back to top |
|
 |
StuBear
Joined: 04 Aug 2003 Posts: 137 Location: Osaka, JAPAN
|
Posted: Sat Aug 07, 2004 8:35 pm Post subject: |
|
|
Here you go
| Code: | ! /usr/bin/perl
# i have a 64mbyte flash (Toshiba TH58512FT
# Manufacture ID: 0x98, Chip ID: 0x76)
# filesize of nand_dump is then:
# 528*4096 +(64*1024*1024) + 16
# ^^^ why 16? then the last page-data must be
# special? only 512 long?
# c760/c860 have bigger NAND images
$filesize=138543120/16;
# i use 16 byte big block.. make the dd faster than with 1 byte blocks
# and the script is still easy
# extract plain flash image
$skip=2;
$seek=0;
for ($i=0;$i<$filesize;$i=$skip) {
$exec= "dd bs=16 obs=16 ibs=16 if=SYSTC760.DBK ".
"of=SYSTC760.raw count=1024 skip=$skip seek=$seek n";
print $exec;
system($exec);
$skip= $skip+1024+33;
$seek = $seek + 1024;
} |
I didn't write this code, just changed the numbers to work with the
larger NAND. Can't find who the original poster was, the site wher I
got it has since gone away
Stu _________________ SL-C760, Sharp Qtopia Rom (hand converted)
Dual booting Cacko and pdaX 1.20 from SD |
|
| Back to top |
|
 |
iain_benson
Joined: 10 Apr 2004 Posts: 6
|
Posted: Sun Aug 08, 2004 10:34 am Post subject: |
|
|
Thanks
for that StuBear, I had a quick play, and soon realied that the file
produced has all three partitions (boot+service/root/home)
concatenated, so using the info from the script (ie 32bytes junk at the
start and 528bytes of junk every 16k) I adapted it to generate 4 files,
one for each partition and on with all the guff. This should allow an
image to be rebuilt, though it may not work if there are checksums in
the padding between the 16K blocks.
I've attached my updated script below, it should be easily
configurable for any Cxxx zaurus, assuming you know the sizes of the
partitions.
| Code: |
#! /usr/bin/perl
# 32bytes at start is junk
# 528bytes are added to data every 16K
# 3 partitions - 7Mb - boot and service/cfg menus
# 53Mb - root
# 68Mb - home
# ---
# 128Mb
# 4224Kb padding
# 32byte leader
# ---------
# 138543136bytes
# -16bytes missing on file end???
# 138543120
# **** CHANGE THESE FOR YOUR ZAURUS
# Partition Sizes in MB
$scfsize=7;
$rootsize=53;
$homesize=68;
# Set up file names
$basename="SYSTC860";
# **** DON'T CHANGE BELOW HERE
# Set up transfer sizes
$blocksize=16;
$blockcount=1024;
# Set up the padding sizes
$leader=32/$blocksize;
$padding=528/$blocksize;
# Set up partition sizes
$part1size=( 7*1024*1024)/$blocksize;
$part2size=(53*1024*1024)/$blocksize;
$part3size=(68*1024*1024)/$blocksize;
# Initialise to start of the file
$skip=0;
$padfileseek=0;
# Extract the intial padding
$exec= "dd bs=$blocksize if=$basename.DBK ".
"of=$basename-PAD.RAW count=$leader skip=$skip seek=$padfileseek 2>/dev/null\n";
system($exec);
# Move the file pointers on
$skip = $skip + $leader;
$padfileseek = $padfileseek + $leader;
# Extract the three partitions
extractPartition( $part1size, "P1" );
extractPartition( $part2size, "P2" );
extractPartition( $part3size, "P3" );
# Routine to extract a partition.
# Param 0 : Number of blocks in partition's true size
# Param 1 : Partition name
sub extractPartition
{
print "Extracting $_[1] ... ";
# Initialise the output file pointer
$seek=0;
# While we haven't read the whole partiton
while ($seek < $_[0])
{
# Extract the data chunk chunk
$exec= "dd bs=$blocksize if=$basename.DBK ".
"of=$basename-$_[1].RAW count=$blockcount skip=$skip seek=$seek 2>/dev/null\n";
system($exec);
# Move the file pointers on
$seek = $seek + $blockcount;
$skip = $skip + $blockcount;
# Extract the padding
$exec= "dd bs=$blocksize if=$basename.DBK ".
"of=$basename-PAD.RAW count=$padding skip=$skip seek=$padfileseek 2>/dev/null\n";
system($exec);
# Move the file pointers on
$skip = $skip + $padding;
$padfileseek = $padfileseek + $padding;
}
print "Done\n";
}
|
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB 2.0.4 © 2001, 2002 phpBB Group
|