diff options
Diffstat (limited to 'packages/zaurus-updater')
-rw-r--r-- | packages/zaurus-updater/.mtn2git_empty | 0 | ||||
-rw-r--r-- | packages/zaurus-updater/akita/.mtn2git_empty | 0 | ||||
-rw-r--r-- | packages/zaurus-updater/c7x0/.mtn2git_empty | 0 | ||||
-rw-r--r-- | packages/zaurus-updater/c7x0/updater.sh | 241 | ||||
-rw-r--r-- | packages/zaurus-updater/encdec-updater-native.bb | 6 | ||||
-rw-r--r-- | packages/zaurus-updater/files/.mtn2git_empty | 0 | ||||
-rw-r--r-- | packages/zaurus-updater/files/encdec-updater.c | 80 | ||||
-rw-r--r-- | packages/zaurus-updater/poodle/.mtn2git_empty | 0 | ||||
-rw-r--r-- | packages/zaurus-updater/spitz/.mtn2git_empty | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | packages/zaurus-updater/spitz/updater.sh | 260 | ||||
-rw-r--r-- | packages/zaurus-updater/tosa/.mtn2git_empty | 0 | ||||
-rw-r--r-- | packages/zaurus-updater/tosa/updater.sh | 241 |
12 files changed, 828 insertions, 0 deletions
diff --git a/packages/zaurus-updater/.mtn2git_empty b/packages/zaurus-updater/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/zaurus-updater/.mtn2git_empty diff --git a/packages/zaurus-updater/akita/.mtn2git_empty b/packages/zaurus-updater/akita/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/zaurus-updater/akita/.mtn2git_empty diff --git a/packages/zaurus-updater/c7x0/.mtn2git_empty b/packages/zaurus-updater/c7x0/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/zaurus-updater/c7x0/.mtn2git_empty diff --git a/packages/zaurus-updater/c7x0/updater.sh b/packages/zaurus-updater/c7x0/updater.sh index e69de29bb2..af404d11d8 100644 --- a/packages/zaurus-updater/c7x0/updater.sh +++ b/packages/zaurus-updater/c7x0/updater.sh @@ -0,0 +1,241 @@ +#!/bin/sh + + +DATAPATH=$1 +TMPPATH=/tmp/update +TMPDATA=$TMPPATH/tmpdata.bin +TMPHEAD=$TMPPATH/tmphead.bin + +WFLG_KERNEL=0 +WFLG_INITRD=0 +WFLG_MVERSION=0 + +RO_MTD_LINE=`cat /proc/mtd | grep "root" | tail -n 1` +if [ "$RO_MTD_LINE" = "" ]; then + RO_MTD_LINE=`cat /proc/mtd | grep "\<NAND\>.*\<2\>" | tail -n 1` +fi +RO_MTD_NO=`echo $RO_MTD_LINE | cut -d: -f1 | cut -dd -f2` +RO_MTD_SIZE_HEX=`echo $RO_MTD_LINE | cut -d" " -f2` +RO_MTD=/dev/mtd$RO_MTD_NO +RO_MTDBLK=/dev/mtdblock$RO_MTD_NO +RO_MTD_SIZE=`dc 0x$RO_MTD_SIZE_HEX 1024 /` + +RW_MTD_LINE=`cat /proc/mtd | grep "home" | tail -n 1` +if [ "$RW_MTD_LINE" = "" ]; then + RW_MTD_LINE=`cat /proc/mtd | grep "\<NAND\>.*\<2\>" | tail -n 1` +fi +RW_MTD_NO=`echo $RW_MTD_LINE | cut -d: -f1 | cut -dd -f2` +RW_MTD_SIZE_HEX=`echo $RW_MTD_LINE | cut -d" " -f2` +RW_MTD=/dev/mtd$RW_MTD_NO +RW_MTDBLK=/dev/mtdblock$RW_MTD_NO +RW_MTD_SIZE=`dc 0x$RW_MTD_SIZE_HEX 1024 /` + +LOGOCAL_MTD=/dev/mtd1 + +VERBLOCK=0x48000 +MVRBLOCK=0x70000 + +RESULT=0 + +Cleanup(){ + rm -f $VTMPNAME > /dev/null 2>&1 + rm -f $MTMPNAME > /dev/null 2>&1 + rm $CTRLPATH/* > /dev/null 2>&1 + rm $DATAPATH/* > /dev/null 2>&1 + exit $1 +} +trap 'Cleanup 1' 1 15 +trap '' 2 3 + + +### Check model ### +/sbin/writerominfo +MODEL=`cat /proc/deviceinfo/product` +echo 'MODEL:'$MODEL +case "$MODEL" in + SL-C700) ;; + SL-C750) ;; + SL-C760) ;; + SL-C860) ;; + SL-B500) ;; + SL-5600) ;; + *) + echo 'ERROR:Invalid model!' + echo 'Please reset' + while true + do + done + ;; +esac + +mkdir -p $TMPPATH > /dev/null 2>&1 + +cd $DATAPATH/ + +for TARGETFILE in zImage.bin zimage.bin ZIMAGE.BIN initrd.bin INITRD.BIN mversion.bin MVERSION.BIN +do + if [ -e $TARGETFILE ] + then + rm -f $TMPPATH/*.bin > /dev/null 2>&1 + DATASIZE=`wc -c $TARGETFILE` + DATASIZE=`echo $DATASIZE | cut -d' ' -f1` + + #echo $TARGETFILE':'$DATASIZE'bytes' + TARGETTYPE=Invalid + case "$TARGETFILE" in + zImage.bin) TARGETTYPE=Kernel;; + zimage.bin) TARGETTYPE=Kernel;; + ZIMAGE.BIN) TARGETTYPE=Kernel;; + initrd.bin) TARGETTYPE=RoFs;; + INITRD.BIN) TARGETTYPE=RoFs;; + mversion.bin) TARGETTYPE=MasterVer;; + MVERSION.BIN) TARGETTYPE=MasterVer;; + *) + continue + ;; + esac + + case "$TARGETTYPE" in + Kernel) + if [ $WFLG_KERNEL != 0 ] + then + continue + fi + WFLG_KERNEL=1 + echo 'kernel' + ISLOGICAL=1 + MODULEID=5 + MODULESIZE=0x13C000 + ADDR=`dc 0xE0000` + ISFORMATTED=1 + DATAPOS=0 + ONESIZE=524288 + HDTOP=`expr $DATASIZE - 16` + /sbin/bcut -a $HDTOP -s 16 -o $TMPHEAD $TARGETFILE + ;; + RoFs) + if [ $WFLG_INITRD != 0 ] + then + continue + fi + WFLG_INITRD=1 + echo 'RO file system' + ISLOGICAL=0 + MODULEID=6 + MODULESIZE=0x1900000 + ADDR=0 + ISFORMATTED=0 + TARGET_MTD=$RO_MTD + DATAPOS=16 + ONESIZE=1048576 + /sbin/bcut -s 16 -o $TMPHEAD $TARGETFILE + ;; + MasterVer) + if [ $WFLG_MVERSION != 0 ] + then + continue + fi + WFLG_MVERSION=1 + echo 'Master version' + MTMPNAME=$TMPPATH'/mtmp'`date '+%s'`'.tmp' + /sbin/nandlogical $LOGOCAL_MTD READ $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 + /sbin/verchg -m $MTMPNAME $TARGETFILE 0 0 > /dev/null 2>&1 + /sbin/nandlogical $LOGOCAL_MTD WRITE $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 + rm -f $MTMPNAME > /dev/null 2>&1 + echo 'Success!' + continue + ;; + *) + continue + ;; + esac + + + #format? + if [ $ISFORMATTED = 0 ] + then + echo -n 'Flash erasing...' + /sbin/eraseall $TARGET_MTD 2> /dev/null > /dev/null + #/sbin/eraseall $TARGET_MTD 2 + echo 'done' + ISFORMATTED=1 + fi + + echo '' + echo '0% 100%' + PROGSTEP=`expr $DATASIZE / $ONESIZE + 1` + PROGSTEP=`expr 25 / $PROGSTEP` + if [ $PROGSTEP = 0 ] + then + PROGSTEP=1 + fi + + #00 means header information + VTMPNAME=$TMPPATH'/vtmp'`date '+%s'`'.tmp' + MTMPNAME=$TMPPATH'/mtmp'`date '+%s'`'.tmp' + /sbin/nandlogical $LOGOCAL_MTD READ $VERBLOCK 0x4000 $VTMPNAME > /dev/null 2>&1 + /sbin/nandlogical $LOGOCAL_MTD READ $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 + + #echo 'found header' + /sbin/verchg -v $VTMPNAME $TMPHEAD $MODULEID $MODULESIZE > /dev/null 2>&1 + /sbin/verchg -m $MTMPNAME $TMPHEAD $MODULEID $MODULESIZE > /dev/null 2>&1 + + #loop + while [ $DATAPOS -lt $DATASIZE ] + do + #data create + bcut -a $DATAPOS -s $ONESIZE -o $TMPDATA $TARGETFILE + TMPSIZE=`wc -c $TMPDATA` + TMPSIZE=`echo $TMPSIZE | cut -d' ' -f1` + DATAPOS=`expr $DATAPOS + $TMPSIZE` + + #handle data file + #echo 'ADDR='$ADDR + #echo 'SIZE='$TMPSIZE + if [ $ISLOGICAL = 0 ] + then + next_addr=`/sbin/nandcp -a $ADDR $TMPDATA $TARGET_MTD 2>/dev/null | fgrep "mtd address" | cut -d- -f2 | cut -d\( -f1` + if [ "$next_addr" = "" ]; then + echo "ERROR:flash write" + rm $TMPDATA > /dev/null 2>&1 + RESULT=3 + break; + fi + ADDR=$next_addr + else + /sbin/nandlogical $LOGOCAL_MTD WRITE $ADDR $DATASIZE $TMPDATA > /dev/null 2>&1 + ADDR=`expr $ADDR + $TMPSIZE` + fi + + rm $TMPDATA > /dev/null 2>&1 + + #progress + SPNUM=0 + while [ $SPNUM -lt $PROGSTEP ] + do + echo -n '.' + SPNUM=`expr $SPNUM + 1` + done + done + + echo '' + +#finish + rm -f $TMPPATH/*.bin > /dev/null 2>&1 + + if [ $RESULT = 0 ] + then + /sbin/nandlogical $LOGOCAL_MTD WRITE $VERBLOCK 0x4000 $VTMPNAME > /dev/null 2>&1 + /sbin/nandlogical $LOGOCAL_MTD WRITE $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 + + rm -f $VTMPNAME > /dev/null 2>&1 + rm -f $MTMPNAME > /dev/null 2>&1 + echo 'Success!' + else + echo 'Error!' + exit $RESULT + fi + fi +done + +exit 0 diff --git a/packages/zaurus-updater/encdec-updater-native.bb b/packages/zaurus-updater/encdec-updater-native.bb index e69de29bb2..d6593193f7 100644 --- a/packages/zaurus-updater/encdec-updater-native.bb +++ b/packages/zaurus-updater/encdec-updater-native.bb @@ -0,0 +1,6 @@ +include encdec-updater.bb +inherit native + +do_stage() { + install -m 0755 encdec-updater ${STAGING_BINDIR} +} diff --git a/packages/zaurus-updater/files/.mtn2git_empty b/packages/zaurus-updater/files/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/zaurus-updater/files/.mtn2git_empty diff --git a/packages/zaurus-updater/files/encdec-updater.c b/packages/zaurus-updater/files/encdec-updater.c index e69de29bb2..b894623c65 100644 --- a/packages/zaurus-updater/files/encdec-updater.c +++ b/packages/zaurus-updater/files/encdec-updater.c @@ -0,0 +1,80 @@ +// +// +// Sharp Zaurus SL-C7x0 updater.sh script encoder/decoder +// +// mailto:sash@cacko.biz +// +// + +#include <stdio.h> + +unsigned char enctab[] = { + 0x4a,0xf7,0x77,0x62,0xb0,0xe3,0xd8,0xf6,0xd1,0x98,0x09,0x2e,0x19,0x0c,0x0d,0x7c, + 0x04,0xe0,0x6b,0x22,0x10,0x08,0x15,0x16,0xb9,0x28,0x83,0x1f,0x91,0x06,0xfa,0xe8, + 0xbd,0xc6,0x21,0x32,0x23,0x6f,0x01,0x26,0x5f,0x03,0x33,0xb6,0x35,0xac,0x2d,0x0a, + 0x6e,0x6c,0xfc,0xc4,0x29,0x34,0x2b,0x42,0x25,0x66,0xc9,0x3e,0x87,0xb4,0x74,0xf2, + 0x11,0x20,0x41,0xb3,0x27,0x14,0xc1,0xcd,0x3d,0x80,0xd5,0x7f,0xcf,0x4c,0x4d,0xca, + 0x75,0x51,0xc8,0xa6,0x17,0xf0,0x55,0x82,0x79,0xdc,0x59,0x5a,0x5b,0xb8,0x5d,0x40, + 0x64,0x58,0xff,0xc5,0xab,0xc0,0xae,0xeb,0xa3,0xad,0xea,0x6a,0x37,0x3b,0x73,0x9a, + 0x88,0x3a,0xe1,0x68,0x0b,0xec,0xc7,0x76,0xf9,0x38,0x57,0xdd,0x49,0x96,0x95,0x7a, + 0x50,0x2a,0x4e,0xdb,0x00,0x48,0xd7,0x86,0x47,0x94,0xa0,0x1c,0x8b,0x8c,0x8d,0x92, + 0x45,0x90,0x7e,0x56,0x93,0xef,0x1a,0x52,0x97,0xbc,0x99,0xb5,0x7d,0x72,0x9d,0x9c, + 0xfb,0x24,0xa1,0xa2,0x07,0x46,0xa5,0x02,0x69,0xe6,0xa9,0xd3,0x30,0xba,0xd6,0x84, + 0x63,0x13,0x1b,0xb2,0x1d,0xaf,0x36,0x8e,0xb7,0x53,0x05,0xbb,0x12,0x78,0x8f,0xbe, + 0x71,0xbf,0xe4,0x1e,0x9e,0xa4,0xe5,0x2f,0x9b,0x31,0x67,0x4b,0xcb,0x43,0xc3,0xce, + 0x44,0x3c,0x0f,0xd2,0xaa,0xd4,0xed,0xa7,0x7b,0x18,0xd0,0xda,0x0e,0x54,0xf1,0xde, + 0xdf,0xa8,0x3f,0xe2,0x6d,0xcc,0xf8,0x70,0xe7,0x61,0xe9,0x85,0x65,0x2c,0x39,0xee, + 0x60,0x81,0x89,0xc2,0xf3,0xf4,0xf5,0x8a,0x5c,0x5e,0xd9,0x4f,0x9f,0xb1,0xfd,0xfe, +}; + +unsigned char decode_c(unsigned char c) +{ + int i; + for (i = 0; i < 256; i++) { + if (c == enctab[i]) return i; + } + printf("Internal bug: encode_c()\n"); + exit(1); + return 0; +} + +unsigned char encode_c(unsigned char c) +{ + int i; + return enctab[c]; +} + +int main(int argc, char *argv[]) +{ + int i, decode; + int c; + FILE *inf, *outf; + char name[256]; + + if (argc < 3) { + printf("Decode file:\n\tencsh -d file.sh\nEncode file:\n\tencsh -c file.sh\n"); + exit(1); + } + + if (strcmp(argv[1], "-d")) decode = 1; + else decode = 0; + + strcpy(name, argv[2]); + strcat(name, ".$$$$"); + + inf = fopen(argv[2], "rb"); + outf = fopen(name, "wb"); + + while ((c = fgetc(inf)) >= 0) { + if (decode) c = decode_c(c); + else c = encode_c(c); + fputc(c, outf); + } + + fclose(inf); + fclose(outf); + + rename(name, argv[2]); + + return 0; +} diff --git a/packages/zaurus-updater/poodle/.mtn2git_empty b/packages/zaurus-updater/poodle/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/zaurus-updater/poodle/.mtn2git_empty diff --git a/packages/zaurus-updater/spitz/.mtn2git_empty b/packages/zaurus-updater/spitz/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/zaurus-updater/spitz/.mtn2git_empty diff --git a/packages/zaurus-updater/spitz/updater.sh b/packages/zaurus-updater/spitz/updater.sh index e69de29bb2..73aa12c9a7 100644..100755 --- a/packages/zaurus-updater/spitz/updater.sh +++ b/packages/zaurus-updater/spitz/updater.sh @@ -0,0 +1,260 @@ +#!/bin/sh + +# +# Noodles' simpler update script. SL-C3000 only for the moment. +# + +DATAPATH=$1 +TMPPATH=/tmp/update +TMPDATA=$TMPPATH/tmpdata.bin +TMPHEAD=$TMPPATH/tmphead.bin + +WFLG_KERNEL=0 +WFLG_INITRD=0 +WFLG_HDD=0 + +RO_MTD_LINE=`cat /proc/mtd | grep "root" | tail -n 1` +if [ "$RO_MTD_LINE" = "" ]; then + RO_MTD_LINE=`cat /proc/mtd | grep "\<NAND\>.*\<2\>" | tail -n 1` +fi +RO_MTD_NO=`echo $RO_MTD_LINE | cut -d: -f1 | cut -dd -f2` +RO_MTD_SIZE_HEX=`echo $RO_MTD_LINE | cut -d" " -f2` +RO_MTD=/dev/mtd$RO_MTD_NO +RO_MTDBLK=/dev/mtdblock$RO_MTD_NO +RO_MTD_SIZE=`dc 0x$RO_MTD_SIZE_HEX 1024 /` + +RW_MTD_LINE=`cat /proc/mtd | grep "home" | tail -n 1` +if [ "$RW_MTD_LINE" = "" ]; then + RW_MTD_LINE=`cat /proc/mtd | grep "\<NAND\>.*\<2\>" | tail -n 1` +fi +RW_MTD_NO=`echo $RW_MTD_LINE | cut -d: -f1 | cut -dd -f2` +RW_MTD_SIZE_HEX=`echo $RW_MTD_LINE | cut -d" " -f2` +RW_MTD=/dev/mtd$RW_MTD_NO +RW_MTDBLK=/dev/mtdblock$RW_MTD_NO +RW_MTD_SIZE=`dc 0x$RW_MTD_SIZE_HEX 1024 /` + +LOGOCAL_MTD=/dev/mtd1 + +VERBLOCK=0x48000 +MVRBLOCK=0x70000 + +RESULT=0 + +Cleanup(){ + rm -f $VTMPNAME > /dev/null 2>&1 + rm -f $MTMPNAME > /dev/null 2>&1 + rm $CTRLPATH/* > /dev/null 2>&1 + rm $DATAPATH/* > /dev/null 2>&1 + exit $1 +} +trap 'Cleanup 1' 1 15 +trap '' 2 3 + +get_dev_pcmcia() +{ +while read SOCKET CLASS DRIVER INSTANCE DEVS MAJOR MINOR; +do + echo $DEVS +done +} +get_dev_pcmcia_slot() +{ + grep "^$1" /var/lib/pcmcia/stab | get_dev_pcmcia +} +sleep 1 +IDE1=`get_dev_pcmcia_slot 1` +if [ "$IDE1" = "" ]; then + echo "Error!! There is no HDD. Now retrying..." + while [ "$IDE1" = "" ]; do + IDE1=`get_dev_pcmcia_slot 1` + done + echo "Found HDD!!" +fi + +#LINUXFMT=ext2 +LINUXFMT=ext3 +MKE2FSOPT= +if [ "$LINUXFMT" = "ext3" ]; then + MKE2FSOPT=-j +fi + + +### Check model ### +/sbin/writerominfo +MODEL=`cat /proc/deviceinfo/product` +if [ "$MODEL" != "SL-C3000" ] +then + echo 'MODEL:'$MODEL + echo 'ERROR:Invalid model!' + echo 'Please reset' + while true + do + done +fi + +mkdir -p $TMPPATH > /dev/null 2>&1 + +cd $DATAPATH/ + +# +# First do the kernel. +# +for TARGETFILE in zImage.bin zimage.bin ZIMAGE.BIN +do + if [ -e $TARGETFILE -a $WFLG_KERNEL = 0 ] + then + # Get the size of the kernel. + DATASIZE=`wc -c $TARGETFILE` + DATASIZE=`echo $DATASIZE | cut -d' ' -f1` + + echo 'Updating kernel.' + echo $TARGETFILE':'$DATASIZE' bytes' + /sbin/nandlogical $LOGOCAL_MTD WRITE 0xe0000 $DATASIZE \ + $TARGETFILE > /dev/null 2>&1 + + WFLG_KERNEL=1 + + fi +done + +# +# Now do the initrd. +# +for TARGETFILE in initrd.bin INITRD.BIN +do + if [ -e $TARGETFILE -a $WFLG_INITRD = 0 ] + then + rm -f $TMPPATH/*.bin > /dev/null 2>&1 + DATASIZE=`wc -c $TARGETFILE` + DATASIZE=`echo $DATASIZE | cut -d' ' -f1` + + WFLG_INITRD=1 + echo 'RO file system' + MODULEID=6 + MODULESIZE=0x500000 + ADDR=0 + TARGET_MTD=$RO_MTD + DATAPOS=16 + ONESIZE=1048576 + /sbin/bcut -s 16 -o $TMPHEAD $TARGETFILE + + echo -n 'Flash erasing...' + /sbin/eraseall $TARGET_MTD 2> /dev/null > /dev/null + echo 'done' + + echo '' + echo '0% 100%' + PROGSTEP=`expr $DATASIZE / $ONESIZE + 1` + PROGSTEP=`expr 28 / $PROGSTEP` + if [ $PROGSTEP = 0 ] + then + PROGSTEP=1 + fi + + #00 means header information + VTMPNAME=$TMPPATH'/vtmp'`date '+%s'`'.tmp' + MTMPNAME=$TMPPATH'/mtmp'`date '+%s'`'.tmp' + /sbin/nandlogical $LOGOCAL_MTD READ $VERBLOCK 0x4000 $VTMPNAME > /dev/null 2>&1 + /sbin/nandlogical $LOGOCAL_MTD READ $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 + + #echo 'found header' + /sbin/verchg -v $VTMPNAME $TMPHEAD $MODULEID $MODULESIZE > /dev/null 2>&1 + /sbin/verchg -m $MTMPNAME $TMPHEAD $MODULEID $MODULESIZE > /dev/null 2>&1 + + #loop + while [ $DATAPOS -lt $DATASIZE ] + do + #data create + bcut -a $DATAPOS -s $ONESIZE -o $TMPDATA $TARGETFILE + TMPSIZE=`wc -c $TMPDATA` + TMPSIZE=`echo $TMPSIZE | cut -d' ' -f1` + DATAPOS=`expr $DATAPOS + $TMPSIZE` + + #handle data file + #echo 'ADDR='$ADDR + #echo 'SIZE='$TMPSIZE + next_addr=`/sbin/nandcp -a $ADDR $TMPDATA $TARGET_MTD 2>/dev/null | fgrep "mtd address" | cut -d- -f2 | cut -d\( -f1` + if [ "$next_addr" = "" ]; then + echo "ERROR:flash write" + rm $TMPDATA > /dev/null 2>&1 + RESULT=3 + break; + fi + ADDR=$next_addr + + rm $TMPDATA > /dev/null 2>&1 + + #progress + SPNUM=0 + while [ $SPNUM -lt $PROGSTEP ] + do + echo -n '.' + SPNUM=`expr $SPNUM + 1` + done + done + + echo '' + + #finish + rm -f $TMPPATH/*.bin > /dev/null 2>&1 + + if [ $RESULT = 0 ] + then + /sbin/nandlogical $LOGOCAL_MTD WRITE $VERBLOCK 0x4000 $VTMPNAME > /dev/null 2>&1 + /sbin/nandlogical $LOGOCAL_MTD WRITE $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 + + rm -f $VTMPNAME > /dev/null 2>&1 + rm -f $MTMPNAME > /dev/null 2>&1 + echo 'Success!' + else + echo 'Error!' + exit $RESULT + fi + fi +done + +## HDD image +for TARGETFILE in hdimage1.tgz HDIMAGE1.TGZ +do + if [ -e $TARGETFILE ]; then + if [ $WFLG_HDD != 0 ] + then + continue + fi + WFLG_HDD=1 + echo '' + echo 'HDD RO file system' + if [ ! -f /hdd1/NotAvailable ]; then + umount /hdd1 + fi + echo 'Now formatting...' + mke2fs $MKE2FSOPT /dev/${IDE1}1 2> /dev/null > /dev/null + e2fsck -p /dev/${IDE1}1 > /dev/null + if [ "$?" != "0" ]; then + echo "Error!" + exit "$?" + fi + + mount -t $LINUXFMT -o noatime /dev/${IDE1}1 /hdd1 + if [ "$?" != "0" ]; then + echo "Error!" + exit "$?" + fi + + cd /hdd1 + echo 'Now extracting...' + gzip -dc $DATAPATH/$TARGETFILE | tar xf - + if [ "$?" != "0" ]; then + echo "Error!" + exit "$?" + fi + + echo 'Success!' + # remount as RO + cd / + umount /hdd1 + mount -t $LINUXFMT -o ro,noatime /dev/${IDE1}1 /hdd1 + fi +done + +exit 0 diff --git a/packages/zaurus-updater/tosa/.mtn2git_empty b/packages/zaurus-updater/tosa/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/zaurus-updater/tosa/.mtn2git_empty diff --git a/packages/zaurus-updater/tosa/updater.sh b/packages/zaurus-updater/tosa/updater.sh index e69de29bb2..e22edbf19a 100644 --- a/packages/zaurus-updater/tosa/updater.sh +++ b/packages/zaurus-updater/tosa/updater.sh @@ -0,0 +1,241 @@ +#!/bin/sh + + +DATAPATH=$1 +TMPPATH=/tmp/update +TMPDATA=$TMPPATH/tmpdata.bin +TMPHEAD=$TMPPATH/tmphead.bin + + +RO_MTD_LINE=`cat /proc/mtd | grep "root" | tail -n 1` +if [ "$RO_MTD_LINE" = "" ]; then + RO_MTD_LINE=`cat /proc/mtd | grep "\<NAND\>.*\<2\>" | tail -n 1` +fi +RO_MTD_NO=`echo $RO_MTD_LINE | cut -d: -f1 | cut -dd -f2` +RO_MTD_SIZE_HEX=`echo $RO_MTD_LINE | cut -d" " -f2` +RO_MTD=/dev/mtd$RO_MTD_NO +RO_MTDBLK=/dev/mtdblock$RO_MTD_NO +RO_MTD_SIZE=`dc 0x$RO_MTD_SIZE_HEX 1024 /` + +RW_MTD_LINE=`cat /proc/mtd | grep "home" | tail -n 1` +if [ "$RW_MTD_LINE" = "" ]; then + RW_MTD_LINE=`cat /proc/mtd | grep "\<NAND\>.*\<2\>" | tail -n 1` +fi +RW_MTD_NO=`echo $RW_MTD_LINE | cut -d: -f1 | cut -dd -f2` +RW_MTD_SIZE_HEX=`echo $RW_MTD_LINE | cut -d" " -f2` +RW_MTD=/dev/mtd$RW_MTD_NO +RW_MTDBLK=/dev/mtdblock$RW_MTD_NO +RW_MTD_SIZE=`dc 0x$RW_MTD_SIZE_HEX 1024 /` + +LOGOCAL_MTD=/dev/mtd1 + +VERBLOCK=0x48000 +MVRBLOCK=0x70000 + +RESULT=0 + +Cleanup(){ + rm -f $VTMPNAME > /dev/null 2>&1 + rm -f $MTMPNAME > /dev/null 2>&1 + rm $CTRLPATH/* > /dev/null 2>&1 + rm $DATAPATH/* > /dev/null 2>&1 + exit $1 +} +trap 'Cleanup 1' 1 15 +trap '' 2 3 + + +### Check model ### +/sbin/writerominfo +MODEL=`cat /proc/deviceinfo/product` +if [ "$MODEL" != "SL-6000" ] > /dev/null 2>&1 +then + echo 'MODEL:'$MODEL + echo 'ERROR:Invalid model!' + echo 'Please reset' + while true + do + done +fi + +mkdir -p $TMPPATH > /dev/null 2>&1 + +cd $DATAPATH/ + +if [ -e consolescroll ] +then + ./consolescroll +fi + +for TARGETFILE in zImage zimage ZIMAGE initrd.bin INITRD.BIN mversion.bin MVERSION.BIN +do + if [ -e $TARGETFILE ] + then + rm -f $TMPPATH/*.bin > /dev/null 2>&1 + DATASIZE=`wc -c $TARGETFILE` + DATASIZE=`echo $DATASIZE | cut -d' ' -f1` + + #echo $TARGETFILE':'$DATASIZE'bytes' + TARGETTYPE=Invalid + case "$TARGETFILE" in +## zImage) TARGETTYPE=Kernel;; + zimage) TARGETTYPE=Kernel;; + ZIMAGE) TARGETTYPE=Kernel;; + initrd.bin) TARGETTYPE=RoFs;; + INITRD.BIN) TARGETTYPE=RoFs;; + mversion.bin) TARGETTYPE=MasterVer;; + MVERSION.BIN) TARGETTYPE=MasterVer;; + *) + continue + ;; + esac + case "$TARGETTYPE" in + Kernel) + echo 'kernel' + ISLOGICAL=1 + MODULEID=5 + MODULESIZE=0x13C000 + ADDR=`dc 0xE0000` + ISFORMATTED=1 + DATAPOS=0 + ONESIZE=524288 + HDTOP=`expr $DATASIZE - 16` + /sbin/bcut -a $HDTOP -s 16 -o $TMPHEAD $TARGETFILE + ;; + RoFs) + echo 'RO file system' + ISLOGICAL=0 + MODULEID=6 + MODULESIZE=0x1E00000 + ADDR=0 + ISFORMATTED=0 + TARGET_MTD=$RO_MTD + DATAPOS=16 + ONESIZE=1048576 + /sbin/bcut -s 16 -o $TMPHEAD $TARGETFILE + ;; + MasterVer) + echo 'Maser version' + MTMPNAME=$TMPPATH'/mtmp'`date '+%s'`'.tmp' + /sbin/nandlogical $LOGOCAL_MTD READ $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 + /sbin/verchg -m $MTMPNAME $TARGETFILE 0 0 > /dev/null 2>&1 + /sbin/nandlogical $LOGOCAL_MTD WRITE $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 + rm -f $MTMPNAME > /dev/null 2>&1 + echo 'Success!' + continue + ;; + *) + continue; + ;; + esac + + #check version + /sbin/bcut -s 6 -o $TMPDATA $TMPHEAD + if [ `cat $TMPDATA` != "SHARP!" ] > /dev/null 2>&1 + then + #no version info... + rm -f $TMPHEAD > /dev/null 2>&1 + DATAPOS=0 + fi + + #format? + if [ $ISFORMATTED = 0 ] + then + echo -n 'Flash erasing...' + /sbin/eraseall $TARGET_MTD 2> /dev/null > /dev/null + #/sbin/eraseall $TARGET_MTD 2 + echo 'done' + ISFORMATTED=1 + fi + + echo '' + echo '0% 100%' + PROGSTEP=`expr $DATASIZE / $ONESIZE + 1` + PROGSTEP=`expr 28 / $PROGSTEP` + if [ $PROGSTEP = 0 ] + then + PROGSTEP=1 + fi + + #header information + if [ -e $TMPHEAD ] + then + VTMPNAME=$TMPPATH'/vtmp'`date '+%s'`'.tmp' + MTMPNAME=$TMPPATH'/mtmp'`date '+%s'`'.tmp' + /sbin/nandlogical $LOGOCAL_MTD READ $VERBLOCK 0x4000 $VTMPNAME > /dev/null 2>&1 + /sbin/nandlogical $LOGOCAL_MTD READ $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 + + #echo 'found header' + /sbin/verchg -v $VTMPNAME $TMPHEAD $MODULEID $MODULESIZE > /dev/null 2>&1 + /sbin/verchg -m $MTMPNAME $TMPHEAD $MODULEID $MODULESIZE > /dev/null 2>&1 + fi + + #loop + while [ $DATAPOS -lt $DATASIZE ] + do + #data create + bcut -a $DATAPOS -s $ONESIZE -o $TMPDATA $TARGETFILE + TMPSIZE=`wc -c $TMPDATA` + TMPSIZE=`echo $TMPSIZE | cut -d' ' -f1` + DATAPOS=`expr $DATAPOS + $TMPSIZE` + + #handle data file + #echo 'ADDR='$ADDR + #echo 'SIZE='$TMPSIZE + if [ $ISLOGICAL = 0 ] + then + next_addr=`/sbin/nandcp -a $ADDR $TMPDATA $TARGET_MTD 2>/dev/null | fgrep "mtd address" | cut -d- -f2 | cut -d\( -f1` + if [ "$next_addr" = "" ]; then + echo "ERROR:flash write" + rm $TMPDATA > /dev/null 2>&1 + RESULT=3 + break; + fi + ADDR=$next_addr + else + /sbin/nandlogical $LOGOCAL_MTD WRITE $ADDR $DATASIZE $TMPDATA > /dev/null 2>&1 + ADDR=`expr $ADDR + $TMPSIZE` + fi + + rm $TMPDATA > /dev/null 2>&1 + + #progress + SPNUM=0 + while [ $SPNUM -lt $PROGSTEP ] + do + echo -n '.' + SPNUM=`expr $SPNUM + 1` + done + done + + echo '' + +#finish + rm -f $TMPPATH/*.bin > /dev/null 2>&1 + + if [ $RESULT = 0 ] + then + if [ -e $VTMPNAME ] + then + /sbin/nandlogical $LOGOCAL_MTD WRITE $VERBLOCK 0x4000 $VTMPNAME > /dev/null 2>&1 + rm -f $VTMPNAME > /dev/null 2>&1 + fi + if [ -e $MTMPNAME ] + then + /sbin/nandlogical $LOGOCAL_MTD WRITE $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 + rm -f $MTMPNAME > /dev/null 2>&1 + fi + echo 'Success!' + else + echo 'Error!' +# exit $RESULT + fi + fi +done + +#exit 0 + +echo 'Please reset' +while true +do +done |