#! /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?
$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=SYSTC750.DBK ".
                "of=SYSTC750.raw count=1024 skip=$skip seek=$seek \n";
        print $exec;
        system($exec);
        $skip= $skip+1024+33;
        $seek = $seek + 1024;
}
